New cage,

This commit is contained in:
Steven Lawson 2011-10-10 08:09:19 -04:00
parent 90bb21b79e
commit 41043845c7
10 changed files with 389 additions and 89 deletions

View file

@ -31,8 +31,8 @@ file.reference.MobDisguise.jar=C:\\github\\MobDisguise\\dist\\MobDisguise.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.MobDisguise.jar}
${file.reference.MobDisguise.jar}:\
${file.reference.bukkit-0.0.1-SNAPSHOT.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View file

@ -15,12 +15,12 @@ import org.bukkit.inventory.ItemStack;
public class TFM_BlockListener extends BlockListener
{
public static TotalFreedomMod plugin;
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
TFM_BlockListener(TotalFreedomMod instance)
{
plugin = instance;
this.plugin = instance;
}
@Override
@ -50,11 +50,11 @@ public class TFM_BlockListener extends BlockListener
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
TotalFreedomMod.userinfo.put(p, playerdata);
}
Location player_pos = p.getLocation();
@ -105,11 +105,11 @@ public class TFM_BlockListener extends BlockListener
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
{
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
TotalFreedomMod.userinfo.put(p, playerdata);
}
playerdata.incrementFreecamPlaceCount();

View file

@ -89,7 +89,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
p = matches.get(0);
}
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata != null)
{
playerdata.setFrozen(!playerdata.isFrozen());
@ -98,7 +98,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
playerdata = new TFM_UserInfo();
playerdata.setFrozen(true);
plugin.userinfo.put(p, playerdata);
TotalFreedomMod.userinfo.put(p, playerdata);
}
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
@ -247,7 +247,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
else if (mode.equals("fr"))
{
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata != null)
{
playerdata.setFrozen(!playerdata.isFrozen());
@ -256,7 +256,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
playerdata = new TFM_UserInfo();
playerdata.setFrozen(true);
plugin.userinfo.put(p, playerdata);
TotalFreedomMod.userinfo.put(p, playerdata);
}
sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + ".");
@ -571,6 +571,86 @@ public class TFM_Cmds_Admin implements CommandExecutor
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("cage"))
{
if (senderIsConsole || plugin.isUserSuperadmin(sender))
{
if (args.length == 0)
{
return false;
}
Player p;
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage(ChatColor.GRAY + "Can't find user " + args[0]);
return true;
}
else
{
p = matches.get(0);
}
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
TotalFreedomMod.userinfo.put(p, playerdata);
}
Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR;
if (args.length >= 2)
{
if (args[1].equalsIgnoreCase("end") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("stop"))
{
playerdata.setCaged(false);
playerdata.regenerateHistory();
playerdata.clearHistory();
return true;
}
else
{
cage_material_outer = Material.matchMaterial(args[1]);
if (cage_material_outer == null)
{
cage_material_outer = Material.GLASS;
}
}
}
if (args.length >= 3)
{
if (args[2].equalsIgnoreCase("water"))
{
cage_material_inner = Material.STATIONARY_WATER;
}
else if (args[2].equalsIgnoreCase("lava"))
{
cage_material_inner = Material.STATIONARY_LAVA;
}
}
Location target_pos = p.getLocation().add(0, 1, 0);
playerdata.setCaged(true, target_pos, cage_material_outer, cage_material_inner);
playerdata.regenerateHistory();
playerdata.clearHistory();
plugin.buildHistory(target_pos, 2, playerdata);
plugin.generateCube(target_pos, 2, playerdata.getCageMaterial(0));
plugin.generateCube(target_pos, 1, playerdata.getCageMaterial(1));
p.setGameMode(GameMode.SURVIVAL);
plugin.tfm_broadcastMessage(sender.getName() + " caged " + p.getName() + "!", ChatColor.YELLOW);
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
}

View file

