Permalink
Browse files

Added config and fixes for the RespawnEvent

  • Loading branch information...
1 parent bf2556e commit 37c109f6dbe91de0e43e4d0f377ef91ab011a359 @GuntherDW committed Sep 22, 2011
@@ -59,8 +59,8 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
if(world.getName().equals(player.getWorld().getName())) {
throw new CommandUsageException("You already are on that world!");
}
- if (!plugin.check(player, "worlds." + world.getName())) {
- throw new PermissionsException(command);
+ if (!plugin.check(player, "worlds." + world.getName()+".world")) {
+ throw new PermissionsException("You don't have permission to /world to that world!");
}
else {
Location oldlocation = player.getLocation();
@@ -62,6 +62,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
if (modus == ExtMode.SELF) {
if (sender instanceof Player) {
Player player = (Player) sender;
+ if(!plugin.check(player, "ext.self"))
if (player.getFireTicks() != 0) {
player.setFireTicks(0);
player.sendMessage(ChatColor.YELLOW + "You have been extinguished!");
@@ -83,7 +84,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
}
} else if (modus == ExtMode.MOBS) {
if (sender instanceof Player) {
- if (!plugin.check((Player) sender, "extother"))
+ if (!plugin.check((Player) sender, "ext.other"))
throw new PermissionsException(command);
}
@@ -171,7 +172,7 @@ public boolean executeCommand(CommandSender sender, String command, String[] arg
@Override
public String getPermissionSuffix() {
- return null;
+ return "ext";
}
}
@@ -87,6 +87,11 @@ public boolean executeCommand(CommandSender sender, String command, String[] rea
override = true; */
}
+ if(!player.getWorld().getName().equals(p.getWorld().getName())) {
+ if(!plugin.check(player, "worlds."+p.getWorld().getName()+".tp"))
+ throw new PermissionsException("You don't have permission to TP to someone in that world!");
+ }
+
if (p.getName().equals(player.getName())) {
player.sendMessage(ChatColor.YELLOW + "You're already there!");
} else {
@@ -73,6 +73,10 @@
public boolean stopChunkUnloadBurningFurnace = false;
public boolean enableCUI = false;
public boolean enablemod_InfDura = false;
+ public boolean enableExperienceOrbsHalt = false;
+
+ public boolean enableRespawnHook = false;
+ public boolean enableRespawnHeal = false;
public boolean enableSpamControl = false;
@@ -118,6 +122,11 @@ public void reloadConfig() {
if(this.enableDebug) {
plugin.getLogger().info("[TweakcraftUtils] Extra verbose messages enabled!");
}
+
+ this.enableRespawnHook = plugin.getConfiguration().getBoolean("respawn.enableHook", false);
+ this.enableRespawnHeal = plugin.getConfiguration().getBoolean("respawn.healOnRespawn", false);
+
+
this.extrahelpplugin = new ArrayList<String>();
this.enableGroupChat = plugin.getConfiguration().getBoolean("ChatMode.GroupChat", true);
this.enablePersistence = plugin.getConfiguration().getBoolean("Persistence.enabled", true);
@@ -158,6 +167,7 @@ public void reloadConfig() {
this.stopIgniteWorldGuard = plugin.getConfiguration().getBoolean("extra.StopGodIgnite", true);
this.enableCUI = plugin.getConfiguration().getBoolean("extra.CUI", false);
this.enablemod_InfDura = plugin.getConfiguration().getBoolean("extra.mod_InfDura", false);
+ this.enableExperienceOrbsHalt = plugin.getConfiguration().getBoolean("extra.stopExperienceOrbs", false);
this.enableSpamControl = plugin.getConfiguration().getBoolean("spamcontrol.enable", false);
if(this.enableSpamControl) {
@@ -41,6 +41,10 @@ public TweakcraftEntityListener(TweakcraftUtils instance) {
this.plugin = instance;
}
+ /* public void onEntityDeath(EntityDeathEvent event) {
+
+ } */
+
public void onEntityCombust(EntityCombustEvent event) {
Entity ent = event.getEntity();
if(ent instanceof Player) {
@@ -61,6 +65,10 @@ public void onEntityDeath(EntityDeathEvent event) {
event.getDrops().add(new ItemStack(Material.SADDLE, 1));
}
}
+
+ if(plugin.getConfigHandler().enableExperienceOrbsHalt) {
+ event.setDroppedExp(0);
+ }
}
public void onExplosionPrime(ExplosionPrimeEvent event) {
@@ -321,6 +321,33 @@ public void onPlayerChat(PlayerChatEvent event) {
}
}
}
+
+ public void onPlayerRespawn(PlayerRespawnEvent event) {
+ // if(event.isBedSpawn())
+ if(!plugin.getConfigHandler().enableRespawnHook) return;
+
+ Player p = event.getPlayer();
+ String fromworld = event.getPlayer().getWorld().getName();
+ boolean isnether = fromworld.endsWith("_nether");
+ if(isnether) fromworld = fromworld.substring(0, fromworld.length()-7); // MINUS _nether
+ World w = plugin.getServer().getWorld(fromworld);
+ if(w!=null) {
+ if(event.isBedSpawn()) {
+ if(!event.getRespawnLocation().getWorld().getName().equals(w.getName())) {
+ p.sendMessage(ChatColor.AQUA+"Your bed was in another world, sending you to spawn!");
+ event.setRespawnLocation(w.getSpawnLocation());
+ }
+ } else {
+ if(!event.getRespawnLocation().getWorld().getName().equals(w.getName())) {
+ p.sendMessage(ChatColor.AQUA+"Your respawn place was in another world, sending you to spawn!");
+ event.setRespawnLocation(w.getSpawnLocation()); // Removed isNether() check
+ }
+
+ }
+ }
+ if(plugin.getConfigHandler().enableRespawnHeal)
+ p.setHealth(20);
+ }
public void onPlayerTeleport(PlayerTeleportEvent event) {
if(event.isCancelled()) return;
@@ -21,6 +21,7 @@
import com.guntherdw.bukkit.tweakcraft.Packages.TamerMode;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
import org.bukkit.ChatColor;
+import org.bukkit.OfflinePlayer;
import org.bukkit.entity.*;
import java.util.HashMap;
@@ -45,15 +46,20 @@ public TamerTool(TweakcraftUtils instance) {
public void getOwner(Player player, Wolf wolf) {
if(wolf.isTamed()) {
AnimalTamer tamer = wolf.getOwner();
- if(tamer instanceof Player) {
- Player ptamer = (Player) tamer;
+ if(tamer instanceof Player || tamer instanceof OfflinePlayer) {
+ // Player ptamer = (Player) tamer;
+ boolean online = false;
+ Player ptamer=null; OfflinePlayer offlinetamer=null;
+ if(tamer instanceof Player) { ptamer = (Player) tamer; online = true; }
+ else { offlinetamer = (OfflinePlayer) tamer; online = false; }
+
boolean allowed = true;
- if(!ptamer.equals(player)) {
+ if(online && !ptamer.equals(player)) {
if(!plugin.check(player, "tamer.info.other"))
allowed = false;
}
if(allowed) {
- player.sendMessage(ChatColor.AQUA + "Wolf owner : "+ptamer.getDisplayName());
+ player.sendMessage(ChatColor.AQUA + "Wolf owner : "+(online?ptamer.getDisplayName():offlinetamer.getName()));
} else {
player.sendMessage(ChatColor.RED + "You do not have the permission to check the ownership of other wolves!");
}
@@ -316,10 +316,12 @@ private void registerEvents() {
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_INTERACT_ENTITY, playerListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_PORTAL, playerListener, Priority.Normal, this);
+ getServer().getPluginManager().registerEvent(Event.Type.PLAYER_RESPAWN, playerListener, 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_DEATH, entityListener, Priority.Normal, this);
getServer().getPluginManager().registerEvent(Event.Type.CHUNK_UNLOAD, worldListener , Priority.Normal, this);
+
}
public TweakcraftWorldListener getWorldListener() {

0 comments on commit 37c109f

Please sign in to comment.