Skip to content

Commit

Permalink
Added TNT Arrows (!) ,
Browse files Browse the repository at this point in the history
Updated /listworlds,
Fixed /reply (wrong copy-paste code),
Added 2 extra commands : /enchant and /addexperience
Updated items.csv
  • Loading branch information
GuntherDW committed Nov 26, 2011
1 parent 88bbd9d commit be87d9b
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 21 deletions.
51 changes: 51 additions & 0 deletions items.csv
Expand Up @@ -261,6 +261,24 @@ fencegate,107,0,64
brickstairs,108,0,64 brickstairs,108,0,64
smoothbrickstairs,108,0,64 smoothbrickstairs,108,0,64
stonebrickstairs,108,0,64 stonebrickstairs,108,0,64
smoothstairs,109,0,64
smoothstonestairs,109,0,64
mycel,110,0,64
watervine,111,0,64
waterlily,111,0,64
netherbrick,112,0,64
netherfence,113,0,64
netherbrickstairs,114,0,64
netherwart,115,0,64
netherwarts,115,0,64
enchantmenttable,116,0,64
magictable,116,0,64
brewingstand,117,0,64
cauldronblock,118,0,64
enderportal,119,0,64
enderportalframe,120,0,64
enderstone,121,0,64
dragonegg,122,0,64
ironshovel,256,0,1 ironshovel,256,0,1
ironpickaxe,257,0,1 ironpickaxe,257,0,1
ironpick,257,0,1 ironpick,257,0,1
Expand Down Expand Up @@ -397,6 +415,7 @@ timer,347,0,64
watch,347,0,64 watch,347,0,64
brightstonedust,348,0,64 brightstonedust,348,0,64
glowstonedone,348,0,64 glowstonedone,348,0,64
glowstonedust,348,0,64
brimstonedust,348,0,64 brimstonedust,348,0,64
brittlegolddust,348,0,64 brittlegolddust,348,0,64
lightstonedust,348,0,64 lightstonedust,348,0,64
Expand Down Expand Up @@ -445,8 +464,40 @@ zombieflesh,367,0,64
zombiemeat,367,0,64 zombiemeat,367,0,64
enderpearl,368,0,64 enderpearl,368,0,64
pearl,368,0,64 pearl,368,0,64
blazerod,369,0,64
firestick,369,0,64
ghasttear,370,0,64
goldnugget,371,0,64
netherstalk,372,0,64
potion,373,0,64
glassbottle,374,0,64
emptybottle,374,0,64
bottle,374,0,64
spidereye,375,0,64
fermentedspidereye,376,0,64
blazepowder,377,0,64
firepowder,377,0,64
magmacream,378,0,64
brewingstand,379,0,64
cauldron,380,0,64
endermaneye,381,0,64
eyeofender,381,0,64
endermaneye,381,0,64
endereye,381,0,64
speckledmelon,382,0,64
glisteringmelon,382,0,64
glistermelon,382,0,64
redstonerepeater,356,0,64 redstonerepeater,356,0,64
golddisc,2256,0,64 golddisc,2256,0,64
goldrecord,2256,0,64 goldrecord,2256,0,64
greenrecord,2257,0,64 greenrecord,2257,0,64
greenddisc,2257,0,64 greenddisc,2257,0,64
record3,2258,0,64
record4,2259,0,64
record5,2260,0,64
record6,2261,0,64
record7,2262,0,64
record8,2263,0,64
record9,2264,0,64
record10,2265,0,64
record11,2266,0,64
13 changes: 12 additions & 1 deletion plugin.yml
Expand Up @@ -217,4 +217,15 @@ commands:
usage: /<command> [p:<player>] [distance] usage: /<command> [p:<player>] [distance]
afk: afk:
description: Manually toggle your AFK status description: Manually toggle your AFK status
usage: /<command> usage: /<command>
tntarrow:
description: Toggles the use of TNT Arrows.
usage: /<command>
aliases: [tnta]
addexp:
description: Adds experience to you or someone else
usage: /<command> <experience>
aliases: [adde]
enchant:
description: Adds an enchantment to your current item
usage: /<command> <enchantmentid> <level>
6 changes: 3 additions & 3 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
Expand Up @@ -71,9 +71,9 @@ public boolean sendMessage(CommandSender sender, String message) {




String targetmsg = plugin.getConfigHandler().AIRCMessageFormat; String targetmsg = plugin.getConfigHandler().AIRCMessageFormat;
targetmsg = targetmsg.replace("%name%", cleanname); targetmsg = targetmsg.replace("%name%", cleanname).
targetmsg = targetmsg.replace("%message%", message); replace("%message%", message).
targetmsg = targetmsg.replace("%dispname%", ChatColor.stripColor(sendername)); replace("%dispname%", ChatColor.stripColor(sendername));


targetmsg = targetmsg.replace("%clearcolors%", Character.toString((char) 3)); targetmsg = targetmsg.replace("%clearcolors%", Character.toString((char) 3));
RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().AIRCtag, "generic"); RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().AIRCtag, "generic");
Expand Down
Expand Up @@ -100,6 +100,9 @@ public CommandHandler(TweakcraftUtils instance) {
commandMap.put("eject", new CommandEject()); commandMap.put("eject", new CommandEject());
commandMap.put("afk", new CommandAFK()); commandMap.put("afk", new CommandAFK());
commandMap.put("getspawn", new CommandGetSpawn()); commandMap.put("getspawn", new CommandGetSpawn());
commandMap.put("tntarrow", new CommandTNTArrow());
commandMap.put("addexp", new CommandAddExperience());
commandMap.put("enchant", new CommandEnchant());


/** /**
* Chat commands * Chat commands
Expand Down
Expand Up @@ -48,6 +48,8 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
if (plugin.check(player, "worlds." + w.getName())) { if (plugin.check(player, "worlds." + w.getName())) {


World.Environment env = w.getEnvironment(); World.Environment env = w.getEnvironment();
boolean customChunkGen = false;
if(w.getGenerator()!=null) { customChunkGen = true; env = null;}
iWorld tw = plugin.getworldManager().getWorld(w.getName()); iWorld tw = plugin.getworldManager().getWorld(w.getName());
if(tw!=null) { if(tw!=null) {
if(tw.getChunkGen()!=null) if(tw.getChunkGen()!=null)
Expand All @@ -59,11 +61,12 @@ else if(env == World.Environment.NORMAL)
col = ChatColor.GREEN.toString(); col = ChatColor.GREEN.toString();
else if (env == World.Environment.NETHER) else if (env == World.Environment.NETHER)
col = ChatColor.RED.toString(); col = ChatColor.RED.toString();
else if (env == World.Environment.SKYLANDS) else if (env == World.Environment.THE_END)
col = ChatColor.AQUA.toString(); col = ChatColor.DARK_GRAY.toString();
else else
col = ChatColor.GRAY.toString(); col = ChatColor.GRAY.toString();
player.sendMessage(ChatColor.LIGHT_PURPLE+ "(" + w.getPlayers().size()+") " + col + w.getName()); player.sendMessage(ChatColor.LIGHT_PURPLE+ "(" + w.getPlayers().size()+") " + col + w.getName() +
(customChunkGen?ChatColor.LIGHT_PURPLE +" (CG:"+ w.getGenerator().getClass().getSimpleName()+")":""));
} }
} }


Expand Down
Expand Up @@ -59,8 +59,8 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
sender.sendMessage("[Me -> " + playerto.getDisplayName() + "] " + message); sender.sendMessage("[Me -> " + playerto.getDisplayName() + "] " + message);
playerto.sendMessage("[" + senderName + " -> Me] " + message); playerto.sendMessage("[" + senderName + " -> Me] " + message);
if (sender instanceof Player) { if (sender instanceof Player) {
LocalPlayer lp = plugin.wrapPlayer((Player)sender); LocalPlayer lp = plugin.wrapPlayer(playerto);
lp.setReplyTo(playerto.getName()); lp.setReplyTo(((Player)sender).getName());
// plugin.setPlayerReply(playerto.getName(), ((Player) sender).getName()); // plugin.setPlayerReply(playerto.getName(), ((Player) sender).getName());
} }


Expand Down
Expand Up @@ -49,14 +49,15 @@ public boolean executeCommand(CommandSender sender, String command, String[] rea


Location loc = player.getTargetBlock((HashSet<Byte>)null, 200).getLocation(); Location loc = player.getTargetBlock((HashSet<Byte>)null, 200).getLocation();
ArgumentParser ap = new ArgumentParser(realargs); ArgumentParser ap = new ArgumentParser(realargs);
String[] args = ap.getUnusedArgs();
Random rnd = new Random(); Random rnd = new Random();


int slimesize = ap.getInteger("s", -1); int slimesize = ap.getInteger("s", -1);
int health = ap.getInteger("h", -1); int health = ap.getInteger("h", -1);
boolean powered = ap.getBoolean("p", false); boolean powered = ap.getBoolean("p", false);
boolean shoven = ap.getBoolean("sh", false); boolean shoven = ap.getBoolean("sh", false);
String sheepcolor = ap.getString("sc", null); String sheepcolor = ap.getString("sc", null);
String[] args = ap.getUnusedArgs();


loc.setY(loc.getY() + 1); // Do not spawn them into the ground, silly! loc.setY(loc.getY() + 1); // Do not spawn them into the ground, silly!
String mobName; String mobName;
Expand Down
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2011 GuntherDW
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.guntherdw.bukkit.tweakcraft.Commands.General;

import com.guntherdw.bukkit.tweakcraft.Commands.iCommand;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
import com.guntherdw.bukkit.tweakcraft.Tools.ArgumentParser;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.List;

/**
* @author GuntherDW
*/
public class CommandAddExperience implements iCommand {

@Override
public boolean executeCommand(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player)
if(!plugin.check((Player)sender, getPermissionSuffix()))
throw new PermissionsException(command);

ArgumentParser ap = new ArgumentParser(args);
String playerString = ap.getString("p", null);
String[] ars = ap.getUnusedArgs();

if(playerString==null) {
if(!(sender instanceof Player))
throw new CommandUsageException("Who do i have to give experience to?");
else
playerString = ((Player) sender).getName();
}

List<Player> p = plugin.findPlayerasPlayerList(playerString);
if(p.size()!=1)
throw new CommandException("Player not found!");
if(ars.length<1)
throw new CommandException("No amount given");
int amount = 0;
try{
amount = Integer.parseInt(ars[0]);
} catch(NumberFormatException ex) {
throw new CommandException("Number expected, garbage given");
}

Player player = p.get(0);
sender.sendMessage(player.getDisplayName()+ChatColor.YELLOW+" had "+player.getTotalExperience()+ " experience, adding "+amount);
player.sendMessage(ChatColor.YELLOW+"Adding "+amount+" to your total experience!");
player.setTotalExperience(player.getTotalExperience()+amount);

return true;
}

@Override
public String getPermissionSuffix() {
return "addexp";
}

}
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2011 GuntherDW
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