@ -10,6 +10,7 @@ import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -240,14 +241,60 @@ public class TFM_Cmds_General implements CommandExecutor
}
else if (cmd.getName().equalsIgnoreCase("flatlands"))
{
Bukkit.getServer().dispatchCommand(sender, "mv tp flatlands");
plugin.gotoWorld(sender, "flatlands");
return true;
}
else if (cmd.getName().equalsIgnoreCase("skylands"))
{
Bukkit.getServer().dispatchCommand(sender, "mv tp skylands");
plugin.gotoWorld(sender, "skylands");
return true;
}
else if (cmd.getName().equalsIgnoreCase("nether"))
{
plugin.gotoWorld(sender, "nether");
return true;
}
else if (cmd.getName().equalsIgnoreCase("banlist"))
{
if (args.length > 0)
{
if (args[0].equalsIgnoreCase("purge"))
{
if (senderIsConsole || plugin.isUserSuperadmin(sender))
{
for (OfflinePlayer p : Bukkit.getBannedPlayers())
{
p.setBanned(false);
}
sender.sendMessage(ChatColor.GRAY + "Ban list has been purged.");
return true;
}
else
{
sender.sendMessage(ChatColor.YELLOW + "You do not have permission to purge the ban list, you may only view it.");
}
}
}
StringBuilder banned_players = new StringBuilder();
banned_players.append("Banned Players: ");
boolean first = true;
for (OfflinePlayer p : Bukkit.getBannedPlayers())
{
if (!first)
{
banned_players.append(", ");
}
first = false;
banned_players.append(p.getName().trim());
}
sender.sendMessage(ChatColor.GRAY + banned_players.toString());
return true;
}
}
catch (Exception ex)
{

View file

@ -9,11 +9,11 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
public class TFM_EntityListener extends EntityListener
{
public static TotalFreedomMod plugin;
private TotalFreedomMod plugin;
TFM_EntityListener(TotalFreedomMod instance)
{
plugin = instance;
this.plugin = instance;
}
@Override

View file

@ -15,12 +15,12 @@ import org.bukkit.inventory.ItemStack;
class TFM_PlayerListener extends PlayerListener
{
public static TotalFreedomMod plugin;
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
TFM_PlayerListener(TotalFreedomMod instance)
{
plugin = instance;
this.plugin = instance;
}
@Override
@ -61,6 +61,7 @@ class TFM_PlayerListener extends PlayerListener
public void onPlayerMove(PlayerMoveEvent event)
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
boolean do_freeze = false;
if (plugin.allPlayersFrozen)
@ -72,7 +73,6 @@ class TFM_PlayerListener extends PlayerListener
}
else
{
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
if (playerdata != null)
{
if (playerdata.isFrozen())
@ -93,6 +93,24 @@ class TFM_PlayerListener extends PlayerListener
event.setTo(to);
}
if (playerdata != null)
{
if (playerdata.isCaged())
{
Location target_pos = p.getLocation().add(0, 1, 0);
if (target_pos.distance(playerdata.getCagePos()) > 2.5)
{
playerdata.setCaged(true, target_pos, playerdata.getCageMaterial(0), playerdata.getCageMaterial(1));
playerdata.regenerateHistory();
playerdata.clearHistory();
plugin.buildHistory(target_pos, 2, playerdata);
plugin.generateCube(target_pos, 2, playerdata.getCageMaterial(0));
plugin.generateCube(target_pos, 1, playerdata.getCageMaterial(1));
}
}
}
}
@Override
@ -100,7 +118,7 @@ class TFM_PlayerListener extends PlayerListener
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = (TFM_UserInfo) plugin.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata != null)
{
playerdata.incrementMsgCount();
@ -119,7 +137,7 @@ class TFM_PlayerListener extends PlayerListener
{
playerdata = new TFM_UserInfo();
playerdata.incrementMsgCount();
plugin.userinfo.put(p, playerdata);
TotalFreedomMod.userinfo.put(p, playerdata);
}
}
@ -152,67 +170,67 @@ class TFM_PlayerListener extends PlayerListener
block_command = true;
}
}
else if (command.matches("^/zeus"))
{
block_command = true;
}
else if (command.matches("^/vulcan"))
{
block_command = true;
}
else if (command.matches("^/myballsareonfire"))
{
block_command = true;
}
else if (command.matches("^/mv\\s*c"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*delete"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*im"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*m"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*reload"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*remove"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/mv\\s*unload"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
// else if (command.matches("^/zeus"))
// {
// block_command = true;
// }
// else if (command.matches("^/vulcan"))
// {
// block_command = true;
// }
// else if (command.matches("^/myballsareonfire"))
// {
// block_command = true;
// }
// else if (command.matches("^/mv\\s*c"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*delete"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*im"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*m"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*reload"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*remove"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
// else if (command.matches("^/mv\\s*unload"))
// {
// if (!plugin.isUserSuperadmin(player))
// {
// block_command = true;
// }
// }
if (block_command)
{

View file

@ -6,9 +6,9 @@ import org.bukkit.entity.Player;
public class TFM_RadarData implements Comparator<TFM_RadarData>
{
Player player;
double distance;
Location location;
public Player player;
public double distance;
public Location location;
public TFM_RadarData(Player inplayer, double indistance, Location inlocation)
{

View file

@ -1,5 +1,10 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
public class TFM_UserInfo
{
private boolean user_frozen = false;
@ -8,10 +13,85 @@ public class TFM_UserInfo
private int freecam_destroy_count = 0;
private int freecam_place_count = 0;
// -- Start Cage
private boolean user_caged = false;
private Location user_cage_pos;
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
private Material cage_material_outer;
private Material cage_material_inner;
public TFM_UserInfo()
{
}
public void setCaged(boolean state)
{
this.user_caged = state;
}
public void setCaged(boolean state, Location location, Material material_outer, Material material_inner)
{
this.user_caged = state;
this.user_cage_pos = location;
this.cage_material_outer = material_outer;
this.cage_material_inner = material_inner;
}
public boolean isCaged()
{
return this.user_caged;
}
public Material getCageMaterial(int layer)
{
if (layer == 1)
{
return this.cage_material_inner;
}
else
{
return this.cage_material_outer;
}
}
public Location getCagePos()
{
return this.user_cage_pos;
}
public void clearHistory()
{
this.user_cage_history.clear();
}
public void insertHistoryBlock(Location location, Material material)
{
this.user_cage_history.add(new TFM_BlockData(location, material));
}
public void regenerateHistory()
{
for (TFM_BlockData blockdata : this.user_cage_history)
{
blockdata.location.getBlock().setType(blockdata.material);
}
}
class TFM_BlockData
{
public Material material;
public Location location;
public TFM_BlockData(Location location, Material material)
{
this.location = location;
this.material = material;
}
}
// -- End Cage
public boolean isFrozen()
{

View file

@ -5,12 +5,15 @@ import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;
import org.bukkit.event.Event;
@ -46,9 +49,9 @@ public class TotalFreedomMod extends JavaPlugin
public int freecamTriggerCount = 10;
public boolean allPlayersFrozen = false;
public HashMap userinfo = new HashMap();
public static Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
private static final long HEARTBEAT_RATE = 5L; //Seconds
public static final long HEARTBEAT_RATE = 5L; //Seconds
public static final String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
@ -181,7 +184,7 @@ public class TotalFreedomMod extends JavaPlugin
{
for (Player p : Bukkit.getOnlinePlayers())
{
TFM_UserInfo playerdata = (TFM_UserInfo) this.userinfo.get(p);
TFM_UserInfo playerdata = TotalFreedomMod.userinfo.get(p);
if (playerdata != null)
{
playerdata.resetMsgCount();
@ -295,6 +298,8 @@ public class TotalFreedomMod extends JavaPlugin
this.getCommand("rd").setExecutor(GeneralCommands);
this.getCommand("flatlands").setExecutor(GeneralCommands);
this.getCommand("skylands").setExecutor(GeneralCommands);
this.getCommand("nether").setExecutor(GeneralCommands);
this.getCommand("banlist").setExecutor(GeneralCommands);
this.getCommand("fr").setExecutor(AdminCommands);
this.getCommand("gtfo").setExecutor(AdminCommands);
@ -307,6 +312,7 @@ public class TotalFreedomMod extends JavaPlugin
this.getCommand("qjail").setExecutor(AdminCommands);
this.getCommand("umd").setExecutor(AdminCommands);
this.getCommand("csay").setExecutor(AdminCommands);
this.getCommand("cage").setExecutor(AdminCommands);
this.getCommand("explosives").setExecutor(AntiblockCommands);
this.getCommand("lavadmg").setExecutor(AntiblockCommands);
@ -320,4 +326,64 @@ public class TotalFreedomMod extends JavaPlugin
this.getCommand("list").setExecutor(OverrideCommands);
this.getCommand("listreal").setExecutor(OverrideCommands);
}
public void gotoWorld(CommandSender sender, String targetworld)
{
if (sender instanceof Player)
{
Player sender_p = (Player) sender;
if (sender_p.getWorld().getName().equalsIgnoreCase(targetworld))
{
sender.sendMessage(ChatColor.GRAY + "Going to main world.");
Bukkit.getServer().dispatchCommand(sender, "world 0");
return;
}
for (World world : Bukkit.getWorlds())
{
if (world.getName().equalsIgnoreCase(targetworld))
{
sender.sendMessage(ChatColor.GRAY + "Going to world: " + targetworld);
Bukkit.getServer().dispatchCommand(sender, "mv tp " + targetworld);
return;
}
}
}
else
{
sender.sendMessage("This command may not be used from the console.");
}
}
public void buildHistory(Location location, int length, TFM_UserInfo playerdata)
{
Block center_block = location.getBlock();
for (int x_offset = -length; x_offset <= length; x_offset++)
{
for (int y_offset = -length; y_offset <= length; y_offset++)
{
for (int z_offset = -length; z_offset <= length; z_offset++)
{
Block block = center_block.getRelative(x_offset, y_offset, z_offset);
playerdata.insertHistoryBlock(block.getLocation(), block.getType());
}
}
}
}
public void generateCube(Location location, int length, Material material)
{
Block center_block = location.getBlock();
for (int x_offset = -length; x_offset <= length; x_offset++)
{
for (int y_offset = -length; y_offset <= length; y_offset++)
{
for (int z_offset = -length; z_offset <= length; z_offset++)
{
center_block.getRelative(x_offset, y_offset, z_offset).setType(material);
}
}
}
}
}

View file

@ -1,9 +1,15 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 1.5
version: 1.6
description: Plugin for the Total Freedom server
author: StevenLawson / Madgeek1450
commands:
banlist:
description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.
usage: /<command> [purge]
cage:
description: Superadmin command - Place a cage around someone.
usage: /<command> [partialname]
cake:
description: Superadmin command - For the people that are still alive.
usage: /<command>
@ -55,6 +61,9 @@ commands:
mp:
description: Use moblimiter to purge all mobs.
usage: /<command>
nether:
description: Goto the nether.
usage: /<command>
nonuke:
description: Attempt to detect "invisible griefers" and "nukers".
usage: /<command> <on|off> [range] [blockrate]