1. Mike Bayer
  2. ZeekTools


zzzeek  committed f060853

- rename giveitem to give
- copy item properties file from SPC, should fix #2, #3
- fix double "bed" name to "bed block"
- give only quantity one for items by default, 64 for blocks

  • Participants
  • Parent commits fc2f5c9
  • Branches default

Comments (0)

Files changed (8)

File pom.xml

View file
+      <resource>
+        <targetPath>defaults/</targetPath>
+        <filtering>true</filtering>
+        <directory>${basedir}/src/main/resources/</directory>
+        <includes>
+          <include>itemnames.properties</include>
+        </includes>
+      </resource>

File src/main/assembly/package.xml

View file
+                <include>itemnames.properties</include>

File src/main/java/com/zzzcomputing/bukkit/ZeekTools/ZeekTools.java

View file
         public void onPlayerJoin(PlayerJoinEvent event) {
             Util.sendPlayerMessage(event.getPlayer(), "ZeekTools enabled.");
             Util.sendPlayerMessage(event.getPlayer(), "Enter '/helpzt' for help.");
+            String motd = config.getString("motd.text");
+            if (motd != null) {
+                Util.sendPlayerMessage(event.getPlayer(), motd);
+            }
         public void onPlayerQuit(PlayerQuitEvent event) {
     private boolean processCommand(Player player, String cmd, String [] args) {
-        if ("giveitem".equals(cmd)) {
+        if ("give".equals(cmd)) {
             new GiveCommand(this, player).execute(cmd, args);
         else if ("destroy".equals(cmd)) {

File src/main/java/com/zzzcomputing/bukkit/ZeekTools/commands/GiveCommand.java

View file
 package com.zzzcomputing.bukkit.ZeekTools.commands;
+import java.io.IOException;
+import java.io.InputStream;
 import java.util.HashMap;
+import java.util.Properties;
 import org.bukkit.Material;
 import org.bukkit.entity.Player;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.plugin.java.JavaPlugin;
+import com.zzzcomputing.bukkit.ZeekTools.util.Logger;
 import com.zzzcomputing.bukkit.ZeekTools.util.Util;
 public class GiveCommand extends Command {
     static HashMap<String, Material> names;
     static {
         names = new HashMap<String, Material>();
-        for (Material m : Material.values()) {
-            names.put(m.toString().toLowerCase().replaceAll("[\\s_-]", ""), m);
-            names.put(String.valueOf(m.getId()), m);
+        try {
+            InputStream is = GiveCommand.class.getResourceAsStream("/defaults/itemnames.properties");  
+            Properties properties = new Properties();  
+            properties.load(is);  
+            is.close();
+            for (Object strId : properties.keySet()) {
+                String name = properties.getProperty(strId.toString());
+                int id = Integer.parseInt(strId.toString());
+                Material m = Material.getMaterial(id);
+                names.put(name.toString().toLowerCase().replaceAll("[\\s_-]", ""), m);
+                names.put(String.valueOf(m.getId()), m);
+            }
+        } catch (IOException ioe) {
+            Logger.severe("Error reading properties file", ioe);
         else {
             String itemname = "";
-            int amount = 64;
+            int amount = -1;
             if (args.length > 1) {
                 try {
                     amount = Integer.valueOf(args[args.length - 1]);
             itemname = itemname.toLowerCase().replaceAll("[\\s_-]", "");
             if (names.containsKey(itemname)) {
                 Material material = names.get(itemname);
+                if (amount == -1) {
+                    if (material.getId() > 255) {
+                        // default to quantity one for items
+                        amount = 1;
+                    }
+                    else {
+                        // default to quantity 64 for blocks
+                        amount = 64;
+                    }
+                }
                 player.getInventory().addItem(new ItemStack(material, amount));
             else {

File src/main/java/com/zzzcomputing/bukkit/ZeekTools/commands/HelpCommand.java

View file
     public void execute(String command, String[] args) {
-        sendPlayerMessage(ChatColor.WHITE, "/giveitem <name_or_id> [quantity] - Give item by name or number");
+        sendPlayerMessage(ChatColor.WHITE, "/give <name_or_id> [quantity] - Give item by name or number");
         sendPlayerMessage(ChatColor.WHITE, "/goto <x> <y> <z> - goto coordinates");
         sendPlayerMessage(ChatColor.WHITE, "/goto <waypoint> - goto saved waypoint");
         sendPlayerMessage(ChatColor.WHITE, "/goto player <player> - goto player position");

File src/main/resources/config.yml

View file
+    text:

File src/main/resources/itemnames.properties

View file
+#Single Player Commands - Rename item names: ITEMID=ITEMNAME
+#Sat Aug 27 18:08:42 EDT 2011
+308=iron leggings
+307=iron chestplate
+306=iron helmet
+305=chain boots
+304=chain leggings
+303=chain chestplate
+302=chain helmet
+301=leather boots
+269=wooden shovel
+300=leather pants
+268=wooden sword
+267=iron sword
+266=gold ingot
+265=iron ingot
+259=flint and steel
+258=iron axe
+257=iron pickaxe
+256=iron shovel
+95=locked chest
+91=jack 'o' lantern
+88=soul sand
+83=sugar cane
+76=redstone torch
+75=redstone torch
+74=redstone ore
+73=redstone ore
+72=pressure plate
+71=iron door
+70=pressure plate
+67=stone stairs
+64=wooden door
+58=crafting table
+57=block of diamond
+56=diamond ore
+55=redstone dust
+53=wooden stairs
+52=monster spawner
+356=redstone repeater
+350=cooked fish
+48=moss stone
+42=block of iron
+41=block of gold
+349=raw fish
+348=glowstone dust
+346=fishing rod
+343=minecart with furnace
+342=minecart with chest
+338=sugar canes
+330=iron door
+299=leather tunic
+298=leather cap
+294=golden hoe
+293=diamond hoe
+292=iron hoe
+291=stone hoe
+290=wooden hoe
+29=sticky piston
+28=detector rail
+27=powered rail
+26=bed block
+25=note block
+22=lapis lazuli block
+21=lapis lazuli ore
+327=lava bucket
+326=water bucket
+324=wooden door
+322=golden apple
+320=cooked porkchop
+5=wooden planks
+286=golden axe
+285=golden pickaxe
+284=golden shovel
+283=golden sword
+282=mushroom stew
+16=coal ore
+15=iron ore
+14=gold ore
+319=raw porkchop
+317=golden boots
+316=golden leggings
+315=golden chestplate
+314=golden helmet
+313=diamond boots
+312=diamond leggings
+311=diamond chestplate
+310=diamond helmet
+279=diamond axe
+2257=music disc
+278=diamond pickaxe
+2256=music disc
+277=diamond shovel
+276=diamond sword
+275=stone axe
+274=stone pickaxe
+273=stone shovel
+272=stone sword
+271=wooden axe
+270=wooden pickaxe
+309=iron boots

File src/main/resources/plugin.yml

View file
 description: Provides some SPC-like features to Bukkit.
 author: zzzeek
-    giveitem:
+    give:
         description: Give item.  Will give the max unless [num] given.
         usage: give <name_or_id> [num]