Lots of new commands.

Code cleanup.
This commit is contained in:
Steven Lawson 2011-10-16 02:00:37 -04:00
parent e2d772bc4f
commit 8119ca553a
11 changed files with 525 additions and 158 deletions

View File

@ -45,13 +45,7 @@ public class TFM_BlockListener extends BlockListener
if (plugin.nukeMonitor)
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
Location player_pos = p.getLocation();
Location block_pos = event.getBlock().getLocation();
@ -59,7 +53,7 @@ public class TFM_BlockListener extends BlockListener
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
{
playerdata.incrementFreecamDestroyCount();
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)
if (playerdata.getFreecamDestroyCount() > plugin.freecamTriggerCount)
{
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
@ -82,6 +76,7 @@ public class TFM_BlockListener extends BlockListener
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);
p.getInventory().clear();
p.kickPlayer("You are breaking blocks too fast. Nukers are not permitted on this server.");
event.setCancelled(true);
return;
@ -101,12 +96,7 @@ public class TFM_BlockListener extends BlockListener
if (player_pos.distance(block_pos) > plugin.nukeMonitorRange)
{
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.incrementFreecamPlaceCount();
if (playerdata.getFreecamPlaceCount() > plugin.freecamTriggerCount)

View File

@ -14,6 +14,7 @@ import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -81,17 +82,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
p = matches.get(0);
}
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.setFrozen(!playerdata.isFrozen());
}
else
{
playerdata = new TFM_UserInfo();
playerdata.setFrozen(true);
plugin.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") + ".");
@ -128,7 +120,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
TFM_Util.tfm_broadcastMessage(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
//Undo WorldEdits:
Bukkit.getServer().dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName()));
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("/undo %d %s", 15, p.getName()));
//Deop
p.setOp(false);
@ -211,11 +203,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
p.getInventory().clear();
//Flag for insta-kill:
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.setForcedDeath(true);
}
//Strike with lightning effect:
final Location target_pos = p.getLocation();
@ -307,17 +296,9 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
else if (mode.equals("fr"))
{
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.setFrozen(!playerdata.isFrozen());
}
else
{
playerdata = new TFM_UserInfo();
playerdata.setFrozen(true);
plugin.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") + ".");
}
@ -354,7 +335,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
{
String out_command = base_command.replaceAll("\\x3f", p.getName());
sender.sendMessage("Running Command: " + out_command);
Bukkit.getServer().dispatchCommand(sender, out_command);
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), out_command);
}
}
else
@ -374,14 +355,26 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
if (args.length >= 2)
{
try
{
plugin.nukeMonitorRange = Double.parseDouble(args[1]);
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 3)
{
try
{
plugin.nukeMonitorCountBreak = Integer.parseInt(args[2]);
}
catch (NumberFormatException nfex)
{
}
}
if (args[0].equalsIgnoreCase("on"))
{
@ -570,7 +563,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
}
//Send to jail "mgjail":
Bukkit.getServer().dispatchCommand(sender, String.format("tjail %s mgjail", p.getName()));
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
TFM_Util.tfm_broadcastMessage(p.getName() + " has been JAILED!", ChatColor.RED);
}
@ -654,12 +647,7 @@ public class TFM_Cmds_Admin implements CommandExecutor
p = matches.get(0);
}
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
plugin.userinfo.put(p, playerdata);
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
Material cage_material_outer = Material.GLASS;
Material cage_material_inner = Material.AIR;
@ -699,8 +687,8 @@ public class TFM_Cmds_Admin implements CommandExecutor
playerdata.regenerateHistory();
playerdata.clearHistory();
TFM_Util.buildHistory(target_pos, 2, playerdata);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
p.setGameMode(GameMode.SURVIVAL);
@ -734,13 +722,127 @@ public class TFM_Cmds_Admin implements CommandExecutor
p = matches.get(0);
}
double strength = 100.0;
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
double strength = 10.0;
if (args.length >= 2)
{
if (args[1].equalsIgnoreCase("stop") || args[1].equalsIgnoreCase("end"))
{
sender.sendMessage(ChatColor.GRAY + "Stopped orbiting " + p.getName());
playerdata.stopOrbiting();
return true;
}
try
{
strength = Double.parseDouble(args[1]);
}
catch (NumberFormatException nfex)
{
strength = 10.0;
}
}
p.setGameMode(GameMode.SURVIVAL);
playerdata.startOrbiting(strength);
p.setVelocity(new Vector(0, strength, 0));
sender.sendMessage(ChatColor.GRAY + "Orbiting " + p.getName());
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("expel"))
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
double radius = 50.0;
double strength = 100.0;
if (args.length >= 1)
{
try
{
radius = Double.parseDouble(args[0]);
}
catch (NumberFormatException nfex)
{
}
}
if (args.length >= 2)
{
try
{
strength = Double.parseDouble(args[1]);
}
catch (NumberFormatException nfex)
{
}
}
Location sender_pos = sender_p.getLocation();
for (Player p : Bukkit.getOnlinePlayers())
{
if (!p.equals(sender_p))
{
Location target_pos = p.getLocation();
if (target_pos.distance(sender_pos) < radius)
{
sender.sendMessage("Pushing " + p.getName());
Vector expel_direction = target_pos.subtract(sender_pos).toVector().normalize();
p.setVelocity(expel_direction.multiply(strength));
}
}
}
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("mp44"))
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
if (args.length == 0)
{
return false;
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(sender_p, plugin);
if (args[0].equalsIgnoreCase("draw"))
{
playerdata.stopArrowShooter();
int schedule_id = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new ArrowShooter(sender_p), 1L, 1L);
playerdata.startArrowShooter(schedule_id);
}
else
{
playerdata.stopArrowShooter();
}
}
else
{
@ -757,4 +859,21 @@ public class TFM_Cmds_Admin implements CommandExecutor
return false;
}
class ArrowShooter implements Runnable
{
private Player _player;
public ArrowShooter(Player player)
{
_player = player;
}
@Override
public void run()
{
Arrow shot_arrow = _player.shootArrow();
shot_arrow.setVelocity(shot_arrow.getVelocity().multiply(2.0));
}
}
}

