No Message

This commit is contained in:
Steven Lawson 2011-09-25 19:00:14 -04:00
parent c7427f492f
commit 18ddcc7560
4 changed files with 660 additions and 568 deletions

View file

@ -29,6 +29,7 @@ public class TotalFreedomMod extends JavaPlugin
public Boolean allowExplosions = false;
public Boolean allowLavaDamage = false;
public Boolean allowFire = false;
public double explosiveRadius = 1.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!";
@ -47,6 +48,7 @@ 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.save();
CONFIG.load();
}
@ -54,13 +56,15 @@ public class TotalFreedomMod extends JavaPlugin
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);
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);
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);
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));
@ -501,14 +505,20 @@ public class TotalFreedomMod extends JavaPlugin
{
if (player == null || isUserSuperadmin(sender.getName()))
{
if (args.length != 1)
if (args.length == 0)
{
return false;
}
if (args.length == 2)
{
explosiveRadius = Double.parseDouble(args[1]);
}
if (args[0].equalsIgnoreCase("on"))
{
this.allowExplosions = true;
//sender.sendMessage("Explosives are now enabled, radius set to " + explosiveRadius + " blocks.");
sender.sendMessage("Explosives are now enabled.");
}
else
@ -594,7 +604,7 @@ public class TotalFreedomMod extends JavaPlugin
for (Player p : Bukkit.getOnlinePlayers())
{
if (sender_world.equals(p.getWorld().getName()))
if (sender_world.equals(p.getWorld().getName()) && !p.getName().equals(sender.getName()))
{
radar_data.add(new RadarData(p, sender_pos.distance(p.getLocation())));
}
@ -623,11 +633,34 @@ public class TotalFreedomMod extends JavaPlugin
return true;
}
else if (cmd.getName().equalsIgnoreCase("rd"))
{
if (player == null)
{
sender.sendMessage("This command can only be used in-game.");
return true;
}
if (sender.isOp())
{
sender.sendMessage(ChatColor.GRAY + "Using WorldEdit to remove all entity drops.");
Bukkit.getServer().dispatchCommand(sender, "remove arrows -1");
Bukkit.getServer().dispatchCommand(sender, "remove items -1");
Bukkit.getServer().dispatchCommand(sender, "remove drops -1");
}
else
{
sender.sendMessage(MSG_NO_PERMS);
}
return true;
}
return false;
}
public static void tfBroadcastMessage(String message, ChatColor color)
public void tfBroadcastMessage(String message, ChatColor color)
{
log.info(message);
@ -637,7 +670,7 @@ public class TotalFreedomMod extends JavaPlugin
}
}
private static String implodeStringList(String glue, List<String> pieces)
public String implodeStringList(String glue, List<String> pieces)
{
StringBuilder output = new StringBuilder();
for (int i = 0; i < pieces.size(); i++)
@ -651,7 +684,16 @@ public class TotalFreedomMod extends JavaPlugin
return output.toString();
}
private boolean isUserSuperadmin(String userName)
public String formatLocation(Location in_loc)
{
return String.format("%s: (%d, %d, %d)",
in_loc.getWorld().getName(),
Math.round(in_loc.getX()),
Math.round(in_loc.getY()),
Math.round(in_loc.getZ()));
}
public boolean isUserSuperadmin(String userName)
{
return superadmins.contains(userName);
}

View file

@ -1,8 +1,13 @@
package me.StevenLawson.TotalFreedomMod;
//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;
public class TotalFreedomModBlockListener extends BlockListener
{
@ -32,4 +37,44 @@ public class TotalFreedomModBlockListener extends BlockListener
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 || 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;
// }
// }
// }
}

View file

@ -23,6 +23,8 @@ public class TotalFreedomModEntityListener extends EntityListener
event.setCancelled(true);
return;
}
//event.setYield((float)plugin.explosiveRadius);
}
@Override

View file

@ -11,17 +11,17 @@ commands:
description: Superadmin command - Deop everyone on the server.
usage: /<command>
explosives:
description: Superadmin command - Enable/disable explosives.
usage: /<command> [on|off]
description: Superadmin command - Enable/disable explosives and set yield radius.
usage: /<command> <on|off> [radius]
fire:
description: Superadmin command - Enable/disable fire.
usage: /<command> [on|off]
usage: /<command> <on|off>
gtfo:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> [partialname]
lavadmg:
description: Superadmin command - Enable/disable lava damage.
usage: /<command> [on|off]
usage: /<command> <on|off>
list:
description: Lists the real names of all online players.
usage: /<command>
@ -43,6 +43,9 @@ commands:
radar:
description: Shows nearby people sorted by distance.
usage: /<command>
rd:
description: Removes drops, arrows, etc.
usage: /<command>
say:
description: Broadcasts the given message as the console, includes sender.
usage: /<command> <message>