Skip to content

Commit

Permalink
784 Slot Crystal Command (#793)
Browse files Browse the repository at this point in the history
SlotCrystal Command with tab complete and default permission.
  • Loading branch information
TrueDarkLord committed Feb 19, 2024
1 parent ef1bdd4 commit b7a3a8d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,45 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @N
return true;
}

case "slotcrystal", "sc" -> { // /ce slotcrystal [amount] [player]
if (hasPermission(sender, "slotcrystal")) {
int amount = 1;
Player player;

if (args.length <= 2 && !isPlayer) {
sender.sendMessage(Messages.PLAYERS_ONLY.getMessage());
return true;
}

if (args.length >= 2) {
if (!checkInt(sender, args[1])) return true;

amount = Integer.parseInt(args[1]);
}

if (args.length >= 3) {
if (!this.methods.isPlayerOnline(args[2], sender)) return true;
player = this.methods.getPlayer(args[2]);
} else {
player = (Player) sender;
}

if (this.methods.isInventoryFull(player)) return true;

ItemStack item = starter.getSlotCrystalListener().getSlotCrystal();
item.setAmount(amount);

this.methods.addItemToInventory(player, item);
HashMap<String, String> placeholders = new HashMap<>();
placeholders.put("%Amount%", String.valueOf(amount));
placeholders.put("%Player%", player.getName());
sender.sendMessage(Messages.GIVE_PROTECTION_CRYSTAL.getMessage(placeholders));
player.sendMessage(Messages.GET_PROTECTION_CRYSTAL.getMessage(placeholders));
}

return true;
}

case "dust" -> { // /ce dust <Success/Destroy/Mystery> [Amount] [Player] [Percent]
if (hasPermission(sender, "dust")) {
if (args.length >= 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
if (hasPermission(sender, "updateenchants")) completions.add("updateEnchants");
if (hasPermission(sender, "give")) completions.add("give");
if (hasPermission(sender, "bottle")) completions.add("bottle");
if (hasPermission(sender, "slotcrystal")) completions.add("slotcrystal");


return StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>());
} else if (args.length == 2) { // /ce arg0
Expand Down Expand Up @@ -90,7 +92,7 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
completions.add("transmog");
}

case "crystal", "scrambler" -> {
case "crystal", "scrambler", "slotcrystal" -> {
completions.add("1");
completions.add("32");
completions.add("64");
Expand Down Expand Up @@ -143,7 +145,7 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
completions.add("32");
completions.add("64");
}
case "crystal", "scrambler" -> this.plugin.getServer().getOnlinePlayers().forEach(player -> completions.add(player.getName()));
case "crystal", "scrambler", "slotcrystal" -> this.plugin.getServer().getOnlinePlayers().forEach(player -> completions.add(player.getName()));
case "give" ->
completions.add("Item:DIAMOND_HELMET, Amount:1, Name:&6&lHat, Protection:4, Overload:1-5, Hulk:2-5, Lore:&aLine 1.,&aLine 2.");
}
Expand Down
3 changes: 3 additions & 0 deletions paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ permissions:

crazyenchantments.crystal:
default: op

crazyenchantments.slotcrystal:
default: op

crazyenchantments.scrambler:
default: op
Expand Down

0 comments on commit b7a3a8d

Please sign in to comment.