View File

@ -47,9 +47,15 @@ public class TFM_Cmds_AntiBlock implements CommandExecutor
}
if (args.length == 2)
{
try
{
plugin.explosiveRadius = Double.parseDouble(args[1]);
}
catch (NumberFormatException nfex)
{
}
}
if (args[0].equalsIgnoreCase("on"))
{

View File

@ -3,7 +3,9 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;
import me.desmin88.mobdisguise.api.MobDisguiseAPI;
import org.bukkit.Bukkit;
@ -20,7 +22,6 @@ import org.bukkit.entity.*;
public class TFM_Cmds_General implements CommandExecutor
{
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
public TFM_Cmds_General(TotalFreedomMod plugin)
@ -144,7 +145,7 @@ public class TFM_Cmds_General implements CommandExecutor
{
if (senderIsConsole)
{
sender.sendMessage("This command can only be used in-game.");
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
@ -168,9 +169,15 @@ public class TFM_Cmds_General implements CommandExecutor
int countmax = 5;
if (args.length == 1)
{
try
{
countmax = Integer.parseInt(args[0]);
}
catch (NumberFormatException nfex)
{
}
}
int count = 0;
for (TFM_RadarData i : radar_data)
@ -183,8 +190,7 @@ public class TFM_Cmds_General implements CommandExecutor
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d, Disguised: %s",
i.player.getName(),
Math.round(i.distance),
MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No"
));
MobDisguiseAPI.isDisguised(i.player) ? "Yes" : "No"));
}
return true;
@ -194,7 +200,7 @@ public class TFM_Cmds_General implements CommandExecutor
if (senderIsConsole || sender.isOp())
{
sender.sendMessage(ChatColor.GRAY + "Removing all dropped items, arrows, exp. orbs and TNT...");
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeDropEntities(plugin)) + " dropped enties removed.");
sender.sendMessage(ChatColor.GRAY + String.valueOf(TFM_Util.wipeDropEntities(true)) + " dropped enties removed.");
}
else
{
@ -332,6 +338,83 @@ public class TFM_Cmds_General implements CommandExecutor
sender.sendMessage(ChatColor.GRAY + banned_ips.toString());
return true;
}
else if (cmd.getName().equalsIgnoreCase("tossmob"))
{
if (senderIsConsole || sender.isOp())
{
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p, plugin);
CreatureType creature = CreatureType.PIG;
if (args.length >= 1)
{
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("end"))
{
playerData.disableMobThrower();
sender.sendMessage(ChatColor.GREEN + "MobThrower is disabled.");
return true;
}
Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
mobtypes.put("chicken", CreatureType.CHICKEN);
mobtypes.put("cow", CreatureType.COW);
mobtypes.put("creeper", CreatureType.CREEPER);
mobtypes.put("pig", CreatureType.PIG);
mobtypes.put("sheep", CreatureType.SHEEP);
mobtypes.put("skeleton", CreatureType.SKELETON);
mobtypes.put("spider", CreatureType.SPIDER);
mobtypes.put("zombie", CreatureType.ZOMBIE);
mobtypes.put("wolf", CreatureType.WOLF);
CreatureType creature_query = mobtypes.get(args[0].toLowerCase().trim());
if (creature_query != null)
{
creature = creature_query;
}
else
{
sender.sendMessage(args[1] + " is not a supported mob type. Using a pig instead.");
}
}
double speed = 1.0;
if (args.length >= 2)
{
try
{
speed = Double.parseDouble(args[1]);
}
catch (NumberFormatException nfex)
{
}
}
if (speed < 1.0)
{
speed = 1.0;
}
else if (speed > 5.0)
{
speed = 5.0;
}
playerData.enableMobThrower(creature, speed);
sender.sendMessage(ChatColor.GREEN + "MobThrower is enabled. Creature: " + creature + " - Speed: " + speed + ".");
sender.sendMessage(ChatColor.GREEN + "Left click while holding a stick to throw mobs!");
sender.sendMessage(ChatColor.GREEN + "Type '/tossmob off' to disable. -By Madgeek1450");
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
}

