Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More refactoring,

Added a test for the newer Event format,
Fixed some typo's,
Added AgeLock tamermode,
Added ClientBridge support (will put that on GitHub shortly, after i iron out some horrible code)
  • Loading branch information...
commit f37610de9596ec01fb1d57b14b2dac0a1ae3f9ba 1 parent 81a1e5d
@GuntherDW authored
Showing with 354 additions and 269 deletions.
  1. +2 −2 plugin.yml
  2. +3 −5 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatHandler.java
  3. +30 −0 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatMode.java
  4. +2 −1  src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
  5. +0 −134 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/TCUtilsChat.java
  6. +9 −0 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
  7. +1 −1  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/AdminCommands.java
  8. +1 −1  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/ChatCommands.java
  9. +1 −1  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/DebugCommands.java
  10. +11 −3 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/EssentialsCommands.java
  11. +9 −1 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/GeneralCommands.java
  12. +4 −2 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/TeleportationCommands.java
  13. +2 −2 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/WeatherCommands.java
  14. +32 −20 src/com/guntherdw/bukkit/tweakcraft/Configuration/ConfigurationHandler.java
  15. +7 −3 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftBlockListener.java
  16. +9 −1 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftEntityListener.java
  17. +94 −15 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftPlayerListener.java
  18. +7 −4 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftWorldListener.java
  19. +2 −2 src/com/guntherdw/bukkit/tweakcraft/Packages/CraftIRCEndPoint.java
  20. +9 −0 src/com/guntherdw/bukkit/tweakcraft/Packages/LocalPlayer.java
  21. +1 −0  src/com/guntherdw/bukkit/tweakcraft/Packages/TamerMode.java
  22. +2 −2 src/com/guntherdw/bukkit/tweakcraft/Tools/ArgumentParser.java
  23. +14 −17 src/com/guntherdw/bukkit/tweakcraft/Tools/PermissionsResolver.java
  24. +11 −0 src/com/guntherdw/bukkit/tweakcraft/Tools/TamerTool.java
  25. +47 −13 src/com/guntherdw/bukkit/tweakcraft/TweakcraftUtils.java
  26. +5 −5 src/com/guntherdw/bukkit/tweakcraft/Util/EntityLocation.java
  27. +39 −34 src/com/guntherdw/bukkit/tweakcraft/Util/TeleportHistory.java
