Why does my code not work (Minecraft Coding)?

fl
- in Plugins
6

I wanted to program a plugin, which saves the helmet with a command in a yml. Saving works, but not loading. Hopefully you can help me.

Thank you.

public boolean onCommand (final CommandSender s, Command c, String label, String [] args) {
Player p = (players) s;

if (c.getName (). EqualsIgnoreCase ("invsave")) {
String playername = p.getName ();
this.checkOrdner ();
File Arm = new File ("plugins // lol // arm //" + playername + ".yml");
File Arm = new File ("plugins // lol // arm //" + playername + ".yml")

if (! Arm.exists ()) {
try {
Arm.createNewFile ();
}
catch (IOException e) {
// TODO Auto-generated catch block
p.sendMessage ("§4The specified path was not found!");
}

YamlConfiguration Armr = YamlConfiguration.loadConfiguration (arm);
Armr.createSection ("Am" + p.getName ());
Armr.set ("Am." + P.getName () + "Helmet:", p.getInventory (). GetHelmet ());
p.getInventory () setArmorContents (zero).

try {
Armr.save (Arm);
}
catch (IOException e) {
// TODO Auto-generated catch block
p.sendMessage ("§4path not found");
}

p.setLevel (0);
p.sendMessage ("§2 armor saved!");
}
}

if (c.getName (). EqualsIgnoreCase ("invload")) {
File Arm = new File ("plugins // lol // arm //" + playername + ".yml");

if (Arm.exists ()) {
YamlConfiguration Armr = YamlConfiguration.loadConfiguration (arm);
ItemStack f = Armr.getItemStack ("Arm." + P.getName () + ".Helm");
p.getInventory () setArmorContents (zero).
p.getInventory () setHelmet (f).
Arm.delete ();
}
}
}

public void checkFolder () {
File Arm = new File ("plugins // Lol // Arm");

if (! Arm.exists ()) {
Arm.mkdir ();
}
}

fl

Sorry did not miss the bottom of the coding line

Gr

Lol

Dr

Please use codes to show websites like paste.ofcode.org or pastebin

fl

Okay, if I'm on tomorrow post I'm left

Bu

You'll probably be able to get your sources of error yourself by repeating code fragments (here, specifying paths / keys) more often.

To save, you create a section in the YAML file and save the value under this key:

Armrestset ("Am." + P.getName () + "Helmet:" // …

but this would have to be the same when loading.

ItemStack f = Armr.getItemStack ("Arm." + P.getName () + ".Helm");

You should store paths / keys in global variables, use decent identifiers (which are meaningful and follow the usual Java conventions), and offload the various functions (load / store) into individual methods, just as you would with checkOrdner have done.

PS.: Line 7 is double and there's no final semicolon.

fl

Danke. I have been doing this with java for only a few months now. Thank you very much. It may be because I was shivering because I was focused. I can't even better code at 1 o'clock