Skip to content

Commit

Permalink
Last minute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kadotcom committed Feb 20, 2024
1 parent faf43a6 commit d3e1d66
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/me/kadotcom/lifestolen/Commands/LifeStolenHelp.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand All @@ -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<String, Map<String, Object>> 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/kadotcom/lifestolen/Commands/ResetHP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/kadotcom/lifestolen/Commands/Revive.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/kadotcom/lifestolen/Commands/ViewUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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;
}
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;
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/kadotcom/lifestolen/Events/ItemEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;
}
Expand Down
9 changes: 0 additions & 9 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down

0 comments on commit d3e1d66

Please sign in to comment.