From b6f81e08236ed4d1ae442a6b8e7b0d605b855345 Mon Sep 17 00:00:00 2001 From: garbagemule Date: Thu, 15 Aug 2013 03:41:21 +0200 Subject: [PATCH] World-change code for set(lobby)region. --- .../commands/setup/SetLobbyRegionCommand.java | 16 ++++++++++++++-- .../commands/setup/SetRegionCommand.java | 18 +++++++++++++++--- .../commands/setup/SetWarpCommand.java | 5 ++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/com/garbagemule/MobArena/commands/setup/SetLobbyRegionCommand.java b/src/com/garbagemule/MobArena/commands/setup/SetLobbyRegionCommand.java index a7880be..21a3a3b 100644 --- a/src/com/garbagemule/MobArena/commands/setup/SetLobbyRegionCommand.java +++ b/src/com/garbagemule/MobArena/commands/setup/SetLobbyRegionCommand.java @@ -1,5 +1,7 @@ package com.garbagemule.MobArena.commands.setup; +import com.garbagemule.MobArena.framework.Arena; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -33,8 +35,18 @@ public class SetLobbyRegionCommand implements Command Messenger.tellPlayer(sender, "Usage: /ma setlobbyregion l1|l2"); return true; } - - am.getSelectedArena().getRegion().set(arg1, p.getLocation()); + + Arena arena = am.getSelectedArena(); + World aw = arena.getWorld(); + World pw = p.getLocation().getWorld(); + + if (!aw.getName().equals(pw.getName())) { + String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName()); + Messenger.tellPlayer(sender, msg); + } + + arena.setWorld(p.getWorld()); + arena.getRegion().set(arg1, p.getLocation()); Messenger.tellPlayer(sender, "Lobby region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set."); return true; } diff --git a/src/com/garbagemule/MobArena/commands/setup/SetRegionCommand.java b/src/com/garbagemule/MobArena/commands/setup/SetRegionCommand.java index 163d3de..f99fb9c 100644 --- a/src/com/garbagemule/MobArena/commands/setup/SetRegionCommand.java +++ b/src/com/garbagemule/MobArena/commands/setup/SetRegionCommand.java @@ -1,5 +1,7 @@ package com.garbagemule.MobArena.commands.setup; +import com.garbagemule.MobArena.framework.Arena; +import org.bukkit.World; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -33,10 +35,20 @@ public class SetRegionCommand implements Command Messenger.tellPlayer(sender, "Usage: /ma setregion p1|p2"); return true; } - - am.getSelectedArena().getRegion().set(arg1, p.getLocation()); + + Arena arena = am.getSelectedArena(); + World aw = arena.getWorld(); + World pw = p.getLocation().getWorld(); + + if (!aw.getName().equals(pw.getName())) { + String msg = String.format("Changing world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName()); + Messenger.tellPlayer(sender, msg); + } + + arena.setWorld(p.getWorld()); + arena.getRegion().set(arg1, p.getLocation()); Messenger.tellPlayer(sender, "Region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set."); - am.getSelectedArena().getRegion().checkData(am.getPlugin(), sender, true, true, false, false); + arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false); return true; } } diff --git a/src/com/garbagemule/MobArena/commands/setup/SetWarpCommand.java b/src/com/garbagemule/MobArena/commands/setup/SetWarpCommand.java index ad2e858..aefafc6 100644 --- a/src/com/garbagemule/MobArena/commands/setup/SetWarpCommand.java +++ b/src/com/garbagemule/MobArena/commands/setup/SetWarpCommand.java @@ -69,9 +69,8 @@ public class SetWarpCommand implements Command // Notify the player if world changed if (changeWorld) { - Messenger.tellPlayer(sender, "Changed world of arena '" + arena.configName() + - "' from '" + aw.getName() + - "' to '" + pw.getName() + "'"); + String msg = String.format("Changed world of arena '%s' from '%s' to '%s'", arena.configName(), aw.getName(), pw.getName()); + Messenger.tellPlayer(sender, msg); } // Then notify about point set