This commit is contained in:
Steven Lawson 2011-11-28 17:44:51 -05:00
parent 1adfb29409
commit 41f2a0e232
19 changed files with 579 additions and 433 deletions

View File

@ -38,6 +38,10 @@ mp44_enabled: false
# Moblimiter:
mob_limiter_enabled: true
mob_limiter_max: 50
mob_limiter_disable_dragon: true
mob_limiter_disable_ghast: true
mob_limiter_disable_slime: true
mob_limiter_disable_giant: true
# Superadmins: Users that can always log in and use the most powerful commands:
# When online-mode = false, only superadmin_ips will be used.

View File

@ -5,12 +5,12 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_skylands extends TFM_Command
public class Command_ender extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
TFM_Util.gotoWorld(sender, "skylands");
TFM_Util.gotoWorld(sender, "the_end");
return true;
}
}

View File

@ -0,0 +1,81 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_fuckoff extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
if (!TFM_Util.isUserSuperadmin(sender, plugin))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
boolean permitted = false;
for (String name : Arrays.asList("madgeek1450", "markbyron"))
{
if (sender.getName().equalsIgnoreCase(name))
{
permitted = true;
break;
}
}
if (!permitted)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (args.length < 1)
{
return false;
}
boolean fuckoff_enabled = false;
double fuckoff_range = 25.0;
if (args[0].equalsIgnoreCase("on"))
{
fuckoff_enabled = true;
if (args.length >= 2)
{
try
{
fuckoff_range = Math.max(5.0, Math.min(100.0, Double.parseDouble(args[1])));
}
catch (NumberFormatException ex)
{
}
}
}
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(sender_p))
{
TotalFreedomMod.fuckoffEnabledFor.remove(sender_p);
}
if (fuckoff_enabled)
{
TotalFreedomMod.fuckoffEnabledFor.put(sender_p, new Double(fuckoff_range));
}
sender.sendMessage("Fuckoff " + (fuckoff_enabled ? ("enabled. Range: " + fuckoff_range + ".") : "disabled."));
return true;
}
}

View File

@ -0,0 +1,32 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_kicknoob extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
{
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
return true;
}
sender.sendMessage("Disconnecting all non-superadmins.");
for (Player p : plugin.getServer().getOnlinePlayers())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
{
p.kickPlayer("Disconnected by admin.");
}
}
return true;
}
}

View File

@ -0,0 +1,84 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_moblimiter extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
{
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
return true;
}
if (args.length < 1)
{
return false;
}
if (args[0].equalsIgnoreCase("on"))
{
TotalFreedomMod.mobLimiterEnabled = true;
}
else if (args[0].equalsIgnoreCase("off"))
{
TotalFreedomMod.mobLimiterEnabled = false;
}
else if (args[0].equalsIgnoreCase("dragon"))
{
TotalFreedomMod.mobLimiterDisableDragon = !TotalFreedomMod.mobLimiterDisableDragon;
}
else if (args[0].equalsIgnoreCase("giant"))
{
TotalFreedomMod.mobLimiterDisableGiant = !TotalFreedomMod.mobLimiterDisableGiant;
}
else if (args[0].equalsIgnoreCase("slime"))
{
TotalFreedomMod.mobLimiterDisableSlime = !TotalFreedomMod.mobLimiterDisableSlime;
}
else if (args[0].equalsIgnoreCase("ghast"))
{
TotalFreedomMod.mobLimiterDisableGhast = !TotalFreedomMod.mobLimiterDisableGhast;
}
else
{
if (args.length < 2)
{
return false;
}
if (args[0].equalsIgnoreCase("setmax"))
{
try
{
TotalFreedomMod.mobLimiterMax = Math.max(0, Math.min(2000, Integer.parseInt(args[1])));
}
catch (NumberFormatException nfex)
{
}
}
}
if (TotalFreedomMod.mobLimiterEnabled)
{
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TotalFreedomMod.mobLimiterMax + ".");
sender.sendMessage("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + ".");
sender.sendMessage("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + ".");
sender.sendMessage("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + ".");
sender.sendMessage("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + ".");
}
else
{
sender.sendMessage("Moblimiter is disabled. No mob restrictions are in effect.");
}
return true;
}
}

View File

@ -12,8 +12,12 @@ public class Command_nonuke extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
{
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");
return true;
}
if (args.length < 1)
{
return false;
@ -53,11 +57,6 @@ public class Command_nonuke extends TFM_Command
TotalFreedomMod.nukeMonitor = false;
sender.sendMessage("Nuke monitor is disabled.");
}
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}

