Skip to content

Commit

Permalink
Added snowPile (needs small CraftBukkit patch!),
Browse files Browse the repository at this point in the history
Started refactoring for commands, needs some additional work though
Removed Java 1.6 code and annotations to make it 1.5 compatible again.
  • Loading branch information
GuntherDW committed Dec 26, 2011
1 parent 9336abc commit 0cd2a79
Show file tree
Hide file tree
Showing 90 changed files with 5,069 additions and 6,928 deletions.
13 changes: 7 additions & 6 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TweakcraftUtils
main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils
version: 2.2.7-git
version: 2.8.0-git
authors:
- GuntherDW
- Meaglin
Expand Down Expand Up @@ -83,7 +83,7 @@ commands:
tphere:
description: Teleport a player to you
usage: /<command> <player>
aliases: [ 's' ]
aliases: [ 's', 'summon' ]
seen:
description: Report the last logout time of the player
usage: /<command> <player>
Expand All @@ -92,7 +92,7 @@ commands:
usage: /<command> <message>
aliases: [ 'b', 'broa' ]
tpmob:
description: Teleports you to a mob
description: Teleports a mob to you
usage: /<command> <mobid>
kick:
description: Kicks a player with reason
Expand Down Expand Up @@ -123,7 +123,7 @@ commands:
description: Shows your current orientation
usage: /<command>
spawnmob:
description: Spawns mobs at your position
description: Spawns mobs at your crosshair
usage: /<command> <mobname> [amount] [player]
motd:
description: Show the message of the day!
Expand Down Expand Up @@ -176,6 +176,7 @@ commands:
rain:
description: Turn storm on or off at command
usage: /<command> <world> <on|off>
aliases: [ 'storm' ]
thunder:
description: Turn thunder on or off at command
usage: /<command> <world> <on|off>
Expand All @@ -197,7 +198,7 @@ commands:
description: Tamer tool control
usage: /<command> <mode>
nick:
description: Setup a nick
description: Give someone a nick
usage: /<command> <nick>
whois:
description: Find out who's behind that nick!
Expand Down Expand Up @@ -229,4 +230,4 @@ commands:
aliases: [ 'adde' ]
enchant:
description: Adds an enchantment to your current item
usage: /<command> <enchantmentid> <level>
usage: /<command> <enchantmentid> <level>
19 changes: 9 additions & 10 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public AdminChat(ChatHandler instance) {
subscribers = new ArrayList<String>();
this.chathandler = instance;
this.plugin = chathandler.getTCUtilsInstance();
if(plugin.getConfigHandler().enableIRC) {
if (plugin.getConfigHandler().enableIRC) {
this.circ = plugin.getCraftIRC();
circ.registerEndPoint("tcutilsadmin", plugin.getAdminEndPoint());
}
Expand All @@ -71,16 +71,16 @@ public boolean sendMessage(CommandSender sender, String message) {


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

targetmsg = targetmsg.replace("%clearcolors%", Character.toString((char) 3));
RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().AIRCtag, "generic");
rmsg.setField("sender", pcolor+sendername);
rmsg.setField("sender", pcolor + sendername);
rmsg.setField("realSender", cleanname);
rmsg.setField("message", targetmsg);
if(sender instanceof Player) {
if (sender instanceof Player) {
Player p = (Player) sender;
// World w = p.getWorld();
rmsg.setField("world", p.getWorld().getName());
Expand Down Expand Up @@ -140,8 +140,8 @@ public List<Player> getRecipients(CommandSender sender) {

for (Player p : plugin.getServer().getOnlinePlayers()) {
if (plugin.check(p, "admon")) {
if(!recp.contains(p))
recp.add(p);
if (!recp.contains(p))
recp.add(p);
}
}
return recp;
Expand Down Expand Up @@ -188,7 +188,6 @@ public List<String> getSubscribers() {
return subscribers;
}

@Override
public String getDescription() {
return "Admin chat (needs permissions!)";
}
Expand All @@ -213,6 +212,6 @@ public String getColor() {
}

public String getPrefix() {
return this.getColor()+"A";
return this.getColor() + "A";
}
}
10 changes: 0 additions & 10 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/GroupChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,42 @@
* @author GuntherDW
*/
public class GroupChat implements ChatMode {
@Override
public boolean sendMessage(CommandSender sender, String message) {
return false;
}

@Override
public List<Player> getRecipients(CommandSender sender) {
return null;
}

@Override
public void addRecipient(String player) {

}

@Override
public boolean broadcastMessage(CommandSender sender, String message) {
return false;
}

@Override
public void removeRecipient(String player) {

}

@Override
public List<String> getSubscribers() {
return null;
}

@Override
public String getDescription() {
return null;
}

@Override
public boolean isEnabled() {
return false;
}

@Override
public String getColor() {
return null;
}

@Override
public String getPrefix() {
return null;
}
Expand Down
7 changes: 3 additions & 4 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/LocalChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public boolean sendMessage(CommandSender sender, String message) {
Player player = (Player) sender;
List<Player> recp = getRecipients(player);
for (Player p : recp) {
p.sendMessage(ChatColor.YELLOW+"L"+ChatColor.WHITE+": [" + player.getDisplayName() + "]: " + message);
p.sendMessage(ChatColor.YELLOW + "L" + ChatColor.WHITE + ": [" + player.getDisplayName() + "]: " + message);
}
if (recp.size() < 2) {
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
Expand Down Expand Up @@ -111,9 +111,8 @@ public List<String> getSubscribers() {
return subscribers;
}

@Override
public String getDescription() {
return "Chat locally ("+plugin.getConfigHandler().localchatdistance+" blocks)";
return "Chat locally (" + plugin.getConfigHandler().localchatdistance + " blocks)";
}

public boolean isEnabled() {
Expand All @@ -125,6 +124,6 @@ public String getColor() {
}

public String getPrefix() {
return this.getColor()+"L";
return this.getColor() + "L";
}
}
43 changes: 18 additions & 25 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/RegionChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,32 @@ public RegionChat(ChatHandler instance) {
this.subscribers = new ArrayList<String>();
}

@Override
public boolean sendMessage(CommandSender sender, String message) {
if (sender instanceof Player) {
Player player = (Player) sender;
List<Player> recp = getRecipients(player);
for (Player p : recp) {
p.sendMessage(ChatColor.AQUA+"R"+ChatColor.WHITE+": [" + player.getDisplayName() + "]: " + message);
p.sendMessage(ChatColor.AQUA + "R" + ChatColor.WHITE + ": [" + player.getDisplayName() + "]: " + message);
}
if(getRegionName(player.getName(), false).equals("")) {
if (getRegionName(player.getName(), false).equals("")) {
sender.sendMessage(ChatColor.GOLD + "You're currently not inside of a region!");
} else if (recp.size() < 2) {
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
}
plugin.getLogger().info("R: ("+getRegionName(player.getName(), false)+") <" + player.getName() + "> " + message);
plugin.getLogger().info("R: (" + getRegionName(player.getName(), false) + ") <" + player.getName() + "> " + message);
} else {
sender.sendMessage("How did you get here?!");
}
return true;
}

@Override
public List<Player> getRecipients(CommandSender sender) {
List<Player> recp = new ArrayList<Player>();
List<String> regionIds = null;
if(sender instanceof Player) {
if (sender instanceof Player) {
GlobalRegionManager gm = plugin.getWorldGuard().getGlobalRegionManager();
Player player = (Player) sender;
if(plugin.getWorldGuard() == null) {
if (plugin.getWorldGuard() == null) {
sender.sendMessage(ChatColor.GOLD + "WorldGuard error!");
} else {

Expand All @@ -90,19 +88,19 @@ public List<Player> getRecipients(CommandSender sender) {
regionIds = rm.getApplicableRegionsIDs(vec);
Vector pvec = null;
List<String> preg = null;
for(Player p : player.getWorld().getPlayers()) {
for (Player p : player.getWorld().getPlayers()) {
pvec = new Vector(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ());
preg = rm.getApplicableRegionsIDs(pvec);
for(String s : preg) {
if(recp.contains(p)) // List already contains player, skip checks
for (String s : preg) {
if (recp.contains(p)) // List already contains player, skip checks
continue;
if(!s.equalsIgnoreCase("__global__") && regionIds.contains(s)) {
if (!s.equalsIgnoreCase("__global__") && regionIds.contains(s)) {
recp.add(p);
}
}
}
}
if(!recp.contains(player)) {
if (!recp.contains(player)) {
recp.add(player);
}
}
Expand All @@ -119,40 +117,36 @@ public boolean broadcastMessage(CommandSender sender, String message) {
if (recp.size() < 2) {
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
}
plugin.getLogger().info("R: ("+getRegionName(player.getName(), false)+") : "+message);
plugin.getLogger().info("R: (" + getRegionName(player.getName(), false) + ") : " + message);
} else {
sender.sendMessage("How did you get here?!");
}
return true;
}

@Override
public void addRecipient(String player) {
if (!subscribers.contains(player)) {
subscribers.add(player);
}
}

@Override
public void removeRecipient(String player) {
if (subscribers.contains(player)) {
subscribers.remove(player);
}
}

@Override
public List<String> getSubscribers() {
return subscribers;
}

@Override
public String getDescription() {
return "WorldGuard regions chat!";
}

public String getRegionName(String sender, boolean color) {
Player p = plugin.getServer().getPlayer(sender);
if(p!=null) {
if (p != null) {
GlobalRegionManager gm = plugin.getWorldGuard().getGlobalRegionManager();
Location loc = p.getLocation().clone();
Vector vec = new Vector(loc.getX(), loc.getY(), loc.getZ());
Expand All @@ -161,15 +155,14 @@ public String getRegionName(String sender, boolean color) {
String msg = "";
for (Iterator<String> iterator = regionIds.iterator(); iterator.hasNext(); ) {
String next = iterator.next();
if(!next.equalsIgnoreCase("__global__"))
{
msg += (color?ChatColor.GOLD:"")+next;
if(iterator.hasNext()) {
msg += (color?ChatColor.WHITE:"")+",";
if (!next.equalsIgnoreCase("__global__")) {
msg += (color ? ChatColor.GOLD : "") + next;
if (iterator.hasNext()) {
msg += (color ? ChatColor.WHITE : "") + ",";
}
}
}
return msg+(color?ChatColor.WHITE:"");
return msg + (color ? ChatColor.WHITE : "");
} else {
return null;
}
Expand All @@ -184,6 +177,6 @@ public String getColor() {
}

public String getPrefix() {
return this.getColor()+"R";
return this.getColor() + "R";
}
}
11 changes: 5 additions & 6 deletions src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/WorldChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public boolean sendMessage(CommandSender sender, String message) {
Player player = (Player) sender;
List<Player> recp = getRecipients(player);
for (Player p : recp) {
p.sendMessage(ChatColor.DARK_GREEN+"W"+ChatColor.WHITE+": [" + player.getDisplayName() + "]: " + message);
p.sendMessage(ChatColor.DARK_GREEN + "W" + ChatColor.WHITE + ": [" + player.getDisplayName() + "]: " + message);
}
if (recp.size() < 2) {
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
}
plugin.getLogger().info("W: ("+player.getWorld().getName()+") <" + player.getName() + "> " + message);
plugin.getLogger().info("W: (" + player.getWorld().getName() + ") <" + player.getName() + "> " + message);
} else {
sender.sendMessage("How did you get here?!");
}
Expand All @@ -71,7 +71,7 @@ public boolean broadcastMessage(CommandSender sender, String message) {
if (recp.size() < 2) {
sender.sendMessage(ChatColor.GOLD + "No one can hear you!");
}
plugin.getLogger().info("W: ("+player.getWorld().getName()+") " + message);
plugin.getLogger().info("W: (" + player.getWorld().getName() + ") " + message);
} else {
sender.sendMessage("How did you get here?!");
}
Expand All @@ -85,7 +85,7 @@ public List<Player> getRecipients(CommandSender sender) {
EntityLocation entityloc = new EntityLocation(player);
for (Player p : player.getWorld().getPlayers()) {
// if (entityloc.getDistance(p) < plugin.getConfigHandler().localchatdistance) {
recp.add(p);
recp.add(p);
// }
}
}
Expand All @@ -108,7 +108,6 @@ public List<String> getSubscribers() {
return subscribers;
}

@Override
public String getDescription() {
return "World Chat (chat in your current world)";
}
Expand All @@ -122,7 +121,7 @@ public String getColor() {
}

public String getPrefix() {
return this.getColor()+"W";
return this.getColor() + "W";
}
}

Loading

0 comments on commit 0cd2a79

Please sign in to comment.