View File

@ -53,9 +53,7 @@ public class TFM_EntityListener extends EntityListener
Player p = (Player) event.getEntity();
if (p != null)
{
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
if (playerdata.getForcedDeath())
{
event.setCancelled(false);
@ -67,7 +65,6 @@ public class TFM_EntityListener extends EntityListener
}
}
}
}
if (event.getCause() == DamageCause.LAVA && !plugin.allowLavaDamage)
{

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -19,17 +18,14 @@ public class TFM_Heartbeat implements Runnable
{
for (Player p : Bukkit.getOnlinePlayers())
{
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.resetMsgCount();
playerdata.resetBlockDestroyCount();
}
}
if (plugin.autoEntityWipe)
{
TFM_Util.wipeDropEntities(plugin);
TFM_Util.wipeDropEntities(!plugin.allowExplosions);
}
if (plugin.disableNight)

View File

@ -5,10 +5,13 @@ import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
class TFM_PlayerListener extends PlayerListener
{
@ -23,12 +26,12 @@ class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if (event.getMaterial() == Material.WATER_BUCKET)
{
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
@ -40,8 +43,6 @@ class TFM_PlayerListener extends PlayerListener
}
else if (event.getMaterial() == Material.LAVA_BUCKET)
{
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
@ -52,13 +53,32 @@ class TFM_PlayerListener extends PlayerListener
return;
}
}
else if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (event.getMaterial() == Material.STICK)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player, plugin);
if (playerdata.mobThrowerEnabled())
{
Location player_pos = player.getLocation();
Vector direction = player_pos.getDirection().normalize();
Location rez_pos = player_pos.add(direction.multiply(2.0));
LivingEntity rezzed_mob = player.getWorld().spawnCreature(rez_pos, playerdata.mobThrowerCreature());
rezzed_mob.setVelocity(direction.multiply(playerdata.mobThrowerSpeed()));
playerdata.enqueueMob(rezzed_mob);
event.setCancelled(true);
}
}
}
}
@Override
public void onPlayerMove(PlayerMoveEvent event)
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = plugin.userinfo.get(p);
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
boolean do_freeze = false;
if (plugin.allPlayersFrozen)
@ -69,15 +89,12 @@ class TFM_PlayerListener extends PlayerListener
}
}
else
{
if (playerdata != null)
{
if (playerdata.isFrozen())
{
do_freeze = true;
}
}
}
if (do_freeze)
{
@ -91,8 +108,6 @@ class TFM_PlayerListener extends PlayerListener
event.setTo(to);
}
if (playerdata != null)
{
if (playerdata.isCaged())
{
Location target_pos = p.getLocation().add(0, 1, 0);
@ -103,10 +118,17 @@ class TFM_PlayerListener extends PlayerListener
playerdata.regenerateHistory();
playerdata.clearHistory();
TFM_Util.buildHistory(target_pos, 2, playerdata);
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 2, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.OUTER));
TFM_Util.generateCube(target_pos, 1, playerdata.getCageMaterial(TFM_UserInfo.CageLayer.INNER));
}
}
if (playerdata.isOrbiting())
{
if (p.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0))
{
p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0));
}
}
}
@ -115,9 +137,7 @@ class TFM_PlayerListener extends PlayerListener
{
Player p = event.getPlayer();
TFM_UserInfo playerdata = plugin.userinfo.get(p);
if (playerdata != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p, plugin);
playerdata.incrementMsgCount();
if (playerdata.getMsgCount() > 10)
@ -125,17 +145,11 @@ class TFM_PlayerListener extends PlayerListener
p.setOp(false);
p.kickPlayer("No Spamming");
TFM_Util.tfm_broadcastMessage(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
playerdata.resetMsgCount();
event.setCancelled(true);
return;
}
}
else
{
playerdata = new TFM_UserInfo();
playerdata.incrementMsgCount();
plugin.userinfo.put(p, playerdata);
}
String message = event.getMessage().toLowerCase();
if (Pattern.compile("\\sbe\\s.*admin").matcher(message).find()
@ -177,6 +191,11 @@ class TFM_PlayerListener extends PlayerListener
block_command = true;
}
}
else if (Pattern.compile("^/time").matcher(command).find())
{
player.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
block_command = true;
}
if (block_command)
{
@ -185,4 +204,34 @@ class TFM_PlayerListener extends PlayerListener
return;
}
}
@Override
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (plugin.autoEntityWipe)
{
if (event.getPlayer().getWorld().getEntities().size() > 750)
{
event.setCancelled(true);
}
else
{
event.getItemDrop().remove();
}
}
}
@Override
public void onPlayerKick(PlayerKickEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
playerdata.stopArrowShooter();
}
@Override
public void onPlayerQuit(PlayerQuitEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer(), plugin);
playerdata.stopArrowShooter();
}
}

