Added more anti-grief tools.

This commit is contained in:
Steven Lawson 2011-09-23 11:45:34 -04:00
parent d72211c289
commit e16a909668
5 changed files with 93 additions and 4 deletions

View File

@ -25,7 +25,7 @@ dist.dir=dist
dist.jar=${dist.dir}/TotalFreedomMod.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\Users\\Steven\\Documents\\NetBeansProjects\\bukkit-0.0.1-SNAPSHOT.jar
file.reference.bukkit-0.0.1-SNAPSHOT.jar=C:\\Documents and Settings\\Steven\\github\\bukkit-0.0.1-SNAPSHOT.jar
includes=**
jar.compress=false
javac.classpath=\

View File

@ -18,29 +18,43 @@ import org.bukkit.util.config.Configuration;
public class TotalFreedomMod extends JavaPlugin
{
private final TotalFreedomModEntityListener entityListener = new TotalFreedomModEntityListener(this);
private final TotalFreedomModBlockListener blockListener = new TotalFreedomModBlockListener(this);
//private final TotalFreedomModPlayerListener playerListener = new TotalFreedomModPlayerListener(this);
private static final Logger log = Logger.getLogger("Minecraft");
protected static Configuration CONFIG;
private List<String> superadmins = new ArrayList<String>();
private final TotalFreedomModEntityListener entityListener = new TotalFreedomModEntityListener(this);
public Boolean allowExplosions = false;
public Boolean allowLavaDamage = false;
public Boolean allowFireDamage = false;
public void onEnable()
{
CONFIG = getConfiguration();
CONFIG.load();
if (CONFIG.getString("superadmins", null) == null)
if (CONFIG.getString("superadmins", null) == null) //Generate config file:
{
log.log(Level.INFO, "[Total Freedom Mod] - Generating default config file (plugins/TotalFreedomMod/config.yml)...");
CONFIG.setProperty("superadmins", new String[] {"Madgeek1450", "markbyron"});
CONFIG.setProperty("allow_explosions", false);
CONFIG.setProperty("allow_lava_damage", false);
CONFIG.setProperty("allow_fire", false);
CONFIG.save();
CONFIG.load();
}
superadmins = CONFIG.getStringList("superadmins", null);
allowExplosions = CONFIG.getBoolean("allow_explosions", false);
allowLavaDamage = CONFIG.getBoolean("allow_lava_damage", false);
allowFireDamage = CONFIG.getBoolean("allow_fire", false);
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);
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.High, this);
log.log(Level.INFO, "[Total Freedom Mod] - Enabled! - Version: " + this.getDescription().getVersion() + " by Madgeek1450");
log.log(Level.INFO, "[Total Freedom Mod] - Loaded superadmins: " + implodeStringList(", ", superadmins));

View File

@ -0,0 +1,35 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockListener;
public class TotalFreedomModBlockListener extends BlockListener
{
public static TotalFreedomMod plugin;
TotalFreedomModBlockListener(TotalFreedomMod instance)
{
plugin = instance;
}
@Override
public void onBlockBurn(BlockBurnEvent event)
{
if (!plugin.allowFireDamage)
{
event.setCancelled(true);
return;
}
}
@Override
public void onBlockIgnite(BlockIgniteEvent event)
{
if (!plugin.allowFireDamage)
{
event.setCancelled(true);
return;
}
}
}

View File

@ -1,5 +1,8 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener;
@ -15,6 +18,30 @@ public class TotalFreedomModEntityListener extends EntityListener
@Override
public void onEntityExplode(EntityExplodeEvent event)
{
event.setCancelled(!plugin.allowExplosions);
if (!plugin.allowExplosions)
{
event.setCancelled(true);
return;
}
}
@Override
public void onEntityCombust(EntityCombustEvent event)
{
if (!plugin.allowFireDamage)
{
event.setCancelled(true);
return;
}
}
@Override
public void onEntityDamage(EntityDamageEvent event)
{
if (event.getCause() == DamageCause.LAVA && !plugin.allowLavaDamage)
{
event.setCancelled(true);
return;
}
}
}

View File

@ -0,0 +1,13 @@
package me.StevenLawson.TotalFreedomMod;
import org.bukkit.event.player.PlayerListener;
class TotalFreedomModPlayerListener extends PlayerListener
{
public static TotalFreedomMod plugin;
TotalFreedomModPlayerListener(TotalFreedomMod instance)
{
plugin = instance;
}
}