View File

@ -1,58 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
public class Command_qjail extends TFM_Command
{
// @Override
// public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
// {
// if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
// {
// if (args.length < 1)
// {
// return false;
// }
//
// Player p;
// try
// {
// p = getPlayer(args[0]);
// }
// catch (CantFindPlayerException ex)
// {
// sender.sendMessage(ex.getMessage());
// return true;
// }
//
// //Deop
// p.setOp(false);
//
// //Set gamemode to survival:
// p.setGameMode(GameMode.SURVIVAL);
//
// //Clear inventory:
// p.getInventory().clear();
//
// //Strike with lightning effect:
// final Location target_pos = p.getLocation();
// for (int x = -1; x <= 1; x++)
// {
// for (int z = -1; z <= 1; z++)
// {
// final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
// target_pos.getWorld().strikeLightning(strike_pos);
// }
// }
//
// //Send to jail "mgjail":
// Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("tjail %s mgjail 1y", p.getName().replace(" ", "").trim()));
//
// TFM_Util.bcastMsg(p.getName() + " has been JAILED!", ChatColor.RED);
// }
// else
// {
// sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
// }
//
// return true;
// }
}

View File

@ -71,7 +71,7 @@ public class Command_saconfig extends TFM_Command
List<String> user_ips = new ArrayList<String>();
if (config.contains(user_name))
{
user_ips = config.getStringListFixed(user_name);
user_ips = (List<String>) config.getStringList(user_name);
}
if (!user_ips.contains(new_ip))
@ -122,7 +122,7 @@ public class Command_saconfig extends TFM_Command
if (config.contains(user_name))
{
List<String> user_ips = config.getStringListFixed(user_name);
List<String> user_ips = (List<String>) config.getStringList(user_name);
for (String ip : user_ips)
{
TotalFreedomMod.superadmin_ips.remove(ip);

View File

@ -0,0 +1,35 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_setspawnworld extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
return true;
}
if (!TFM_Util.isUserSuperadmin(sender, plugin))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
Location pos = sender_p.getLocation();
sender_p.getWorld().setSpawnLocation(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
sender.sendMessage(ChatColor.GRAY + "Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation()));
return true;
}
}

View File

@ -1,47 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
public class Command_stacker extends TFM_Command
{
// @Override
// public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
// {
// if (senderIsConsole)
// {
// sender.sendMessage(TotalFreedomMod.NOT_FROM_CONSOLE);
// }
// else if (TFM_Util.isUserSuperadmin(sender, plugin))
// {
// if (args.length >= 1)
// {
// if (TFM_Util.isStopCommand(args[0]))
// {
// for (World world : Bukkit.getWorlds())
// {
// for (LivingEntity entity : world.getLivingEntities())
// {
// entity.leaveVehicle();
// }
// }
// return true;
// }
// }
//
// LivingEntity parent = sender_p;
// for (LivingEntity entity : sender_p.getWorld().getLivingEntities())
// {
// if (parent != null)
// {
// parent.setPassenger(entity);
// }
//
// parent = entity;
// }
// }
// else
// {
// sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
// }
//
// return true;
// }
}

View File

@ -1,86 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Command_tfsmite extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{
List<Player> targets = new ArrayList<Player>();
if (args[0].equalsIgnoreCase("all"))
{
targets = Arrays.asList(Bukkit.getOnlinePlayers());
}
else
{
List<Player> matches = Bukkit.matchPlayer(args[0]);
if (matches.isEmpty())
{
sender.sendMessage("Can't find user " + args[0]);
return true;
}
else
{
targets.add(matches.get(0));
}
}
for (Player p : targets)
{
TFM_Util.bcastMsg(p.getName() + " has been a naughty, naughty boy.", ChatColor.RED);
//Deop
p.setOp(false);
//Set gamemode to survival:
p.setGameMode(GameMode.SURVIVAL);
//Clear inventory:
p.getInventory().clear();
//Flag for insta-kill:
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.setForcedDeath(true);
//Strike with lightning effect:
final Location target_pos = p.getLocation();
for (int x = -1; x <= 1; x++)
{
for (int z = -1; z <= 1; z++)
{
final Location strike_pos = new Location(target_pos.getWorld(), target_pos.getBlockX() + x, target_pos.getBlockY(), target_pos.getBlockZ() + z);
target_pos.getWorld().strikeLightning(strike_pos);
}
}
}
}
else
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
}
return true;
}
}

