-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from SmartGecko44/custom-items
Fixed permissions, fixed name formatting, fixed BedrockListener, added new command
- Loading branch information
Showing
20 changed files
with
221 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/org/gecko/wauh/commands/GiveCustomItems.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.gecko.wauh.commands; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.gecko.wauh.items.TriggerItems; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class GiveCustomItems implements CommandExecutor, TabCompleter { | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
TriggerItems items = new TriggerItems(); | ||
if (sender instanceof Player) { | ||
if (args.length == 1) { | ||
String operation = args[0].toLowerCase(); | ||
|
||
if (operation.equals("bucket") || operation.equals("barrier") || operation.equals("bedrock") || operation.equals("tsunami") || operation.equals("all")) { | ||
ItemStack customBucket = items.createCustomItem(Material.BUCKET, "Water Drainer", (short) 0, "Removes all fluids", "Custom Bucket"); | ||
ItemStack customBarrier = items.createCustomItem(Material.BARRIER, "Surface Remover", (short) 0, "Removes grass and dirt blocks", "Custom Barrier"); | ||
ItemStack customBedrock = items.createCustomItem(Material.BEDROCK, "Block Obliterator", (short) 0, "Removes almost all blocks", "Custom Bedrock"); | ||
ItemStack customTsunami = items.createCustomItem(Material.WATER_BUCKET, "Tsunami Bucket", (short) 0, "Creates a tsunami if you shift + right click on a block", "Custom Tsunami"); | ||
switch (operation) { | ||
case "bucket": | ||
((Player) sender).getInventory().addItem(customBucket); | ||
break; | ||
case "barrier": | ||
((Player) sender).getInventory().addItem(customBarrier); | ||
break; | ||
case "bedrock": | ||
((Player) sender).getInventory().addItem(customBedrock); | ||
break; | ||
case "tsunami": | ||
((Player) sender).getInventory().addItem(customTsunami); | ||
break; | ||
default: | ||
((Player) sender).getInventory().addItem(customBucket, customBarrier, customBedrock, customTsunami); | ||
break; | ||
} | ||
} else return true; | ||
} else { | ||
sender.sendMessage("Usage: /givecustomitems [bucket/barrier/bedrock/tsunami/all]"); | ||
return true; | ||
} | ||
} else { | ||
sender.sendMessage("Only players can execute this command"); | ||
return true; | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender commandSender, Command command, String alias, String[] args) { | ||
List<String> completions = new ArrayList<>(); | ||
|
||
if (args.length == 1) { | ||
String input = args[0].toLowerCase(); | ||
|
||
if ("bucket".startsWith(input)) { | ||
completions.add("bucket"); | ||
} else if ("barrier".startsWith(input)) { | ||
completions.add("barrier"); | ||
} else if ("bedrock".startsWith(input)) { | ||
completions.add("bedrock"); | ||
} else if ("tsunami".startsWith(input)) { | ||
completions.add("tsunami"); | ||
} else if ("all".startsWith(input)) { | ||
completions.add("all"); | ||
} | ||
} | ||
return completions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/org/gecko/wauh/informations/RemovalInfo.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.gecko.wauh.items; | ||
|
||
import de.tr7zw.changeme.nbtapi.NBTItem; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class TriggerItems { | ||
|
||
public ItemStack createCustomItem(Material material, String name, short data, String lore, String ident) { | ||
ItemStack item = new ItemStack(material, 1, data); | ||
name = ChatColor.RESET + name; | ||
lore = ChatColor.RESET + "" + ChatColor.DARK_PURPLE + lore; | ||
List<String> loreToList = Collections.singletonList(lore); | ||
ItemMeta meta = item.getItemMeta(); | ||
meta.setDisplayName(name); | ||
meta.setLore(loreToList); | ||
item.setItemMeta(meta); | ||
|
||
NBTItem nbtItem = new NBTItem(item); | ||
nbtItem.setString("Ident", ident); | ||
|
||
return nbtItem.getItem(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.