Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed /reply,

Added seperate permission node to disenchant tools
Added TweakTravel, a nether portal travel agent
Fixed bug with /tamer sit (where it healed the wolf as well)
  • Loading branch information...
commit 5702e98794c673381af390e93ca16368d1ba2ae2 1 parent aa0b60a
@GuntherDW authored
View
3  src/com/guntherdw/bukkit/tweakcraft/Commands/Essentials/CommandMsg.java
@@ -59,8 +59,9 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
sender.sendMessage("[Me -> " + playerto.getDisplayName() + "] " + message);
playerto.sendMessage("[" + senderName + " -> Me] " + message);
if (sender instanceof Player) {
+ Player player = (Player) sender;
LocalPlayer lp = plugin.wrapPlayer(playerto);
- lp.setReplyTo(((Player)sender).getName());
+ lp.setReplyTo(player.getName());
// plugin.setPlayerReply(playerto.getName(), ((Player) sender).getName());
}
View
2  src/com/guntherdw/bukkit/tweakcraft/Commands/Essentials/CommandReply.java
@@ -49,7 +49,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
}
LocalPlayer lpTo = plugin.wrapPlayer(replyTo);
- Player playerto = lp.getBukkitPlayerSafe();
+ Player playerto = lpTo.getBukkitPlayerSafe();
if (playerto == null)
throw new CommandException("That player is no longer online!");
View
28 src/com/guntherdw/bukkit/tweakcraft/Commands/General/CommandEnchant.java
@@ -25,8 +25,8 @@
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.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -40,8 +40,13 @@
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()))
+ String permNode = getPermissionSuffix();
+ if(args.length>0 && args[0].equalsIgnoreCase("disenchant"))
+ permNode+=".disenchant";
+
+ if(!plugin.check((Player)sender, permNode)) {
throw new PermissionsException(command);
+ }
} else {
throw new CommandSenderException("What do you want to enchant today?");
}
@@ -55,7 +60,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
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));
+ sender.sendMessage(ChatColor.YELLOW+ench.getName()+" at level "+enchantments.get(ench));
}
}
} else {
@@ -66,32 +71,41 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
ItemStack is = ((Player)sender).getItemInHand();
if(is!=null) {
sender.sendMessage(ChatColor.YELLOW+"Clearing any enchantments this item had");
- is.clearEnchantments();
+ for(Enchantment ench : is.getEnchantments().keySet()) {
+ is.removeEnchantment(ench);
+ }
} else {
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything");
}
+ return true;
} else if(args.length!=2)
throw new CommandUsageException("I need exactly 2 values, an ID and a level!");
Integer enchantmentId = null;
Integer enchantmentLevel = null;
+ String encName = null;
try{
enchantmentId = Integer.parseInt(args[0]);
+ } catch(NumberFormatException ex) {
+ encName = args[0];
+ }
+
+ try{
enchantmentLevel = Integer.parseInt(args[1]);
} catch(NumberFormatException ex) {
throw new CommandUsageException("I need numbers, not garbage!");
}
- Enchantment enchantment = Enchantment.byId(enchantmentId);
+ Enchantment enchantment = encName==null?Enchantment.getById(enchantmentId):Enchantment.getByName(encName.toUpperCase());
if(enchantment!=null) {
ItemStack is = ((Player)sender).getItemInHand();
if(is==null) {
sender.sendMessage(ChatColor.YELLOW+"You're not holding anything");
} else {
- is.addEnchantment(enchantment, enchantmentLevel);
- sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.name()+" level "+enchantmentLevel);
+ is.addUnsafeEnchantment(enchantment, enchantmentLevel);
+ sender.sendMessage(ChatColor.YELLOW+"Adding "+enchantment.getName()+" level "+enchantmentLevel);
}
} else {
sender.sendMessage(ChatColor.YELLOW+"Couldn't find Enchantment with id "+enchantmentId+"!");
View
4 src/com/guntherdw/bukkit/tweakcraft/Configuration/ConfigurationHandler.java
@@ -80,6 +80,8 @@
public boolean enableWorldMOTD = false;
public boolean enableTNTArrows = false;
public float tntArrowForce = 4.0F;
+ public boolean enableTweakTravel = false;
+ public int tweakTravelSearchWidth = 3;
public boolean enableFallDistanceNullify = false;
@@ -193,6 +195,8 @@ public void reloadConfig() {
this.enableFallDistanceNullify = globalconfig.getBoolean("extra.nullifyTeleportFallDistance", false);
this.enableWorldMOTD = globalconfig.getBoolean("worlds.worldMOTD", false);
+ this.enableTweakTravel = globalconfig.getBoolean("worlds.TweakTravel", false);
+ this.tweakTravelSearchWidth = globalconfig.getInt("worlds.TweakTravelSearchWidth", 3);
this.enableSpamControl = globalconfig.getBoolean("spamcontrol.enable", false);
if(this.enableSpamControl) {
View
44 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftBlockListener.java
@@ -0,0 +1,44 @@
+/*
+ * 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.Listeners;
+
+import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+import org.bukkit.ChatColor;
+import org.bukkit.event.block.BlockListener;
+import org.bukkit.event.block.SignChangeEvent;
+
+/**
+ * @author GuntherDW
+ */
+public class TweakcraftBlockListener extends BlockListener {
+
+ private TweakcraftUtils plugin = null;
+
+ public TweakcraftBlockListener(TweakcraftUtils instance) {
+ this.plugin = instance;
+ }
+
+ public void onSignChange(SignChangeEvent event) {
+ if(event.isCancelled()) return;
+ if(plugin.getConfigHandler().enableTweakTravel&&event.getLine(0).equalsIgnoreCase("[TweakTravel]") && !plugin.check(event.getPlayer(), "tweaktravel.create")) {
+ event.getPlayer().sendMessage(ChatColor.RED+"You don't have permission to create TweakTravel signs!");
+ event.setCancelled(true);
+ }
+ }
+}
View
127 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftPlayerListener.java
@@ -31,6 +31,9 @@
import com.guntherdw.bukkit.tweakcraft.Worlds.WorldManager;
import com.guntherdw.bukkit.tweakcraft.Worlds.iWorld;
import org.bukkit.*;
+import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
+import org.bukkit.block.Sign;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.*;
import org.bukkit.event.block.Action;
@@ -612,35 +615,125 @@ public void reloadInvisTable() {
for(String s : lijst)
plugin.getLogger().info("[TweakcraftUtils] Adding "+s+" to the invisble playerlist!");
}
+
+ private boolean isTweakTravelSign(Block block) {
+ BlockState state = block.getState();
+ if(state.getType().equals(Material.WALL_SIGN) && ((Sign) state).getLine(0).equals("[TweakTravel]"))
+ return true;
+
+ return false;
+ }
public void onPlayerPortal(PlayerPortalEvent event) {
if(event.isCancelled()) return;
Player p = event.getPlayer();
- String fromworld = event.getFrom().getWorld().getName();
- boolean isnether = fromworld.endsWith("_nether");
- if(isnether) fromworld = fromworld.substring(0, fromworld.length()-7); // MINUS _nether
- iWorld w = plugin.getworldManager().getWorld(fromworld);
+ Location from = event.getFrom();
+ World worldFrom = from.getWorld();
+
+ boolean signMode = false;
+ if(plugin.getConfigHandler().enableTweakTravel) { /* Go look for a portalSign */
+ Block signBlock = null;
+ Location ploc = p.getLocation();
+ int searchwidth = plugin.getConfigHandler().tweakTravelSearchWidth;
+ for(int i=ploc.getBlockX()-searchwidth; i<ploc.getBlockX()+searchwidth; i++) {
+ for(int j=ploc.getBlockY()-searchwidth; j<ploc.getBlockY()+searchwidth; j++) {
+ for(int k=ploc.getBlockZ()-searchwidth; k<ploc.getBlockZ()+searchwidth; k++) {
+ Block b = worldFrom.getBlockAt(i,j,k);
+ if(isTweakTravelSign(b)) {
+ if(signBlock==null) {
+ signBlock = b;
+ p.sendMessage(ChatColor.YELLOW+"TweakTravel : taking you to "+(((Sign)b.getState()).getLine(1)));
+ } else {
+ plugin.getLogger().warning("[TweakcraftUtils] Found more than one TweakTravel sign");
+ Location lold = signBlock.getLocation();
+ Location lnew = b.getLocation();
+ plugin.getLogger().warning("[TweakcraftUtils] original location : "+lold);
+ plugin.getLogger().warning("[TweakcraftUtils] other : "+lnew);
+
+ p.sendMessage(ChatColor.RED+"WARNING: Found more than one TweakTravel sign!");
+ }
+ }
+ }
+ }
+ }
+
+ if(signBlock!=null) {
+ signMode=true;
+ Sign sign = (Sign) signBlock.getState();
+ String toWorld = sign.getLine(1);
+ String line3 = sign.getLine(2);
+
+ // if(line3.length()>3)
+ iWorld iw = plugin.getworldManager().getWorld(toWorld);
+ if(!plugin.check(p, "worlds."+iw.getName())) {
+ p.sendMessage(ChatColor.RED+"You do not have permission to portal to this world!");
+ event.setCancelled(true);
+ } else {
+ if(iw!=null) {
+ String[] coordsStrings = null;
+ Integer[] coords = new Integer[3];
+ coordsStrings=line3.split(",");
+ Location loc = iw.getBukkitWorld().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]);
+ }
- if(w!=null) {
- if(!w.isNetherEnabled()) {
- if(plugin.getConfigHandler().cancelNetherPortal) event.setCancelled(true);
- event.getPlayer().sendMessage(ChatColor.RED+"This world doesn't have an extra nether!");
+ TravelAgent ta = event.getPortalTravelAgent();
+ event.useTravelAgent(true);
- return;
+
+ if(loc != null) {
+ event.setTo(loc);
+ } else {
+ event.setTo(iw.getBukkitWorld().getSpawnLocation());
+ }
+
+ ta.setSearchRadius(0);
+
+ ta.setCanCreatePortal(false);
+ event.setPortalTravelAgent(ta);
+
+ } else {
+ p.sendMessage(ChatColor.RED+"Couldn't find that world!");
+ event.setCancelled(true);
+ }
+ }
}
+ }
- org.bukkit.Location to = event.getFrom();
- if(isnether) { to.setWorld(w.getBukkitWorld()); to.setX(Math.floor(to.getX()*8)); to.setZ(Math.floor(to.getZ()*8)); }
- else { to.setWorld(w.getNetherWorld()); to.setX(Math.floor(to.getX()/8)); to.setZ(Math.floor(to.getZ()/8));}
- TravelAgent agent = event.getPortalTravelAgent();
- event.setTo(to);
- event.useTravelAgent(true);
- int radius = w.getPortalSearchWidth();
- agent.setSearchRadius(radius);
+ if(!signMode) {
+ String fromworld = event.getFrom().getWorld().getName();
+ boolean isnether = fromworld.endsWith("_nether");
+ if(isnether) fromworld = fromworld.substring(0, fromworld.length()-7); // MINUS _nether
+ iWorld w = plugin.getworldManager().getWorld(fromworld);
+
+ if(w!=null && w.getBukkitWorld()!=plugin.getworldManager().getDefaultWorld()) {
+
+ if(!w.isNetherEnabled()) {
+ if(plugin.getConfigHandler().cancelNetherPortal) event.setCancelled(true);
+ event.getPlayer().sendMessage(ChatColor.RED+"This world doesn't have an extra nether!");
+
+ return;
+ }
+
+ org.bukkit.Location to = event.getFrom();
+ if(isnether) { to.setWorld(w.getBukkitWorld()); to.setX(Math.floor(to.getX()*8)); to.setZ(Math.floor(to.getZ()*8)); }
+ else { to.setWorld(w.getNetherWorld()); to.setX(Math.floor(to.getX()/8)); to.setZ(Math.floor(to.getZ()/8));}
+
+ TravelAgent agent = event.getPortalTravelAgent();
+ event.setTo(to);
+ event.useTravelAgent(true);
+ int radius = w.getPortalSearchWidth();
+ agent.setSearchRadius(radius);
+ event.setPortalTravelAgent(agent);
+ }
}
}
View
1  src/com/guntherdw/bukkit/tweakcraft/Packages/LocalPlayer.java
@@ -94,6 +94,7 @@ public boolean isAfk() {
public void setAfk(boolean afk) {
this.afk = afk;
+ this.getBukkitPlayerSafe().setSleepingIgnored(afk);
}
public long getLastmessagetime() {
View
2  src/com/guntherdw/bukkit/tweakcraft/Tools/TamerTool.java
@@ -178,6 +178,7 @@ public void sit(Wolf wolf, Boolean sit, Player player) {
if(allowed)
wolf.setSitting(sit);
+
else
player.sendMessage(ChatColor.RED + "You do not have permission to command this wolf!");
} else {
@@ -227,6 +228,7 @@ public void handleEvent(Player player, Wolf wolf) {
break;
case SIT:
this.sit(wolf, tamermode.getState(), player);
+ break;
case HEAL:
this.heal(wolf, tamermode.getState(), player);
break;
View
11 src/com/guntherdw/bukkit/tweakcraft/TweakcraftUtils.java
@@ -30,6 +30,7 @@
import com.guntherdw.bukkit.tweakcraft.DataSources.PersistenceClass.PlayerInfo;
import com.guntherdw.bukkit.tweakcraft.DataSources.PersistenceClass.PlayerOptions;
import com.guntherdw.bukkit.tweakcraft.Exceptions.*;
+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;
@@ -84,6 +85,7 @@
private final TweakcraftPlayerListener playerListener = new TweakcraftPlayerListener(this);
private final TweakcraftEntityListener entityListener = new TweakcraftEntityListener(this);
+ private final TweakcraftBlockListener blockListener = new TweakcraftBlockListener(this);
private final TweakcraftWorldListener worldListener = new TweakcraftWorldListener(this);
private final CommandHandler commandHandler = new CommandHandler(this);
private final BanHandler banhandler = new BanHandler(this);
@@ -376,9 +378,9 @@ public String findPlayer(String partOfName) {
private void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.High, this);
- getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
- getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
- getServer().getPluginManager().registerEvent(Event.Type.PLAYER_KICK, playerListener, Priority.Normal, 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);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
@@ -386,7 +388,8 @@ private void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_INTERACT_ENTITY, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_PORTAL, playerListener, Priority.High, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, Priority.High, this);
- getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHANGED_WORLD, playerListener, Priority.Normal, this);
+ getServer().getPluginManager().registerEvent(Event.Type.PLAYER_CHANGED_WORLD, playerListener, Priority.High, this);
+ getServer().getPluginManager().registerEvent(Event.Type.SIGN_CHANGE, blockListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.EXPLOSION_PRIME, entityListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.ENTITY_TARGET, entityListener, Priority.Normal, this);
View
7 src/com/guntherdw/bukkit/tweakcraft/Worlds/WorldManager.java
@@ -21,6 +21,7 @@
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import com.guntherdw.bukkit.tweakcraft.Worlds.Generators.FlatGen;
import org.bukkit.GameMode;
+import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.util.config.Configuration;
@@ -45,6 +46,10 @@
return worlds;
}
+ public World getDefaultWorld() {
+ return plugin.getServer().getWorlds().get(0);
+ }
+
public int getDefaultViewDistance() {
return plugin.getServer().getViewDistance();
}
@@ -214,7 +219,7 @@ public iWorld getWorld(String name) {
public iWorld getWorld(String name, boolean filterNether) {
if(filterNether) {
- boolean isnether = name.endsWith("_nether");
+ boolean isnether = name.endsWith("_nether") || name.endsWith("_the_end");
if(isnether) name = name.substring(0, name.length()-7); // MINUS _nether
}
if (worlds.containsKey(name)) {
Please sign in to comment.
Something went wrong with that request. Please try again.