Skip to content

Commit

Permalink
[galaipa#17] Add /sr unbreakable/breakable command
Browse files Browse the repository at this point in the history
Closes galaipa#17
  • Loading branch information
galaipa committed Nov 17, 2019
1 parent b67989b commit f9909eb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/io/github/galaipa/sr/Methods.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ public static void duplicateItem(ItemStack item, int amount){
int result = amountInHand*amount;
item.setAmount(result);
}
// Make item unbreakable
public static void makeUnbreakable(ItemStack item, boolean unbreakable){
ItemMeta itemStackMeta = item.getItemMeta();
itemStackMeta.setUnbreakable(unbreakable);
item.setItemMeta(itemStackMeta);
}
//Copy / paste
public static HashMap<String, ItemMeta > copy = new HashMap<String, ItemMeta>();
// Copy
Expand Down Expand Up @@ -138,6 +144,8 @@ public static void helpInfo(Player sender, String version1){
sender.sendMessage(ChatColor.BLUE + "/sr reload");
sender.sendMessage(ChatColor.BLUE + "/removelore <lineN>");
sender.sendMessage(ChatColor.BLUE + "/sr hideflags" );
sender.sendMessage(ChatColor.BLUE + "/sr glow/unglow" );
sender.sendMessage(ChatColor.BLUE + "/sr breakable/unbreakable" );
}
//Get Skull
public static ItemStack getSkull(String owner){
Expand Down
21 changes: 21 additions & 0 deletions src/io/github/galaipa/sr/SimpleRename.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ public void cmdSR(Player player, String[] args){
case "unglow":
cmdSR_UnGlow(player);
break;
case "breakable":
cmdSR_Breakable(player);
break;
case "unbreakable":
cmdSR_Unbreakable(player);
break;
case "mob":
cmdSR_Mob(player,args);
break;
Expand Down Expand Up @@ -341,6 +347,21 @@ public void cmdSR_Hideflags(Player player){
}
}

public void cmdSR_Breakable(Player player){
if(Utils.checkEverything(player, null, "sr.unbreakable", 1, player.getItemInHand())){
Methods.makeUnbreakable(player.getItemInHand(),false);
player.updateInventory();
player.sendMessage(ChatColor.GREEN+(getTranslation("5")));
}
}
public void cmdSR_Unbreakable(Player player){
if(Utils.checkEverything(player, null, "sr.unbreakable", 1, player.getItemInHand())){
Methods.makeUnbreakable(player.getItemInHand(),true);
player.updateInventory();
player.sendMessage(ChatColor.GREEN+(getTranslation("5")));
}
}

public void cmdSR_Info(Player player){
PluginDescriptionFile pdfFile = this.getDescription();
String version1 = pdfFile.getVersion();
Expand Down
3 changes: 3 additions & 0 deletions src/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ permissions:
sr.glow:
description: Perm to use /sr glow command
default: op
sr.unbreakable:
description: Perm to use /sr unbreakable command
default: op
sr.hide:
description: Perm to use /sr hideflags command
default: op
Expand Down

0 comments on commit f9909eb

Please sign in to comment.