This commit is contained in:
Steven Lawson 2011-10-19 12:04:44 -04:00
parent f84f10a7ad
commit 45cc2e8c47
4 changed files with 39 additions and 27 deletions

View File

@ -48,13 +48,11 @@ public class Command_expel extends TFM_Command
} }
Location sender_pos = sender_p.getLocation(); Location sender_pos = sender_p.getLocation();
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : sender_pos.getWorld().getPlayers())
{ {
if (!p.equals(sender_p)) if (!p.equals(sender_p))
{ {
Location target_pos = p.getLocation(); Location target_pos = p.getLocation();
if (target_pos.getWorld().equals(sender_pos.getWorld()))
{
if (target_pos.distance(sender_pos) < radius) if (target_pos.distance(sender_pos) < radius)
{ {
sender.sendMessage("Pushing " + p.getName()); sender.sendMessage("Pushing " + p.getName());
@ -64,7 +62,6 @@ public class Command_expel extends TFM_Command
} }
} }
} }
}
else else
{ {
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);

View File

@ -24,23 +24,27 @@ public class Command_radar extends TFM_Command
return true; return true;
} }
Player sender_player = Bukkit.getPlayerExact(sender.getName()); Location sender_pos = sender_p.getLocation();
Location sender_pos = sender_player.getLocation();
String sender_world = sender_player.getWorld().getName();
List<TFM_RadarData> radar_data = new ArrayList<TFM_RadarData>(); List<TFM_RadarData> radar_data = new ArrayList<TFM_RadarData>();
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : sender_pos.getWorld().getPlayers())
{ {
if (sender_world.equals(p.getWorld().getName()) && !p.getName().equals(sender.getName())) if (!p.equals(sender_p))
{ {
radar_data.add(new TFM_RadarData(p, sender_pos.distance(p.getLocation()), p.getLocation())); radar_data.add(new TFM_RadarData(p, sender_pos.distance(p.getLocation()), p.getLocation()));
} }
} }
if (radar_data.isEmpty())
{
sender.sendMessage(ChatColor.YELLOW + "You are the only player in this world. (Forever alone...)");
return true;
}
Collections.sort(radar_data, new TFM_RadarData()); Collections.sort(radar_data, new TFM_RadarData());
sender.sendMessage(ChatColor.YELLOW + "People nearby in " + sender_world + ":"); sender.sendMessage(ChatColor.YELLOW + "People nearby in " + sender_pos.getWorld().getName() + ":");
int countmax = 5; int countmax = 5;
if (args.length == 1) if (args.length == 1)
@ -54,18 +58,17 @@ public class Command_radar extends TFM_Command
} }
} }
int count = 0;
for (TFM_RadarData i : radar_data) for (TFM_RadarData i : radar_data)
{ {
if (count++ > countmax)
{
break;
}
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s", sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s",
i.player.getName(), i.player.getName(),
Math.round(i.distance), Math.round(i.distance),
MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No")); MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No"));
if (--countmax <= 0)
{
break;
}
} }
return true; return true;

View File

@ -5,6 +5,7 @@ import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -114,7 +115,17 @@ public class TFM_PlayerListener extends PlayerListener
{ {
Location target_pos = p.getLocation().add(0, 1, 0); Location target_pos = p.getLocation().add(0, 1, 0);
if (target_pos.distance(playerdata.getCagePos()) > 2.5) boolean out_of_cage = false;
if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld()))
{
out_of_cage = true;
}
else
{
out_of_cage = target_pos.distance(playerdata.getCagePos()) > 2.5;
}
if (out_of_cage)
{ {
playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER)); playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER), playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
playerdata.regenerateHistory(); playerdata.regenerateHistory();
@ -146,6 +157,7 @@ public class TFM_PlayerListener extends PlayerListener
{ {
p.setOp(false); p.setOp(false);
p.kickPlayer("No Spamming"); p.kickPlayer("No Spamming");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tempban %s 1m", p.getName()));
TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED); TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
playerdata.resetMsgCount(); playerdata.resetMsgCount();

View File

@ -10,11 +10,11 @@ public class TFM_RadarData implements Comparator<TFM_RadarData>
public double distance; public double distance;
public Location location; public Location location;
public TFM_RadarData(Player inplayer, double indistance, Location inlocation) public TFM_RadarData(Player player, double distance, Location location)
{ {
this.player = inplayer; this.player = player;
this.distance = indistance; this.distance = distance;
this.location = inlocation; this.location = location;
} }
public TFM_RadarData() public TFM_RadarData()