Java / Minecraft: Is it possible to cut back?

Je
- in Plugins
5

So I'm currently programming a plugin for Minecraft. However, something bothers me, the long lines.

e.g.:

Player p = (player) transmitter;
p.sendMessage (this.plugin.getConfig (). GetString ("Server.Prefix"). Replace ("&", "§");

Is it possible to cut that somehow? I'm still very inexperienced, so sorry, if that's pretty wrong. But I've already tried this here:

private string prefix = this.plugin.getConfig (). GetString ("Server.Prefix"). Replace ("&", "§");

But that does not work and I get no error message. Is it because I wrote that as a string?

Vi

Well, you're just doing a replace in the string, but that does not happen, you just created a new string. Of course, the actual function sendMessage () will not be executed. That would be sendMessage (prefix). Purely logical, whether the syntax is right now I do not know

Je

Well, it was assigned to p.sendMessage (prefix) but that did not work, but thanks for your answer.

Ia

I did not look at your attempt, but the line

p.sendMessage (this.plugin.getConfig (). GetString ("Server.Prefix"). Replace ("&", "§");

It is in Java as with compound words in the German language, you can break down the text "Hochschulgesetztkommentare" in "Comments on the laws of the university" (would be "simple" or "good" language)

MyPlugin = this.plugin.getConfig ();

ServString = MyPlugin.getString ("Server.Prefix);

ReplaceString = ServString.replace ("&", "§");

p.sendMessage (ReplaceString);

But you just have to declare MyPlugin, ServString and ReplaceString to match (String ServString;)

Je

Oooh, I got it, thank you.

Ia

But no guarantee that what I have written, so in the code works - have only syntactic "zergebröselt" --but it was all about understanding.

Meanwhile, I also program with the "long lines", but in the initial phase, I had there as synonymous understanding problems