diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/AddHealth.java b/src/main/java/me/kadotcom/lifestolen/Commands/AddHealth.java index dc0bff9..91e5c34 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/AddHealth.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/AddHealth.java @@ -20,7 +20,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; Player sName = Bukkit.getPlayer(args[0]); - if(p.isOp() || p.hasPermission(plugin.getCommand("addhealth").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.addhealth") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if(sName != null){ try { int i = Integer.parseInt(args[1]); diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/ClearUsage.java b/src/main/java/me/kadotcom/lifestolen/Commands/ClearUsage.java index 2464cb7..222012a 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/ClearUsage.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/ClearUsage.java @@ -23,7 +23,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(sender instanceof Player) { Player player = (Player)sender; - if(player.isOp() || player.hasPermission(plugin.getCommand("sethealth").getPermission()) || player.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(player.isOp() || player.hasPermission("lifestolen.clearusage") || player.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if (args.length < 1) { player.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f]] Usage: /clearusage [player] [heart/reviver]"); return true; diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/GiveHeart.java b/src/main/java/me/kadotcom/lifestolen/Commands/GiveHeart.java index d859f96..fe59ddd 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/GiveHeart.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/GiveHeart.java @@ -16,7 +16,7 @@ public GiveHeart(LifeStolen ls){ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player){ Player p = (Player) sender; - if(p.isOp() || p.hasPermission(plugin.getCommand("giveheart").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.giveheart") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if(plugin.getConfig().getBoolean("heart.isEnabled")){ p.getInventory().addItem(ItemManager.heart); }else { diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/GiveReviver.java b/src/main/java/me/kadotcom/lifestolen/Commands/GiveReviver.java index c53c99a..ad30186 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/GiveReviver.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/GiveReviver.java @@ -16,7 +16,7 @@ public GiveReviver(LifeStolen ls){ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if(sender instanceof Player){ Player p = (Player) sender; - if(p.isOp() || p.hasPermission(plugin.getCommand("givereviver").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.givereviver") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if(plugin.getConfig().getBoolean("reviver.isEnabled")){ p.getInventory().addItem(ItemManager.reviver); }else { diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/LifeStolenHelp.java b/src/main/java/me/kadotcom/lifestolen/Commands/LifeStolenHelp.java index 77c6102..ebc58ed 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/LifeStolenHelp.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/LifeStolenHelp.java @@ -1,6 +1,7 @@ package me.kadotcom.lifestolen.Commands; -import com.google.common.collect.Iterables; +import java.util.Map; +import java.util.Set; import me.kadotcom.lifestolen.LifeStolen; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -11,7 +12,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.help.HelpTopic; +import org.bukkit.plugin.PluginDescriptionFile; +import java.security.KeyStore; import java.util.Objects; public class LifeStolenHelp implements CommandExecutor { @@ -20,19 +23,18 @@ public LifeStolenHelp(LifeStolen ls){ plugin = ls; } - HelpTopic topic = Iterables.get(Bukkit.getHelpMap().getHelpTopics(), 0);; - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof Player){ Player p = (Player) sender; if(!plugin.getConfig().getBoolean("permissions.lshelp.bePermissionBased") || plugin.getConfig().getBoolean("permissions.lshelp.bePermissionBased") && p.hasPermission(plugin.getConfig().getString("permissions.lshelp.permission"))){ - p.sendMessage(ChatColor.GRAY + "" + topic.getName()); - /* - This is gonna go under a HUGE rework. - So I am gonna delete the code in here for now, if I do a tested 5.0 without this done, expect it to be disabled. - */ + for(Map.Entry> pdf : plugin.getDescription().getCommands().entrySet()){ + String cmdName = pdf.getKey(); + Object cmdProperties = pdf.getValue(); + String stringedProperties = cmdProperties.toString().replace("{","").replace("}","").replace("description=","").replace(", usage="," | "); + p.sendMessage(ChatColor.RED + "/" + cmdName + " | " + stringedProperties); + } //p.sendMessage("§f[§cLifeStolen§f] This command is disabled as it's going under a rework that will be out either next Tested release, or in 5.0."); }else if (plugin.getConfig().getBoolean("permissions.lshelp.bePermissionBased") && !p.hasPermission(plugin.getConfig().getString("permissions.lshelp.permission"))){ p.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] " + plugin.getConfig().getString("translation.errorMessages.noPermission")); diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/ReloadLifeStolen.java b/src/main/java/me/kadotcom/lifestolen/Commands/ReloadLifeStolen.java index df9e19e..7b1d799 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/ReloadLifeStolen.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/ReloadLifeStolen.java @@ -20,7 +20,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(sender instanceof Player){ Player p = (Player) sender; - if(p.isOp() || p.hasPermission(plugin.getCommand("reloadls").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.reloadls") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ plugin.reloadConfig(); p.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] Reloaded!"); }else{ diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/RemoveHealth.java b/src/main/java/me/kadotcom/lifestolen/Commands/RemoveHealth.java index 615a0d9..6516d6a 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/RemoveHealth.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/RemoveHealth.java @@ -20,7 +20,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; Player sName = Bukkit.getPlayer(args[0]); - if(p.isOp() || p.hasPermission(plugin.getCommand("removehealth").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.removehealth") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if(sName != null){ try { int i = Integer.parseInt(args[1]); diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java b/src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java index 3854f87..69d4636 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java @@ -18,7 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(sender instanceof Player){ Player p = (Player) sender; - if(p.isOp() || p.hasPermission(plugin.getCommand("resethp").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.resethp") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ for (Player target : Bukkit.getServer().getOnlinePlayers()) { HealthManager.setMaxHealth(20, target); target.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] " + ChatColor.RED + "Your hearts has been resetted."); diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/Revive.java b/src/main/java/me/kadotcom/lifestolen/Commands/Revive.java index 8705def..0358fc3 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/Revive.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/Revive.java @@ -18,7 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if(sender instanceof Player){ Player p = (Player) sender; - if(p.isOp() || p.hasPermission(plugin.getCommand("revive").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.revive") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if (args.length < 1) { sender.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] Usage: " + plugin.getCommand("revive").getUsage()); } diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/SetHealth.java b/src/main/java/me/kadotcom/lifestolen/Commands/SetHealth.java index e57cff8..d834ef1 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/SetHealth.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/SetHealth.java @@ -21,7 +21,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St Player p = (Player) sender; Player sName = Bukkit.getPlayer(args[0]); - if(p.isOp() || p.hasPermission(plugin.getCommand("sethealth").getPermission()) || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ + if(p.isOp() || p.hasPermission("lifestolen.sethealth") || p.hasPermission(plugin.getConfig().getString("permissions.permissionToDoEverything"))){ if(sName != null){ try { int i = Integer.parseInt(args[1]); diff --git a/src/main/java/me/kadotcom/lifestolen/Commands/ViewUsage.java b/src/main/java/me/kadotcom/lifestolen/Commands/ViewUsage.java index 088ba48..ddb1a84 100644 --- a/src/main/java/me/kadotcom/lifestolen/Commands/ViewUsage.java +++ b/src/main/java/me/kadotcom/lifestolen/Commands/ViewUsage.java @@ -30,7 +30,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St return true; } - if(args[1].equalsIgnoreCase("heart")){ + if(args[0].equalsIgnoreCase("heart")){ if(!plugin.getConfig().getBoolean("heart.haveLimitedUses")){ player.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] heart.haveLimitedUses is disabled, so this command will not be executed."); return true; @@ -38,7 +38,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St UserDataHandler user = new UserDataHandler(plugin, player.getUniqueId()); int usage = user.getUserFile().getInt("User.Config.Item.HeartUses"); player.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] You have used " + usage + "/" + plugin.getConfig().getInt("heart.uses") + " hearts."); - }else if(args[1].equalsIgnoreCase("reviver")){ + }else if(args[0].equalsIgnoreCase("reviver")){ if(!plugin.getConfig().getBoolean("reviver.haveLimitedUses")){ player.sendMessage("§f[§c" + plugin.getConfig().getString("translation.serverName") + "§f] reviver.haveLimitedUses is disabled, so this command will not be executed."); return true; diff --git a/src/main/java/me/kadotcom/lifestolen/Events/ItemEvent.java b/src/main/java/me/kadotcom/lifestolen/Events/ItemEvent.java index 5fbc40d..97aa560 100644 --- a/src/main/java/me/kadotcom/lifestolen/Events/ItemEvent.java +++ b/src/main/java/me/kadotcom/lifestolen/Events/ItemEvent.java @@ -62,6 +62,9 @@ public void onRightClick(PlayerInteractEvent event) { if(HealthManager.getMaxHealth(event.getPlayer()) != plugin.getConfig().getInt("HP.maxHP")) { if(plugin.getConfig().getBoolean("heart.haveLimitedUses")) { if(user.getUserFile().getInt("User.Config.Item.HeartUses") >= plugin.getConfig().getInt("heart.uses")){ + user.getUserFile().set("User.Config.Item.HeartUses", plugin.getConfig().getInt("heart.maxUses")); + user.saveUserFile(); + event.setCancelled(true); return; } int uses = user.getUserFile().getInt("User.Config.Item.HeartUses"); @@ -84,6 +87,8 @@ public void onRightClick(PlayerInteractEvent event) { if(plugin.getConfig().getBoolean("reviver.haveLimitedUses")) { if(user.getUserFile().getInt("User.Config.Item.ReviverUses") >= plugin.getConfig().getInt("reviver.uses")){ + user.getUserFile().set("User.Config.Item.ReviverUses", plugin.getConfig().getInt("reviver.maxUses")); + user.saveUserFile(); event.setCancelled(true); return; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7cae64b..c61c2a9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -9,41 +9,33 @@ commands: resethp: description: Resets everyone that is onlines health usage: /resethp - permission: "lifestolen.resethp" health: description: Shows your exact health usage: /health giveheart: description: Gives you a heart item. usage: /giveheart - permission: "lifestolen.giveheart" givereviver: description: Gives you a reviver item. usage: /givereviver - permission: "lifestolen.givereviver" sethealth: description: Sets a players health. usage: /sethealth [player] [amount] - permission: "lifestolen.sethealth" addhealth: description: Adds to players health. usage: /addhealth [player] [amount] - permission: "lifestolen.addhealth" removehealth: description: Removes from players health. usage: /removehealth [player] [amount] - permission: "lifestolen.removehealth" revive: description: Revives a player. usage: /revive [player] - permission: "lifestolen.revive" withdraw: description: Withdraws a heart from yourself usage: /withdraw [amount] reloadls: description: Reloads the plugin usage: /reloadls - permission: "lifestolen.reloadls" lshelp: description: Shows all commands available to LifeStolen. usage: /lshelp [page] @@ -56,7 +48,6 @@ commands: clearusage: description: Clears a players usage of an item. usage: /clearusage [player] [heart/reviver] - permission: "lifestolen.clearusage" viewusage: description: Shows your usage of an item. usage: /viewusage [heart/reviver]