Added: gadmin

Changed: lava cookiefication
This commit is contained in:
Steven Lawson 2011-09-28 13:42:21 -04:00
parent a730e9f67f
commit 0f6a1d6687
5 changed files with 177 additions and 42 deletions

View File

@ -25,9 +25,7 @@ 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 List<String> superadmin_ips = new ArrayList<String>();
@ -36,7 +34,6 @@ public class TotalFreedomMod extends JavaPlugin
public Boolean allowFire = false;
public double explosiveRadius = 4.0;
public Boolean preprocessLogEnabled = false;
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!";
@ -753,6 +750,92 @@ public class TotalFreedomMod extends JavaPlugin
return true;
}
else if (cmd.getName().equalsIgnoreCase("gadmin"))
{
if (args.length == 0)
{
return false;
}
String mode = args[0].toLowerCase();
if (player == null || isUserSuperadmin(sender))
{
if (mode.equals("list"))
{
sender.sendMessage(ChatColor.GOLD + "[Real Name]:[Display Name] - Hash:");
}
for (Player p : Bukkit.getOnlinePlayers())
{
String hash = p.getUniqueId().toString().substring(0, 4);
if (mode.equals("list"))
{
sender.sendMessage(ChatColor.GOLD + String.format("[%s]:[%s] - %s",
p.getName(),
ChatColor.stripColor(p.getDisplayName()),
hash));
}
else if (hash.equalsIgnoreCase(args[1]))
{
if (mode.equals("kick"))
{
p.kickPlayer("Kicked by Administrator");
}
else if (mode.equals("nameban"))
{
Bukkit.getOfflinePlayer(p.getName()).setBanned(true);
tfBroadcastMessage(String.format("Banning Name: %s.", p.getName()), ChatColor.RED);
p.kickPlayer("Username banned by Administrator.");
}
else if (mode.equals("ipban"))
{
String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
tfBroadcastMessage(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED);
Bukkit.banIP(user_ip);
p.kickPlayer("IP address banned by Administrator.");
}
else if (mode.equals("ban"))
{
String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
tfBroadcastMessage(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
Bukkit.banIP(user_ip);
Bukkit.getOfflinePlayer(p.getName()).setBanned(true);
p.kickPlayer("IP and username banned by Administrator.");
}
else if (mode.equals("op"))
{
tfBroadcastMessage(String.format("(%s: Opping %s)", sender.getName(), p.getName()), ChatColor.GRAY);
p.setOp(false);
p.sendMessage(YOU_ARE_OP);
}
else if (mode.equals("deop"))
{
tfBroadcastMessage(String.format("(%s: De-opping %s)", sender.getName(), p.getName()), ChatColor.GRAY);
p.setOp(false);
p.sendMessage(YOU_ARE_NOT_OP);
}
else if (mode.equals("ci"))
{
p.getInventory().clear();
}
return true;
}
}
if (!mode.equals("list"))
{
sender.sendMessage(ChatColor.RED + "Invalid hash.");
}
}
else
{
sender.sendMessage(MSG_NO_PERMS);
}
return true;
}
else if (cmd.getName().equalsIgnoreCase("status"))
{
sender.sendMessage(ChatColor.GRAY + "Server is currently running with 'online-mode=" + (Bukkit.getOnlineMode() ? "true" : "false") + "'.");

View File

@ -43,23 +43,32 @@ public class TotalFreedomModBlockListener extends BlockListener
@Override
public void onBlockPlace(BlockPlaceEvent event)
{
log.info("Got onBlockPlace by " + event.getPlayer().getName());
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())));
Player player = event.getPlayer();
event.getItemInHand().setType(Material.COOKIE);
event.getItemInHand().setAmount(1);
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
player.sendMessage(ChatColor.GOLD + "LAVA NO FUN, YOU EAT COOKIE INSTEAD, NO?");
event.setCancelled(true);
return;
}
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())));
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
player.sendMessage(ChatColor.GOLD + "Does this look like a waterpark to you?");
event.setCancelled(true);
return;
}
else if (is.getType() == Material.TNT)
{
@ -67,7 +76,14 @@ public class TotalFreedomModBlockListener extends BlockListener
if (!plugin.allowExplosions)
{
p.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
event.setCancelled(true);
return;
}

View File

@ -8,6 +8,7 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
class TotalFreedomModPlayerListener extends PlayerListener
{
@ -26,20 +27,29 @@ class TotalFreedomModPlayerListener extends PlayerListener
{
if (event.getMaterial() == Material.WATER_BUCKET)
{
log.info(String.format("%s placed water @ %s",
event.getPlayer().getName(),
plugin.formatLocation(event.getClickedBlock().getLocation())));
Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
player.sendMessage(ChatColor.GOLD + "Does this look like a waterpark to you?");
event.setCancelled(true);
return;
}
else if (event.getMaterial() == Material.LAVA_BUCKET)
{
log.info(String.format("%s tried to placed lava @ %s",
event.getPlayer().getName(),
plugin.formatLocation(event.getClickedBlock().getLocation())));
Player player = event.getPlayer();
event.getPlayer().getItemInHand().setType(Material.COOKIE);
event.getPlayer().getItemInHand().setAmount(1);
int slot = player.getInventory().getHeldItemSlot();
ItemStack heldItem = new ItemStack(Material.COOKIE, 1);
player.getInventory().setItem(slot, heldItem);
player.sendMessage(ChatColor.GOLD + "LAVA NO FUN, YOU EAT COOKIE INSTEAD, NO?");
event.setCancelled(true);
return;
}
}
}
@ -55,15 +65,38 @@ class TotalFreedomModPlayerListener extends PlayerListener
log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command));
}
if (command.startsWith("/stop") && !command.equals("/stop"))
command = command.toLowerCase();
boolean block_command = false;
if (command.matches("^/stop"))
{
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "Piss off.");
}
else if (command.startsWith("/zeus") || command.startsWith("/vulcan"))
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/reload"))
{
if (!plugin.isUserSuperadmin(player))
{
block_command = true;
}
}
else if (command.matches("^/zeus"))
{
block_command = true;
}
else if (command.matches("^/vulcan"))
{
block_command = true;
}
if (block_command)
{
player.sendMessage(ChatColor.RED + "That command is prohibited.");
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "Piss off.");
return;
}
}
}

View File

@ -16,6 +16,9 @@ commands:
fire:
description: Superadmin command - Enable/disable fire.
usage: /<command> <on|off>
gadmin:
description: Superadmin command - Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci
usage: /<command> [list | <kick|nameban|ipban|ban|op|deop|ci> <targethash>]
gtfo:
description: Superadmin command - Makes someone GTFO (deop and ip ban by username).
usage: /<command> [partialname]
@ -59,7 +62,7 @@ commands:
description: Show random server info.
usage: /<command>
stop:
description: Kicks everyone and stops the server.
description: Superadmin command - Kicks everyone and stops the server.
usage: /<command>
survival:
description: Quickly change your own gamemode to survival, or define someone's username to change theirs.