mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Fixed explosion radius.
Added /mp - mob purge.
This commit is contained in:
parent
c769f98c8a
commit
bb2e32519b
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -23,13 +24,16 @@ 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>();
|
||||
public Boolean allowExplosions = false;
|
||||
public Boolean allowLavaDamage = false;
|
||||
public Boolean allowFire = false;
|
||||
public double explosiveRadius = 2.0;
|
||||
public double explosiveRadius = 4.0;
|
||||
|
||||
public final static String MSG_NO_PERMS = ChatColor.YELLOW + "You do not have permission to use this command.";
|
||||
public final static String YOU_ARE_OP = ChatColor.YELLOW + "You are now op!";
|
||||
public final static String YOU_ARE_NOT_OP = ChatColor.YELLOW + "You are no longer op!";
|
||||
@ -37,8 +41,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public void onEnable()
|
||||
{
|
||||
CONFIG = getConfiguration();
|
||||
CONFIG.load();
|
||||
if (CONFIG.getString("superadmins", null) == null) //Generate config file:
|
||||
File configfile = new File("plugins/TotalFreedomMod/config.yml");
|
||||
if (!configfile.exists())
|
||||
{
|
||||
log.log(Level.INFO, "[Total Freedom Mod] - Generating default config file (plugins/TotalFreedomMod/config.yml)...");
|
||||
CONFIG.setProperty("superadmins", new String[]
|
||||
@ -48,23 +52,24 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
CONFIG.setProperty("allow_explosions", false);
|
||||
CONFIG.setProperty("allow_lava_damage", false);
|
||||
CONFIG.setProperty("allow_fire", false);
|
||||
CONFIG.setProperty("explosiveRadius", 2.0);
|
||||
CONFIG.setProperty("explosiveRadius", 4.0);
|
||||
CONFIG.save();
|
||||
CONFIG.load();
|
||||
}
|
||||
CONFIG.load();
|
||||
superadmins = CONFIG.getStringList("superadmins", null);
|
||||
allowExplosions = CONFIG.getBoolean("allow_explosions", false);
|
||||
allowLavaDamage = CONFIG.getBoolean("allow_lava_damage", false);
|
||||
allowFire = CONFIG.getBoolean("allow_fire", false);
|
||||
explosiveRadius = CONFIG.getDouble("explosiveRadius", 2.0);
|
||||
explosiveRadius = CONFIG.getDouble("explosiveRadius", 4.0);
|
||||
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Event.Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.Highest, this);
|
||||
pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.Highest, this);
|
||||
//pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Event.Priority.Highest, this);
|
||||
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.EXPLOSION_PRIME, 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);
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, 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));
|
||||
@ -627,7 +632,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
break;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d blocks away @ ", i.player.getName(), Math.round(i.distance), formatLocation(i.location)));
|
||||
sender.sendMessage(ChatColor.YELLOW + String.format("%s - %d blocks away @ %s.", i.player.getName(), Math.round(i.distance), formatLocation(i.location)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -655,6 +660,27 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (cmd.getName().equalsIgnoreCase("mp"))
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
sender.sendMessage("This command can only be used in-game.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Using MobLimiter to purge all mobs.");
|
||||
|
||||
Bukkit.getServer().dispatchCommand(sender, "moblimiter purge");
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(MSG_NO_PERMS);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1,17 +1,19 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
//import org.bukkit.ChatColor;
|
||||
//import org.bukkit.Material;
|
||||
//import org.bukkit.entity.Player;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
//import org.bukkit.event.block.BlockPlaceEvent;
|
||||
//import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class TotalFreedomModBlockListener extends BlockListener
|
||||
{
|
||||
public static TotalFreedomMod plugin;
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
TotalFreedomModBlockListener(TotalFreedomMod instance)
|
||||
{
|
||||
@ -38,43 +40,41 @@ public class TotalFreedomModBlockListener extends BlockListener
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void onBlockPlace(BlockPlaceEvent event)
|
||||
// {
|
||||
// ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
|
||||
// if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA || is.getType() == Material.LAVA_BUCKET)
|
||||
// {
|
||||
// Player p = event.getPlayer();
|
||||
//
|
||||
// plugin.tfBroadcastMessage(String.format("%s placed lava @ %s",
|
||||
// p.getName(),
|
||||
// plugin.formatLocation(p.getLocation())
|
||||
// ), ChatColor.GRAY);
|
||||
// }
|
||||
// else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER || is.getType() == Material.WATER_BUCKET)
|
||||
// {
|
||||
// Player p = event.getPlayer();
|
||||
//
|
||||
// plugin.tfBroadcastMessage(String.format("%s placed water @ %s",
|
||||
// p.getName(),
|
||||
// plugin.formatLocation(p.getLocation())
|
||||
// ), ChatColor.GRAY);
|
||||
// }
|
||||
// else if (is.getType() == Material.TNT)
|
||||
// {
|
||||
// Player p = event.getPlayer();
|
||||
//
|
||||
// plugin.tfBroadcastMessage(String.format("%s placed TNT @ %s",
|
||||
// p.getName(),
|
||||
// plugin.formatLocation(p.getLocation())
|
||||
// ), ChatColor.GRAY);
|
||||
//
|
||||
// if (!plugin.allowExplosions)
|
||||
// {
|
||||
// p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short) 0, event.getBlockPlaced().getData());
|
||||
if (is.getType() == Material.LAVA || is.getType() == Material.STATIONARY_LAVA)
|
||||
{
|
||||
log.info(String.format("%s placed lava @ %s",
|
||||
event.getPlayer().getName(),
|
||||
plugin.formatLocation(event.getBlock().getLocation())
|
||||
));
|
||||
}
|
||||
else if (is.getType() == Material.WATER || is.getType() == Material.STATIONARY_WATER)
|
||||
{
|
||||
log.info(String.format("%s placed water @ %s",
|
||||
event.getPlayer().getName(),
|
||||
plugin.formatLocation(event.getBlock().getLocation())
|
||||
));
|
||||
}
|
||||
else if (is.getType() == Material.TNT)
|
||||
{
|
||||
Player p = event.getPlayer();
|
||||
|
||||
if (!plugin.allowExplosions)
|
||||
{
|
||||
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.info(String.format("%s placed TNT @ %s",
|
||||
p.getName(),
|
||||
plugin.formatLocation(event.getBlock().getLocation())
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
|
||||
public class TotalFreedomModEntityListener extends EntityListener
|
||||
{
|
||||
@ -23,8 +24,18 @@ public class TotalFreedomModEntityListener extends EntityListener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.setYield((float)plugin.explosiveRadius);
|
||||
@Override
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (!plugin.allowExplosions)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setRadius((float)plugin.explosiveRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: TotalFreedomMod
|
||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||
version: 1.2.0
|
||||
version: 1.3
|
||||
description: Plugin for the Total Freedom server
|
||||
author: StevenLawson / Madgeek1450
|
||||
commands:
|
||||
@ -11,7 +11,7 @@ commands:
|
||||
description: Superadmin command - Deop everyone on the server.
|
||||
usage: /<command>
|
||||
explosives:
|
||||
description: Superadmin command - Enable/disable explosives and set yield radius.
|
||||
description: Superadmin command - Enable/disable explosives and set effect radius.
|
||||
usage: /<command> <on|off> [radius]
|
||||
fire:
|
||||
description: Superadmin command - Enable/disable fire.
|
||||
@ -28,9 +28,12 @@ commands:
|
||||
listreal:
|
||||
description: Lists the real names of all online players.
|
||||
usage: /<command>
|
||||
opall:
|
||||
description: Superadmin command - Op everyone on the server.
|
||||
mp:
|
||||
description: Use moblimiter to purge all mobs.
|
||||
usage: /<command>
|
||||
opall:
|
||||
description: Superadmin command - Op everyone on the server, optionally change everyone's gamemode at the same time.
|
||||
usage: /<command> [-c|-s]
|
||||
opme:
|
||||
description: Superadmin command - Automatically ops user.
|
||||
usage: /<command>
|
||||
@ -44,7 +47,7 @@ commands:
|
||||
description: Shows nearby people sorted by distance.
|
||||
usage: /<command>
|
||||
rd:
|
||||
description: Removes drops, arrows, etc.
|
||||
description: Use WorldEdit to remove drops, arrows, and primed TNT.
|
||||
usage: /<command>
|
||||
say:
|
||||
description: Broadcasts the given message as the console, includes sender.
|
||||
|
Loading…
Reference in New Issue
Block a user