Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8280517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:42:25+00:00 2026-06-08T09:42:25+00:00

public static void setMOTD(final String motd) throws Exception { final Field field = MinecraftServer.class.getDeclaredField(motd);

  • 0
    public static void setMOTD(final String motd) throws Exception {
    final Field field = MinecraftServer.class.getDeclaredField("motd");
    final Field server = CraftServer.class.getDeclaredField("console");
    field.setAccessible(true);
    server.setAccessible(true);
    MinecraftServer instance = (MinecraftServer) server.get(CraftServer.class);
    field.set(instance, motd);
}

My goal with this is to change the Message of the day on a minecraft server (running craftbukkit). To do this I need to change a non-static field motd. I am doing all of this with a plugin so I can’t get the instance for the MinecraftServer. The second last line was my attempt at doing this with reflection however it failed. I don’t have access to change the MinecraftServer class or CraftServer because they are in an external library.

motd and console are both non-static fields.

motd is a String with the modifiers public final.

console is an instance of MinecraftServer with the modifiers protected final.

This is the error I’m getting (on the second last line of setMOTD):

2012-07-22 22:16:31 [SEVERE] java.lang.IllegalArgumentException: Can not set final net.minecraft.server.MinecraftServer field org.bukkit.craftbukkit.CraftServer.console to java.lang.Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T09:42:28+00:00Added an answer on June 8, 2026 at 9:42 am

    Solved by fetching the bukkit instance which extends CraftServer

        public static void setServerMOTD(final String motd) throws Exception {
        final Field field = MinecraftServer.class.getDeclaredField("motd");
        final Field server = CraftServer.class.getDeclaredField("console");
        Field modifiersField = Field.class.getDeclaredField("modifiers");
        modifiersField.setAccessible(true);
        field.setAccessible(true);
        server.setAccessible(true);
        modifiersField.setInt(server, server.getModifiers() & ~Modifier.FINAL);
        MinecraftServer instance = (MinecraftServer) server.get(Bukkit.getServer());
        field.set(instance, motd);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class ConnectGmail { public static void main(String args[]) throws Exception { PasswordAuthentication authentication;
public static void main(String[] args) throws Exception { RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator(); AsymmetricCipherKeyPair
public class Main { public static void main(String[] args) throws InterruptedException { ClassA a
public static void main(String[] args) throws Exception { Socket socket = new Socket(127.0.0.1, 2345);
public class ReplaceVowels { public static void main(String args[]) throws IOException { BufferedReader bf
public static void main(String[] args) throws IOException, URISyntaxException,TransformerException { TransformerFactory factory = TransformerFactory.newInstance(); String
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class Foo { public static void main(String[] args) { float f; System.out.println(f); }
public class MultiplicationTable { public static void main (String[]a){ int[] x; x = new
public class Employee { public static void main(String[] args) { int j=3; staples[] stemp

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.