package com.guntherdw.bukkit.tweakcraft.Commands.General;

import com.guntherdw.bukkit.tweakcraft.Commands.iCommand;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandSenderException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.CommandUsageException;
import com.guntherdw.bukkit.tweakcraft.Exceptions.PermissionsException;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import org.bukkit.ChatColor;
import org.bukkit.Enchantment;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.Map;

/**
* @author GuntherDW
*/
public class CommandEnchant implements iCommand {
@Override
public boolean executeCommand(CommandSender sender, String command, String[] args, TweakcraftUtils plugin)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
if(sender instanceof Player) {
if(!plugin.check((Player)sender, getPermissionSuffix()))
throw new PermissionsException(command);
} else {
throw new CommandSenderException("What do you want to enchant today?");
}

if(args.length==0) {
ItemStack is = ((Player)sender).getItemInHand();
if(is!=null) {
sender.sendMessage(ChatColor.YELLOW+"Enchantments for this item :");
Map<Enchantment, Integer> enchantments = is.getEnchantments();
if(enchantments==null) {
sender.sendMessage(ChatColor.YELLOW+"This item doesn't have any enchantments!");
} else {
for(Enchantment ench : enchantments.keySet()) {
sender.sendMessage(ChatColor.YELLOW+ench.name()+" at level "+enchantments.get(ench));
}
}
} else {
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything");
}
return true;
} else if(args.length==1 && args[0].equalsIgnoreCase("disenchant")) {
ItemStack is = ((Player)sender).getItemInHand();
if(is!=null) {
sender.sendMessage(ChatColor.YELLOW+"Clearing any enchantments this item had");
is.clearEnchantments();
} else {
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything");
}
} else if(args.length!=2)
throw new CommandUsageException("I need exactly 2 values, an ID and a level!");

Integer enchantmentId = null;
Integer enchantmentLevel = null;

try{
enchantmentId = Integer.parseInt(args[0]);
enchantmentLevel = Integer.parseInt(args[1]);
} catch(NumberFormatException ex) {
throw new CommandUsageException("I need numbers, not garbage!");
}

Enchantment enchantment = Enchantment.byId(enchantmentId);

if(enchantment!=null) {
ItemStack is = ((Player)sender).getItemInHand();
is.clearEnchantments();
is.addEnchantment(enchantment, enchantmentLevel);
sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.name()+" level "+enchantmentLevel);
} else {
sender.sendMessage(ChatColor.YELLOW+"Couldn't find Enchantment with id "+enchantmentId+"!");
}

return true;

}

@Override
public String getPermissionSuffix() {
return "enchant";
}
}

0 comments on commit be87d9b

Please sign in to comment.