Untitled diff

Created Diff never expires
3 Entfernungen
Zeilen
Gesamt
Entfernt
Wörter
Gesamt
Entfernt
Um diese Funktion weiterhin zu nutzen, aktualisieren Sie auf
Diffchecker logo
Diffchecker Pro
27 Zeilen
10 Hinzufügungen
Zeilen
Gesamt
Hinzugefügt
Wörter
Gesamt
Hinzugefügt
Um diese Funktion weiterhin zu nutzen, aktualisieren Sie auf
Diffchecker logo
Diffchecker Pro
34 Zeilen
//There's some missing variables in this code, created in the new code so it'd work
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if(cmd.getName().equalsIgnoreCase("crmake")) {
if(cmd.getName().equalsIgnoreCase("crmake")) {
if(!(sender instanceof Player)) {
sender.sendMessage("Can't add a chest if you don't have a body...");
return true;
}
Player p = (Player) sender;
Block b = p.getTargetBlock((Set<Material>)null, 100);
Location loc = b.getLocation();
if(b.getType() != Material.CHEST) {
if(b.getType() != Material.CHEST) {
p.sendMessage(ChatColor.RED + "ChestRefill >> You should be looking directly at a Chest!");
p.sendMessage(ChatColor.RED + "ChestRefill >> You should be looking directly at a Chest!");
} else {
} else {
try {
try {
int t = 0;
int t = -1; //just in case we have no chests in the section, it'll start at chest #0.
if(ch.getConfigurationSection("Chests") == null) ch.createSection("Chests");
for(String s : ch.getConfigurationSection("Chests").getKeys(false)) {
for(String s : ch.getConfigurationSection("Chests").getKeys(false)) {
int i = Integer.parseInt(s); // if it's potato, it'll fail here
int i = Integer.parseInt(s); // if it's potato, it'll fail here
if(i > t) t = i;
if(i > t) t = i;
}
}
String w = loc.getWorld().getName();
String w = loc.getWorld().getName();
int locx = loc.getBlockX();
int locx = loc.getBlockX();
int locy = loc.getBlockY();
int locy = loc.getBlockY();
int locz = loc.getBlockZ();
int locz = loc.getBlockZ();
ch.set("Chests." + String.valueOf(t+1) + ".location", w+"|"+locx+"|"+locy+"|"+locz);
ch.set("Chests." + String.valueOf(t+1) + ".location", w+"|"+locx+"|"+locy+"|"+locz);
ch.save(new File(main.getDataFolder(), "Chests.yml"));
ch.save(new File(getDataFolder(), "Chests.yml"));
p.sendMessage(ChatColor.DARK_GREEN + "ChestRefill >> Chest saved successfully!");
p.sendMessage(ChatColor.DARK_GREEN + "ChestRefill >> Chest saved successfully!");
} catch (Exception e) {
} catch (Exception e) {
p.sendMessage(ChatColor.DARK_RED + "ChestRefill >> Failed to save chest!");
p.sendMessage(ChatColor.DARK_RED + "ChestRefill >> Failed to save chest!");
e.printStackTrace();
e.printStackTrace();
}
}
}
}
}
}
return false;
return false;
}
}