View File

@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Map.Entry;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
@ -34,9 +37,25 @@ public class Command_tossmob extends TFM_Command
return true;
}
if ((creature = TFM_Util.getCreatureType(args[0])) == null)
if (args[0].equalsIgnoreCase("list"))
{
StringBuilder output = new StringBuilder("Supported mobs: ");
for (Entry<String, CreatureType> mob : TFM_Util.mobtypes.entrySet())
{
output.append(mob.getKey()).append(", ");
}
sender.sendMessage(ChatColor.GREEN + output.toString());
return true;
}
try
{
creature = TFM_Util.getCreatureType(args[0]);
}
catch (Exception ex)
{
sender.sendMessage(ChatColor.RED + args[0] + " is not a supported mob type. Using a pig instead.");
sender.sendMessage(ChatColor.RED + "By the way, you can type /tossmob list to see all possible mobs.");
creature = CreatureType.PIG;
}
}

View File

@ -83,6 +83,8 @@ public class TFM_BlockListener extends BlockListener
TFM_Util.bcastMsg(p.getName() + " is breaking blocks too fast!", ChatColor.RED);
TFM_Util.autoEject(p, "You are breaking blocks too fast. Nukers are not permitted on this server.");
playerdata.resetBlockDestroyCount();
event.setCancelled(true);
return;
}
@ -132,99 +134,90 @@ public class TFM_BlockListener extends BlockListener
TFM_Util.bcastMsg(p.getName() + " is placing blocks too fast!", ChatColor.RED);
TFM_Util.autoEject(p, "You are placing blocks too fast.");
playerdata.resetBlockPlaceCount();
event.setCancelled(true);
return;
}
}
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
switch (is.getType())
{
case LAVA:
case STATIONARY_LAVA:
{
if (TotalFreedomMod.allowLavaPlace)
{
log.info(String.format("%s placed lava @ %s",
p.getName(),
TFM_Util.formatLocation(event.getBlock().getLocation())));
log.info(String.format("%s placed lava @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
p.getInventory().clear(p.getInventory().getHeldItemSlot());
}
else
{
int slot = p.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
p.getInventory().setItem(slot, heldItem);
p.sendMessage(ChatColor.GOLD + "LAVA NO FUN, YOU EAT COOKIE INSTEAD, NO?");
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
p.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER)
case WATER:
case STATIONARY_WATER:
{
if (TotalFreedomMod.allowWaterPlace)
{
log.info(String.format("%s placed water @ %s",
p.getName(),
TFM_Util.formatLocation(event.getBlock().getLocation())));
log.info(String.format("%s placed water @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
p.getInventory().clear(p.getInventory().getHeldItemSlot());
}
else
{
int slot = p.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
p.getInventory().setItem(slot, heldItem);
p.sendMessage(ChatColor.GOLD + "Does this look like a waterpark to you?");
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
p.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
else if (is.getType() == Material.FIRE)
case FIRE:
{
if (TotalFreedomMod.allowFirePlace)
{
log.info(String.format("%s placed fire @ %s",
p.getName(),
TFM_Util.formatLocation(event.getBlock().getLocation())));
log.info(String.format("%s placed fire @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
p.getInventory().clear(p.getInventory().getHeldItemSlot());
}
else
{
int slot = p.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
p.getInventory().setItem(slot, heldItem);
p.sendMessage(ChatColor.GOLD + "It's gettin (too) hot in here...");
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
p.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
else if (is.getType() == Material.TNT)
case TNT:
{
if (TotalFreedomMod.allowExplosions)
{
log.info(String.format("%s placed TNT @ %s",
p.getName(),
TFM_Util.formatLocation(event.getBlock().getLocation())));
log.info(String.format("%s placed TNT @ %s", p.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
p.getInventory().clear(p.getInventory().getHeldItemSlot());
}
else
{
int slot = p.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
p.getInventory().setItem(slot, heldItem);
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
return;
}
break;
}
}
}
}

View File

@ -1,16 +1,9 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Creature;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Ghast;
import org.bukkit.entity.Player;
import org.bukkit.entity.Slime;
import org.bukkit.entity.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -60,24 +53,6 @@ public class TFM_EntityListener extends EntityListener
@Override
public void onEntityDamage(EntityDamageEvent event)
{
if (event.getEntity() instanceof Player)
{
Player p = (Player) event.getEntity();
if (p != null)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
if (playerdata.getForcedDeath())
{
event.setCancelled(false);
p.setFoodLevel(0);
p.setHealth(0);
event.setDamage(100);
playerdata.setForcedDeath(false);
return;
}
}
}
if (event.getCause() == DamageCause.LAVA && !TotalFreedomMod.allowLavaDamage)
{
event.setCancelled(true);
@ -90,11 +65,40 @@ public class TFM_EntityListener extends EntityListener
{
if (TotalFreedomMod.mobLimiterEnabled)
{
if (event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime || event.getEntity() instanceof EnderDragon)
Entity spawned = event.getEntity();
if (spawned instanceof EnderDragon)
{
if (TotalFreedomMod.mobLimiterDisableDragon)
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Ghast)
{
if (TotalFreedomMod.mobLimiterDisableGhast)
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Slime)
{
if (TotalFreedomMod.mobLimiterDisableSlime)
{
event.setCancelled(true);
return;
}
}
else if (spawned instanceof Giant)
{
if (TotalFreedomMod.mobLimiterDisableGiant)
{
event.setCancelled(true);
return;
}
}
if (TotalFreedomMod.mobLimiterMax > 0)
{

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
@ -15,7 +16,6 @@ import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -34,29 +34,37 @@ public class TFM_PlayerListener extends PlayerListener
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
Action action = event.getAction();
Material material = event.getMaterial();
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK)
switch (event.getAction())
{
if (material == Material.WATER_BUCKET)
case RIGHT_CLICK_AIR:
case RIGHT_CLICK_BLOCK:
{
player.getInventory().setItemInHand(new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GOLD + "Does this look like a waterpark to you?");
switch (event.getMaterial())
{
case WATER_BUCKET:
{
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
event.setCancelled(true);
return;
}
else if (material == Material.LAVA_BUCKET)
case LAVA_BUCKET:
{
player.getInventory().setItemInHand(new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GOLD + "LAVA NO FUN, YOU EAT COOKIE INSTEAD, NO?");
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
event.setCancelled(true);
return;
}
}
else if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK)
break;
}
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
{
if (material == Material.STICK)
switch (event.getMaterial())
{
case STICK:
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.mobThrowerEnabled())
@ -69,12 +77,13 @@ public class TFM_PlayerListener extends PlayerListener
playerdata.enqueueMob(rezzed_mob);
event.setCancelled(true);
return;
}
break;
}
else if (material == Material.SULPHUR)
case SULPHUR:
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(player);
if (playerdata.isMP44Armed())
{
if (playerdata.toggleMP44Firing())
@ -87,7 +96,12 @@ public class TFM_PlayerListener extends PlayerListener
}
event.setCancelled(true);
return;
}
break;
}
}
break;
}
}
}
@ -98,6 +112,37 @@ public class TFM_PlayerListener extends PlayerListener
Player p = event.getPlayer();
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet())
{
Player fuckoff_player = fuckoff.getKey();
if (fuckoff_player.equals(p) || !fuckoff_player.isOnline())
{
continue;
}
double fuckoff_range = fuckoff.getValue().doubleValue();
Location mover_pos = p.getLocation();
Location fuckoff_pos = fuckoff_player.getLocation();
double distance;
try
{
distance = mover_pos.distance(fuckoff_pos);
}
catch (IllegalArgumentException ex)
{
continue;
}
if (distance < fuckoff_range)
{
event.setTo(fuckoff_pos.clone().add(mover_pos.subtract(fuckoff_pos).toVector().normalize().multiply(fuckoff_range * 1.1)));
break;
}
}
boolean do_freeze = false;
if (TotalFreedomMod.allPlayersFrozen)
{
@ -209,7 +254,8 @@ public class TFM_PlayerListener extends PlayerListener
if (playerdata.getMsgCount() > 10)
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
TFM_Util.autoEject(p, "No Spamming");
TFM_Util.autoEject(p, "Kicked for spamming chat.");
playerdata.resetMsgCount();
event.setCancelled(true);
@ -229,7 +275,8 @@ public class TFM_PlayerListener extends PlayerListener
if (playerdata.getMsgCount() > 10)
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
TFM_Util.autoEject(p, "No Spamming");
TFM_Util.autoEject(p, "Kicked for spamming commands.");
playerdata.resetMsgCount();
TFM_Util.wipeDropEntities(true);
@ -247,6 +294,7 @@ public class TFM_PlayerListener extends PlayerListener
boolean block_command = false;
//Commands that will auto-kick the user:
if (Pattern.compile("^/stop").matcher(command).find())
{
if (!TFM_Util.isUserSuperadmin(p, plugin))
@ -276,6 +324,7 @@ public class TFM_PlayerListener extends PlayerListener
}
else
{
//Commands that will not auto-kick the user, but still deny:
if (Pattern.compile("^/time").matcher(command).find())
{
p.sendMessage(ChatColor.GRAY + "Server-side time changing is disabled. Please use /ptime to set your own personal time.");
@ -310,7 +359,12 @@ public class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerKick(PlayerKickEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
Player p = event.getPlayer();
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(p))
{
TotalFreedomMod.fuckoffEnabledFor.remove(p);
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.disarmMP44();
if (playerdata.isCaged())
{
@ -322,7 +376,12 @@ public class TFM_PlayerListener extends PlayerListener
@Override
public void onPlayerQuit(PlayerQuitEvent event)
{
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(event.getPlayer());
Player p = event.getPlayer();
if (TotalFreedomMod.fuckoffEnabledFor.containsKey(p))
{
TotalFreedomMod.fuckoffEnabledFor.remove(p);
}
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.disarmMP44();
if (playerdata.isCaged())
{

View File

@ -18,7 +18,6 @@ public class TFM_UserInfo
private int block_place_total = 0;
private int freecam_destroy_count = 0;
private int freecam_place_count = 0;
private boolean forced_death = false;
private boolean user_caged = false;
private Location user_cage_pos;
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
@ -144,16 +143,6 @@ public class TFM_UserInfo
}
}
public boolean getForcedDeath()
{
return this.forced_death;
}
public void setForcedDeath(boolean forced_death)
{
this.forced_death = forced_death;
}
public boolean isFrozen()
{
return this.user_frozen;

View File

@ -38,20 +38,33 @@ public class TFM_Util
{
private static final Logger log = Logger.getLogger("Minecraft");
private static Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
private static final Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
private static final List<String> stop_commands = new ArrayList<String>();
public static final Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
public static final List<String> stop_commands = new ArrayList<String>();
static
{
mobtypes.put("chicken", CreatureType.CHICKEN);
mobtypes.put("cow", CreatureType.COW);
mobtypes.put("creeper", CreatureType.CREEPER);
mobtypes.put("ghast", CreatureType.GHAST);
mobtypes.put("giant", CreatureType.GIANT);
mobtypes.put("monster", CreatureType.MONSTER);
mobtypes.put("pig", CreatureType.PIG);
mobtypes.put("pigzombie", CreatureType.PIG_ZOMBIE);
mobtypes.put("sheep", CreatureType.SHEEP);
mobtypes.put("skeleton", CreatureType.SKELETON);
mobtypes.put("slime", CreatureType.SLIME);
mobtypes.put("spider", CreatureType.SPIDER);
mobtypes.put("squid", CreatureType.SQUID);
mobtypes.put("zombie", CreatureType.ZOMBIE);
mobtypes.put("wolf", CreatureType.WOLF);
mobtypes.put("cavespider", CreatureType.CAVE_SPIDER);
mobtypes.put("enderman", CreatureType.ENDERMAN);
mobtypes.put("silverfish", CreatureType.SILVERFISH);
mobtypes.put("enderdragon", CreatureType.ENDER_DRAGON);
mobtypes.put("villager", CreatureType.VILLAGER);
mobtypes.put("blaze", CreatureType.BLAZE);
mobtypes.put("mushroomcow", CreatureType.MUSHROOM_COW);
stop_commands.add("stop");
stop_commands.add("off");
@ -117,7 +130,7 @@ public class TFM_Util
if (sender_p.getWorld().getName().equalsIgnoreCase(targetworld))
{
sender.sendMessage(ChatColor.GRAY + "Going to main world.");
Bukkit.getServer().dispatchCommand(sender, "world 0");
sender_p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
return;
}
@ -126,10 +139,12 @@ public class TFM_Util
if (world.getName().equalsIgnoreCase(targetworld))
{
sender.sendMessage(ChatColor.GRAY + "Going to world: " + targetworld);
Bukkit.getServer().dispatchCommand(sender, "mv tp " + targetworld);
sender_p.teleport(world.getSpawnLocation());
return;
}
}
sender.sendMessage(ChatColor.GRAY + "World " + targetworld + " not found.");
}
else
{
@ -327,7 +342,7 @@ public class TFM_Util
fileloop:
for (String user : config.getKeys(false))
{
List<String> user_ips = config.getStringListFixed(user);
List<String> user_ips = (List<String>) config.getStringList(user);
for (String ip : user_ips)
{
ip = ip.toLowerCase().trim();
@ -395,9 +410,16 @@ public class TFM_Util
}
}
public static CreatureType getCreatureType(String mobname)
public static CreatureType getCreatureType(String mobname) throws Exception
{
return TFM_Util.mobtypes.get(mobname.toLowerCase().trim());
mobname = mobname.toLowerCase().trim();
if (!TFM_Util.mobtypes.containsKey(mobname))
{
throw new Exception();
}
return TFM_Util.mobtypes.get(mobname);
}
public static void zip(File directory, File zipfile, boolean verbose, CommandSender sender) throws IOException

View File

@ -3,7 +3,9 @@ package me.StevenLawson.TotalFreedomMod;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
@ -35,6 +37,7 @@ public class TotalFreedomMod extends JavaPlugin
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
public static boolean allPlayersFrozen = false;
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
@Override
public void onEnable()
@ -137,6 +140,10 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean mp44Enabled = false;
public static boolean mobLimiterEnabled = true;
public static int mobLimiterMax = 50;
public static boolean mobLimiterDisableDragon = true;
public static boolean mobLimiterDisableGhast = true;
public static boolean mobLimiterDisableSlime = true;
public static boolean mobLimiterDisableGiant = true;
public void loadMainConfig()
{
@ -163,6 +170,10 @@ public class TotalFreedomMod extends JavaPlugin
mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled);
mobLimiterEnabled = config.getBoolean("mob_limiter_enabled", mobLimiterEnabled);
mobLimiterMax = config.getInt("mob_limiter_max", mobLimiterMax);
mobLimiterDisableDragon = config.getBoolean("mob_limiter_disable_dragon", mobLimiterDisableDragon);
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant);
}
public static List<String> superadmins = new ArrayList<String>();
@ -180,7 +191,7 @@ public class TotalFreedomMod extends JavaPlugin
{
superadmins.add(user.toLowerCase().trim());
List<String> user_ips = config.getStringListFixed(user);
List<String> user_ips = (List<String>) config.getStringList(user);
for (String ip : user_ips)
{
ip = ip.toLowerCase().trim();

View File

@ -1,6 +1,6 @@
name: TotalFreedomMod
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
version: 2.2
version: 2.3
description: Plugin for the Total Freedom server.
author: StevenLawson / Madgeek1450
commands:
@ -43,6 +43,9 @@ commands:
fr:
description: Superadmin command - Freeze all players (toggles on and off).
usage: /<command>
fuckoff:
description: Lawl
usage: /<command>
gadmin:
description: Superadmin command - Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci
usage: /<command> [list | [<kick | nameban | ipban | ban | op | deop | ci> <targethash>] ]
@ -52,6 +55,9 @@ commands:
gtfo:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> <partialname>
kicknoob:
description: Superadmin command - Kick all non-superadmins on server.
usage: /<command>
landmine:
description: Set a landmine trap.
usage: /<command>
@ -64,7 +70,9 @@ commands:
list:
description: Lists the real names of all online players.
usage: /<command>
aliases: [listreal]
moblimiter:
description: Owner command - Controll mob rezzing parameters.
usage: /<command> <on|off|setmax <count>|dragon|giant|ghast|slime>
mp:
description: Purge all mobs in all worlds.
usage: /<command>
@ -110,12 +118,12 @@ commands:
say:
description: Broadcasts the given message as the console, includes sender name.
usage: /<command> <message>
skylands:
description: Goto the skylands.
setspawnworld:
description: Superadmin Command - Set world spawnpoint.
usage: /<command>
ender:
description: Goto the ender / "The End".
usage: /<command>
# stacker:
# description: Superadmin command - Stack people onto your head. For the lulz.
# usage: /<command> [end]
status:
description: Show misc. server info.
usage: /<command>
@ -134,12 +142,9 @@ commands:
tfipbanlist:
description: Shows all banned IPs. Superadmins may optionally use 'purge' to clear the list.
usage: /<command> [purge]
tfsmite:
description: De-op, inventory clear, de-godmode, lightning, and kill your target. For naughty people only (or the entire server).
usage: /<command> <playername | all>
tossmob:
description: Throw a mob in the direction you are facing when you left click with a stick.
usage: /<command> [mobtype | off] [speed]
usage: /<command> <mobtype [speed] | off | list>
waterplace:
description: Superadmin command - Enable/disable water placement.
usage: /<command> <on | off>