View
4 plugin.yml
@@ -1,7 +1,7 @@
name: TweakcraftUtils
main: com.guntherdw.bukkit.tweakcraft.TweakcraftUtils
-softdepend: [ 'CraftIRC' ]
-#depend: [ CraftIRC ]
+# softdepend: [ 'CraftIRC' ]
+# depend: [ CraftIRC ]
version: 2.8.0-git
authors:
- GuntherDW
View
8 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatHandler.java
@@ -45,8 +45,6 @@ public ChatHandler(TweakcraftUtils instance) {
this.registerChatMode("region", new RegionChat(this));
this.registerChatMode("zones", new ZoneChat(this));
this.registerChatMode("world", new WorldChat(this));
-
- this.registerChatMode("tcutils", new TCUtilsChat(this)); /* IRC extra stuff */
}
public boolean registerChatMode(String chatModeLabel, ChatMode chatMode) {
@@ -82,9 +80,9 @@ public TweakcraftUtils getTCUtilsInstance() {
public List<String> listChatModes() {
List<String> l = new ArrayList<String>();
- for (String s : chatmodes.keySet()) {
- if ((chatmodes.get(s)).isEnabled() && !((chatmodes.get(s)).isHidden()))
- l.add(s);
+ for (Map.Entry<String, ChatMode> s : chatmodes.entrySet()) {
+ if(s.getValue().isEnabled() && !s.getValue().isHidden())
+ l.add(s.getKey());
}
return l;
}
View
30 src/com/guntherdw/bukkit/tweakcraft/Chat/ChatMode.java
@@ -61,6 +61,22 @@ public boolean sendMessage(CommandSender sender, String message) {
}
/**
+ * Broadcasts a message in the ChatMode without a playertag
+ *
+ * @param message
+ * @return
+ */
+ public boolean broadcastMessage(String message) {
+ // String msg = message;
+ for (Player p : getRecipients(null)) {
+ p.sendMessage(message);
+ }
+
+ logChat(message);
+ return true;
+ }
+
+ /**
* Returns a list of players that will get the message
*
* @return
@@ -155,6 +171,11 @@ public String getLoggingFormatString() {
return name + ": <%1$s> %2$s";
}
+ public String getLoggingFormatStringNoPlayerTag() {
+ String name = this.chatModeName == null ? getClass().getSimpleName() : chatModeName;
+ return name + ": %1$s";
+ }
+
public String getChatFormatString() {
String prefix = getPrefix();
return (prefix != null ? prefix + ": " : "") + "[%1$s] %2$s";
@@ -167,4 +188,13 @@ public void logChat(CommandSender sender, String message) {
logger.info(logMessage);
}
}
+
+ public void logChat(String message) {
+
+ String logFormat = getLoggingFormatString();
+ if (logFormat != null) {
+ String logMessage = String.format(getLoggingFormatStringNoPlayerTag(), message);
+ logger.info(logMessage);
+ }
+ }
}
View
3  src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/AdminChat.java
@@ -110,6 +110,7 @@ public boolean broadcastMessage(CommandSender sender, String message) {
return true;
}
+ @Override
public boolean broadcastMessage(String message) {
// String msg = message;
for (Player p : getRecipients(null)) {
@@ -194,6 +195,6 @@ public String getColor() {
}
public String getPrefix() {
- return this.getColor() + "A";
+ return this.getColor() + "A" + ChatColor.WHITE.toString();
}
}
View
134 src/com/guntherdw/bukkit/tweakcraft/Chat/Modes/TCUtilsChat.java
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2012 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.Chat.Modes;
-
-import com.ensifera.animosity.craftirc.CraftIRC;
-import com.ensifera.animosity.craftirc.EndPoint;
-import com.ensifera.animosity.craftirc.RelayedMessage;
-import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
-import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
-import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author GuntherDW
- */
-public class TCUtilsChat extends ChatMode {
-
- private TweakcraftUtils plugin;
- // private EndPoint tcendpoint = null;
- private CraftIRC circ = null;
- private Set<Player> emptyHashSet = new HashSet<Player>();
-
- public TCUtilsChat(ChatHandler instance) {
- super(instance);
- this.plugin = instance.getTCUtilsInstance();
- // this.tcendpoint = plugin.getEndPoint();
- if (plugin.getConfigHandler().enableIRC) {
- this.circ = plugin.getCraftIRC();
- circ.registerEndPoint("tcutils", plugin.getEndPoint());
-
- // this.tcendpoint =
- }
- }
-
- @Override
- public Set<Player> getRecipients(CommandSender sender) {
- return emptyHashSet;
- }
-
- @Override
- public boolean broadcastMessage(CommandSender sender, String message) {
- String msg = message;
- if (sender instanceof Player) {
- sender.sendMessage(msg);
- }
- for (Player p : getRecipients(sender)) {
- p.sendMessage(msg);
- }
- return true;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public boolean sendMessage(CommandSender sender, String message) {
- String sendername = "";
- String pcolor = "";
- String cleanname;
-
- if(plugin.getConfigHandler().enableIRC) {
-
- if (sender instanceof Player) {
- sendername = ((Player) sender).getDisplayName(); // ((Player)sender).getName();
- pcolor = ""; // getDisplayName handles this one!
- cleanname = ((Player) sender).getName();
- } else {
- sendername = "CONSOLE";
- cleanname = sendername;
- pcolor = ChatColor.LIGHT_PURPLE.toString();
- }
- String targetmsg = plugin.getConfigHandler().GIRCMessageFormat;
- targetmsg = targetmsg.replace("%name%", cleanname).
- replace("%message%", message).
- replace("%dispname%", ChatColor.stripColor(sendername));
- RelayedMessage rmsg = plugin.getCraftIRC().newMsgToTag(plugin.getAdminEndPoint(), plugin.getConfigHandler().GIRCtag, "generic");
- rmsg.setField("sender", pcolor + sendername);
- rmsg.setField("realSender", cleanname);
- rmsg.setField("message", targetmsg);
- if (sender instanceof Player) {
- Player p = (Player) sender;
- // World w = p.getWorld();
- rmsg.setField("world", p.getWorld().getName());
- rmsg.setField("prefix", plugin.getPermissions().getResolver().getUserPrefix(p.getWorld().getName(), p));
- rmsg.setField("suffix", plugin.getPermissions().getResolver().getUserSuffix(p.getWorld().getName(), p));
- }
- rmsg.post();
- }
- return true;
- }
-
- @Override
- public boolean isHidden() {
- return true;
- }
-
- @Override
- public String getDescription() {
- return "CraftIRC extra endpoint";
- }
-
- @Override
- public String getColor() {
- return ChatColor.WHITE.toString();
- }
-
- @Override
- public String getPrefix() {
- return "TCIRC";
- }
-}
View
9 src/com/guntherdw/bukkit/tweakcraft/Commands/CommandHandler.java
@@ -186,6 +186,11 @@ public boolean executeCommand(CommandSender sender, String name, String[] args)
public boolean runMethod(CommandSender sender, String name, String[] args)
throws PermissionsException, CommandSenderException, CommandUsageException, CommandException {
+ String argsString = "";
+ for(String a : args) {
+ argsString+= a+" ";
+ }
+
try {
Method command = getCommand(name);
return (Boolean) command.invoke(getMethodInstance(command), sender, name, args);
@@ -201,9 +206,13 @@ public boolean runMethod(CommandSender sender, String name, String[] args)
throw (CommandException) t;
logger.warning("[TweakcraftUtils] Error occured while executing command!");
+ logger.warning("[TweakcraftUtils] Errornous command : "+name+" "+argsString+"!");
+ logger.warning("[TweakcraftUtils] CommandSender : "+(sender instanceof Player?((Player)sender).getName():"CONSOLE"));
e.printStackTrace();
} catch (IllegalAccessException e) {
logger.warning("[TweakcraftUtils] Error occured while executing command!");
+ logger.warning("[TweakcraftUtils] Errornous command : "+name+" "+argsString+"!");
+ logger.warning("[TweakcraftUtils] CommandSender : "+(sender instanceof Player?((Player)sender).getName():"CONSOLE"));
e.printStackTrace();
}
View
2  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/AdminCommands.java
@@ -45,7 +45,7 @@
*/
public class AdminCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public AdminCommands(TweakcraftUtils instance) {
this.plugin = instance;
View
2  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/ChatCommands.java
@@ -38,7 +38,7 @@
*/
public class ChatCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public ChatCommands(TweakcraftUtils instance) {
this.plugin = instance;
View
2  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/DebugCommands.java
@@ -34,7 +34,7 @@
*/
public class DebugCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public DebugCommands(TweakcraftUtils instance) {
this.plugin = instance;
View
14 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/EssentialsCommands.java
@@ -53,8 +53,7 @@
*/
public class EssentialsCommands {
-
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public EssentialsCommands(TweakcraftUtils instance) {
this.plugin = instance;
@@ -987,6 +986,7 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
int health = ap.getInteger("h", -1);
boolean powered = ap.getBoolean("pow", false);
boolean shoven = ap.getBoolean("sh", false);
+ boolean agelock = ap.getBoolean("l", false);
String sheepcolor = ap.getString("sc", null);
String victim = ap.getString("p", null);
int age = ap.getInteger("a", -1);
@@ -1066,6 +1066,7 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
if (sender instanceof Player) {
victimplayer = (Player) sender;
loc = victimplayer.getTargetBlock((HashSet<Byte>) null, 200).getLocation();
+ loc.add(0, 1, 0);
} else {
throw new CommandException("If you're a console, at least tell me who i need to scare?");
}
@@ -1078,8 +1079,15 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
if (health > 0)
lent.setHealth(health);
- if (lent instanceof Animals && age != -1)
+ if (lent instanceof Animals && age != -1) {
((Animals) lent).setAge(age);
+ if(ap.isflagUsed("l"))
+ ((Animals) lent).setAgeLock(true);
+ else
+ ((Animals) lent).setAgeLock(agelock);
+
+ }
+
if (lent instanceof Slime && slimesize > 0)
((Slime) lent).setSize(slimesize);
View
10 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/GeneralCommands.java
@@ -51,7 +51,7 @@
*/
public class GeneralCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public GeneralCommands(TweakcraftUtils instance) {
this.plugin = instance;
@@ -927,6 +927,14 @@ public boolean tamer(CommandSender sender, String command, String[] args)
}
mode = new TamerMode(state, TamerMode.TamerModes.SIT);
player.sendMessage(ChatColor.GREEN+"TamerTool SIT MODE selected!");
+ } else if(args.length>0 && args[0].equalsIgnoreCase("agelock")) {
+ // Boolean ageLock = false;
+ if(args.length>1) {
+ state = Boolean.parseBoolean(args[1]);
+ }
+ mode = new TamerMode(state, TamerMode.TamerModes.SETAGELOCK);
+ player.sendMessage(ChatColor.GREEN+"TamerTool AGELOCK MODE selected!");
+
} else if(args.length>0 && args[0].equalsIgnoreCase("setage")) {
int age = -1;
if(args.length>1) {
View
6 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/TeleportationCommands.java
@@ -40,7 +40,7 @@
*/
public class TeleportationCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public TeleportationCommands(TweakcraftUtils instance) {
this.plugin = instance;
@@ -123,7 +123,7 @@ public boolean teleportToLocation(CommandSender sender, String command, String[]
if (args.length == 3) {
if (y == null) y = Integer.parseInt(args[2]);
} else {
- y = 129;
+ y = -1;
}
} catch (NumberFormatException ex) {
throw new CommandException("I need numbers not strings!");
@@ -164,6 +164,8 @@ public boolean teleportToLocation(CommandSender sender, String command, String[]
Location oldloc = victim.getLocation();
Location loc = new Location(world, x.doubleValue(), y.doubleValue(), z.doubleValue());
+ if (y == -1) loc.setY(loc.getWorld().getMaxHeight() + 1);
+
if (victim.teleport(loc)) {
plugin.getTelehistory().addHistory(victim.getName(), oldloc);
}
View
4 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/WeatherCommands.java
@@ -42,7 +42,7 @@
*/
public class WeatherCommands {
- TweakcraftUtils plugin;
+ private TweakcraftUtils plugin;
public WeatherCommands(TweakcraftUtils instance) {
this.plugin = instance;
@@ -71,7 +71,7 @@ public boolean strikeLightning(CommandSender sender, String command, String[] ar
throw new CommandUsageException("Can't find player!");
}
loc = players.get(0).getLocation();
- sender.sendMessage(ChatColor.RED + "I hope " + players.get(0).getName() + ChatColor.RED + " wasn't standing under a tree!");
+ sender.sendMessage(ChatColor.RED + "I hope " + players.get(0).getDisplayName() + ChatColor.RED + " wasn't standing under a tree!");
}
if (loc != null) {
View
52 src/com/guntherdw/bukkit/tweakcraft/Configuration/ConfigurationHandler.java
@@ -27,6 +27,7 @@
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -40,7 +41,7 @@
private File globalconfigFile;
private File seenconfigFile;
-
+
private YamlConfiguration globalconfig = new YamlConfiguration();
private YamlConfiguration seenconfig = new YamlConfiguration();
private TweakcraftUtils plugin;
@@ -74,9 +75,12 @@
public boolean useTweakBotSeen = false;
public String AIRCtag = "mchatadmin";
public String GIRCtag = "mchat";
- public String GIRCMessageFormat = "[A] <%name%> %message%";
- public String AIRCMessageFormat = "<%name%> %message%";
+ public String LoggingIRCtag = "mchatlog";
+ public String AIRCMessageFormat = "[A] <%name%> %message%";
+ public String GIRCMessageFormat = "<%name%> %message%";
+ public String LoggingIRCMessageFormat = "<%name%> %message%";
public boolean cancelNickChat = true;
+ public boolean LoggingIRCenabled = true;
public boolean GIRCenabled = true;
public boolean AIRCenabled = false;
public boolean enableDebug = false; /* Verbose messages */
@@ -96,6 +100,7 @@
public int snowPileMaxHeight = 7;
public boolean enableSnowDouble = false;
public int tweakTravelSearchWidth = 3;
+ public boolean enableVanish = false;
public boolean enableFallDistanceNullify = false;
@@ -133,26 +138,34 @@ public void reloadConfig() {
plugin.getDataFolder().mkdirs();
}
// if(this.globalconfig==null) this.globalconfig = (YamlConfiguration) plugin.getConfig();
- if(globalconfigFile==null) {
+ if (!globalconfigFile.exists()) {
plugin.getLogger().warning("[TweakcraftUtils] No config file found, using default values!");
return;
}
try {
globalconfig.load(globalconfigFile);
- } catch (IOException e) {
- plugin.getLogger().warning("[TweakcraftUtils] IOException while loading config file, using old values!");
- e.printStackTrace();
- return;
} catch (InvalidConfigurationException e) {
plugin.getLogger().warning("[TweakcraftUtils] InvalidConfigurationException while loading config file, using old values!");
e.printStackTrace();
return;
+ } /* catch (FileNotFoundException e) {
+ plugin.getLogger().warning("[TweakcraftUtils] No config file found, using default values!");
+ e.printStackTrace();
+ return;
+ } */ catch (IOException e) {
+ plugin.getLogger().warning("[TweakcraftUtils] IOException while loading config file, using old values!");
+ e.printStackTrace();
+ return;
}
// plugin.reloadConfig();
this.plugin.getLogger().info("[TweakcraftUtils] Parsing configuration file...");
this.plugin.getLogger().info("[TweakcraftUtils] Config : "+globalconfigFile.getAbsolutePath());
+ this.enablePersistence = globalconfig.getBoolean("Persistence.enabled", true);
+ this.useTweakBotSeen = globalconfig.getBoolean("Persistence.useTweakBotSeen", false);
+ plugin.getLogger().info("[TweakcraftUtils] Using TweakBot's seen table for /seen!");
+
this.enableLocalChat = globalconfig.getBoolean("ChatMode.LocalChat.enabled", true);
this.localchatdistance = globalconfig.getInt("ChatMode.LocalChat.range", 200);
this.enableWorldChat = globalconfig.getBoolean("ChatMode.WorldChat.enabled", true);
@@ -163,8 +176,11 @@ public void reloadConfig() {
this.AIRCenabled = globalconfig.getBoolean("CraftIRC.admin.enabled", false);
this.AIRCtag = globalconfig.getString("CraftIRC.admin.tag", "mchatadmin");
this.GIRCMessageFormat = globalconfig.getString("CraftIRC.regular.MessageFormat");
- this.GIRCtag = globalconfig.getString("CraftIRC.regular.tag", "mchatadmin");
- this.GIRCenabled = globalconfig.getBoolean("CraftIRC.regular.enabled", true);
+ this.GIRCtag = globalconfig.getString("CraftIRC.regular.tag", "mchat");
+ this.GIRCMessageFormat = globalconfig.getString("CraftIRC.regular.MessageFormat");
+ this.LoggingIRCenabled = globalconfig.getBoolean("CraftIRC.log.enabled", true);
+ this.LoggingIRCtag = globalconfig.getString("CraftIRC.log.tag", "mchatlog");
+ this.LoggingIRCMessageFormat = globalconfig.getString("CraftIRC.log.MessageFormat");
this.enableTPBack = globalconfig.getBoolean("enableTPBack", true);
this.enableDebug = globalconfig.getBoolean("debug.enabled", false);
if(this.enableDebug) {
@@ -176,13 +192,7 @@ public void reloadConfig() {
this.extrahelpplugin = new ArrayList<String>();
this.enableGroupChat = globalconfig.getBoolean("ChatMode.GroupChat", true);
- this.enablePersistence = globalconfig.getBoolean("Persistence.enabled", true);
- this.useTweakBotSeen = globalconfig.getBoolean("Persistence.useTweakBotSeen", false);
- plugin.getLogger().info("[TweakcraftUtils] Using TweakBot's seen table for /seen!");
- if(this.enablePersistence) {
- if(!plugin.databaseloaded)
- plugin.setupDatabase();
- }
+
List<String> extralist = globalconfig.getStringList("extrahelp.plugins");
if(extralist!=null)
for(String plist : extralist) {
@@ -201,7 +211,7 @@ public void reloadConfig() {
this.cancelNetherPortal = globalconfig.getBoolean("worlds.cancelportal", false);
this.extrahelphide = globalconfig.getStringList("extrahelp.hide");
-
+
if (globalconfig.getBoolean("PlayerHistory.enabled", false)) {
plugin.getLogger().info("[TweakcraftUtils] Keeping player history!");
File seenFile = new File(plugin.getDataFolder(), "players.yml");
@@ -241,6 +251,8 @@ public void reloadConfig() {
this.snowPileMaxHeight = Math.max(this.snowPileMaxHeight, 7);
this.enableSnowDouble = globalconfig.getBoolean("extra.snowpile.doublesnowball", false);
this.enableInjectedCommandsHanding = globalconfig.getBoolean("extra.enableInjectedCommandsHanding", false);
+ this.enableVanish = globalconfig.getBoolean("invisible.useVanish", false);
+
this.enableWorldMOTD = globalconfig.getBoolean("worlds.worldMOTD", false);
@@ -285,7 +297,7 @@ public boolean isEnableSeenConfig() {
public YamlConfiguration getSeenconfig() {
return seenconfig;
}
-
+
public Map<String, Map<Integer, Boolean>> getLsbindmap() {
return lsbindmap;
}
@@ -293,7 +305,7 @@ public YamlConfiguration getSeenconfig() {
public Map<String, LockdownLocation> getLockdowns() {
return lockdowns;
}
-
+
public String getDirSeperator() {
return System.getProperty("file.separator");
}
View
10 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftBlockListener.java
@@ -23,9 +23,11 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFormEvent;
-import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.inventory.ItemStack;
@@ -34,7 +36,7 @@
/**
* @author GuntherDW
*/
-public class TweakcraftBlockListener extends BlockListener {
+public class TweakcraftBlockListener implements Listener {
private TweakcraftUtils plugin = null;
@@ -42,6 +44,7 @@ public TweakcraftBlockListener(TweakcraftUtils instance) {
this.plugin = instance;
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onSignChange(SignChangeEvent event) {
if (event.isCancelled()) return;
if (plugin.getConfigHandler().enableTweakTravel && event.getLine(0).equalsIgnoreCase("[TweakTravel]") && !plugin.check(event.getPlayer(), "tweaktravel.create")) {
@@ -50,6 +53,7 @@ public void onSignChange(SignChangeEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onBlockForm(BlockFormEvent event) {
if (event.isCancelled()) return;
if (!plugin.getConfigHandler().enableSnowPile) return;
@@ -72,7 +76,7 @@ public void onBlockForm(BlockFormEvent event) {
}
}
-
+ @EventHandler(priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled()) return;
if (!plugin.getConfigHandler().enableSnowDouble) return;
View
10 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftEntityListener.java
@@ -27,6 +27,9 @@
import org.bukkit.entity.Entity;
import org.bukkit.entity.Pig;
import org.bukkit.entity.Player;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@@ -35,7 +38,7 @@
/**
* @author GuntherDW
*/
-public class TweakcraftEntityListener extends EntityListener {
+public class TweakcraftEntityListener implements Listener {
private TweakcraftUtils plugin;
@@ -43,6 +46,7 @@ public TweakcraftEntityListener(TweakcraftUtils instance) {
this.plugin = instance;
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onEntityTarget(EntityTargetEvent event) {
if (!plugin.getConfigHandler().enableTargetIgnoreAFKPlayers
|| event.isCancelled() || !(event.getTarget() instanceof Player)) return;
@@ -54,6 +58,7 @@ public void onEntityTarget(EntityTargetEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onProjectileHit(ProjectileHitEvent event) {
if (!plugin.getConfigHandler().enableTNTArrows) return;
if (event.getEntity() == null || !(event.getEntity() instanceof Arrow)) return;
@@ -90,6 +95,7 @@ public void onProjectileHit(ProjectileHitEvent event) {
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onEntityCombust(EntityCombustEvent event) {
if (!plugin.getConfigHandler().stopIgniteWorldGuard) return;
Entity ent = event.getEntity();
@@ -102,6 +108,7 @@ public void onEntityCombust(EntityCombustEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
Entity ent = event.getEntity();
if (ent instanceof Pig) {
@@ -116,6 +123,7 @@ public void onEntityDeath(EntityDeathEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onExplosionPrime(ExplosionPrimeEvent event) {
if (event.isCancelled()) return;
View
109 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftPlayerListener.java
@@ -37,10 +37,15 @@
import org.bukkit.block.Sign;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.*;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.plugin.messaging.Messenger;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.*;
@@ -48,12 +53,13 @@
/**
* @author GuntherDW
*/
-public class TweakcraftPlayerListener extends PlayerListener {
+public class TweakcraftPlayerListener implements Listener {
//private final Logger log = Logger.getLogger("Minecraft");
private final TweakcraftUtils plugin;
private Set<String> invisplayers;
private Map<String, String> nicks;
+ private Map<String, String> capes;
private Set<PlayerInfo> playerinfo = new HashSet<PlayerInfo>();
private Set<PlayerOptions> playeroptions = new HashSet<PlayerOptions>();
private Set<String> nomount = new HashSet<String>();
@@ -62,6 +68,7 @@
return nomount;
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (event.isCancelled()) return;
@@ -71,7 +78,7 @@ public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if (line.contains(" ")) {
String c[] = cmd.split(" ");
cmd = c[0];
- for(int x=1; x<c.length; x++)
+ for (int x = 1; x < c.length; x++)
args.add(c[x]);
}
if (cmd.startsWith("/") && cmd.length() > 1)
@@ -126,6 +133,7 @@ public TweakcraftPlayerListener(TweakcraftUtils instance) {
plugin = instance;
invisplayers = new HashSet<String>();
nicks = new HashMap<String, String>();
+ capes = new HashMap<String, String>();
}
public void setNick(String player, String nick) {
@@ -141,12 +149,19 @@ public void setNick(String player, String nick) {
pi.setNick(nick);
plugin.getDatabase().save(pi);
}
+
+ if (plugin.getClientBridge() != null) {
+ for(Player p : plugin.getServer().getOnlinePlayers()) {
+ plugin.getClientBridge().getPlayerListener().sendPlayerInfo(p, lp.getBukkitPlayerSafe().getName(), true);
+ }
+ }
}
public boolean removeNick(String player) {
LocalPlayer lp = plugin.wrapPlayer(player);
if (lp.hasNick()) {
+ System.out.println("Doing nicks.remove");
nicks.remove(player);
if (plugin.getConfigHandler().enablePersistence) {
PlayerInfo pi = plugin.getDatabase().find(PlayerInfo.class).where().ieq("name", player).findUnique();
@@ -158,8 +173,14 @@ public boolean removeNick(String player) {
lp.setNick(null);
plugin.getDatabase().update(pi);
}
+ if (plugin.getClientBridge() != null) {
+ for(Player p : plugin.getServer().getOnlinePlayers()) {
+ plugin.getClientBridge().getPlayerListener().sendPlayerInfo(p, lp.getBukkitPlayerSafe().getName(), true);
+ }
+ }
return true;
} else {
+ System.out.println("NOT doing nicks.remove");
return false;
}
}
@@ -262,6 +283,7 @@ public void reloadInfo() {
playerinfo = plugin.getDatabase().find(PlayerInfo.class).findSet();
nicks.clear();
+ capes.clear();
for (PlayerInfo pi : playerinfo) {
LocalPlayer lp = plugin.wrapPlayer(pi.getName());
if (pi.getNick() != null) {
@@ -269,6 +291,7 @@ public void reloadInfo() {
plugin.getLogger().info("[TweakcraftUtils] Setting " + pi.getName() + "'s nick to " + pi.getNick());
nicks.put(pi.getName(), pi.getNick());
pi.setNick(pi.getNick());
+ lp.setNick(pi.getNick());
}
}
playeroptions = plugin.getDatabase().find(PlayerOptions.class).findSet();
@@ -292,9 +315,28 @@ public void reloadInfo() {
}
plugin.getChathandler().updateMute(po.getName(), toTime);
}
+ if(po.getOptionname().equals("capeurl")) {
+ if (plugin.getConfigHandler().enableDebug)
+ plugin.getLogger().info("[TweakcraftUtils] Setting " + po.getName() + "'s CapeURL option!");
+ LocalPlayer lp = plugin.wrapPlayer(po.getName());
+ lp.setCapeURL(po.getOptionvalue());
+ capes.put(po.getName(), po.getOptionvalue());
+ }
+ }
+ if(plugin.getClientBridge() != null) {
+ plugin.getClientBridge().getPlayerListener().reloadInfo();
}
}
+
+ public Map<String, String> getNicks() {
+ return nicks;
+ }
+ public Map<String, String> getCapeURLs() {
+ return capes;
+ }
+
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerChat(PlayerChatEvent event) {
if (event.isCancelled()) return;
@@ -378,6 +420,7 @@ public void onPlayerChat(PlayerChatEvent event) {
}
}
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerRespawn(PlayerRespawnEvent event) {
// if(event.isBedSpawn())
if (!plugin.getConfigHandler().enableRespawnHook) return;
@@ -405,6 +448,7 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
p.setHealth(20);
}
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (event.isCancelled()) return;
if (event.getFrom().getWorld() != event.getTo().getWorld()) { // The world is different, make a check!
@@ -425,7 +469,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
}
}
-
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerLogin(PlayerLoginEvent event) {
BanHandler handler = plugin.getBanhandler();
Ban isBanned = handler.isBannedBan(event.getPlayer().getName());
@@ -434,7 +478,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
}
}
-
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
String name = p.getName();
@@ -463,6 +507,14 @@ public void onPlayerJoin(PlayerJoinEvent event) {
for (Player play : plugin.getServer().getOnlinePlayers()) {
if (plugin.check(play, "tpinvis"))
play.sendMessage(ChatColor.AQUA + "Stealth join : " + event.getPlayer().getDisplayName());
+ else {
+ if(plugin.getConfigHandler().enableVanish)
+ play.hidePlayer(p);
+ }
+ }
+
+ if(plugin.getConfigHandler().enableVanish) {
+ //p.hidePlayer();
}
}
@@ -480,6 +532,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event) {
String name = event.getPlayer().getName();
@@ -548,6 +601,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
/**
* I still don't get why my event.getItem or i keeps on nulling out, if anyone can help, please do
*/
+ @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
@@ -609,6 +663,7 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerKick(PlayerKickEvent event) {
if (event.isCancelled()) return;
@@ -622,7 +677,7 @@ public void onPlayerKick(PlayerKickEvent event) {
}
public void reloadInvisTable() {
- List<String> lijst = plugin.getConfig().getStringList("invisible-playerlist");
+ List<String> lijst = plugin.getConfig().getStringList("invisible.playerList");
if (lijst != null) {
/* Clear the old playerlist, there could be old players on there,
@@ -653,7 +708,7 @@ private boolean isTweakTravelSign(Block block) {
return false;
}
-
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerPortal(PlayerPortalEvent event) {
if (event.isCancelled()) return;
@@ -695,21 +750,22 @@ public void onPlayerPortal(PlayerPortalEvent event) {
String line3 = sign.getLine(2);
// if(line3.length()>3)
- iWorld iw = plugin.getworldManager().getWorld(toWorld);
- if (!plugin.check(p, "worlds." + iw.getName())) {
+ // iWorld iw = plugin.getworldManager().getWorld(toWorld);
+ World world = plugin.getServer().getWorld(toWorld);
+ if (world != null && !plugin.check(p, "worlds." + world.getName())) {
p.sendMessage(ChatColor.RED + "You do not have permission to portal to this world!");
event.setCancelled(true);
} else {
- if (iw != null) {
+ if (world != null) {
String[] coordsStrings = null;
Integer[] coords = new Integer[3];
coordsStrings = line3.split(",");
- Location loc = iw.getBukkitWorld().getSpawnLocation();
+ Location loc = world.getSpawnLocation();
if (coordsStrings.length == 3) {
coords[0] = Integer.parseInt(coordsStrings[0]);
coords[1] = Integer.parseInt(coordsStrings[1]);
coords[2] = Integer.parseInt(coordsStrings[2]);
- loc = new Location(iw.getBukkitWorld(), coords[0], coords[1], coords[2]);
+ loc = new Location(world, coords[0], coords[1], coords[2]);
}
@@ -720,7 +776,7 @@ public void onPlayerPortal(PlayerPortalEvent event) {
if (loc != null) {
event.setTo(loc);
} else {
- event.setTo(iw.getBukkitWorld().getSpawnLocation());
+ event.setTo(world.getSpawnLocation());
}
ta.setSearchRadius(0);
@@ -773,6 +829,7 @@ public void onPlayerPortal(PlayerPortalEvent event) {
}
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Entity entity = event.getRightClicked();
Player player = event.getPlayer();
@@ -793,14 +850,25 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
event.setCancelled(true);
TamerMode mode = plugin.getTamerTool().getTamers().get(player);
-
- if (mode.getMode() == TamerMode.TamerModes.SETAGE) {
+ if (mode == null) {
+ return;
+ } else if (mode.getMode() == TamerMode.TamerModes.SETAGE) {
if (!plugin.check(player, "tamer.setage")) {
player.sendMessage(ChatColor.RED + "You don't have permission to set the age of animals!");
} else {
player.sendMessage(ChatColor.BLUE + "Setting animal age to " + mode.getData());
animal.setAge(mode.getData());
}
+ } else if(mode.getMode() == TamerMode.TamerModes.SETAGELOCK) {
+
+ if(plugin.check(player, "tamer.setage")) {
+ if(mode.getState() == null)
+ mode.setState(!animal.getAgeLock());
+ player.sendMessage(ChatColor.BLUE + "Setting animal agelock to " + mode.getState());
+ animal.setAgeLock(mode.getState());
+ } else {
+ player.sendMessage(ChatColor.RED + "You don't have permission to set the age of animals!");
+ }
} else {
CreatureType type = CreatureType.fromName(animal.getClass().getCanonicalName().split("Craft")[1]);
@@ -808,7 +876,8 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
player.sendMessage(ChatColor.BLUE + "Animal info : ");
player.sendMessage(ChatColor.BLUE + "type : " + ChatColor.YELLOW + cname);
player.sendMessage(ChatColor.BLUE + "health : " + ChatColor.YELLOW + animal.getHealth());
- player.sendMessage(ChatColor.BLUE + "age : " + ChatColor.YELLOW + animal.getAge());
+ player.sendMessage(ChatColor.BLUE + "entityId : "+ChatColor.YELLOW + animal.getEntityId());
+ player.sendMessage(ChatColor.BLUE + "age : " + ChatColor.YELLOW + animal.getAge() + (animal.getAgeLock()? ChatColor.RED+" L":""));
}
return;
@@ -835,6 +904,15 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
player.setItemInHand(new ItemStack(Material.BUCKET, 1));
player.getWorld().playEffect(animal.getLocation(), Effect.POTION_BREAK, 0);
}
+ } else if (entity instanceof Monster || entity instanceof Flying) {
+ if (player.getItemInHand().getTypeId() == plugin.getConfigHandler().tamertoolid) {
+ LivingEntity lent = (LivingEntity) entity;
+ CreatureType type = CreatureType.fromName(lent.getClass().getCanonicalName().split("Craft")[1]);
+ String cname = type.getName().toLowerCase();
+ player.sendMessage(ChatColor.BLUE + "Creature info : ");
+ player.sendMessage(ChatColor.BLUE + "type : " + ChatColor.YELLOW + cname);
+ player.sendMessage(ChatColor.BLUE + "health : " + ChatColor.YELLOW + lent.getHealth());
+ }
}
}
}
@@ -907,6 +985,7 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
}
}
+ @EventHandler(priority = EventPriority.HIGH)
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
if (!plugin.getConfigHandler().enableWorldMOTD) return;
View
11 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftWorldListener.java
@@ -22,13 +22,15 @@
import org.bukkit.Chunk;
import org.bukkit.block.BlockState;
import org.bukkit.block.Furnace;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkUnloadEvent;
-import org.bukkit.event.world.WorldListener;
/**
* @author GuntherDW
*/
-public class TweakcraftWorldListener extends WorldListener {
+public class TweakcraftWorldListener implements Listener {
private TweakcraftUtils plugin;
@@ -36,14 +38,15 @@ public TweakcraftWorldListener(TweakcraftUtils instance) {
this.plugin = instance;
}
+ @EventHandler(priority = EventPriority.NORMAL)
public void onChunkUnload(ChunkUnloadEvent event) {
if (event.isCancelled())
return;
if (plugin.getConfigHandler().stopChunkUnloadBurningFurnace) {
Chunk chunk = event.getChunk();
- BlockState[] states = chunk.getTileEntities();
- for (BlockState state : states) {
+ // BlockState[] states = chunk.getTileEntities();
+ for (BlockState state : chunk.getTileEntities()) {
if (state instanceof Furnace) {
// Furnace f = (Furnace) state;
if (((Furnace) state).getBurnTime() > 0) {
View
4 src/com/guntherdw/bukkit/tweakcraft/Packages/CraftIRCEndPoint.java
@@ -34,10 +34,10 @@
private ChatHandler ch = null;
private CraftIRC circ = null;
- public CraftIRCEndPoint(TweakcraftUtils instance) {
+ public CraftIRCEndPoint(TweakcraftUtils instance, String tag) {
this.ch = instance.getChathandler();
this.circ = instance.getCraftIRC();
- circ.registerEndPoint("tcutils", this);
+ circ.registerEndPoint(tag, this);
}
public Type getType() {
View
9 src/com/guntherdw/bukkit/tweakcraft/Packages/LocalPlayer.java
@@ -39,6 +39,7 @@
private boolean invisible = false;
private String replyTo = null;
private boolean tntArrow = false;
+ private String capeURL = null;
public boolean isInvisible() {
return this.invisible;
@@ -137,6 +138,14 @@ public ChatMode getChatMode() {
public void setChatMode(ChatMode chatMode) {
this.chatMode = chatMode;
}
+
+ public void setCapeURL(String URL) {
+ this.capeURL = URL;
+ }
+
+ public String getCapeURL() {
+ return this.capeURL;
+ }
/**
* Try to resolve a ChatMode and set it
View
1  src/com/guntherdw/bukkit/tweakcraft/Packages/TamerMode.java
@@ -34,6 +34,7 @@
HEAL,
SIT,
SETAGE,
+ SETAGELOCK,
NONE
}
View
4 src/com/guntherdw/bukkit/tweakcraft/Tools/ArgumentParser.java
@@ -77,7 +77,7 @@ public void setUsed(String argName, boolean state) {
arg.set_used(state);
if(arg.isArgType()) {
int pos = arg.getId();
- if(_args.size()>pos) _args.get(pos+1).set_used(true);
+ if(_args.size()>pos+1) _args.get(pos+1).set_used(true);
}
}
// Second the List<Argument> one, this'll require a for loop
@@ -85,7 +85,7 @@ public void setUsed(String argName, boolean state) {
arg = _args.get(x);
if(arg.getArgname() != null && arg.getArgname().equals(argName)) arg.set_used(state);
if(arg.isArgType()) {
- if(_args.size()>x) _args.get(x+1).set_used(true);
+ if(_args.size()>x+1) _args.get(x+1).set_used(true);
}
}
}
View
31 src/com/guntherdw/bukkit/tweakcraft/Tools/PermissionsResolver.java
@@ -42,38 +42,35 @@ public PermissionsResolver(TweakcraftUtils instance) {
public void init() {
boolean foundPlugin = false;
- foundPlugin=tryPermissionsEx();
- if(!foundPlugin) foundPlugin=tryNijiPerms();
- if(!foundPlugin) tryWEPIF();
- if(!foundPlugin) {
+ foundPlugin = tryPermissionsEx();
+ if (!foundPlugin) foundPlugin = tryNijiPerms();
+ if (!foundPlugin) tryWEPIF();
+ if (!foundPlugin) {
plugin.getLogger().info("[TweakcraftUtils] DinnerPerms found, using that for permissions resolving!");
resolver = new BukkitPerms(this);
- plugin.getLogger().warning("[TweakcraftUtils] Use this only as a fallback please, install and/or manage a real permissions plugin.!");
+ plugin.getLogger().warning("[TweakcraftUtils] Use this only as a fallback please, install and/or manage a real permissions plugin!");
}
}
public Permissions getResolver() {
- if(resolver==null) init();
+ if (resolver == null) init();
return resolver;
}
private boolean tryPermissionsEx() {
- try{
- if(Class.forName("ru.tehkode.permissions.PermissionsManager")!=null) {
- resolver = new PermsEx(this);
- plugin.getLogger().info("[TweakcraftUtils] PermissionsEx found, using that for permissions resolving!");
- return true;
- }
- } catch(ClassNotFoundException ex) {
- return false;
+ Plugin p = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
+ if (p != null) {
+ resolver = new PermsEx(this);
+ plugin.getLogger().info("[TweakcraftUtils] PermissionsEx found, using that for permissions resolving!");
+ return true;
}
return false;
}
private boolean tryNijiPerms() {
Plugin p = plugin.getServer().getPluginManager().getPlugin("Permissions");
- if(p!=null) {
- resolver = new NijiPerms(this, ((com.nijikokun.bukkit.Permissions.Permissions)p).getHandler());
+ if (p != null) {
+ resolver = new NijiPerms(this, ((com.nijikokun.bukkit.Permissions.Permissions) p).getHandler());
plugin.getLogger().info("[TweakcraftUtils] NijiPermissions found, using that for permissions resolving!");
return true;
}
@@ -81,7 +78,7 @@ private boolean tryNijiPerms() {
}
private boolean tryWEPIF() {
- if(plugin.getWorldEdit()!=null) {
+ if (plugin.getWorldEdit() != null) {
resolver = new WEPIFPerms(this, plugin.getWorldEdit().getPermissionsResolver());
plugin.getLogger().info("[TweakcraftUtils] WorldEdit found, using that for permissions resolving!");
plugin.getLogger().warning("[TweakcraftUtils] Use this only as a fallback please, install and/or manage a real permissions plugin.!");
View
11 src/com/guntherdw/bukkit/tweakcraft/Tools/TamerTool.java
@@ -73,6 +73,7 @@ public void getOwner(Player player, Wolf wolf) {
player.sendMessage(ChatColor.AQUA + "This wolf isn't tamed!");
}
player.sendMessage(ChatColor.AQUA + "Wolf health : "+wolf.getHealth());
+ player.sendMessage(ChatColor.AQUA + "Wolf age : "+wolf.getAge() + (wolf.getAgeLock() ? ChatColor.RED+" L":""));
if(wolf.isAngry()) {
player.sendMessage(ChatColor.AQUA + "This wolf is "+ChatColor.RED+"angry"+ChatColor.AQUA+"!");
LivingEntity le = wolf.getTarget();
@@ -217,6 +218,13 @@ public void setAge(Wolf wolf, Integer age, Player player) {
}
}
+ public void setAgeLock(Wolf wolf, Boolean lock, Player player) {
+ if(plugin.check(player, "tamer.setage")) {
+ player.sendMessage(ChatColor.BLUE + "Setting animal agelock to " + lock);
+ wolf.setAgeLock(lock);
+ }
+ }
+
public void handleEvent(Player player, Wolf wolf) {
if(!tamers.containsKey(player))
return;
@@ -238,6 +246,9 @@ public void handleEvent(Player player, Wolf wolf) {
case HEAL:
this.heal(wolf, tamermode.getState(), player);
break;
+ case SETAGELOCK:
+ this.setAgeLock(wolf, tamermode.getState(), player);
+ break;
case SETAGE:
this.setAge(wolf, tamermode.getData(), player);
break;
View
60 src/com/guntherdw/bukkit/tweakcraft/TweakcraftUtils.java
@@ -22,6 +22,7 @@
import com.ensifera.animosity.craftirc.CraftIRC;
import com.ensifera.animosity.craftirc.EndPoint;
+import com.guntherdw.bukkit.tcutilsclientbridge.TCUtilsClientBridgePlugin;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatHandler;
import com.guntherdw.bukkit.tweakcraft.Chat.ChatMode;
import com.guntherdw.bukkit.tweakcraft.Commands.CommandHandler;
@@ -34,10 +35,7 @@
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.Listeners.TweakcraftBlockListener;
-import com.guntherdw.bukkit.tweakcraft.Listeners.TweakcraftEntityListener;
-import com.guntherdw.bukkit.tweakcraft.Listeners.TweakcraftPlayerListener;
-import com.guntherdw.bukkit.tweakcraft.Listeners.TweakcraftWorldListener;
+import com.guntherdw.bukkit.tweakcraft.Listeners.*;
import com.guntherdw.bukkit.tweakcraft.Packages.CraftIRCAdminEndPoint;
import com.guntherdw.bukkit.tweakcraft.Packages.CraftIRCEndPoint;
import com.guntherdw.bukkit.tweakcraft.Packages.ItemDB;
@@ -56,11 +54,10 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
-import org.bukkit.event.Event;
-import org.bukkit.event.Event.Priority;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
+import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import javax.persistence.PersistenceException;
@@ -68,7 +65,6 @@
import java.util.*;
import java.util.logging.Logger;
-// import com.ensifera.animosity.craftirc.EndPoint;
/**
* @author GuntherDW
@@ -82,6 +78,7 @@
protected Zones zones = null;
protected LogBlock lb = null;
protected WorldEditPlugin we = null;
+ protected TCUtilsClientBridgePlugin tcUtilsClientBridgePlugin = null;
// protected NoLagg nolagg = null;
// protected PermissionHandler ph = null;
@@ -99,10 +96,10 @@
private final ChatHandler chathandler = new ChatHandler(this);
private final PermissionsResolver permsResolver = new PermissionsResolver(this);
-
private HashMap<String, LocalPlayer> localPlayers = new HashMap<String, LocalPlayer>();
private Object circendpoint = null;
+ private Object cirdlogendpoint = null;
private Object circadminendpoint = null;
private Set<String> donottplist;
@@ -145,6 +142,15 @@ public static TweakcraftUtils getInstance() {
return instance;
}
+ public TCUtilsClientBridgePlugin getClientBridge() {
+ return tcUtilsClientBridgePlugin;
+ }
+
+ public static void registerClientBridge(TCUtilsClientBridgePlugin clientBridgePlugin) {
+ if(instance==null) return;
+ instance.tcUtilsClientBridgePlugin = clientBridgePlugin;
+ }
+
public void sendCUIChatMode(Player player) {
if (this.cuiPlayers != null && this.cuiPlayers.contains(player)) {
ChatMode cm = getChathandler().getPlayerChatMode(player);
@@ -152,8 +158,10 @@ public void sendCUIChatMode(Player player) {
if (cm == null)
player.sendRawMessage(CUIPattern + "null");
else
- player.sendRawMessage(CUIPattern + "[" + cm.getPrefix() + ChatColor.WHITE + "]");
+ player.sendRawMessage(CUIPattern + "[" + cm.getPrefix() + "]");
}
+ if(tcUtilsClientBridgePlugin != null)
+ tcUtilsClientBridgePlugin.sendChatMode(player);
}
public LocalPlayer wrapPlayer(Player player) {
@@ -196,6 +204,8 @@ public void sendToolDuraMode(Player player, World world) {
if (getConfigHandler().enablemod_InfDura && mod_InfDuraplayers.contains(player)) {
player.sendRawMessage(ToolDuraPattern + world.getToolDurability());
}
+ if(tcUtilsClientBridgePlugin != null)
+ tcUtilsClientBridgePlugin.getPlayerListener().sendToolDuraMode(player, world);
}
/**
@@ -402,7 +412,7 @@ public String findPlayer(String partOfName) {
* Register the Bukkit events to the appropriate event handlers.
*/
private void registerEvents() {
- getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.High, this);
+ /* getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.High, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.High, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.High, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.High, this);
@@ -422,7 +432,14 @@ private void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PROJECTILE_HIT, entityListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Normal, this);
- getServer().getPluginManager().registerEvent(Event.Type.CHUNK_UNLOAD, worldListener, Priority.Normal, this);
+ // getServer().getPluginManager().registerEvent(Event.Type.CHUNK_LOAD, worldListener, Priority.Monitor, this);
+ getServer().getPluginManager().registerEvent(Event.Type.CHUNK_UNLOAD, worldListener, Priority.Normal, this); */
+ PluginManager manager = getServer().getPluginManager();
+
+ manager.registerEvents(playerListener, this);
+ manager.registerEvents(entityListener, this);
+ manager.registerEvents(blockListener, this);
+ manager.registerEvents(worldListener, this);
}
public TweakcraftWorldListener getWorldListener() {
@@ -596,7 +613,7 @@ public CommandHandler getCommandHandler() {
}
public String getNickWithColors(String player) {
- String nick = playerListener.getNick(player);
+ String nick = this.wrapPlayer(player).getNick();
String realname = player;
if (nick == null) nick = realname;
/// return getPlayerColor(realname, false) + nick + ChatColor.WHITE;
@@ -628,6 +645,7 @@ public boolean hasNick(String player) {
return playerListener.getNick(player) != null;
}
+
public void onEnable() {
pdfFile = this.getDescription();
instance = this;
@@ -637,6 +655,13 @@ public void onEnable() {
this.reloadMOTD();
configHandler.setGlobalConfig(new File(this.getDataFolder(), "config.yml"));
configHandler.reloadConfig();
+
+ if(configHandler.enablePersistence) {
+ if(!databaseloaded) {
+ setupDatabase();
+ }
+ }
+
this.cuiPlayers = new HashSet<Player>();
this.mod_InfDuraplayers = new HashSet<Player>();
@@ -654,7 +679,8 @@ public void onEnable() {
banhandler.reloadBans();
if (configHandler.enableIRC) {
- circendpoint = new CraftIRCEndPoint(this);
+ circendpoint = new CraftIRCEndPoint(this, "tcutils");
+ cirdlogendpoint = new CraftIRCEndPoint(this, "tcutilslog");
circadminendpoint = new CraftIRCAdminEndPoint(this);
}
@@ -675,6 +701,14 @@ public EndPoint getEndPoint() {
public EndPoint getAdminEndPoint() {
return (EndPoint) circadminendpoint;
}
+
+ public String getVersion() {
+ return pdfFile.getVersion();
+ }
+
+ public EndPoint getLogginEndPoint() {
+ return (EndPoint) cirdlogendpoint;
+ }
public Set<String> getDonottplist() {
return donottplist;
View
10 src/com/guntherdw/bukkit/tweakcraft/Util/EntityLocation.java
@@ -34,20 +34,20 @@ public EntityLocation(LivingEntity entity) {
public Integer getDistance(LivingEntity entity) {
Location dloc;
- Integer xdiff, zdiff;
+ // Integer xdiff, zdiff;
Integer xdiffi, zdiffi;
dloc = entity.getLocation();
if (dloc.getWorld() != entityLocation.getWorld())
return null; // Different world, different result!
- xdiff = dloc.getBlockX() - entityLocation.getBlockX();
- xdiffi = xdiff.intValue();
+ xdiffi = dloc.getBlockX() - entityLocation.getBlockX();
+ // xdiffi = xdiff.intValue();
if (xdiffi < 0) {
xdiffi = ~xdiffi + 1;
}
- zdiff = dloc.getBlockZ() - entityLocation.getBlockZ();
- zdiffi = zdiff.intValue();
+ zdiffi = dloc.getBlockZ() - entityLocation.getBlockZ();
+ // zdiffi = zdiff.intValue();
if (zdiffi < 0) {
zdiffi = ~zdiffi + 1;
}
View
73 src/com/guntherdw/bukkit/tweakcraft/Util/TeleportHistory.java
@@ -42,7 +42,7 @@ public TeleportHistory(TweakcraftUtils instance) {
}
public int getRemaining(String playername) {
- if(!historymap.containsKey(playername)) {
+ if (!historymap.containsKey(playername)) {
return 0;
} else {
return historymap.get(playername).size();
@@ -50,23 +50,26 @@ public int getRemaining(String playername) {
}
public boolean atOrigin(String player) {
- if(!historymap.containsKey(player)) return true;
- int size = historymap.get(player).size()-1;
+ if (!historymap.containsKey(player)) return true;
+ int size = historymap.get(player).size() - 1;
int position = 0;
- if(historyoffset.containsKey(player)) { Integer i = historyoffset.get(player);position+=(i!=null?i:0); }
- return position==size;
+ if (historyoffset.containsKey(player)) {
+ Integer i = historyoffset.get(player);
+ position += (i != null ? i : 0);
+ }
+ return position == size;
}
public List<Location> getHistoryList(String player) {
- if(!historymap.containsKey(player)) return null;
+ if (!historymap.containsKey(player)) return null;
return historymap.get(player);
}
// public int get
public void setHistoryOffset(String player, Integer pos) {
- if((pos==null || pos < 0)
- && historyoffset.containsKey(player)) {
+ if ((pos == null || pos < 0)
+ && historyoffset.containsKey(player)) {
historyoffset.remove(player);
} else {
historyoffset.put(player, pos);
@@ -75,22 +78,22 @@ public void setHistoryOffset(String player, Integer pos) {
public int getOffset(String player) {
Integer offs = -1;
- if(historyoffset.containsKey(player)) {
+ if (historyoffset.containsKey(player)) {
offs = historyoffset.get(player);
}
- return offs!=null?offs:0;
+ return offs != null ? offs : 0;
}
public Location get(String player, int position, Boolean back) {
- if(!plugin.getConfigHandler().enableTPBack) return null;
- if(!historymap.containsKey(player)) return null;
+ if (!plugin.getConfigHandler().enableTPBack) return null;
+ if (!historymap.containsKey(player)) return null;
List<Location> locList = historymap.get(player);
- if(position<0 || position>=locList.size()) return null;
+ if (position < 0 || position >= locList.size()) return null;
- if(back!=null) {
+ if (back != null) {
int offset = getOffset(player);
- offset = offset + (back? 1 : -1);
+ offset = offset + (back ? 1 : -1);
setHistoryOffset(player, offset);
}
@@ -99,10 +102,10 @@ public Location get(String player, int position, Boolean back) {
public void removeLast(String playername) {
- if(historymap.containsKey(playername)) {
+ if (historymap.containsKey(playername)) {
List<Location> locmap = historymap.get(playername);
- locmap.remove(locmap.size()-1);
- if(locmap.size()==0) {
+ locmap.remove(locmap.size() - 1);
+ if (locmap.size() == 0) {
historymap.remove(playername);
} else {
historymap.put(playername, locmap);
@@ -111,11 +114,11 @@ public void removeLast(String playername) {
}
public void removeNext(String playername) {
- if(historymap.containsKey(playername) && historyoffset.containsKey(playername)) {
+ if (historymap.containsKey(playername) && historyoffset.containsKey(playername)) {
List<Location> locmap = historymap.get(playername);
int pos = locmap.size() - getOffset(playername);
locmap.remove(pos);
- if(locmap.size()==0) {
+ if (locmap.size() == 0) {
historymap.remove(playername);
} else {
historymap.put(playername, locmap);
@@ -124,26 +127,27 @@ public void removeNext(String playername) {
}
public void addHistory(String playername, Location loc) {
- if(plugin.getConfigHandler().enableTPBack) {
+ if (plugin.getConfigHandler().enableTPBack) {
List<Location> locmap;
- if(loc.getY() > 128 || loc.getY() < 1) { // failsafe
- loc.setY(130);
+ if (loc.getY() > loc.getWorld().getMaxHeight() + 2 || loc.getY() < 1) { // failsafe
+ loc.setY(loc.getWorld().getMaxHeight() + 2);
}
- if(historymap.containsKey(playername)) {
+ if (historymap.containsKey(playername)) {
locmap = historymap.get(playername);
- if(historyoffset.containsKey(playername) && getOffset(playername) > 0) {
+ if (historyoffset.containsKey(playername) && getOffset(playername) > 0) {
int siz = locmap.size();
- int pos = siz-getOffset(playername)+1;
- /* List<Location> toRemove = */ locmap.subList(pos, siz).clear();
+ int pos = siz - getOffset(playername) + 1;
+ /* List<Location> toRemove = */
+ locmap.subList(pos, siz).clear();
// locmap.en
// locmap.removeAll(toRemove);
setHistoryOffset(playername, null);
}
- if(locmap.size()>0&&!locmap.get(locmap.size()-1).equals(loc)) locmap.add(loc);
+ if (locmap.size() > 0 && !locmap.get(locmap.size() - 1).equals(loc)) locmap.add(loc);
} else {
locmap = new ArrayList<Location>();
locmap.add(loc);
@@ -159,12 +163,13 @@ public void clearHistory() {
}
public void clearFuture(String playername) {
- plugin.getLogger().info("[TweakcraftUtils] Clearing TPBack future for player "+playername+"!");
- if(historymap.containsKey(playername) && historyoffset.containsKey(playername)) {
+ plugin.getLogger().info("[TweakcraftUtils] Clearing TPBack future for player " + playername + "!");
+ if (historymap.containsKey(playername) && historyoffset.containsKey(playername)) {
List<Location> loclist = historymap.get(playername);
int size = loclist.size();
// loclist.removeAll();
- /* List<Location> toRemove = */ loclist.subList(size - getOffset(playername), size).clear();
+ /* List<Location> toRemove = */
+ loclist.subList(size - getOffset(playername), size).clear();
/* loclist.removeAll(toRemove); */
historymap.put(playername, loclist);
setHistoryOffset(playername, null);
@@ -172,11 +177,11 @@ public void clearFuture(String playername) {
}
public void clearHistory(String playername) {
- plugin.getLogger().info("[TweakcraftUtils] Clearing TPBack history for player "+playername+"!");
- if(historymap.containsKey(playername)) {
+ plugin.getLogger().info("[TweakcraftUtils] Clearing TPBack history for player " + playername + "!");
+ if (historymap.containsKey(playername)) {
historymap.remove(playername);
}
- if(historyoffset.containsKey(playername)) {
+ if (historyoffset.containsKey(playername)) {
historyoffset.remove(playername);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.