diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java index 0418ebaa..d97f42e3 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/Strings.java @@ -117,7 +117,8 @@ private Strings() { public static final String PLUGIN_COMMAND_MORE = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast mehr von " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " erzeugt!"; public static final String PLUGIN_COMMAND_MORE_PLAYER = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast mehr von " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " erhalten!"; - public static final String PLUGIN_COMMAND_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " repariert!"; + public static final String PLUGIN_COMMAND_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " repariert!"; + public static final String PLUGIN_COMMAND_CANNOT_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du kannst " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " nicht reparieren!"; public static final String PLUGIN_COMMAND_REPAIR_PLAYER = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " repariert bekommen!"; public static final String PLUGIN_COMMAND_GAMERULES = PLUGIN_FORMS_COMMAND_PREFIX + "Die Welt " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "hat folgende Einstellungen:"; diff --git a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java index e05a5dc8..5e49c833 100644 --- a/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java +++ b/src/main/java/de/relluem94/minecraft/server/spigot/essentials/commands/Repair.java @@ -1,6 +1,8 @@ package de.relluem94.minecraft.server.spigot.essentials.commands; import lombok.NonNull; +import net.md_5.bungee.api.chat.TextComponent; +import net.md_5.bungee.api.chat.TranslatableComponent; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -30,14 +32,15 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul ItemStack item = p.getInventory().getItemInMainHand(); ItemMeta im = item.getItemMeta(); - if (im instanceof Damageable dmg) { - if (dmg.hasDamage()) { - dmg.setDamage(0); - } + if (im instanceof Damageable dmg && dmg.hasDamage()) { + dmg.setDamage(0); item.setItemMeta(im); + p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType().name())); + } + else{ + p.sendMessage(String.format(PLUGIN_COMMAND_CANNOT_REPAIR, p.getInventory().getItemInMainHand().getType().name())); } - p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING); @@ -54,15 +57,16 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul ItemStack item = target.getInventory().getItemInMainHand(); ItemMeta im = item.getItemMeta(); - if (im instanceof Damageable dmg) { - if (dmg.hasDamage()) { - dmg.setDamage(0); - } + if (im instanceof Damageable dmg && dmg.hasDamage()) { + dmg.setDamage(0); item.setItemMeta(im); + p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType().name())); + target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType().name())); + } + else{ + p.sendMessage(String.format(PLUGIN_COMMAND_CANNOT_REPAIR, p.getInventory().getItemInMainHand().getType().name())); } - p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType())); - target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType())); return true; } else { p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING);