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

This commit is contained in:
Steven Lawson 2011-11-21 01:47:51 -05:00
commit 1adfb29409
6 changed files with 121 additions and 4 deletions

View File

@ -35,6 +35,10 @@ disable_weather: true
landmines_enabled: false landmines_enabled: false
mp44_enabled: false mp44_enabled: false
# Moblimiter:
mob_limiter_enabled: true
mob_limiter_max: 50
# Superadmins: Users that can always log in and use the most powerful commands: # Superadmins: Users that can always log in and use the most powerful commands:
# When online-mode = false, only superadmin_ips will be used. # When online-mode = false, only superadmin_ips will be used.
# The superadmin lists have been moved to superadmin.yml # The superadmin lists have been moved to superadmin.yml

View File

@ -0,0 +1,62 @@
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.ExperienceOrb;
import org.bukkit.entity.Player;
public class Command_addexp 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 (!sender.isOp())
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (args.length != 1)
{
return false;
}
int exp_amount;
try
{
exp_amount = Integer.parseInt(args[0]);
if (exp_amount < 0)
{
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount (MUST BE POSITIVE).");
return true;
}
else if (exp_amount > 2000)
{
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount (MAX = 2000).");
return true;
}
}
catch (NumberFormatException ex)
{
sender.sendMessage(ChatColor.AQUA + "Invalid exp amount.");
return true;
}
ExperienceOrb exp_orb = sender_p.getWorld().spawn(sender_p.getLocation(), ExperienceOrb.class);
exp_orb.setExperience(exp_amount);
sender.sendMessage(ChatColor.AQUA + String.valueOf(exp_amount) + " exp added.");
return true;
}
}

View File

@ -20,9 +20,9 @@ public class Command_mp extends TFM_Command
int removed = 0; int removed = 0;
for (World world : Bukkit.getWorlds()) for (World world : Bukkit.getWorlds())
{ {
for (Entity ent : world.getEntities()) for (Entity ent : world.getLivingEntities())
{ {
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime) if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
{ {
ent.remove(); ent.remove();
removed++; removed++;

View File

@ -1,8 +1,16 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; 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.Player;
import org.bukkit.entity.Slime;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
@ -76,4 +84,39 @@ public class TFM_EntityListener extends EntityListener
return; return;
} }
} }
@Override
public void onCreatureSpawn(CreatureSpawnEvent event)
{
if (TotalFreedomMod.mobLimiterEnabled)
{
if (event.getEntity() instanceof Ghast || event.getEntity() instanceof Slime || event.getEntity() instanceof EnderDragon)
{
event.setCancelled(true);
return;
}
if (TotalFreedomMod.mobLimiterMax > 0)
{
int mobcount = 0;
for (World world : Bukkit.getWorlds())
{
for (Entity ent : world.getLivingEntities())
{
if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon)
{
mobcount++;
}
}
}
if (mobcount > TotalFreedomMod.mobLimiterMax)
{
event.setCancelled(true);
return;
}
}
}
}
} }

View File

@ -135,6 +135,8 @@ public class TotalFreedomMod extends JavaPlugin
public static Boolean disableWeather = true; public static Boolean disableWeather = true;
public static boolean landminesEnabled = false; public static boolean landminesEnabled = false;
public static boolean mp44Enabled = false; public static boolean mp44Enabled = false;
public static boolean mobLimiterEnabled = true;
public static int mobLimiterMax = 50;
public void loadMainConfig() public void loadMainConfig()
{ {
@ -159,6 +161,8 @@ public class TotalFreedomMod extends JavaPlugin
disableWeather = config.getBoolean("disable_weather", disableWeather); disableWeather = config.getBoolean("disable_weather", disableWeather);
landminesEnabled = config.getBoolean("landmines_enabled", landminesEnabled); landminesEnabled = config.getBoolean("landmines_enabled", landminesEnabled);
mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled); mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled);
mobLimiterEnabled = config.getBoolean("mob_limiter_enabled", mobLimiterEnabled);
mobLimiterMax = config.getInt("mob_limiter_max", mobLimiterMax);
} }
public static List<String> superadmins = new ArrayList<String>(); public static List<String> superadmins = new ArrayList<String>();
@ -201,6 +205,7 @@ public class TotalFreedomMod extends JavaPlugin
pm.registerEvent(Event.Type.ENTITY_COMBUST, 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); pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.EXPLOSION_PRIME, entityListener, Event.Priority.High, this); pm.registerEvent(Event.Type.EXPLOSION_PRIME, entityListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.High, this); pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.High, this); pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.High, this);

View File

@ -4,6 +4,9 @@ version: 2.2
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
author: StevenLawson / Madgeek1450 author: StevenLawson / Madgeek1450
commands: commands:
addexp:
description: Add levels to your survival level.
usage: /<command> [level]
cage: cage:
description: Superadmin command - Place a cage around someone. description: Superadmin command - Place a cage around someone.
usage: /<command> <partialname> [off | outermaterial] [water | lava] usage: /<command> <partialname> [off | outermaterial] [water | lava]