mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-27 20:27:37 +00:00
Added: gadmin
Changed: lava cookiefication
This commit is contained in:
parent
a730e9f67f
commit
0f6a1d6687
@ -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!";
|
||||
@ -73,16 +70,16 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
preprocessLogEnabled = CONFIG.getBoolean("preprocess_log", 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.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);
|
||||
|
||||
|
||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this);
|
||||
|
||||
@ -202,7 +199,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
onlineUsers.append(ChatColor.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sender.sendMessage(onlineStats.toString());
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
|
||||
@ -513,7 +510,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
String user_ip = p.getAddress().getAddress().toString().replaceAll("/", "").trim();
|
||||
tfBroadcastMessage(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
|
||||
Bukkit.banIP(user_ip);
|
||||
|
||||
|
||||
//Ban Username:
|
||||
Bukkit.getOfflinePlayer(p.getName()).setBanned(true);
|
||||
|
||||
@ -741,7 +738,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
this.preprocessLogEnabled = false;
|
||||
sender.sendMessage("Command preprocess logging is now disabled.");
|
||||
}
|
||||
|
||||
|
||||
CONFIG.load();
|
||||
CONFIG.setProperty("preprocess_log", this.preprocessLogEnabled);
|
||||
CONFIG.save();
|
||||
@ -750,7 +747,93 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
sender.sendMessage(MSG_NO_PERMS);
|
||||
}
|
||||
|
||||
|
||||
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"))
|
||||
@ -809,7 +892,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (Bukkit.getOnlineMode())
|
||||
{
|
||||
if (superadmins.contains(user.getName()))
|
||||
|
@ -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())));
|
||||
|
||||
event.getItemInHand().setType(Material.COOKIE);
|
||||
event.getItemInHand().setAmount(1);
|
||||
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 + "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;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
public class TotalFreedomModEntityListener extends EntityListener
|
||||
{
|
||||
public static TotalFreedomMod plugin;
|
||||
|
||||
|
||||
TotalFreedomModEntityListener(TotalFreedomMod instance)
|
||||
{
|
||||
plugin = instance;
|
||||
@ -34,10 +34,10 @@ public class TotalFreedomModEntityListener extends EntityListener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setRadius((float)plugin.explosiveRadius);
|
||||
|
||||
event.setRadius((float) plugin.explosiveRadius);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
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.getPlayer().getItemInHand().setType(Material.COOKIE);
|
||||
event.getPlayer().getItemInHand().setAmount(1);
|
||||
|
||||
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.");
|
||||
if (!plugin.isUserSuperadmin(player))
|
||||
{
|
||||
block_command = true;
|
||||
}
|
||||
}
|
||||
else if (command.startsWith("/zeus") || command.startsWith("/vulcan"))
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user