Updates for v1.2 compatibility.

This commit is contained in:
Steven Lawson 2012-03-02 23:29:54 -05:00
parent d60963cc7c
commit 6e2cbc8e9f
10 changed files with 131 additions and 89 deletions

View File

@ -38,12 +38,9 @@ tossmob_enabled: false
# Moblimiter:
mob_limiter_enabled: true
# Max per world:
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.
# The superadmin lists have been moved to superadmin.yml

View File

@ -22,6 +22,8 @@ public class Command_setexp extends TFM_Command
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
/*
if (args.length != 1)
{
@ -52,6 +54,11 @@ public class Command_setexp extends TFM_Command
sender_p.setExperience(exp_amount);
sender.sendMessage(ChatColor.AQUA + "Experience points set to: " + sender_p.getExperience());
*/
sender_p.setExp(1.0f);
sender.sendMessage(ChatColor.AQUA + "Level up!");
return true;
}

View File

@ -1,8 +1,6 @@
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;
@ -10,7 +8,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.CreatureType;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -33,7 +31,7 @@ public class Command_tossmob extends TFM_Command
{
TFM_UserInfo playerData = TFM_UserInfo.getPlayerData(sender_p);
CreatureType creature = CreatureType.PIG;
EntityType creature = EntityType.PIG;
if (args.length >= 1)
{
if (TFM_Util.isStopCommand(args[0]))
@ -46,7 +44,7 @@ public class Command_tossmob extends TFM_Command
if (args[0].equalsIgnoreCase("list"))
{
StringBuilder output = new StringBuilder("Supported mobs: ");
for (Entry<String, CreatureType> mob : TFM_Util.mobtypes.entrySet())
for (Entry<String, EntityType> mob : TFM_Util.mobtypes.entrySet())
{
output.append(mob.getKey()).append(", ");
}
@ -56,13 +54,13 @@ public class Command_tossmob extends TFM_Command
try
{
creature = TFM_Util.getCreatureType(args[0]);
creature = TFM_Util.getEntityType(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;
creature = EntityType.PIG;
}
}

View File

@ -8,10 +8,13 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.inventory.ItemStack;
public class TFM_BlockListener extends BlockListener
public class TFM_BlockListener implements Listener
{
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
@ -21,7 +24,7 @@ public class TFM_BlockListener extends BlockListener
this.plugin = instance;
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBurn(BlockBurnEvent event)
{
if (!TotalFreedomMod.allowFireSpread)
@ -31,7 +34,7 @@ public class TFM_BlockListener extends BlockListener
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onBlockIgnite(BlockIgniteEvent event)
{
if (!TotalFreedomMod.allowFirePlace)
@ -41,7 +44,7 @@ public class TFM_BlockListener extends BlockListener
}
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockBreak(BlockBreakEvent event)
{
if (TotalFreedomMod.nukeMonitor)
@ -91,7 +94,7 @@ public class TFM_BlockListener extends BlockListener
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event)
{
Player p = event.getPlayer();

View File

@ -1,13 +1,13 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
public class TFM_EntityListener extends EntityListener
public class TFM_EntityListener implements Listener
{
private TotalFreedomMod plugin;
@ -16,7 +16,7 @@ public class TFM_EntityListener extends EntityListener
this.plugin = instance;
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onEntityExplode(EntityExplodeEvent event)
{
if (!TotalFreedomMod.allowExplosions)
@ -28,7 +28,7 @@ public class TFM_EntityListener extends EntityListener
event.setYield(0.0f);
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if (!TotalFreedomMod.allowExplosions)
@ -40,7 +40,7 @@ public class TFM_EntityListener extends EntityListener
event.setRadius((float) TotalFreedomMod.explosiveRadius);
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onEntityCombust(EntityCombustEvent event)
{
if (!TotalFreedomMod.allowFireSpread)
@ -50,17 +50,23 @@ public class TFM_EntityListener extends EntityListener
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDamage(EntityDamageEvent event)
{
if (event.getCause() == DamageCause.LAVA && !TotalFreedomMod.allowLavaDamage)
switch (event.getCause())
{
event.setCancelled(true);
return;
case LAVA:
{
if (!TotalFreedomMod.allowLavaDamage)
{
event.setCancelled(true);
return;
}
}
}
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onCreatureSpawn(CreatureSpawnEvent event)
{
if (TotalFreedomMod.mobLimiterEnabled)
@ -104,14 +110,11 @@ public class TFM_EntityListener extends EntityListener
{
int mobcount = 0;
for (World world : Bukkit.getWorlds())
for (Entity ent : event.getLocation().getWorld().getLivingEntities())
{
for (Entity ent : world.getLivingEntities())
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
{
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
{
mobcount++;
}
mobcount++;
}
}

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@ -16,11 +17,14 @@ import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class TFM_PlayerListener extends PlayerListener
public class TFM_PlayerListener implements Listener
{
private TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft");
@ -30,11 +34,11 @@ public class TFM_PlayerListener extends PlayerListener
this.plugin = instance;
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
{
Player player = event.getPlayer();
switch (event.getAction())
{
case RIGHT_CLICK_AIR:
@ -106,26 +110,26 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove(PlayerMoveEvent event)
{
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
{
@ -135,7 +139,7 @@ public class TFM_PlayerListener extends PlayerListener
{
continue;
}
if (distance < fuckoff_range)
{
event.setTo(fuckoff_pos.clone().add(mover_pos.subtract(fuckoff_pos).toVector().normalize().multiply(fuckoff_range * 1.1)));
@ -243,7 +247,7 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChat(PlayerChatEvent event)
{
Player p = event.getPlayer();
@ -255,15 +259,33 @@ public class TFM_PlayerListener extends PlayerListener
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
TFM_Util.autoEject(p, "Kicked for spamming chat.");
playerdata.resetMsgCount();
event.setCancelled(true);
return;
}
if (Pattern.compile("^mad(?:geek)?(?:1450)?[\\?\\.\\!]?$").matcher(event.getMessage().toLowerCase()).find())
{
List<Player> matches = Bukkit.matchPlayer("Madgeek1450");
if (!matches.isEmpty())
{
//TFM_Util.bcastMsg("<" + matches.get(0).getDisplayName() + "> Bitch says Madgeek...");
p.setGameMode(GameMode.SURVIVAL);
p.setFoodLevel(0);
p.setHealth(1);
TNTPrimed tnt1 = p.getWorld().spawn(p.getLocation(), TNTPrimed.class);
tnt1.setFuseTicks(40);
tnt1.setPassenger(p);
tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
}
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
String command = event.getMessage();
@ -276,7 +298,7 @@ public class TFM_PlayerListener extends PlayerListener
{
TFM_Util.bcastMsg(p.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
TFM_Util.autoEject(p, "Kicked for spamming commands.");
playerdata.resetMsgCount();
TFM_Util.wipeDropEntities(true);
@ -340,7 +362,7 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
if (TotalFreedomMod.autoEntityWipe)
@ -356,7 +378,7 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event)
{
Player p = event.getPlayer();
@ -373,7 +395,7 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
Player p = event.getPlayer();
@ -390,7 +412,7 @@ public class TFM_PlayerListener extends PlayerListener
}
}
@Override
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
try

View File

@ -1,9 +1,12 @@
package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.weather.*;
public class TFM_WeatherListener extends WeatherListener
public class TFM_WeatherListener implements Listener
{
private TotalFreedomMod plugin;
@ -12,7 +15,7 @@ public class TFM_WeatherListener extends WeatherListener
this.plugin = instance;
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onThunderChange(ThunderChangeEvent event)
{
if (event.toThunderState() && TotalFreedomMod.disableWeather)
@ -22,7 +25,7 @@ public class TFM_WeatherListener extends WeatherListener
}
}
@Override
@EventHandler(priority = EventPriority.HIGH)
public void onWeatherChange(WeatherChangeEvent event)
{
if (event.toWeatherState() && TotalFreedomMod.disableWeather)

View File

@ -26,7 +26,7 @@ public class TFM_UserInfo
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 EntityType mob_thrower_creature = EntityType.PIG;
private double mob_thrower_speed = 4.0;
private List<LivingEntity> mob_thrower_queue = new ArrayList<LivingEntity>();
private int mp44_schedule_id = -1;
@ -228,7 +228,7 @@ public class TFM_UserInfo
this.freecam_place_count = 0;
}
public void enableMobThrower(CreatureType mob_thrower_creature, double mob_thrower_speed)
public void enableMobThrower(EntityType mob_thrower_creature, double mob_thrower_speed)
{
this.mob_thrower_enabled = true;
this.mob_thrower_creature = mob_thrower_creature;
@ -240,7 +240,7 @@ public class TFM_UserInfo
this.mob_thrower_enabled = false;
}
public CreatureType mobThrowerCreature()
public EntityType mobThrowerCreature()
{
return this.mob_thrower_creature;
}

View File

@ -38,33 +38,32 @@ public class TFM_Util
{
private static final Logger log = Logger.getLogger("Minecraft");
private static Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
public static final Map<String, CreatureType> mobtypes = new HashMap<String, CreatureType>();
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
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);
mobtypes.put("chicken", EntityType.CHICKEN);
mobtypes.put("cow", EntityType.COW);
mobtypes.put("creeper", EntityType.CREEPER);
mobtypes.put("ghast", EntityType.GHAST);
mobtypes.put("giant", EntityType.GIANT);
mobtypes.put("pig", EntityType.PIG);
mobtypes.put("pigzombie", EntityType.PIG_ZOMBIE);
mobtypes.put("sheep", EntityType.SHEEP);
mobtypes.put("skeleton", EntityType.SKELETON);
mobtypes.put("slime", EntityType.SLIME);
mobtypes.put("spider", EntityType.SPIDER);
mobtypes.put("squid", EntityType.SQUID);
mobtypes.put("zombie", EntityType.ZOMBIE);
mobtypes.put("wolf", EntityType.WOLF);
mobtypes.put("cavespider", EntityType.CAVE_SPIDER);
mobtypes.put("enderman", EntityType.ENDERMAN);
mobtypes.put("silverfish", EntityType.SILVERFISH);
mobtypes.put("enderdragon", EntityType.ENDER_DRAGON);
mobtypes.put("villager", EntityType.VILLAGER);
mobtypes.put("blaze", EntityType.BLAZE);
mobtypes.put("mushroomcow", EntityType.MUSHROOM_COW);
stop_commands.add("stop");
stop_commands.add("off");
@ -410,7 +409,7 @@ public class TFM_Util
}
}
public static CreatureType getCreatureType(String mobname) throws Exception
public static EntityType getEntityType(String mobname) throws Exception
{
mobname = mobname.toLowerCase().trim();
@ -552,30 +551,34 @@ public class TFM_Util
{
player_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
Integer num_kicks = eject_tracker.get(player_ip);
Integer num_kicks = TFM_Util.eject_tracker.get(player_ip);
if (num_kicks == null)
{
num_kicks = new Integer(0);
}
num_kicks = new Integer(num_kicks.intValue() + 1);
TFM_Util.eject_tracker.put(player_ip, num_kicks);
if (num_kicks <= 1)
if (num_kicks.intValue() <= 1)
{
method = EjectMethod.STRIKE_ONE;
}
else if (num_kicks == 2)
else if (num_kicks.intValue() == 2)
{
method = EjectMethod.STRIKE_TWO;
}
else if (num_kicks >= 3)
else if (num_kicks.intValue() >= 3)
{
method = EjectMethod.STRIKE_THREE;
}
}
catch (Throwable ex)
catch (Exception ex)
{
}
log.info("autoEject -> name: " + p.getName() + " - player_ip: " + player_ip + " - method: " + method.toString());
p.setOp(false);
p.setGameMode(GameMode.SURVIVAL);

View File

@ -17,7 +17,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -213,7 +212,8 @@ public class TotalFreedomMod extends JavaPlugin
private void registerEventHandlers()
{
PluginManager pm = this.getServer().getPluginManager();
/*
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.High, this);
@ -236,5 +236,11 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this);
*/
pm.registerEvents(entityListener, this);
pm.registerEvents(blockListener, this);
pm.registerEvents(playerListener, this);
pm.registerEvents(weatherListener, this);
}
}