View File

@ -2,8 +2,12 @@ package me.StevenLawson.TotalFreedomMod;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class TFM_UserInfo
{
@ -16,13 +20,52 @@ public class TFM_UserInfo
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;
private Material cage_material_outer = Material.GLASS;
private Material cage_material_inner = Material.AIR;
private boolean is_orbiting = false;
private double orbit_strength = 10.0;
private boolean mob_thrower_enabled = false;
private CreatureType mob_thrower_creature = CreatureType.PIG;
private double mob_thrower_speed = 4.0;
private List<LivingEntity> mobqueue = new ArrayList<LivingEntity>();
private int schedule_id = -1;
public TFM_UserInfo()
{
}
public static TFM_UserInfo getPlayerData(Player p, TotalFreedomMod tfm)
{
TFM_UserInfo playerdata = tfm.userinfo.get(p);
if (playerdata == null)
{
playerdata = new TFM_UserInfo();
tfm.userinfo.put(p, playerdata);
}
return playerdata;
}
public boolean isOrbiting()
{
return this.is_orbiting;
}
public void startOrbiting(double orbit_strength)
{
this.is_orbiting = true;
this.orbit_strength = orbit_strength;
}
public void stopOrbiting()
{
this.is_orbiting = false;
}
public double orbitStrength()
{
return this.orbit_strength;
}
public void setCaged(boolean state)
{
this.user_caged = state;
@ -173,4 +216,58 @@ public class TFM_UserInfo
{
this.freecam_place_count = 0;
}
public void enableMobThrower(CreatureType mob_thrower_creature, double mob_thrower_speed)
{
this.mob_thrower_enabled = true;
this.mob_thrower_creature = mob_thrower_creature;
this.mob_thrower_speed = mob_thrower_speed;
}
public void disableMobThrower()
{
this.mob_thrower_enabled = false;
}
public CreatureType mobThrowerCreature()
{
return this.mob_thrower_creature;
}
public double mobThrowerSpeed()
{
return this.mob_thrower_speed;
}
public boolean mobThrowerEnabled()
{
return this.mob_thrower_enabled;
}
public void enqueueMob(LivingEntity mob)
{
mobqueue.add(mob);
if (mobqueue.size() > 4)
{
LivingEntity oldmob = mobqueue.remove(0);
if (oldmob != null)
{
oldmob.damage(20);
}
}
}
void startArrowShooter(int schedule_id)
{
this.schedule_id = schedule_id;
}
void stopArrowShooter()
{
if (this.schedule_id != -1)
{
Bukkit.getScheduler().cancelTask(this.schedule_id);
this.schedule_id = -1;
}
}
}

View File

@ -95,7 +95,7 @@ public class TFM_Util
}
else
{
sender.sendMessage("This command may not be used from the console.");
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
}
}
@ -219,7 +219,7 @@ public class TFM_Util
if (Bukkit.getOnlineMode())
{
if (tfm.superadmins.contains(user.getName()))
if (tfm.superadmins.contains(user.getName().toLowerCase()))
{
return true;
}
@ -250,14 +250,14 @@ public class TFM_Util
return false;
}
public static int wipeDropEntities(TotalFreedomMod tfm)
public static int wipeDropEntities(boolean wipe_tnt)
{
int removed = 0;
for (World world : Bukkit.getWorlds())
{
for (Entity ent : world.getEntities())
{
if (ent instanceof Arrow || (ent instanceof TNTPrimed && !tfm.allowExplosions) || ent instanceof Item || ent instanceof ExperienceOrb)
if (ent instanceof Arrow || (ent instanceof TNTPrimed && wipe_tnt) || ent instanceof Item || ent instanceof ExperienceOrb)
{
ent.remove();
removed++;

View File

@ -27,6 +27,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
public static final String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public Map<Player, TFM_UserInfo> userinfo = new HashMap<Player, TFM_UserInfo>();
public boolean allPlayersFrozen = false;
@ -92,20 +93,34 @@ public class TotalFreedomMod extends JavaPlugin
disableNight = config.getBoolean("disable_night", disableNight);
disableWeather = config.getBoolean("disable_weather", disableWeather);
superadmins = (List<String>) config.getList("superadmins", null);
if (superadmins == null)
{
superadmins = new ArrayList<String>();
List<String> superadmins_temp = (List<String>) config.getList("superadmins", null);
if (superadmins_temp == null || superadmins_temp.isEmpty())
{
superadmins.add("Madgeek1450");
superadmins.add("markbyron");
}
superadmin_ips = (List<String>) config.getList("superadmin_ips", null);
if (superadmin_ips == null)
else
{
for (String admin_name : superadmins_temp)
{
superadmins.add(admin_name.toLowerCase().trim());
}
}
superadmin_ips = new ArrayList<String>();
List<String> superadmin_ips_temp = (List<String>) config.getList("superadmin_ips", null);
if (superadmin_ips_temp == null || superadmin_ips_temp.isEmpty())
{
superadmin_ips.add("127.0.0.1");
}
else
{
for (String admin_ip : superadmin_ips_temp)
{
superadmin_ips.add(admin_ip.toLowerCase().trim());
}
}
}
private final TFM_EntityListener entityListener = new TFM_EntityListener(this);
@ -131,6 +146,9 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Event.Priority.Monitor, this);
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this);
pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this);
@ -161,10 +179,12 @@ public class TotalFreedomMod extends JavaPlugin
this.getCommand("skylands").setExecutor(GeneralCommands);
this.getCommand("status").setExecutor(GeneralCommands);
this.getCommand("survival").setExecutor(GeneralCommands);
this.getCommand("tossmob").setExecutor(GeneralCommands);
this.getCommand("cage").setExecutor(AdminCommands);
this.getCommand("cake").setExecutor(AdminCommands);
this.getCommand("csay").setExecutor(AdminCommands);
this.getCommand("expel").setExecutor(AdminCommands);
this.getCommand("fr").setExecutor(AdminCommands);
this.getCommand("gadmin").setExecutor(AdminCommands);
this.getCommand("gcmd").setExecutor(AdminCommands);
@ -176,6 +196,7 @@ public class TotalFreedomMod extends JavaPlugin
this.getCommand("tfsmite").setExecutor(AdminCommands);
this.getCommand("umd").setExecutor(AdminCommands);
this.getCommand("wildcard").setExecutor(AdminCommands);
this.getCommand("mp44").setExecutor(AdminCommands);
this.getCommand("explosives").setExecutor(AntiblockCommands);
this.getCommand("fireplace").setExecutor(AntiblockCommands);

View File

@ -22,6 +22,9 @@ commands:
explosives:
description: Superadmin command - Enable/disable explosives and set effect radius.
usage: /<command> <on|off> [radius]
expel:
description: Superadmin command - Push people away from you.
usage: /<command> [radius] [strength]
fireplace:
description: Superadmin command - Enable/disable fire placement.
usage: /<command> <on|off>
@ -58,6 +61,9 @@ commands:
mp:
description: Use moblimiter to purge all mobs.
usage: /<command>
mp44:
description: Superadmin Command - Modern weaponry, FTW. Use 'draw' to start firing, 'sling' to stop firing.
usage: /<command> [draw|sling]
nether:
description: Goto the nether.
usage: /<command>
@ -106,6 +112,9 @@ commands:
survival:
description: Quickly change your own gamemode to survival, or define someone's username to change theirs.
usage: /<command> [partialname]
tossmob:
description: Throw a mob in the direction you are facing when you left click with a stick.
usage: /<command> [mobtype | off] [speed]
tfbanlist:
description: Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.
usage: /<command> [purge]