Merge branch 'master' of github.com:StevenLawson/TotalFreedomMod

This commit is contained in:
Steven Lawson 2011-10-19 15:51:44 -04:00
commit 0f071abd44
4 changed files with 39 additions and 27 deletions

View file

@ -48,19 +48,16 @@ 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());
{ Vector expel_direction = target_pos.subtract(sender_pos).toVector().normalize();
sender.sendMessage("Pushing " + p.getName()); p.setVelocity(expel_direction.multiply(strength));
Vector expel_direction = target_pos.subtract(sender_pos).toVector().normalize();
p.setVelocity(expel_direction.multiply(strength));
}
} }
} }
} }

View file

@ -23,24 +23,28 @@ public class Command_radar extends TFM_Command
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE); sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
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)
@ -53,19 +57,18 @@ 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;
@ -113,8 +114,18 @@ public class TFM_PlayerListener extends PlayerListener
if (playerdata.isCaged()) if (playerdata.isCaged())
{ {
Location target_pos = p.getLocation().add(0, 1, 0); Location target_pos = p.getLocation().add(0, 1, 0);
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 (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()