mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 12:36:41 +00:00
Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
2168aa957a | |||
3babf8388c | |||
0b0e17e526 | |||
5247a33f88 | |||
3f2aa224f6 | |||
bc00e42990 | |||
88103cefc2 | |||
3819c57adf | |||
c3f8bd33ff | |||
baf7a3b2c1 | |||
74bfdad389 | |||
08a9329864 | |||
be87075337 | |||
ada803cd7d | |||
0b146943ff | |||
0f31ea2953 | |||
3ca46853ac | |||
ee6b93e208 | |||
3e5e11197f | |||
6035f9e50b | |||
f45cc11846 | |||
b28a0778b4 | |||
174043fa58 | |||
dfb6df63c8 | |||
7a6cc55640 | |||
5c61ff27b0 | |||
3da03393e6 | |||
5876f86ac3 | |||
fbdf2b5fc2 | |||
fd6aa7b94b | |||
5981f7f33f | |||
55d94b5d59 | |||
d71b043102 | |||
143b323854 | |||
1f32455e06 | |||
8718b3a8c2 | |||
f5e21f69fd | |||
bf7877addc | |||
6d0b8362b7 | |||
10f905ea36 | |||
dcb6a4513e | |||
ff4751941b | |||
e64fd42855 | |||
467d1d2d3a | |||
6ba8dcaa58 | |||
a3cf53f5b1 | |||
23907ef7e4 | |||
485945047b | |||
75ec2330f5 | |||
5c32c66390 | |||
4494a4c039 | |||
f53b67abf1 | |||
2827ca98a7 | |||
64b1e568b3 | |||
3e57696a21 | |||
fd1bd995ed | |||
9fe05add7f | |||
25fbb0c05a | |||
f646a5122a | |||
af4071c582 | |||
86ee0e96d2 | |||
57efdd2269 | |||
26bcd3ec1c |
@ -1,5 +1,5 @@
|
||||
#Wed, 14 Aug 2013 15:57:37 +0200
|
||||
#Tue, 03 Sep 2013 15:57:44 +0200
|
||||
|
||||
program.VERSION=3.00
|
||||
program.BUILDNUM=459
|
||||
program.BUILDDATE=08/14/2013 03\:57 PM
|
||||
program.VERSION=3.2
|
||||
program.BUILDNUM=551
|
||||
program.BUILDDATE=09/03/2013 03\:57 PM
|
||||
|
@ -1,3 +1,3 @@
|
||||
#Build Number for ANT. Do not edit!
|
||||
#Wed Aug 14 15:57:37 CEST 2013
|
||||
build.number=460
|
||||
#Tue Sep 03 15:57:44 CEST 2013
|
||||
build.number=552
|
||||
|
@ -1,4 +1,4 @@
|
||||
# TotalFreedomMod v3.00 Configuration
|
||||
# TotalFreedomMod v3.2 Configuration
|
||||
# by Madgeek1450 and DarthSalamon
|
||||
|
||||
# Block placement prevention:
|
||||
@ -12,7 +12,7 @@ allow_tnt_minecarts: false
|
||||
|
||||
# Explosion management:
|
||||
allow_explosions: false
|
||||
explosiveRadius: 4.0
|
||||
explosive_radius: 4.0
|
||||
|
||||
# Blocked commands:
|
||||
#
|
||||
@ -124,17 +124,52 @@ host_sender_names:
|
||||
- rcon
|
||||
- remotebukkit
|
||||
|
||||
# Players who cannot be banned by username
|
||||
unbannable_usernames:
|
||||
- honeydew
|
||||
- xephos
|
||||
- captainsparklez
|
||||
- truemu
|
||||
- kiershar
|
||||
- fvdisco
|
||||
- sethbling
|
||||
- notch
|
||||
- jeb_
|
||||
- gamechap
|
||||
- bertiechap
|
||||
- vechs
|
||||
- antvenom
|
||||
- chimneyswift
|
||||
- deadmau5
|
||||
- etho
|
||||
- skydoesminecraft
|
||||
- tobyturner
|
||||
- xxslyfoxhoundxx
|
||||
- paulsoaresjr
|
||||
- sips_
|
||||
- deadlox
|
||||
- xxslyxx
|
||||
- jeromeasf
|
||||
- dinnerbone
|
||||
- grumm
|
||||
- cavemanfilms
|
||||
|
||||
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
||||
twitterbot_enabled: false
|
||||
twitterbot_url:
|
||||
twitterbot_secret:
|
||||
twitterbot_url: ''
|
||||
twitterbot_secret: ''
|
||||
|
||||
# Pet Protect - Prevent tamed pets from being killed.
|
||||
pet_protect_enabled: true
|
||||
|
||||
# Logs Registration
|
||||
logs_register_password:
|
||||
logs_register_url:
|
||||
logs_register_password: ''
|
||||
logs_register_url: ''
|
||||
|
||||
# Mojang service checker
|
||||
service_checker_url: http://status.mojang.com/check
|
||||
|
||||
# HTTPD
|
||||
httpd_enabled: true
|
||||
httpd_public_folder: ./public_html
|
||||
httpd_port: 28966
|
||||
|
@ -2,5 +2,17 @@ package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
public enum AdminLevel
|
||||
{
|
||||
ALL, OP, SUPER, SENIOR
|
||||
ALL("All Player Commands"), OP("OP Commands"), SUPER("SuperAdmin Commands"), SENIOR("Senior Admin Commands");
|
||||
//
|
||||
private final String friendlyName;
|
||||
|
||||
private AdminLevel(String friendlyName)
|
||||
{
|
||||
this.friendlyName = friendlyName;
|
||||
}
|
||||
|
||||
public String getFriendlyName()
|
||||
{
|
||||
return friendlyName;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,13 +21,13 @@ public class Command_adminmode extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
TotalFreedomMod.adminOnlyMode = false;
|
||||
TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
||||
TFM_Util.adminAction(sender.getName(), "Opening the server to all players.", true);
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.adminOnlyMode = true;
|
||||
TFM_ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||
TFM_Util.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
|
@ -1,27 +1,233 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Go to the AdminWorld.", usage = "/<command>")
|
||||
@CommandPermissions(level = AdminLevel.OP, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Go to the AdminWorld.", usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]")
|
||||
public class Command_adminworld extends TFM_Command
|
||||
{
|
||||
private enum CommandMode
|
||||
{
|
||||
TELEPORT, GUEST, TIME, WEATHER
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (sender_p.getWorld() == TFM_AdminWorld.getInstance().getAdminWorld())
|
||||
CommandMode commandMode = null;
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
commandMode = CommandMode.TELEPORT;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
if ("guest".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.GUEST;
|
||||
}
|
||||
else if ("time".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.TIME;
|
||||
}
|
||||
else if ("weather".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
commandMode = CommandMode.WEATHER;
|
||||
}
|
||||
}
|
||||
|
||||
if (commandMode == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
switch (commandMode)
|
||||
{
|
||||
case TELEPORT:
|
||||
{
|
||||
if (!(sender instanceof Player) || sender_p == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
World adminWorld = null;
|
||||
try
|
||||
{
|
||||
adminWorld = TFM_AdminWorld.getInstance().getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (adminWorld == null || sender_p.getWorld() == adminWorld)
|
||||
{
|
||||
playerMsg("Going to the main world.");
|
||||
sender_p.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_AdminWorld.getInstance().canAccessWorld(sender_p))
|
||||
{
|
||||
playerMsg("Going to the AdminWorld.");
|
||||
TFM_AdminWorld.getInstance().sendToAdminWorld(sender_p);
|
||||
TFM_AdminWorld.getInstance().sendToWorld(sender_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("You don't have permission to access the AdminWorld.");
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case GUEST:
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
if ("list".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
playerMsg("AdminWorld guest list: " + TFM_AdminWorld.getInstance().guestListToString());
|
||||
}
|
||||
else if ("purge".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
assertCommandPerms(sender, sender_p);
|
||||
TFM_AdminWorld.getInstance().purgeGuestList();
|
||||
TFM_Util.adminAction(sender.getName(), "AdminWorld guest list purged.", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (args.length == 3)
|
||||
{
|
||||
assertCommandPerms(sender, sender_p);
|
||||
|
||||
if ("add".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
player = getPlayer(args[2]);
|
||||
}
|
||||
catch (PlayerNotFoundException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (player != null && TFM_AdminWorld.getInstance().addGuest(player, sender_p))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Could not add player to guest list.");
|
||||
}
|
||||
}
|
||||
else if (TFM_Util.isRemoveCommand(args[1]))
|
||||
{
|
||||
Player player = TFM_AdminWorld.getInstance().removeGuest(args[2]);
|
||||
if (player != null)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Can't find guest entry for: " + args[2]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case TIME:
|
||||
{
|
||||
assertCommandPerms(sender, sender_p);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
TFM_AdminWorld.TimeOfDay timeOfDay = TFM_AdminWorld.TimeOfDay.getByAlias(args[1]);
|
||||
if (timeOfDay != null)
|
||||
{
|
||||
TFM_AdminWorld.getInstance().setTimeOfDay(timeOfDay);
|
||||
playerMsg("AdminWorld time set to: " + timeOfDay.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case WEATHER:
|
||||
{
|
||||
assertCommandPerms(sender, sender_p);
|
||||
|
||||
if (args.length == 2)
|
||||
{
|
||||
TFM_AdminWorld.WeatherMode weatherMode = TFM_AdminWorld.WeatherMode.getByAlias(args[1]);
|
||||
if (weatherMode != null)
|
||||
{
|
||||
TFM_AdminWorld.getInstance().setWeatherMode(weatherMode);
|
||||
playerMsg("AdminWorld weather set to: " + weatherMode.name());
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Invalid weather mode. Can be: off, rain, storm");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (PermissionDeniedException ex)
|
||||
{
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void assertCommandPerms(CommandSender sender, Player sender_p) throws PermissionDeniedException
|
||||
{
|
||||
if (!(sender instanceof Player) || sender_p == null || !TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
throw new PermissionDeniedException(TotalFreedomMod.MSG_NO_PERMS);
|
||||
}
|
||||
}
|
||||
|
||||
private class PermissionDeniedException extends Exception
|
||||
{
|
||||
public PermissionDeniedException(String string)
|
||||
{
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,17 @@ public class Command_cage extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TFM_Util.isStopCommand(args[0]) && sender instanceof Player)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
|
||||
|
||||
playerdata.setCaged(false);
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player;
|
||||
try
|
||||
{
|
||||
@ -34,13 +45,14 @@ public class Command_cage extends TFM_Command
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Material cage_material_outer = Material.GLASS;
|
||||
Material cage_material_inner = Material.AIR;
|
||||
Material outerMaterial = Material.GLASS;
|
||||
Material innerMaterial = Material.AIR;
|
||||
|
||||
if (args.length >= 2)
|
||||
{
|
||||
if (TFM_Util.isStopCommand(args[1]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName() + ".", true);
|
||||
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
||||
|
||||
playerdata.setCaged(false);
|
||||
playerdata.regenerateHistory();
|
||||
@ -50,10 +62,13 @@ public class Command_cage extends TFM_Command
|
||||
}
|
||||
else
|
||||
{
|
||||
cage_material_outer = Material.matchMaterial(args[1]);
|
||||
if (cage_material_outer == null)
|
||||
if ("darth".equalsIgnoreCase(args[1]))
|
||||
{
|
||||
cage_material_outer = Material.GLASS;
|
||||
outerMaterial = Material.SKULL;
|
||||
}
|
||||
else if (Material.matchMaterial(args[1]) != null)
|
||||
{
|
||||
outerMaterial = Material.matchMaterial(args[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -62,25 +77,32 @@ public class Command_cage extends TFM_Command
|
||||
{
|
||||
if (args[2].equalsIgnoreCase("water"))
|
||||
{
|
||||
cage_material_inner = Material.STATIONARY_WATER;
|
||||
innerMaterial = Material.STATIONARY_WATER;
|
||||
}
|
||||
else if (args[2].equalsIgnoreCase("lava"))
|
||||
{
|
||||
cage_material_inner = Material.STATIONARY_LAVA;
|
||||
innerMaterial = Material.STATIONARY_LAVA;
|
||||
}
|
||||
}
|
||||
|
||||
Location targetPos = player.getLocation().add(0, 1, 0);
|
||||
playerdata.setCaged(true, targetPos, cage_material_outer, cage_material_inner);
|
||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||
playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial);
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
||||
TFM_Util.generateCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
TFM_Util.generateHollowCube(targetPos, 2, outerMaterial);
|
||||
TFM_Util.generateCube(targetPos, 1, innerMaterial);
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + ".", true);
|
||||
if (outerMaterial != Material.SKULL)
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,7 +18,7 @@ public class Command_droptoggle extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
TFM_Util.adminAction(sender.getName(),
|
||||
((TotalFreedomMod.autoEntityWipe = !args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
|
||||
(TFM_ConfigEntry.AUTO_ENTITY_WIPE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "Enabled" : "Disabled")
|
||||
+ " automatic entity wiping.", false);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -121,7 +122,7 @@ public class Command_enchant extends TFM_Command
|
||||
playerMsg("Can't use this enchantment on held item.");
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("remove"))
|
||||
else if (TFM_Util.isRemoveCommand(args[0]))
|
||||
{
|
||||
itemInHand.removeEnchantment(ench);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -22,7 +22,7 @@ public class Command_explosives extends TFM_Command
|
||||
{
|
||||
try
|
||||
{
|
||||
TotalFreedomMod.explosiveRadius = Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1])));
|
||||
TFM_ConfigEntry.EXPLOSIVE_RADIUS.setDouble(Math.max(1.0, Math.min(30.0, Double.parseDouble(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
@ -33,12 +33,12 @@ public class Command_explosives extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowExplosions = true;
|
||||
playerMsg("Explosives are now enabled, radius set to " + TotalFreedomMod.explosiveRadius + " blocks.");
|
||||
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
||||
playerMsg("Explosives are now enabled, radius set to " + TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble() + " blocks.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowExplosions = false;
|
||||
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(false);
|
||||
playerMsg("Explosives are now disabled.");
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,12 +19,12 @@ public class Command_fireplace extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowFirePlace = true;
|
||||
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
||||
playerMsg("Fire placement is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowFirePlace = false;
|
||||
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(false);
|
||||
playerMsg("Fire placement is now disabled.");
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,9 +18,13 @@ public class Command_firespread extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
playerMsg("Fire spread is now " + ((TotalFreedomMod.allowFireSpread = !args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
boolean fireSpread = !args[0].equalsIgnoreCase("off");
|
||||
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TotalFreedomMod.allowFireSpread);
|
||||
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(fireSpread);
|
||||
|
||||
playerMsg("Fire spread is now " + (fireSpread ? "enabled" : "disabled") + ".");
|
||||
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, fireSpread);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,21 +1,21 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Flatlands;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.ONLY_IN_GAME)
|
||||
@CommandParameters(description = "Goto the flatlands.", usage = "/<command>")
|
||||
public class Command_flatlands extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (TotalFreedomMod.generateFlatlands)
|
||||
if (TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean())
|
||||
{
|
||||
TFM_Util.gotoWorld(sender, "flatlands");
|
||||
TFM_Flatlands.getInstance().sendToWorld(sender_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,16 +17,7 @@ public class Command_fluidspread extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowFliudSpread = true;
|
||||
playerMsg("Lava and water spread is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowFliudSpread = false;
|
||||
playerMsg("Lava and water spread is now disabled.");
|
||||
}
|
||||
playerMsg("Lava and water spread is now " + (TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -17,11 +17,11 @@ public class Command_landmine extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!TotalFreedomMod.landminesEnabled)
|
||||
if (!TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean())
|
||||
{
|
||||
playerMsg("The landmine is currently disabled.", ChatColor.GREEN);
|
||||
}
|
||||
else if (!TotalFreedomMod.allowExplosions)
|
||||
else if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
playerMsg("Explosions are currently disabled.", ChatColor.GREEN);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,16 +17,7 @@ public class Command_lavadmg extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowLavaDamage = true;
|
||||
playerMsg("Lava damage is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowLavaDamage = false;
|
||||
playerMsg("Lava damage is now disabled.");
|
||||
}
|
||||
playerMsg("Lava damage is now " + (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -17,16 +17,7 @@ public class Command_lavaplace extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowLavaPlace = true;
|
||||
playerMsg("Lava placement is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowLavaPlace = false;
|
||||
playerMsg("Lava placement is now disabled.");
|
||||
}
|
||||
playerMsg("Lava placement is now " + (TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
@ -46,12 +47,10 @@ public class Command_logs extends TFM_Command
|
||||
|
||||
public static void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
||||
{
|
||||
if (TotalFreedomMod.logsRegisterURL == null || TotalFreedomMod.logsRegisterPassword == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String logsRegisterURL = TFM_ConfigEntry.LOGS_REGISTER_URL.getString();
|
||||
final String logsRegisterPassword = TFM_ConfigEntry.LOGS_REGISTER_PASSWORD.getString();
|
||||
|
||||
if (TotalFreedomMod.logsRegisterPassword.isEmpty() || TotalFreedomMod.logsRegisterURL.isEmpty())
|
||||
if (logsRegisterURL == null || logsRegisterPassword == null || logsRegisterURL.isEmpty() || logsRegisterPassword.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -68,9 +67,9 @@ public class Command_logs extends TFM_Command
|
||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||
}
|
||||
|
||||
URL url = new URLBuilder(TotalFreedomMod.logsRegisterURL)
|
||||
URL url = new URLBuilder(logsRegisterURL)
|
||||
.addQueryParameter("mode", mode.toString())
|
||||
.addQueryParameter("password", TotalFreedomMod.logsRegisterPassword)
|
||||
.addQueryParameter("password", logsRegisterPassword)
|
||||
.addQueryParameter("name", targetName)
|
||||
.addQueryParameter("ip", targetIP)
|
||||
.getURL();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -20,27 +20,27 @@ public class Command_moblimiter extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterEnabled = true;
|
||||
TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(true);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("off"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterEnabled = false;
|
||||
TFM_ConfigEntry.MOB_LIMITER_ENABLED.setBoolean(false);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("dragon"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterDisableDragon = !TotalFreedomMod.mobLimiterDisableDragon;
|
||||
TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("giant"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterDisableGiant = !TotalFreedomMod.mobLimiterDisableGiant;
|
||||
TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("slime"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterDisableSlime = !TotalFreedomMod.mobLimiterDisableSlime;
|
||||
TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean());
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("ghast"))
|
||||
{
|
||||
TotalFreedomMod.mobLimiterDisableGhast = !TotalFreedomMod.mobLimiterDisableGhast;
|
||||
TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.setBoolean(!TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -53,7 +53,7 @@ public class Command_moblimiter extends TFM_Command
|
||||
{
|
||||
try
|
||||
{
|
||||
TotalFreedomMod.mobLimiterMax = Math.max(0, Math.min(2000, Integer.parseInt(args[1])));
|
||||
TFM_ConfigEntry.MOB_LIMITER_MAX.setInteger(Math.max(0, Math.min(2000, Integer.parseInt(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
@ -61,21 +61,21 @@ public class Command_moblimiter extends TFM_Command
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.mobLimiterEnabled)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
||||
{
|
||||
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TotalFreedomMod.mobLimiterMax + ".");
|
||||
sender.sendMessage("Moblimiter enabled. Maximum mobcount set to: " + TFM_ConfigEntry.MOB_LIMITER_MAX.getInteger() + ".");
|
||||
|
||||
playerMsg("Dragon: " + (TotalFreedomMod.mobLimiterDisableDragon ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Giant: " + (TotalFreedomMod.mobLimiterDisableGiant ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Slime: " + (TotalFreedomMod.mobLimiterDisableSlime ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Ghast: " + (TotalFreedomMod.mobLimiterDisableGhast ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Dragon: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean() ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Giant: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean() ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Slime: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean() ? "disabled" : "enabled") + ".");
|
||||
playerMsg("Ghast: " + (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean() ? "disabled" : "enabled") + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
playerMsg("Moblimiter is disabled. No mob restrictions are in effect.");
|
||||
}
|
||||
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TotalFreedomMod.mobLimiterEnabled);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
@ -16,7 +16,7 @@ public class Command_mp44 extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!TotalFreedomMod.mp44Enabled)
|
||||
if (!TFM_ConfigEntry.MP44_ENABLED.getBoolean())
|
||||
{
|
||||
playerMsg("The mp44 is currently disabled.", ChatColor.GREEN);
|
||||
return true;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,7 +21,7 @@ public class Command_nonuke extends TFM_Command
|
||||
{
|
||||
try
|
||||
{
|
||||
TotalFreedomMod.nukeMonitorRange = Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1])));
|
||||
TFM_ConfigEntry.NUKE_MONITOR_RANGE.setDouble(Math.max(1.0, Math.min(500.0, Double.parseDouble(args[1]))));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
@ -32,7 +32,7 @@ public class Command_nonuke extends TFM_Command
|
||||
{
|
||||
try
|
||||
{
|
||||
TotalFreedomMod.nukeMonitorCountBreak = Math.max(1, Math.min(500, Integer.parseInt(args[2])));
|
||||
TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.setInteger(Math.max(1, Math.min(500, Integer.parseInt(args[2]))));
|
||||
}
|
||||
catch (NumberFormatException nfex)
|
||||
{
|
||||
@ -41,14 +41,14 @@ public class Command_nonuke extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.nukeMonitor = true;
|
||||
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(true);
|
||||
playerMsg("Nuke monitor is enabled.");
|
||||
playerMsg("Anti-freecam range is set to " + TotalFreedomMod.nukeMonitorRange + " blocks.");
|
||||
playerMsg("Block throttle rate is set to " + TotalFreedomMod.nukeMonitorCountBreak + " blocks destroyed per 5 seconds.");
|
||||
playerMsg("Anti-freecam range is set to " + TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble() + " blocks.");
|
||||
playerMsg("Block throttle rate is set to " + TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger() + " blocks destroyed per 5 seconds.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.nukeMonitor = false;
|
||||
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
|
||||
playerMsg("Nuke monitor is disabled.");
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,11 +18,9 @@ public class Command_petprotect extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
TotalFreedomMod.petProtectEnabled = !TFM_Util.isStopCommand(args[0]);
|
||||
|
||||
TFM_Util.adminAction(
|
||||
sender.getName(),
|
||||
"Tamed pet protection is now " + (TotalFreedomMod.petProtectEnabled ? "enabled" : "disabled") + ".",
|
||||
"Tamed pet protection is now " + (TFM_ConfigEntry.PET_PROTECT_ENABLED.setBoolean(!TFM_Util.isStopCommand(args[0])) ? "enabled" : "disabled") + ".",
|
||||
false);
|
||||
|
||||
return true;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,12 +21,12 @@ public class Command_prelog extends TFM_Command
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.preprocessLogEnabled = true;
|
||||
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(true);
|
||||
playerMsg("Command preprocess logging is now enabled. This will be spammy in the log.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.preprocessLogEnabled = false;
|
||||
TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.setBoolean(false);
|
||||
playerMsg("Command preprocess logging is now disabled.");
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,7 +17,7 @@ public class Command_protectarea extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!TotalFreedomMod.protectedAreasEnabled)
|
||||
if (!TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
|
||||
{
|
||||
playerMsg("Protected areas are currently disabled in the TotalFreedomMod configuration.");
|
||||
return true;
|
||||
@ -43,7 +44,7 @@ public class Command_protectarea extends TFM_Command
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("remove"))
|
||||
if (TFM_Util.isRemoveCommand(args[0]))
|
||||
{
|
||||
TFM_ProtectedArea.removeProtectedArea(args[1]);
|
||||
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
|
||||
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | purge [partialname] | purgeall>", aliases = "rb")
|
||||
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | undo [partialname] purge [partialname] | purgeall>", aliases = "rb")
|
||||
public class Command_rollback extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
@ -16,25 +16,58 @@ public class Command_rollback extends TFM_Command
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("purgeall"))
|
||||
if ("purgeall".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
TFM_Util.adminAction(sender.getName(), "Purging all rollback history.", false);
|
||||
TFM_Util.adminAction(sender.getName(), "Purging all rollback history", false);
|
||||
playerMsg("Purged all rollback history for " + TFM_RollbackManager.purgeEntries() + " players.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String playerName = getPlayerName(args[0]);
|
||||
|
||||
if (!TFM_RollbackManager.canRollback(playerName))
|
||||
{
|
||||
playerMsg("That player has no entries stored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TFM_RollbackManager.canUndoRollback(playerName))
|
||||
{
|
||||
playerMsg("That player has just been rolled back.");
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Rolling back player: " + playerName, false);
|
||||
playerMsg("Rolled back " + TFM_RollbackManager.rollback(playerName) + " edits for " + playerName + ".");
|
||||
playerMsg("If this rollback was a mistake, use /rollback undo " + playerName + " within 20 seconds to reverse the rollback.");
|
||||
}
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("purge"))
|
||||
if ("purge".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
String playerName = getPlayerName(args[1]);
|
||||
|
||||
if (!TFM_RollbackManager.canRollback(playerName))
|
||||
{
|
||||
playerMsg("That player has no entries stored.");
|
||||
return true;
|
||||
}
|
||||
|
||||
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(playerName) + " rollback history entries for " + playerName + ".");
|
||||
}
|
||||
else if ("undo".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
String playerName = getPlayerName(args[1]);
|
||||
|
||||
if (!TFM_RollbackManager.canUndoRollback(playerName))
|
||||
{
|
||||
playerMsg("That player hasn't been rolled back recently.");
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "Reverting rollback for player: " + playerName, false);
|
||||
playerMsg("Reverted " + TFM_RollbackManager.undoRollback(playerName) + " edits for " + playerName + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Superadmin;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
|
||||
@ -123,7 +124,7 @@ public class Command_saconfig extends TFM_Command
|
||||
TFM_SuperadminList.addSuperadmin(admin_name);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("del") || args[0].equalsIgnoreCase("remove"))
|
||||
else if (TFM_Util.isRemoveCommand(args[0]))
|
||||
{
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
{
|
||||
@ -150,13 +151,13 @@ public class Command_saconfig extends TFM_Command
|
||||
TFM_Util.adminAction(sender.getName(), "Removing " + targetName + " from the superadmin list", true);
|
||||
TFM_SuperadminList.removeSuperadmin(targetName);
|
||||
|
||||
if (!TotalFreedomMod.twitterbotEnabled)
|
||||
if (!TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Twitterbot
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
|
||||
String reply = twitterbot.delTwitter(targetName);
|
||||
if ("ok".equals(reply))
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -20,9 +20,9 @@ public class Command_setspawnworld extends TFM_Command
|
||||
|
||||
playerMsg("Spawn location for this world set to: " + TFM_Util.formatLocation(sender_p.getWorld().getSpawnLocation()));
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled && TotalFreedomMod.autoProtectSpawnpoints)
|
||||
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean() && TFM_ConfigEntry.AUTO_PROTECT_SPAWNPOINTS.getBoolean())
|
||||
{
|
||||
TFM_ProtectedArea.addProtectedArea("spawn_" + sender_p.getWorld().getName(), pos, TotalFreedomMod.autoProtectRadius);
|
||||
TFM_ProtectedArea.addProtectedArea("spawn_" + sender_p.getWorld().getName(), pos, TFM_ConfigEntry.AUTO_PROTECT_RADIUS.getDouble());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope")
|
||||
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "noob")
|
||||
public class Command_tban extends TFM_Command
|
||||
{
|
||||
@Override
|
||||
@ -30,10 +30,9 @@ public class Command_tban extends TFM_Command
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction(sender.getName(), "NOPE: " + player.getName(), true);
|
||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes",
|
||||
sender.getName(), TFM_Util.parseDateOffset("5m"));
|
||||
player.kickPlayer(ChatColor.RED + "NOPE!\nYou have been temporarily banned for five minutes.");
|
||||
TFM_Util.adminAction(sender.getName(), "Tempbanning: " + player.getName() + " for 5 minutes.", true);
|
||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "You have been temporarily banned for 5 minutes.", sender.getName(), TFM_Util.parseDateOffset("5m"));
|
||||
player.kickPlayer(ChatColor.RED + "You have been temporarily banned for five minutes. Please read totalfreedom.me for more info.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -19,7 +19,7 @@ public class Command_tossmob extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!TotalFreedomMod.tossmobEnabled)
|
||||
if (!TFM_ConfigEntry.TOSSMOB_ENABLED.getBoolean())
|
||||
{
|
||||
playerMsg("Tossmob is currently disabled.");
|
||||
return true;
|
||||
|
@ -105,4 +105,27 @@ public class Command_trail extends TFM_Command
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void startTrail(Player player)
|
||||
{
|
||||
if (!trailPlayers.contains(player))
|
||||
{
|
||||
trailPlayers.add(player);
|
||||
}
|
||||
|
||||
if (!trailPlayers.isEmpty())
|
||||
{
|
||||
registerMovementHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stopTrail(Player player)
|
||||
{
|
||||
trailPlayers.remove(player);
|
||||
|
||||
if (trailPlayers.isEmpty())
|
||||
{
|
||||
unregisterMovementHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_TwitterHandler;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
@ -15,7 +16,7 @@ public class Command_twitter extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
if (!TotalFreedomMod.twitterbotEnabled)
|
||||
if (!TFM_ConfigEntry.TWITTERBOT_ENABLED.getBoolean())
|
||||
{
|
||||
TFM_Util.playerMsg(sender, "TwitterBot has been disabled in config.", ChatColor.RED);
|
||||
return true;
|
||||
@ -26,7 +27,7 @@ public class Command_twitter extends TFM_Command
|
||||
return false;
|
||||
}
|
||||
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
|
||||
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance();
|
||||
|
||||
if ("set".equals(args[0]))
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -12,22 +12,12 @@ public class Command_waterplace extends TFM_Command
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
|
||||
if (args.length != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("on"))
|
||||
{
|
||||
TotalFreedomMod.allowWaterPlace = true;
|
||||
playerMsg("Water placement is now enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalFreedomMod.allowWaterPlace = false;
|
||||
playerMsg("Water placement is now disabled.");
|
||||
}
|
||||
playerMsg("Water placement is now " + (TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(!args[0].equalsIgnoreCase("off")) ? "enabled" : "disabled") + ".");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class Command_whitelist extends TFM_Command
|
||||
}
|
||||
|
||||
// remove
|
||||
if (args[0].equalsIgnoreCase("remove"))
|
||||
if (TFM_Util.isRemoveCommand(args[0]))
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
|
@ -46,26 +46,11 @@ public class TFM_CommandLoader
|
||||
|
||||
for (TFM_CommandInfo commandInfo : commandList)
|
||||
{
|
||||
String description = commandInfo.getDescription();
|
||||
switch (commandInfo.getLevel())
|
||||
{
|
||||
case SENIOR:
|
||||
description = "Senior " + (commandInfo.getSource() == SourceType.ONLY_CONSOLE ? "Console" : "") + " Command - " + description;
|
||||
break;
|
||||
case SUPER:
|
||||
description = "Superadmin Command - " + description;
|
||||
break;
|
||||
case OP:
|
||||
description = "OP Command - " + description;
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo.getCommandName(), description, commandInfo.getUsage(), commandInfo.getAliases());
|
||||
TFM_DynamicCommand dynamicCommand = new TFM_DynamicCommand(commandInfo);
|
||||
|
||||
Command existing = commandMap.getCommand(dynamicCommand.getName());
|
||||
if (existing != null)
|
||||
{
|
||||
TFM_Log.info("Replacing command: " + existing.getName());
|
||||
unregisterCommand(existing, commandMap);
|
||||
}
|
||||
|
||||
@ -192,7 +177,7 @@ public class TFM_CommandLoader
|
||||
return commandList;
|
||||
}
|
||||
|
||||
private static class TFM_CommandInfo
|
||||
public static class TFM_CommandInfo
|
||||
{
|
||||
private final String commandName;
|
||||
private final Class<?> commandClass;
|
||||
@ -235,6 +220,26 @@ public class TFM_CommandLoader
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getDescriptionPermissioned()
|
||||
{
|
||||
String _description = description;
|
||||
|
||||
switch (this.getLevel())
|
||||
{
|
||||
case SENIOR:
|
||||
_description = "Senior " + (this.getSource() == SourceType.ONLY_CONSOLE ? "Console" : "") + " Command - " + _description;
|
||||
break;
|
||||
case SUPER:
|
||||
_description = "Superadmin Command - " + _description;
|
||||
break;
|
||||
case OP:
|
||||
_description = "OP Command - " + _description;
|
||||
break;
|
||||
}
|
||||
|
||||
return _description;
|
||||
}
|
||||
|
||||
public AdminLevel getLevel()
|
||||
{
|
||||
return level;
|
||||
@ -271,11 +276,15 @@ public class TFM_CommandLoader
|
||||
}
|
||||
}
|
||||
|
||||
private class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||
public class TFM_DynamicCommand extends Command implements PluginIdentifiableCommand
|
||||
{
|
||||
public TFM_DynamicCommand(String commandName, String description, String usage, List<String> aliases)
|
||||
private final TFM_CommandInfo commandInfo;
|
||||
|
||||
private TFM_DynamicCommand(TFM_CommandInfo commandInfo)
|
||||
{
|
||||
super(commandName, description, usage, aliases);
|
||||
super(commandInfo.getCommandName(), commandInfo.getDescriptionPermissioned(), commandInfo.getUsage(), commandInfo.getAliases());
|
||||
|
||||
this.commandInfo = commandInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -313,6 +322,11 @@ public class TFM_CommandLoader
|
||||
{
|
||||
return TotalFreedomMod.plugin;
|
||||
}
|
||||
|
||||
public TFM_CommandInfo getCommandInfo()
|
||||
{
|
||||
return commandInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandLoader getInstance()
|
||||
|
@ -0,0 +1,59 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
||||
|
||||
public class HTMLGenerationTools
|
||||
{
|
||||
private HTMLGenerationTools()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static String paragraph(String data)
|
||||
{
|
||||
return "<p>" + escapeHtml4(data) + "</p>\r\n";
|
||||
}
|
||||
|
||||
public static String heading(String data, int level)
|
||||
{
|
||||
return "<h" + level + ">" + escapeHtml4(data) + "</h" + level + ">\r\n";
|
||||
}
|
||||
|
||||
public static <K, V> String list(Map<K, V> map)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
output.append("<ul>\r\n");
|
||||
|
||||
Iterator<Map.Entry<K, V>> it = map.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry<K, V> entry = it.next();
|
||||
output.append("<li>").append(escapeHtml4(entry.getKey().toString() + " = " + entry.getValue().toString())).append("</li>\r\n");
|
||||
}
|
||||
|
||||
output.append("</ul>\r\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
public static <T> String list(List<T> list)
|
||||
{
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
output.append("<ul>\r\n");
|
||||
|
||||
for (T entry : list)
|
||||
{
|
||||
output.append("<li>").append(escapeHtml4(entry.toString())).append("</li>\r\n");
|
||||
}
|
||||
|
||||
output.append("</ul>\r\n");
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
}
|
41
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_dump.java
Normal file
41
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_dump.java
Normal file
@ -0,0 +1,41 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.util.Map;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;
|
||||
|
||||
public class Module_dump extends TFM_HTTPD_Module
|
||||
{
|
||||
public Module_dump(String uri, NanoHTTPD.Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files)
|
||||
{
|
||||
super(uri, method, headers, params, files);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody()
|
||||
{
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
|
||||
String[] args = StringUtils.split(uri, "/");
|
||||
|
||||
responseBody
|
||||
.append(paragraph("URI: " + uri))
|
||||
.append(paragraph("args (Length: " + args.length + "): " + StringUtils.join(args, ",")))
|
||||
.append(paragraph("Method: " + method.toString()))
|
||||
.append(paragraph("Headers:"))
|
||||
.append(list(headers))
|
||||
.append(paragraph("Params:"))
|
||||
.append(list(params))
|
||||
.append(paragraph("Files:"))
|
||||
.append(list(files));
|
||||
|
||||
return responseBody.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return "TotalFreedomMod :: Request Debug Dumper";
|
||||
}
|
||||
}
|
363
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java
Normal file
363
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_file.java
Normal file
@ -0,0 +1,363 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import static me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.*;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
|
||||
/*
|
||||
* This class was adapted from https://github.com/NanoHttpd/nanohttpd/blob/master/webserver/src/main/java/fi/iki/elonen/SimpleWebServer.java
|
||||
*/
|
||||
public class Module_file extends TFM_HTTPD_Module
|
||||
{
|
||||
private final File rootDir = new File(TFM_ConfigEntry.HTTPD_PUBLIC_FOLDER.getString());
|
||||
private static final Map<String, String> MIME_TYPES = new HashMap<String, String>();
|
||||
|
||||
static
|
||||
{
|
||||
MIME_TYPES.put("css", "text/css");
|
||||
MIME_TYPES.put("htm", "text/html");
|
||||
MIME_TYPES.put("html", "text/html");
|
||||
MIME_TYPES.put("xml", "text/xml");
|
||||
MIME_TYPES.put("java", "text/x-java-source, text/java");
|
||||
MIME_TYPES.put("txt", "text/plain");
|
||||
MIME_TYPES.put("asc", "text/plain");
|
||||
MIME_TYPES.put("gif", "image/gif");
|
||||
MIME_TYPES.put("jpg", "image/jpeg");
|
||||
MIME_TYPES.put("jpeg", "image/jpeg");
|
||||
MIME_TYPES.put("png", "image/png");
|
||||
MIME_TYPES.put("mp3", "audio/mpeg");
|
||||
MIME_TYPES.put("m3u", "audio/mpeg-url");
|
||||
MIME_TYPES.put("mp4", "video/mp4");
|
||||
MIME_TYPES.put("ogv", "video/ogg");
|
||||
MIME_TYPES.put("flv", "video/x-flv");
|
||||
MIME_TYPES.put("mov", "video/quicktime");
|
||||
MIME_TYPES.put("swf", "application/x-shockwave-flash");
|
||||
MIME_TYPES.put("js", "application/javascript");
|
||||
MIME_TYPES.put("pdf", "application/pdf");
|
||||
MIME_TYPES.put("doc", "application/msword");
|
||||
MIME_TYPES.put("ogg", "application/x-ogg");
|
||||
MIME_TYPES.put("zip", "application/octet-stream");
|
||||
MIME_TYPES.put("exe", "application/octet-stream");
|
||||
MIME_TYPES.put("class", "application/octet-stream");
|
||||
}
|
||||
|
||||
public Module_file(String uri, NanoHTTPD.Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files)
|
||||
{
|
||||
super(uri, method, headers, params, files);
|
||||
}
|
||||
|
||||
private File getRootDir()
|
||||
{
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
private String encodeUri(String uri)
|
||||
{
|
||||
String newUri = "";
|
||||
StringTokenizer st = new StringTokenizer(uri, "/ ", true);
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
String tok = st.nextToken();
|
||||
if (tok.equals("/"))
|
||||
{
|
||||
newUri += "/";
|
||||
}
|
||||
else if (tok.equals(" "))
|
||||
{
|
||||
newUri += "%20";
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
newUri += URLEncoder.encode(tok, "UTF-8");
|
||||
}
|
||||
catch (UnsupportedEncodingException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
return newUri;
|
||||
}
|
||||
|
||||
private Response serveFile(String uri, Map<String, String> header, File homeDir)
|
||||
{
|
||||
Response res = null;
|
||||
|
||||
// Make sure we won't die of an exception later
|
||||
if (!homeDir.isDirectory())
|
||||
{
|
||||
res = new Response(Response.Status.INTERNAL_ERROR, NanoHTTPD.MIME_PLAINTEXT, "INTERNAL ERRROR: serveFile(): given homeDir is not a directory.");
|
||||
}
|
||||
|
||||
if (res == null)
|
||||
{
|
||||
// Remove URL arguments
|
||||
uri = uri.trim().replace(File.separatorChar, '/');
|
||||
if (uri.indexOf('?') >= 0)
|
||||
{
|
||||
uri = uri.substring(0, uri.indexOf('?'));
|
||||
}
|
||||
|
||||
// Prohibit getting out of current directory
|
||||
if (uri.startsWith("src/main") || uri.endsWith("src/main") || uri.contains("../"))
|
||||
{
|
||||
res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: Won't serve ../ for security reasons.");
|
||||
}
|
||||
}
|
||||
|
||||
File f = new File(homeDir, uri);
|
||||
if (res == null && !f.exists())
|
||||
{
|
||||
res = new Response(Response.Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "Error 404, file not found.");
|
||||
}
|
||||
|
||||
// List the directory, if necessary
|
||||
if (res == null && f.isDirectory())
|
||||
{
|
||||
// Browsers get confused without '/' after the
|
||||
// directory, send a redirect.
|
||||
if (!uri.endsWith("/"))
|
||||
{
|
||||
uri += "/";
|
||||
res = new Response(Response.Status.REDIRECT, NanoHTTPD.MIME_HTML, "<html><body>Redirected: <a href=\"" + uri + "\">" + uri
|
||||
+ "</a></body></html>");
|
||||
res.addHeader("Location", uri);
|
||||
}
|
||||
|
||||
if (res == null)
|
||||
{
|
||||
// First try index.html and index.htm
|
||||
if (new File(f, "index.html").exists())
|
||||
{
|
||||
f = new File(homeDir, uri + "/index.html");
|
||||
}
|
||||
else if (new File(f, "index.htm").exists())
|
||||
{
|
||||
f = new File(homeDir, uri + "/index.htm");
|
||||
}
|
||||
else if (f.canRead())
|
||||
{
|
||||
// No index file, list the directory if it is readable
|
||||
res = new Response(listDirectory(uri, f));
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: No directory listing.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (res == null)
|
||||
{
|
||||
// Get MIME type from file name extension, if possible
|
||||
String mime = null;
|
||||
int dot = f.getCanonicalPath().lastIndexOf('.');
|
||||
if (dot >= 0)
|
||||
{
|
||||
mime = MIME_TYPES.get(f.getCanonicalPath().substring(dot + 1).toLowerCase());
|
||||
}
|
||||
if (mime == null)
|
||||
{
|
||||
mime = NanoHTTPD.MIME_DEFAULT_BINARY;
|
||||
}
|
||||
|
||||
// Calculate etag
|
||||
String etag = Integer.toHexString((f.getAbsolutePath() + f.lastModified() + "" + f.length()).hashCode());
|
||||
|
||||
// Support (simple) skipping:
|
||||
long startFrom = 0;
|
||||
long endAt = -1;
|
||||
String range = header.get("range");
|
||||
if (range != null)
|
||||
{
|
||||
if (range.startsWith("bytes="))
|
||||
{
|
||||
range = range.substring("bytes=".length());
|
||||
int minus = range.indexOf('-');
|
||||
try
|
||||
{
|
||||
if (minus > 0)
|
||||
{
|
||||
startFrom = Long.parseLong(range.substring(0, minus));
|
||||
endAt = Long.parseLong(range.substring(minus + 1));
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change return code and add Content-Range header when skipping is requested
|
||||
long fileLen = f.length();
|
||||
if (range != null && startFrom >= 0)
|
||||
{
|
||||
if (startFrom >= fileLen)
|
||||
{
|
||||
res = new Response(Response.Status.RANGE_NOT_SATISFIABLE, NanoHTTPD.MIME_PLAINTEXT, "");
|
||||
res.addHeader("Content-Range", "bytes 0-0/" + fileLen);
|
||||
res.addHeader("ETag", etag);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (endAt < 0)
|
||||
{
|
||||
endAt = fileLen - 1;
|
||||
}
|
||||
long newLen = endAt - startFrom + 1;
|
||||
if (newLen < 0)
|
||||
{
|
||||
newLen = 0;
|
||||
}
|
||||
|
||||
final long dataLen = newLen;
|
||||
FileInputStream fis = new FileInputStream(f)
|
||||
{
|
||||
@Override
|
||||
public int available() throws IOException
|
||||
{
|
||||
return (int) dataLen;
|
||||
}
|
||||
};
|
||||
fis.skip(startFrom);
|
||||
|
||||
res = new Response(Response.Status.PARTIAL_CONTENT, mime, fis);
|
||||
res.addHeader("Content-Length", "" + dataLen);
|
||||
res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen);
|
||||
res.addHeader("ETag", etag);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (etag.equals(header.get("if-none-match")))
|
||||
{
|
||||
res = new Response(Response.Status.NOT_MODIFIED, mime, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
res = new Response(Response.Status.OK, mime, new FileInputStream(f));
|
||||
res.addHeader("Content-Length", "" + fileLen);
|
||||
res.addHeader("ETag", etag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
res = new Response(Response.Status.FORBIDDEN, NanoHTTPD.MIME_PLAINTEXT, "FORBIDDEN: Reading file failed.");
|
||||
}
|
||||
|
||||
res.addHeader("Accept-Ranges", "bytes"); // Announce that the file server accepts partial content requestes
|
||||
return res;
|
||||
}
|
||||
|
||||
private String listDirectory(String uri, File f)
|
||||
{
|
||||
String heading = "Directory " + uri;
|
||||
String msg = "<html><head><title>" + heading + "</title><style><!--\n"
|
||||
+ "span.dirname { font-weight: bold; }\n"
|
||||
+ "span.filesize { font-size: 75%; }\n"
|
||||
+ "// -->\n"
|
||||
+ "</style>"
|
||||
+ "</head><body><h1>" + heading + "</h1>";
|
||||
|
||||
String up = null;
|
||||
if (uri.length() > 1)
|
||||
{
|
||||
String u = uri.substring(0, uri.length() - 1);
|
||||
int slash = u.lastIndexOf('/');
|
||||
if (slash >= 0 && slash < u.length())
|
||||
{
|
||||
up = uri.substring(0, slash + 1);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> _files = Arrays.asList(f.list(new FilenameFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
return new File(dir, name).isFile();
|
||||
}
|
||||
}));
|
||||
Collections.sort(_files);
|
||||
List<String> directories = Arrays.asList(f.list(new FilenameFilter()
|
||||
{
|
||||
@Override
|
||||
public boolean accept(File dir, String name)
|
||||
{
|
||||
return new File(dir, name).isDirectory();
|
||||
}
|
||||
}));
|
||||
Collections.sort(directories);
|
||||
if (up != null || directories.size() + _files.size() > 0)
|
||||
{
|
||||
msg += "<ul>";
|
||||
if (up != null || directories.size() > 0)
|
||||
{
|
||||
msg += "<section class=\"directories\">";
|
||||
if (up != null)
|
||||
{
|
||||
msg += "<li><a rel=\"directory\" href=\"" + up + "\"><span class=\"dirname\">..</span></a></b></li>";
|
||||
}
|
||||
for (int i = 0; i < directories.size(); i++)
|
||||
{
|
||||
String dir = directories.get(i) + "/";
|
||||
msg += "<li><a rel=\"directory\" href=\"" + encodeUri(uri + dir) + "\"><span class=\"dirname\">" + dir + "</span></a></b></li>";
|
||||
}
|
||||
msg += "</section>";
|
||||
}
|
||||
if (_files.size() > 0)
|
||||
{
|
||||
msg += "<section class=\"files\">";
|
||||
for (int i = 0; i < _files.size(); i++)
|
||||
{
|
||||
String file = _files.get(i);
|
||||
|
||||
msg += "<li><a href=\"" + encodeUri(uri + file) + "\"><span class=\"filename\">" + file + "</span></a>";
|
||||
File curFile = new File(f, file);
|
||||
long len = curFile.length();
|
||||
msg += " <span class=\"filesize\">(";
|
||||
if (len < 1024)
|
||||
{
|
||||
msg += len + " bytes";
|
||||
}
|
||||
else if (len < 1024 * 1024)
|
||||
{
|
||||
msg += len / 1024 + "." + (len % 1024 / 10 % 100) + " KB";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += len / (1024 * 1024) + "." + len % (1024 * 1024) / 10 % 100 + " MB";
|
||||
}
|
||||
msg += ")</span></li>";
|
||||
}
|
||||
msg += "</section>";
|
||||
}
|
||||
msg += "</ul>";
|
||||
}
|
||||
msg += "</body></html>";
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response getResponse()
|
||||
{
|
||||
return serveFile(uri, headers, getRootDir());
|
||||
}
|
||||
}
|
150
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_help.java
Normal file
150
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_help.java
Normal file
@ -0,0 +1,150 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.AdminLevel;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader.TFM_DynamicCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import static me.StevenLawson.TotalFreedomMod.HTTPD.HTMLGenerationTools.*;
|
||||
import static org.apache.commons.lang3.StringEscapeUtils.*;
|
||||
|
||||
public class Module_help extends TFM_HTTPD_Module
|
||||
{
|
||||
public Module_help(String uri, NanoHTTPD.Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files)
|
||||
{
|
||||
super(uri, method, headers, params, files);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody()
|
||||
{
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
|
||||
CommandMap commandMap;
|
||||
HashMap<String, Command> knownCommands;
|
||||
if ((commandMap = TFM_CommandLoader.getInstance().getCommandMap()) == null
|
||||
|| (knownCommands = TFM_CommandLoader.getInstance().getKnownCommands(commandMap)) == null)
|
||||
{
|
||||
return paragraph("Error loading commands.");
|
||||
}
|
||||
|
||||
responseBody
|
||||
.append(heading("Command Help", 1))
|
||||
.append(paragraph(
|
||||
"This page is an automatically generated listing of all plugin commands that are currently live on the server. "
|
||||
+ "Please note that it does not include vanilla server commands."));
|
||||
|
||||
final Map<String, List<Command>> commandsByPlugin = new HashMap<String, List<Command>>();
|
||||
|
||||
final Iterator<Map.Entry<String, Command>> itKnownCommands = knownCommands.entrySet().iterator();
|
||||
while (itKnownCommands.hasNext())
|
||||
{
|
||||
final Map.Entry<String, Command> entry = itKnownCommands.next();
|
||||
final String name = entry.getKey();
|
||||
final Command command = entry.getValue();
|
||||
if (name.equalsIgnoreCase(command.getName()))
|
||||
{
|
||||
String pluginName = "Bukkit Default";
|
||||
if (command instanceof PluginIdentifiableCommand)
|
||||
{
|
||||
pluginName = ((PluginIdentifiableCommand) command).getPlugin().getName();
|
||||
}
|
||||
List<Command> pluginCommands = commandsByPlugin.get(pluginName);
|
||||
if (pluginCommands == null)
|
||||
{
|
||||
commandsByPlugin.put(pluginName, pluginCommands = new ArrayList<Command>());
|
||||
}
|
||||
pluginCommands.add(command);
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<Map.Entry<String, List<Command>>> itCommandsByPlugin = commandsByPlugin.entrySet().iterator();
|
||||
while (itCommandsByPlugin.hasNext())
|
||||
{
|
||||
final Map.Entry<String, List<Command>> entry = itCommandsByPlugin.next();
|
||||
final String pluginName = entry.getKey();
|
||||
final List<Command> commands = entry.getValue();
|
||||
|
||||
Collections.sort(commands, new Comparator<Command>()
|
||||
{
|
||||
@Override
|
||||
public int compare(Command a, Command b)
|
||||
{
|
||||
if (a instanceof TFM_DynamicCommand && b instanceof TFM_DynamicCommand)
|
||||
{
|
||||
String aName = ((TFM_DynamicCommand) a).getCommandInfo().getLevel().name() + a.getName();
|
||||
String bName = ((TFM_DynamicCommand) b).getCommandInfo().getLevel().name() + b.getName();
|
||||
return aName.compareTo(bName);
|
||||
}
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
});
|
||||
|
||||
responseBody.append(heading(pluginName, 2)).append("<ul>\r\n");
|
||||
|
||||
AdminLevel lastTfmCommandLevel = null;
|
||||
for (Command command : commands)
|
||||
{
|
||||
if ("TotalFreedomMod".equals(pluginName))
|
||||
{
|
||||
AdminLevel tfmCommandLevel = ((TFM_DynamicCommand) command).getCommandInfo().getLevel();
|
||||
if (lastTfmCommandLevel == null || lastTfmCommandLevel != tfmCommandLevel)
|
||||
{
|
||||
responseBody.append("</ul>\r\n").append(heading(tfmCommandLevel.getFriendlyName(), 3)).append("<ul>\r\n");
|
||||
}
|
||||
lastTfmCommandLevel = tfmCommandLevel;
|
||||
}
|
||||
responseBody.append(buildDescription(command));
|
||||
}
|
||||
|
||||
responseBody.append("</ul>\r\n");
|
||||
}
|
||||
|
||||
return responseBody.toString();
|
||||
}
|
||||
|
||||
private static String buildDescription(Command command)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(
|
||||
"<li><span class=\"commandName\">{$CMD_NAME}</span> - Usage: <span class=\"commandUsage\">{$CMD_USAGE}</span>"
|
||||
.replace("{$CMD_NAME}", escapeHtml4(command.getName().trim()))
|
||||
.replace("{$CMD_USAGE}", escapeHtml4(command.getUsage().trim())));
|
||||
|
||||
if (!command.getAliases().isEmpty())
|
||||
{
|
||||
sb.append(
|
||||
" - Aliases: <span class=\"commandAliases\">{$CMD_ALIASES}</span>"
|
||||
.replace("{$CMD_ALIASES}", escapeHtml4(StringUtils.join(command.getAliases(), ", "))));
|
||||
}
|
||||
|
||||
sb.append(
|
||||
"<br><span class=\"commandDescription\">{$CMD_DESC}</span></li>\r\n"
|
||||
.replace("{$CMD_DESC}", escapeHtml4(command.getDescription().trim())));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return "TotalFreedomMod :: Command Help";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStyle()
|
||||
{
|
||||
return ".commandName{font-weight:bold;}.commandDescription{padding-left:15px;}li{margin:.15em;padding:.15em;}";
|
||||
}
|
||||
}
|
72
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_list.java
Normal file
72
src/me/StevenLawson/TotalFreedomMod/HTTPD/Module_list.java
Normal file
@ -0,0 +1,72 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.util.Map;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Module_list extends TFM_HTTPD_Module
|
||||
{
|
||||
public Module_list(String uri, NanoHTTPD.Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files)
|
||||
{
|
||||
super(uri, method, headers, params, files);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBody()
|
||||
{
|
||||
final StringBuilder body = new StringBuilder();
|
||||
|
||||
final Player[] onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
|
||||
body.append("<p>There are ").append(onlinePlayers.length).append("/").append(Bukkit.getMaxPlayers()).append(" players online:</p>\r\n");
|
||||
|
||||
body.append("<ul>\r\n");
|
||||
|
||||
for (Player player : onlinePlayers)
|
||||
{
|
||||
String prefix = "";
|
||||
if (TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player))
|
||||
{
|
||||
prefix = "[SrA]";
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix = "[SA]";
|
||||
}
|
||||
|
||||
if (TFM_Util.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
prefix = "[Dev]";
|
||||
}
|
||||
|
||||
if (player.getName().equals("markbyron"))
|
||||
{
|
||||
prefix = "[Owner]";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.isOp())
|
||||
{
|
||||
prefix = "[OP]";
|
||||
}
|
||||
}
|
||||
|
||||
body.append("<li>").append(prefix).append(player.getName()).append("</li>\r\n");
|
||||
}
|
||||
|
||||
body.append("</ul>\r\n");
|
||||
|
||||
return body.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return "Total Freedom - Online Users";
|
||||
}
|
||||
}
|
1364
src/me/StevenLawson/TotalFreedomMod/HTTPD/NanoHTTPD.java
Normal file
1364
src/me/StevenLawson/TotalFreedomMod/HTTPD/NanoHTTPD.java
Normal file
File diff suppressed because it is too large
Load Diff
181
src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java
Normal file
181
src/me/StevenLawson/TotalFreedomMod/HTTPD/TFM_HTTPD_Manager.java
Normal file
@ -0,0 +1,181 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import static me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.MIME_PLAINTEXT;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TFM_HTTPD_Manager
|
||||
{
|
||||
public static final int PORT = TFM_ConfigEntry.HTTPD_PORT.getInteger();
|
||||
//
|
||||
private final TFM_HTTPD httpd = new TFM_HTTPD(PORT);
|
||||
|
||||
private TFM_HTTPD_Manager()
|
||||
{
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
if (!TFM_ConfigEntry.HTTPD_ENABLED.getBoolean())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
httpd.start();
|
||||
|
||||
if (httpd.isAlive())
|
||||
{
|
||||
TFM_Log.info("TFM HTTPd started. Listening on port: " + httpd.getListeningPort());
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.info("Error starting TFM HTTPd.");
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if (!TFM_ConfigEntry.HTTPD_ENABLED.getBoolean())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
httpd.stop();
|
||||
|
||||
TFM_Log.info("TFM HTTPd stopped.");
|
||||
}
|
||||
|
||||
private static enum ModuleType
|
||||
{
|
||||
DUMP(false, "dump"),
|
||||
HELP(true, "help"),
|
||||
LIST(true, "list"),
|
||||
FILE(false, "file");
|
||||
private final boolean runOnBukkitThread;
|
||||
private final String name;
|
||||
|
||||
private ModuleType(boolean runOnBukkitThread, String name)
|
||||
{
|
||||
this.runOnBukkitThread = runOnBukkitThread;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isRunOnBukkitThread()
|
||||
{
|
||||
return runOnBukkitThread;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
private static ModuleType getByName(String needle)
|
||||
{
|
||||
for (ModuleType type : values())
|
||||
{
|
||||
if (type.getName().equalsIgnoreCase(needle))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return FILE;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TFM_HTTPD extends NanoHTTPD
|
||||
{
|
||||
public TFM_HTTPD(int port)
|
||||
{
|
||||
super(port);
|
||||
}
|
||||
|
||||
public TFM_HTTPD(String hostname, int port)
|
||||
{
|
||||
super(hostname, port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response serve(final String uri, final Method method, final Map<String, String> headers, final Map<String, String> params, final Map<String, String> files)
|
||||
{
|
||||
Response response = null;
|
||||
|
||||
final String[] args = StringUtils.split(uri, "/");
|
||||
final ModuleType moduleType = args.length >= 1 ? ModuleType.getByName(args[0]) : ModuleType.FILE;
|
||||
|
||||
if (moduleType.isRunOnBukkitThread())
|
||||
{
|
||||
Future<Response> responseCall = Bukkit.getScheduler().callSyncMethod(TotalFreedomMod.plugin, new Callable<Response>()
|
||||
{
|
||||
@Override
|
||||
public Response call() throws Exception
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case HELP:
|
||||
return new Module_help(uri, method, headers, params, files).getResponse();
|
||||
case LIST:
|
||||
return new Module_list(uri, method, headers, params, files).getResponse();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
response = responseCall.get();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (moduleType)
|
||||
{
|
||||
case DUMP:
|
||||
response = new Module_dump(uri, method, headers, params, files).getResponse();
|
||||
break;
|
||||
default:
|
||||
response = new Module_file(uri, method, headers, params, files).getResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
return new Response(Response.Status.NOT_FOUND, MIME_PLAINTEXT, "Error 404: Not Found - The requested resource was not found on this server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_HTTPD_Manager getInstance()
|
||||
{
|
||||
return TFM_HTTPDManagerHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_HTTPDManagerHolder
|
||||
{
|
||||
private static final TFM_HTTPD_Manager INSTANCE = new TFM_HTTPD_Manager();
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import java.util.Map;
|
||||
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.*;
|
||||
|
||||
public abstract class TFM_HTTPD_Module
|
||||
{
|
||||
protected final String uri;
|
||||
protected final Method method;
|
||||
protected final Map<String, String> headers;
|
||||
protected final Map<String, String> params;
|
||||
protected final Map<String, String> files;
|
||||
|
||||
public TFM_HTTPD_Module(String uri, Method method, Map<String, String> headers, Map<String, String> params, Map<String, String> files)
|
||||
{
|
||||
this.uri = uri;
|
||||
this.method = method;
|
||||
this.headers = headers;
|
||||
this.params = params;
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public String getBody()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getStyle()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return new TFM_HTTPD_PageBuilder(getBody(), getTitle(), getStyle()).getResponse();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package me.StevenLawson.TotalFreedomMod.HTTPD;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.HTTPD.NanoHTTPD.Response;
|
||||
|
||||
public class TFM_HTTPD_PageBuilder
|
||||
{
|
||||
private static final String TEMPLATE =
|
||||
"<!DOCTYPE html>\r\n"
|
||||
+ "<html>\r\n"
|
||||
+ "<head>\r\n"
|
||||
+ "<title>{$TITLE}</title>\r\n"
|
||||
+ "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\r\n"
|
||||
+ "<style type=\"text/css\">{$STYLE}</style>\r\n"
|
||||
+ "</head>\r\n"
|
||||
+ "<body>{$BODY}</body>\r\n"
|
||||
+ "</html>\r\n";
|
||||
//
|
||||
private String body = "";
|
||||
private String title = "";
|
||||
private String style = "";
|
||||
|
||||
public TFM_HTTPD_PageBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
public TFM_HTTPD_PageBuilder(String body, String title, String style)
|
||||
{
|
||||
this.body = body;
|
||||
this.title = title;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public void setBody(String body)
|
||||
{
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
{
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setStyle(String style)
|
||||
{
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
public Response getResponse()
|
||||
{
|
||||
return new Response(this.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return TEMPLATE.replace("{$BODY}", body).replace("{$TITLE}", title).replace("{$STYLE}", style);
|
||||
}
|
||||
}
|
@ -1,13 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Heartbeat;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Log;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_PlayerData;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ProtectedArea;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -23,7 +16,7 @@ public class TFM_BlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBurn(BlockBurnEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowFireSpread)
|
||||
if (!TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -32,7 +25,7 @@ public class TFM_BlockListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockIgnite(BlockIgniteEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowFirePlace)
|
||||
if (!TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -42,27 +35,29 @@ public class TFM_BlockListener implements Listener
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location block_pos = event.getBlock().getLocation();
|
||||
Location blockLocation = event.getBlock().getLocation();
|
||||
|
||||
if (TotalFreedomMod.nukeMonitor)
|
||||
if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Location player_pos = player.getLocation();
|
||||
Location playerLocation = player.getLocation();
|
||||
|
||||
boolean out_of_range = false;
|
||||
if (!player_pos.getWorld().equals(block_pos.getWorld()))
|
||||
final double nukeMonitorRange = TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
|
||||
|
||||
boolean outOfRange = false;
|
||||
if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
|
||||
{
|
||||
out_of_range = true;
|
||||
outOfRange = true;
|
||||
}
|
||||
else if (player_pos.distanceSquared(block_pos) > (TotalFreedomMod.nukeMonitorRange * TotalFreedomMod.nukeMonitorRange))
|
||||
else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
|
||||
{
|
||||
out_of_range = true;
|
||||
outOfRange = true;
|
||||
}
|
||||
|
||||
if (out_of_range)
|
||||
if (outOfRange)
|
||||
{
|
||||
if (playerdata.incrementAndGetFreecamDestroyCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
if (playerdata.incrementAndGetFreecamDestroyCount() > TFM_ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
||||
@ -77,11 +72,11 @@ public class TFM_BlockListener implements Listener
|
||||
Long lastRan = TFM_Heartbeat.getLastRan();
|
||||
if (lastRan == null || lastRan + TotalFreedomMod.HEARTBEAT_RATE * 1000L < System.currentTimeMillis())
|
||||
{
|
||||
//TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
// TFM_Log.warning("Heartbeat service timeout - can't check block place/break rates.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.incrementAndGetBlockDestroyCount() > TotalFreedomMod.nukeMonitorCountBreak)
|
||||
if (playerdata.incrementAndGetBlockDestroyCount() > TFM_ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||
@ -94,11 +89,11 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
|
||||
if (TFM_ProtectedArea.isInProtectedArea(blockLocation))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -106,37 +101,33 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
TFM_RollbackManager.blockBreak(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Location block_pos = event.getBlock().getLocation();
|
||||
Location blockLocation = event.getBlock().getLocation();
|
||||
|
||||
if (TotalFreedomMod.nukeMonitor)
|
||||
if (TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
Location player_pos = player.getLocation();
|
||||
Location playerLocation = player.getLocation();
|
||||
|
||||
boolean out_of_range = false;
|
||||
if (!player_pos.getWorld().equals(block_pos.getWorld()))
|
||||
double nukeMonitorRange = TFM_ConfigEntry.NUKE_MONITOR_RANGE.getDouble().doubleValue();
|
||||
|
||||
boolean outOfRange = false;
|
||||
if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
|
||||
{
|
||||
out_of_range = true;
|
||||
outOfRange = true;
|
||||
}
|
||||
else if (player_pos.distanceSquared(block_pos) > (TotalFreedomMod.nukeMonitorRange * TotalFreedomMod.nukeMonitorRange))
|
||||
else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
|
||||
{
|
||||
out_of_range = true;
|
||||
outOfRange = true;
|
||||
}
|
||||
|
||||
if (out_of_range)
|
||||
if (outOfRange)
|
||||
{
|
||||
if (playerdata.incrementAndGetFreecamPlaceCount() > TotalFreedomMod.freecamTriggerCount)
|
||||
if (playerdata.incrementAndGetFreecamPlaceCount() > TFM_ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
||||
@ -155,7 +146,7 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.incrementAndGetBlockPlaceCount() > TotalFreedomMod.nukeMonitorCountPlace)
|
||||
if (playerdata.incrementAndGetBlockPlaceCount() > TFM_ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||
{
|
||||
TFM_Util.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||
TFM_Util.autoEject(player, "You are placing blocks too fast.");
|
||||
@ -168,11 +159,11 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
if (TFM_ProtectedArea.isInProtectedArea(block_pos))
|
||||
if (TFM_ProtectedArea.isInProtectedArea(blockLocation))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -185,7 +176,7 @@ public class TFM_BlockListener implements Listener
|
||||
case LAVA:
|
||||
case STATIONARY_LAVA:
|
||||
{
|
||||
if (TotalFreedomMod.allowLavaPlace)
|
||||
if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed lava @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
@ -203,7 +194,7 @@ public class TFM_BlockListener implements Listener
|
||||
case WATER:
|
||||
case STATIONARY_WATER:
|
||||
{
|
||||
if (TotalFreedomMod.allowWaterPlace)
|
||||
if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed water @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
@ -220,7 +211,7 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
case FIRE:
|
||||
{
|
||||
if (TotalFreedomMod.allowFirePlace)
|
||||
if (TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed fire @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
@ -237,7 +228,7 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
case TNT:
|
||||
{
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
TFM_Log.info(String.format("%s placed TNT @ %s", player.getName(), TFM_Util.formatLocation(event.getBlock().getLocation())));
|
||||
|
||||
@ -255,16 +246,28 @@ public class TFM_BlockListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(event.getPlayer()))
|
||||
{
|
||||
TFM_RollbackManager.blockBreak(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onRollbackBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(event.getPlayer()))
|
||||
{
|
||||
TFM_RollbackManager.blockPlace(event);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockFromTo(BlockFromToEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowFliudSpread)
|
||||
if (!TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -12,7 +12,7 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowExplosions)
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -24,19 +24,19 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowExplosions)
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
event.setRadius((float) TotalFreedomMod.explosiveRadius);
|
||||
event.setRadius((float) TFM_ConfigEntry.EXPLOSIVE_RADIUS.getDouble().doubleValue());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
{
|
||||
if (!TotalFreedomMod.allowExplosions)
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class TFM_EntityListener implements Listener
|
||||
{
|
||||
case LAVA:
|
||||
{
|
||||
if (!TotalFreedomMod.allowLavaDamage)
|
||||
if (!TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -57,7 +57,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.petProtectEnabled)
|
||||
if (TFM_ConfigEntry.PET_PROTECT_ENABLED.getBoolean())
|
||||
{
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Tameable)
|
||||
@ -73,7 +73,7 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterEnabled)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
||||
{
|
||||
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.EGG))
|
||||
{
|
||||
@ -85,7 +85,7 @@ public class TFM_EntityListener implements Listener
|
||||
|
||||
if (spawned instanceof EnderDragon)
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterDisableDragon)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -93,7 +93,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
else if (spawned instanceof Ghast)
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterDisableGhast)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -101,7 +101,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
else if (spawned instanceof Slime)
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterDisableSlime)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -109,7 +109,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
else if (spawned instanceof Giant)
|
||||
{
|
||||
if (TotalFreedomMod.mobLimiterDisableGiant)
|
||||
if (TFM_ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -121,7 +121,9 @@ public class TFM_EntityListener implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.mobLimiterMax > 0)
|
||||
int mobLimiterMax = TFM_ConfigEntry.MOB_LIMITER_MAX.getInteger().intValue();
|
||||
|
||||
if (mobLimiterMax > 0)
|
||||
{
|
||||
int mobcount = 0;
|
||||
|
||||
@ -133,7 +135,7 @@ public class TFM_EntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (mobcount > TotalFreedomMod.mobLimiterMax)
|
||||
if (mobcount > mobLimiterMax)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -144,7 +146,7 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
if (TotalFreedomMod.autoEntityWipe)
|
||||
if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||
{
|
||||
event.setDroppedExp(0);
|
||||
}
|
||||
@ -153,7 +155,7 @@ public class TFM_EntityListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onProjectileHit(ProjectileHitEvent event)
|
||||
{
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
Projectile entity = event.getEntity();
|
||||
if (event.getEntityType() == EntityType.ARROW && entity.getShooter() instanceof Player)
|
||||
|
@ -7,6 +7,8 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.*;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.EntryType;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_RollbackManager.RollbackEntry;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -35,7 +37,8 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
|
||||
switch (event.getAction())
|
||||
{
|
||||
@ -46,37 +49,46 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
case WATER_BUCKET:
|
||||
{
|
||||
if (!TotalFreedomMod.allowWaterPlace)
|
||||
if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LAVA_BUCKET:
|
||||
{
|
||||
if (!TotalFreedomMod.allowLavaPlace)
|
||||
if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EXPLOSIVE_MINECART:
|
||||
{
|
||||
if (!TotalFreedomMod.allowTntMinecarts)
|
||||
if (TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
{
|
||||
@ -84,9 +96,38 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
case STICK:
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.mobThrowerEnabled())
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
final Location location = player.getTargetBlock(null, 5).getLocation();
|
||||
final List<RollbackEntry> entries = TFM_RollbackManager.getEntriesAtLocation(location);
|
||||
|
||||
if (entries.isEmpty())
|
||||
{
|
||||
TFM_Util.playerMsg(player, "No block edits at that location.");
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.playerMsg(player, "Block edits at (" + ChatColor.WHITE + "x" + location.getBlockX() + ", y" + location.getBlockY() + ", z" + location.getBlockZ() + ChatColor.BLUE + ")" + ChatColor.WHITE + ":", ChatColor.BLUE);
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
TFM_Util.playerMsg(player, " - " + ChatColor.BLUE + entry.author + " " + entry.getType() + " " + StringUtils.capitalize(entry.getMaterial().toString().toLowerCase()) + (entry.data == 0 ? "" : ":" + entry.data));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case BONE:
|
||||
{
|
||||
if (!playerdata.mobThrowerEnabled())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location player_pos = player.getLocation();
|
||||
Vector direction = player_pos.getDirection().normalize();
|
||||
|
||||
@ -95,14 +136,18 @@ public class TFM_PlayerListener implements Listener
|
||||
playerdata.enqueueMob(rezzed_mob);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SULPHUR:
|
||||
{
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
if (playerdata.isMP44Armed())
|
||||
if (!playerdata.isMP44Armed())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (playerdata.toggleMP44Firing())
|
||||
{
|
||||
playerdata.startArrowShooter(TotalFreedomMod.plugin);
|
||||
@ -111,17 +156,22 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
playerdata.stopArrowShooter();
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case BLAZE_ROD:
|
||||
{
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
break;
|
||||
}
|
||||
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
Block targetBlock;
|
||||
|
||||
if (event.getAction().equals(Action.LEFT_CLICK_AIR))
|
||||
@ -133,52 +183,55 @@ public class TFM_PlayerListener implements Listener
|
||||
targetBlock = event.getClickedBlock();
|
||||
}
|
||||
|
||||
if (targetBlock != null)
|
||||
{
|
||||
player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
}
|
||||
else
|
||||
if (targetBlock == null)
|
||||
{
|
||||
player.sendMessage("Can't resolve target block.");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
player.getWorld().createExplosion(targetBlock.getLocation(), 4F, true);
|
||||
player.getWorld().strikeLightning(targetBlock.getLocation());
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CARROT:
|
||||
{
|
||||
if (TotalFreedomMod.allowExplosions)
|
||||
if (!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
Location player_location = player.getLocation().clone();
|
||||
break;
|
||||
}
|
||||
|
||||
Vector player_pos = player_location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
||||
Vector player_dir = player_location.getDirection().normalize();
|
||||
if (!TFM_SuperadminList.isSeniorAdmin(player, true))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().clone();
|
||||
|
||||
Vector playerPostion = location.toVector().add(new Vector(0.0, 1.65, 0.0));
|
||||
Vector playerDirection = location.getDirection().normalize();
|
||||
|
||||
double distance = 150.0;
|
||||
Block targetBlock = player.getTargetBlock(null, Math.round((float) distance));
|
||||
if (targetBlock != null)
|
||||
{
|
||||
distance = player_location.distance(targetBlock.getLocation());
|
||||
distance = location.distance(targetBlock.getLocation());
|
||||
}
|
||||
|
||||
final List<Block> affected = new ArrayList<Block>();
|
||||
|
||||
Block last_block = null;
|
||||
Block lastBlock = null;
|
||||
for (double offset = 0.0; offset <= distance; offset += (distance / 25.0))
|
||||
{
|
||||
Block test_block = player_pos.clone().add(player_dir.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
||||
Block block = playerPostion.clone().add(playerDirection.clone().multiply(offset)).toLocation(player.getWorld()).getBlock();
|
||||
|
||||
if (!test_block.equals(last_block))
|
||||
if (!block.equals(lastBlock))
|
||||
{
|
||||
if (test_block.isEmpty())
|
||||
if (block.isEmpty())
|
||||
{
|
||||
affected.add(test_block);
|
||||
test_block.setType(Material.TNT);
|
||||
affected.add(block);
|
||||
block.setType(Material.TNT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -186,7 +239,7 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
last_block = test_block;
|
||||
lastBlock = block;
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
@ -194,18 +247,16 @@ public class TFM_PlayerListener implements Listener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for (Block tnt_block : affected)
|
||||
for (Block tntBlock : affected)
|
||||
{
|
||||
TNTPrimed tnt_primed = tnt_block.getWorld().spawn(tnt_block.getLocation(), TNTPrimed.class);
|
||||
tnt_primed.setFuseTicks(5);
|
||||
tnt_block.setType(Material.AIR);
|
||||
TNTPrimed tnt = tntBlock.getWorld().spawn(tntBlock.getLocation(), TNTPrimed.class);
|
||||
tnt.setFuseTicks(5);
|
||||
tntBlock.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 30L);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -247,52 +298,52 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet())
|
||||
{
|
||||
Player fuckoff_player = fuckoff.getKey();
|
||||
Player fuckoffPlayer = fuckoff.getKey();
|
||||
|
||||
if (fuckoff_player.equals(player) || !fuckoff_player.isOnline())
|
||||
if (fuckoffPlayer.equals(player) || !fuckoffPlayer.isOnline())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double fuckoff_range = fuckoff.getValue().doubleValue();
|
||||
double fuckoffRange = fuckoff.getValue().doubleValue();
|
||||
|
||||
Location mover_pos = player.getLocation();
|
||||
Location fuckoff_pos = fuckoff_player.getLocation();
|
||||
Location playerLocation = player.getLocation();
|
||||
Location fuckoffLocation = fuckoffPlayer.getLocation();
|
||||
|
||||
double distanceSquared;
|
||||
try
|
||||
{
|
||||
distanceSquared = mover_pos.distanceSquared(fuckoff_pos);
|
||||
distanceSquared = playerLocation.distanceSquared(fuckoffLocation);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (distanceSquared < (fuckoff_range * fuckoff_range))
|
||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||
{
|
||||
event.setTo(fuckoff_pos.clone().add(mover_pos.subtract(fuckoff_pos).toVector().normalize().multiply(fuckoff_range * 1.1)));
|
||||
event.setTo(fuckoffLocation.clone().add(playerLocation.subtract(fuckoffLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean do_freeze = false;
|
||||
boolean freeze = false;
|
||||
if (TotalFreedomMod.allPlayersFrozen)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
do_freeze = true;
|
||||
freeze = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata.isFrozen())
|
||||
{
|
||||
do_freeze = true;
|
||||
freeze = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_freeze)
|
||||
if (freeze)
|
||||
{
|
||||
Location freezeTo = to.clone();
|
||||
|
||||
@ -307,23 +358,23 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
Location targetPos = player.getLocation().add(0, 1, 0);
|
||||
|
||||
boolean out_of_cage;
|
||||
boolean outOfCage;
|
||||
if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld()))
|
||||
{
|
||||
out_of_cage = true;
|
||||
outOfCage = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
out_of_cage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
outOfCage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5);
|
||||
}
|
||||
|
||||
if (out_of_cage)
|
||||
if (outOfCage)
|
||||
{
|
||||
playerdata.setCaged(true, targetPos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
||||
TFM_Util.generateCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateHollowCube(targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER));
|
||||
TFM_Util.generateCube(targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER));
|
||||
}
|
||||
}
|
||||
@ -341,43 +392,51 @@ public class TFM_PlayerListener implements Listener
|
||||
TFM_Jumppads.getInstance().PlayerMoveEvent(event);
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions)
|
||||
if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator();
|
||||
while (landmines.hasNext())
|
||||
{
|
||||
TFM_LandmineData landmine = landmines.next();
|
||||
|
||||
Location landmine_pos = landmine.landmine_pos;
|
||||
if (landmine_pos.getBlock().getType() != Material.TNT)
|
||||
Location location = landmine.location;
|
||||
if (location.getBlock().getType() != Material.TNT)
|
||||
{
|
||||
landmines.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!landmine.player.equals(player))
|
||||
if (landmine.player.equals(player))
|
||||
{
|
||||
if (player.getWorld().equals(landmine_pos.getWorld()))
|
||||
{
|
||||
if (player.getLocation().distanceSquared(landmine_pos) <= (landmine.radius * landmine.radius))
|
||||
{
|
||||
landmine.landmine_pos.getBlock().setType(Material.AIR);
|
||||
break;
|
||||
}
|
||||
|
||||
TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class);
|
||||
if (!player.getWorld().equals(location.getWorld()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
landmine.location.getBlock().setType(Material.AIR);
|
||||
|
||||
TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class);
|
||||
tnt1.setFuseTicks(40);
|
||||
tnt1.setPassenger(player);
|
||||
tnt1.setVelocity(new Vector(0.0, 2.0, 0.0));
|
||||
|
||||
TNTPrimed tnt2 = landmine_pos.getWorld().spawn(player.getLocation(), TNTPrimed.class);
|
||||
TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class);
|
||||
tnt2.setFuseTicks(1);
|
||||
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
landmines.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -424,6 +483,7 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
playerdata.setLastMessage(message);
|
||||
|
||||
// Check for muted
|
||||
@ -435,11 +495,9 @@ public class TFM_PlayerListener implements Listener
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
playerdata.setMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Strip color from messages
|
||||
message = ChatColor.stripColor(message);
|
||||
@ -526,9 +584,9 @@ public class TFM_PlayerListener implements Listener
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
for (String test_command : BLOCKED_MUTED_CMDS)
|
||||
for (String commandName : BLOCKED_MUTED_CMDS)
|
||||
{
|
||||
if (Pattern.compile("^/" + test_command.toLowerCase() + " ").matcher(command).find())
|
||||
if (Pattern.compile("^/" + commandName.toLowerCase() + " ").matcher(command).find())
|
||||
{
|
||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||
event.setCancelled(true);
|
||||
@ -542,7 +600,7 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.preprocessLogEnabled)
|
||||
if (TFM_ConfigEntry.PREPROCESS_LOG_ENABLED.getBoolean())
|
||||
{
|
||||
TFM_Log.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), command), true);
|
||||
}
|
||||
@ -550,7 +608,7 @@ public class TFM_PlayerListener implements Listener
|
||||
command = command.toLowerCase().trim();
|
||||
|
||||
// Blocked commands
|
||||
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(command, event.getPlayer()))
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(command, event.getPlayer()))
|
||||
{
|
||||
// CommandBlocker handles messages and broadcasts
|
||||
event.setCancelled(true);
|
||||
@ -571,7 +629,7 @@ public class TFM_PlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||
{
|
||||
if (TotalFreedomMod.autoEntityWipe)
|
||||
if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||
{
|
||||
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
||||
{
|
||||
@ -629,13 +687,13 @@ public class TFM_PlayerListener implements Listener
|
||||
|
||||
TFM_UserList.getInstance(TotalFreedomMod.plugin).addUser(player);
|
||||
|
||||
boolean superadmin_impostor = TFM_SuperadminList.isSuperadminImpostor(player);
|
||||
boolean impostor = TFM_SuperadminList.isSuperadminImpostor(player);
|
||||
|
||||
if (superadmin_impostor || TFM_SuperadminList.isUserSuperadmin(player))
|
||||
if (impostor || TFM_SuperadminList.isUserSuperadmin(player))
|
||||
{
|
||||
TFM_Util.bcastMsg(ChatColor.AQUA + player.getName() + " is " + TFM_Util.getRank(player));
|
||||
|
||||
if (superadmin_impostor)
|
||||
if (impostor)
|
||||
{
|
||||
player.getInventory().clear();
|
||||
player.setOp(false);
|
||||
@ -661,7 +719,7 @@ public class TFM_PlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.adminOnlyMode)
|
||||
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
{
|
||||
new BukkitRunnable()
|
||||
{
|
||||
|
@ -3,11 +3,11 @@ package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlockerNew;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_CommandBlocker;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ServerInterface;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_Util;
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
@ -52,7 +52,7 @@ public class TFM_ServerListener implements Listener
|
||||
topLevelCommand = topLevelCommand.toLowerCase().trim();
|
||||
|
||||
// We need to make it look like the command is coming from the console, so keep the player's name without the Player instance via dummy:
|
||||
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(topLevelCommand, new TFM_ServerListener_DummyCommandSender(player.getName()), false))
|
||||
{
|
||||
player.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
||||
event.setCancelled(true);
|
||||
@ -64,7 +64,7 @@ public class TFM_ServerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onRemoteServerCommand(RemoteServerCommandEvent event)
|
||||
{
|
||||
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCommand("");
|
||||
}
|
||||
@ -73,7 +73,7 @@ public class TFM_ServerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onServerCommand(ServerCommandEvent event)
|
||||
{
|
||||
if (TFM_CommandBlockerNew.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
if (TFM_CommandBlocker.getInstance().isCommandBlocked(event.getCommand(), event.getSender()))
|
||||
{
|
||||
event.setCommand("");
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class TFM_ServerListener implements Listener
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "You are banned.");
|
||||
}
|
||||
else if (TotalFreedomMod.adminOnlyMode)
|
||||
else if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
{
|
||||
event.setMotd(ChatColor.RED + "Server is closed.");
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.StevenLawson.TotalFreedomMod.Listener;
|
||||
|
||||
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_AdminWorld;
|
||||
import me.StevenLawson.TotalFreedomMod.TFM_ConfigEntry;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -12,7 +13,18 @@ public class TFM_WeatherListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onThunderChange(ThunderChangeEvent event)
|
||||
{
|
||||
if (event.toThunderState() && TotalFreedomMod.disableWeather)
|
||||
try
|
||||
{
|
||||
if (event.getWorld() == TFM_AdminWorld.getInstance().getWorld() && TFM_AdminWorld.getInstance().getWeatherMode() != TFM_AdminWorld.WeatherMode.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (event.toThunderState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -22,7 +34,18 @@ public class TFM_WeatherListener implements Listener
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onWeatherChange(WeatherChangeEvent event)
|
||||
{
|
||||
if (event.toWeatherState() && TotalFreedomMod.disableWeather)
|
||||
try
|
||||
{
|
||||
if (event.getWorld() == TFM_AdminWorld.getInstance().getWorld() && TFM_AdminWorld.getInstance().getWeatherMode() != TFM_AdminWorld.WeatherMode.OFF)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (event.toWeatherState() && TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -1,13 +1,13 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,41 +15,143 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TFM_AdminWorld
|
||||
public final class TFM_AdminWorld extends TFM_CustomWorld
|
||||
{
|
||||
private static final long CACHE_CLEAR_FREQUENCY = 30L * 1000L; //30 seconds, milliseconds
|
||||
private static final long TP_COOLDOWN_TIME = 500L; //0.5 seconds, milliseconds
|
||||
private static final String GENERATION_PARAMETERS = "16,stone,32,dirt,1,grass";
|
||||
private static final String ADMINWORLD_NAME = "adminworld";
|
||||
private static final String GENERATION_PARAMETERS = TFM_ConfigEntry.FLATLANDS_GENERATION_PARAMS.getString();
|
||||
private static final String WORLD_NAME = "adminworld";
|
||||
//
|
||||
private final Map<Player, Long> teleportCooldown = new HashMap<Player, Long>();
|
||||
private final Map<CommandSender, Boolean> superadminCache = new HashMap<CommandSender, Boolean>();
|
||||
private final Map<CommandSender, Boolean> accessCache = new HashMap<CommandSender, Boolean>();
|
||||
//
|
||||
private Long cacheLastCleared = null;
|
||||
private World adminWorld = null;
|
||||
private Map<Player, Player> guestList = new HashMap<Player, Player>();
|
||||
private WeatherMode weatherMode = WeatherMode.OFF;
|
||||
private TimeOfDay timeOfDay = TimeOfDay.INHERIT;
|
||||
|
||||
private TFM_AdminWorld()
|
||||
{
|
||||
}
|
||||
|
||||
public void sendToAdminWorld(Player player)
|
||||
@Override
|
||||
public void sendToWorld(Player player)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(player))
|
||||
if (!canAccessWorld(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(getAdminWorld().getSpawnLocation());
|
||||
super.sendToWorld(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected World generateWorld()
|
||||
{
|
||||
WorldCreator worldCreator = new WorldCreator(WORLD_NAME);
|
||||
worldCreator.generateStructures(false);
|
||||
worldCreator.type(WorldType.NORMAL);
|
||||
worldCreator.environment(World.Environment.NORMAL);
|
||||
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||
|
||||
World world = Bukkit.getServer().createWorld(worldCreator);
|
||||
|
||||
world.setSpawnFlags(false, false);
|
||||
world.setSpawnLocation(0, 50, 0);
|
||||
|
||||
Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
public boolean addGuest(Player guest, Player supervisor)
|
||||
{
|
||||
if (guest == supervisor || TFM_SuperadminList.isUserSuperadmin(guest))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TFM_SuperadminList.isUserSuperadmin(supervisor))
|
||||
{
|
||||
guestList.put(guest, supervisor);
|
||||
wipeAccessCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public Player removeGuest(Player guest)
|
||||
{
|
||||
Player player = guestList.remove(guest);
|
||||
wipeAccessCache();
|
||||
return player;
|
||||
}
|
||||
|
||||
public Player removeGuest(String partialName)
|
||||
{
|
||||
partialName = partialName.toLowerCase().trim();
|
||||
Iterator<Player> it = guestList.values().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Player player = it.next();
|
||||
if (player.getName().toLowerCase().trim().contains(partialName))
|
||||
{
|
||||
return removeGuest(player);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String guestListToString()
|
||||
{
|
||||
List<String> output = new ArrayList<String>();
|
||||
Iterator<Map.Entry<Player, Player>> it = guestList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
Map.Entry<Player, Player> entry = it.next();
|
||||
Player player = entry.getKey();
|
||||
Player supervisor = entry.getValue();
|
||||
output.add(player.getName() + " (Supervisor: " + supervisor.getName() + ")");
|
||||
}
|
||||
return StringUtils.join(output, ", ");
|
||||
}
|
||||
|
||||
public void purgeGuestList()
|
||||
{
|
||||
guestList.clear();
|
||||
wipeAccessCache();
|
||||
}
|
||||
|
||||
public boolean validateMovement(PlayerMoveEvent event)
|
||||
{
|
||||
if (adminWorld != null)
|
||||
World world;
|
||||
try
|
||||
{
|
||||
if (event.getTo().getWorld() == adminWorld)
|
||||
world = getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (world != null && event.getTo().getWorld() == world)
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
if (!cachedIsUserSuperadmin(player))
|
||||
if (!canAccessWorld(player))
|
||||
{
|
||||
Long lastTP = teleportCooldown.get(player);
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
@ -70,71 +172,163 @@ public class TFM_AdminWorld
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public World getAdminWorld()
|
||||
{
|
||||
if (adminWorld == null || !Bukkit.getWorlds().contains(adminWorld))
|
||||
{
|
||||
generateWorld();
|
||||
}
|
||||
|
||||
return adminWorld;
|
||||
}
|
||||
|
||||
public void wipeSuperadminCache()
|
||||
public void wipeAccessCache()
|
||||
{
|
||||
cacheLastCleared = System.currentTimeMillis();
|
||||
superadminCache.clear();
|
||||
accessCache.clear();
|
||||
}
|
||||
|
||||
private boolean cachedIsUserSuperadmin(CommandSender user)
|
||||
public boolean canAccessWorld(final Player player)
|
||||
{
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
if (cacheLastCleared == null || cacheLastCleared.longValue() + CACHE_CLEAR_FREQUENCY <= currentTimeMillis)
|
||||
{
|
||||
cacheLastCleared = currentTimeMillis;
|
||||
superadminCache.clear();
|
||||
accessCache.clear();
|
||||
}
|
||||
|
||||
Boolean cached = superadminCache.get(user);
|
||||
Boolean cached = accessCache.get(player);
|
||||
if (cached == null)
|
||||
{
|
||||
cached = TFM_SuperadminList.isUserSuperadmin(user);
|
||||
superadminCache.put(user, cached);
|
||||
boolean canAccess = TFM_SuperadminList.isUserSuperadmin(player);
|
||||
if (!canAccess)
|
||||
{
|
||||
Player supervisor = guestList.get(player);
|
||||
canAccess = supervisor != null && supervisor.isOnline() && TFM_SuperadminList.isUserSuperadmin(supervisor);
|
||||
if (!canAccess)
|
||||
{
|
||||
guestList.remove(player);
|
||||
}
|
||||
}
|
||||
cached = canAccess;
|
||||
accessCache.put(player, cached);
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
private void generateWorld()
|
||||
public static enum WeatherMode
|
||||
{
|
||||
WorldCreator adminWorldCreator = new WorldCreator(ADMINWORLD_NAME);
|
||||
adminWorldCreator.generateStructures(false);
|
||||
adminWorldCreator.type(WorldType.NORMAL);
|
||||
adminWorldCreator.environment(World.Environment.NORMAL);
|
||||
adminWorldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||
OFF("off"),
|
||||
RAIN("rain"),
|
||||
STORM("storm,thunderstorm");
|
||||
//
|
||||
private final List<String> aliases;
|
||||
|
||||
adminWorld = Bukkit.getServer().createWorld(adminWorldCreator);
|
||||
private WeatherMode(String aliases)
|
||||
{
|
||||
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
|
||||
}
|
||||
|
||||
adminWorld.setSpawnFlags(false, false);
|
||||
adminWorld.setSpawnLocation(0, 50, 0);
|
||||
private void setWorldToWeather(World world)
|
||||
{
|
||||
world.setStorm(this == RAIN || this == STORM);
|
||||
world.setWeatherDuration(this == RAIN || this == STORM ? 20 * 60 * 5 : 0);
|
||||
|
||||
Block welcomeSignBlock = adminWorld.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
|
||||
world.setThundering(this == STORM);
|
||||
world.setThunderDuration(this == STORM ? 20 * 60 * 5 : 0);
|
||||
}
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
public static WeatherMode getByAlias(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase();
|
||||
for (WeatherMode mode : values())
|
||||
{
|
||||
if (mode.aliases.contains(needle))
|
||||
{
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
public static enum TimeOfDay
|
||||
{
|
||||
INHERIT(),
|
||||
SUNRISE("sunrise,morning", 0),
|
||||
NOON("noon,midday,day", 6000),
|
||||
SUNSET("sunset,evening", 12000),
|
||||
MIDNIGHT("midnight,night", 18000);
|
||||
//
|
||||
private final int timeTicks;
|
||||
private final List<String> aliases;
|
||||
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
private TimeOfDay()
|
||||
{
|
||||
this.timeTicks = 0;
|
||||
this.aliases = null;
|
||||
}
|
||||
|
||||
private TimeOfDay(String aliases, int timeTicks)
|
||||
{
|
||||
this.timeTicks = timeTicks;
|
||||
this.aliases = Arrays.asList(StringUtils.split(aliases, ","));
|
||||
}
|
||||
|
||||
public int getTimeTicks()
|
||||
{
|
||||
return timeTicks;
|
||||
}
|
||||
|
||||
public void setWorldToTime(World world)
|
||||
{
|
||||
long time = world.getTime();
|
||||
time -= time % 24000;
|
||||
world.setTime(time + 24000 + getTimeTicks());
|
||||
}
|
||||
|
||||
public static TimeOfDay getByAlias(String needle)
|
||||
{
|
||||
needle = needle.toLowerCase();
|
||||
for (TimeOfDay time : values())
|
||||
{
|
||||
if (time.aliases != null && time.aliases.contains(needle))
|
||||
{
|
||||
return time;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public WeatherMode getWeatherMode()
|
||||
{
|
||||
return weatherMode;
|
||||
}
|
||||
|
||||
public void setWeatherMode(final WeatherMode weatherMode)
|
||||
{
|
||||
this.weatherMode = weatherMode;
|
||||
|
||||
try
|
||||
{
|
||||
weatherMode.setWorldToWeather(getWorld());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public TimeOfDay getTimeOfDay()
|
||||
{
|
||||
return timeOfDay;
|
||||
}
|
||||
|
||||
public void setTimeOfDay(final TimeOfDay timeOfDay)
|
||||
{
|
||||
this.timeOfDay = timeOfDay;
|
||||
|
||||
try
|
||||
{
|
||||
timeOfDay.setWorldToTime(getWorld());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_AdminWorld getInstance()
|
||||
|
@ -1,5 +1,10 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
@ -9,98 +14,148 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlocker
|
||||
{
|
||||
public static boolean isCommandBlocked(String usedcommand, CommandSender sender)
|
||||
{
|
||||
private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
|
||||
|
||||
String name = sender.getName();
|
||||
usedcommand = usedcommand.toLowerCase().trim();
|
||||
|
||||
for (String blocked_command : TotalFreedomMod.blockedCommands)
|
||||
private TFM_CommandBlocker()
|
||||
{
|
||||
String[] parts = blocked_command.split(":");
|
||||
parseBlockingRules();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void parseBlockingRules()
|
||||
{
|
||||
blockedCommands.clear();
|
||||
|
||||
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
TFM_Log.severe("Error loading commandMap.");
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> _blockedCommands = (List<String>) TFM_ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||
for (String rawEntry : _blockedCommands)
|
||||
{
|
||||
String[] parts = rawEntry.split(":");
|
||||
if (parts.length < 3 || parts.length > 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(usedcommand + " ").startsWith(parts[2] + " "))
|
||||
{
|
||||
|
||||
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
|
||||
if (commandMap == null)
|
||||
CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
||||
if (rank == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Command command = commandMap.getCommand(parts[2].replaceAll("/", ""));
|
||||
CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
||||
if (action == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String command = parts[2];
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
||||
if (matcher.find())
|
||||
{
|
||||
command = matcher.group(1);
|
||||
if (command == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean block = false;
|
||||
for (String alias : command.getAliases())
|
||||
else
|
||||
{
|
||||
if (usedcommand.replaceAll("/", "").startsWith(alias))
|
||||
{
|
||||
block = true;
|
||||
break;
|
||||
command = command.toLowerCase().trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (!block)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (SenderRank.hasPermissions(sender, parts[0]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Past this line indicates that the command is blocked.
|
||||
|
||||
// Optional: Send a message
|
||||
if (parts.length == 4)
|
||||
{
|
||||
if ("_".equals(parts[3]))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "That command is blocked.");
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + TFM_Util.colorise(parts[3]));
|
||||
continue;
|
||||
}
|
||||
|
||||
String message = null;
|
||||
if (parts.length == 4)
|
||||
{
|
||||
message = parts[3];
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
|
||||
|
||||
Command bukkitCommand = commandMap.getCommand(command);
|
||||
if (bukkitCommand == null)
|
||||
{
|
||||
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
|
||||
|
||||
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
|
||||
for (String alias : bukkitCommand.getAliases())
|
||||
{
|
||||
//TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Action
|
||||
if ("b".equals(parts[1]))
|
||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||
{
|
||||
return true;
|
||||
return isCommandBlocked(command, sender, true);
|
||||
}
|
||||
else if ("a".equals(parts[1]))
|
||||
|
||||
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||
{
|
||||
if (SenderRank.getSenderRank(sender).rank < 2) // Only auto-eject Ops and non-ops
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + usedcommand);
|
||||
TFM_Util.bcastMsg(name + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if ("u".equals(parts[1]))
|
||||
{
|
||||
sender.sendMessage("Unknown command. Type \"help\" for help.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
||||
if (matcher.find())
|
||||
{
|
||||
command = matcher.group(1);
|
||||
if (command == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
command = command.toLowerCase().trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
|
||||
|
||||
if (blockedCommandEntry != null)
|
||||
{
|
||||
if (!blockedCommandEntry.getRank().hasPermission(sender))
|
||||
{
|
||||
if (doAction)
|
||||
{
|
||||
blockedCommandEntry.doActions(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public enum SenderRank
|
||||
private static enum CommandBlockerRank
|
||||
{
|
||||
ANYONE("a", 0),
|
||||
OP("o", 1),
|
||||
@ -108,57 +163,169 @@ public class TFM_CommandBlocker
|
||||
TELNET("t", 3),
|
||||
SENIOR("c", 4),
|
||||
NOBODY("n", 5);
|
||||
private String letter = "n";
|
||||
private int rank = 5;
|
||||
private final String token;
|
||||
private final int level;
|
||||
|
||||
SenderRank(String letter, int rank)
|
||||
private CommandBlockerRank(String token, int level)
|
||||
{
|
||||
this.letter = letter;
|
||||
this.rank = rank;
|
||||
this.token = token;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public static boolean hasPermissions(CommandSender sender, String letter)
|
||||
public String getToken()
|
||||
{
|
||||
return (getSenderRank(sender).rank >= getSenderRankByLetter(letter).rank);
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public static SenderRank getSenderRank(CommandSender sender)
|
||||
public boolean hasPermission(CommandSender sender)
|
||||
{
|
||||
if (!(sender instanceof Player))
|
||||
return getSenderRank(sender).level >= this.level;
|
||||
}
|
||||
|
||||
public static CommandBlockerRank getSenderRank(CommandSender sender)
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
return SenderRank.SENIOR;
|
||||
if (sender.isOp())
|
||||
{
|
||||
return OP;
|
||||
}
|
||||
|
||||
return ANYONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SenderRank.TELNET;
|
||||
if (TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
{
|
||||
return SENIOR;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return TELNET;
|
||||
}
|
||||
|
||||
return SUPER;
|
||||
}
|
||||
}
|
||||
|
||||
if (TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
public static CommandBlockerRank fromToken(String token)
|
||||
{
|
||||
return SenderRank.SUPER;
|
||||
}
|
||||
|
||||
if (sender.isOp())
|
||||
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||
{
|
||||
return SenderRank.OP;
|
||||
}
|
||||
|
||||
return SenderRank.ANYONE;
|
||||
}
|
||||
|
||||
public static SenderRank getSenderRankByLetter(String letter)
|
||||
{
|
||||
for (SenderRank rank : SenderRank.values())
|
||||
{
|
||||
if (letter.equals(rank.letter))
|
||||
if (rank.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return SenderRank.NOBODY;
|
||||
return ANYONE;
|
||||
}
|
||||
}
|
||||
|
||||
private enum CommandBlockerAction
|
||||
{
|
||||
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
|
||||
private final String token;
|
||||
|
||||
private CommandBlockerAction(String token)
|
||||
{
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public static CommandBlockerAction fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||
{
|
||||
if (action.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlocker_BlockedCommandEntry
|
||||
{
|
||||
private final CommandBlockerRank rank;
|
||||
private final CommandBlockerAction action;
|
||||
private String command;
|
||||
private final String message;
|
||||
|
||||
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||
{
|
||||
this.rank = rank;
|
||||
this.action = action;
|
||||
this.command = command;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CommandBlockerAction getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public CommandBlockerRank getRank()
|
||||
{
|
||||
return this.rank;
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
private void doActions(CommandSender sender)
|
||||
{
|
||||
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||
{
|
||||
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
|
||||
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
String response;
|
||||
|
||||
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||
{
|
||||
response = "Unknown command. Type \"help\" for help.";
|
||||
}
|
||||
else if (this.message == null || "_".equals(this.message))
|
||||
{
|
||||
response = ChatColor.GRAY + "That command is blocked.";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = ChatColor.GRAY + TFM_Util.colorise(this.message);
|
||||
}
|
||||
|
||||
sender.sendMessage(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandBlocker getInstance()
|
||||
{
|
||||
return TFM_CommandBlockerNewHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlockerNewHolder
|
||||
{
|
||||
private static final TFM_CommandBlocker INSTANCE = new TFM_CommandBlocker();
|
||||
}
|
||||
}
|
||||
|
@ -1,328 +0,0 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TFM_CommandBlockerNew
|
||||
{
|
||||
private Map<String, TFM_CommandBlocker_BlockedCommandEntry> blockedCommands = new HashMap<String, TFM_CommandBlocker_BlockedCommandEntry>();
|
||||
|
||||
private TFM_CommandBlockerNew()
|
||||
{
|
||||
parseBlockingRules();
|
||||
}
|
||||
|
||||
public final void parseBlockingRules()
|
||||
{
|
||||
blockedCommands.clear();
|
||||
|
||||
CommandMap commandMap = TFM_CommandLoader.getInstance().getCommandMap();
|
||||
if (commandMap == null)
|
||||
{
|
||||
TFM_Log.severe("Error loading commandMap.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String rawEntry : TotalFreedomMod.blockedCommands)
|
||||
{
|
||||
String[] parts = rawEntry.split(":");
|
||||
if (parts.length < 3 || parts.length > 4)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
||||
if (rank == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
||||
if (action == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String command = parts[2];
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
||||
if (matcher.find())
|
||||
{
|
||||
command = matcher.group(1);
|
||||
if (command == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
command = command.toLowerCase().trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String message = null;
|
||||
if (parts.length == 4)
|
||||
{
|
||||
message = parts[3];
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = new TFM_CommandBlocker_BlockedCommandEntry(rank, action, command, message);
|
||||
|
||||
Command bukkitCommand = commandMap.getCommand(command);
|
||||
if (bukkitCommand == null)
|
||||
{
|
||||
//TFM_Log.info("Blocking unknown command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
blockedCommandEntry.setCommand(bukkitCommand.getName().toLowerCase());
|
||||
|
||||
//TFM_Log.info("Blocking command: " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||
|
||||
for (String alias : bukkitCommand.getAliases())
|
||||
{
|
||||
//TFM_Log.info("Blocking alias: " + alias.toLowerCase() + " of " + blockedCommandEntry.getCommand());
|
||||
blockedCommands.put(alias.toLowerCase(), blockedCommandEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||
{
|
||||
return isCommandBlocked(command, sender, true);
|
||||
}
|
||||
|
||||
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Matcher matcher = Pattern.compile("^/?(\\S+)").matcher(command);
|
||||
if (matcher.find())
|
||||
{
|
||||
command = matcher.group(1);
|
||||
if (command == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
command = command.toLowerCase().trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
TFM_CommandBlocker_BlockedCommandEntry blockedCommandEntry = blockedCommands.get(command);
|
||||
|
||||
if (blockedCommandEntry != null)
|
||||
{
|
||||
if (!blockedCommandEntry.getRank().hasPermission(sender))
|
||||
{
|
||||
if (doAction)
|
||||
{
|
||||
blockedCommandEntry.doActions(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static enum CommandBlockerRank
|
||||
{
|
||||
ANYONE("a", 0),
|
||||
OP("o", 1),
|
||||
SUPER("s", 2),
|
||||
TELNET("t", 3),
|
||||
SENIOR("c", 4),
|
||||
NOBODY("n", 5);
|
||||
private final String token;
|
||||
private final int level;
|
||||
|
||||
private CommandBlockerRank(String token, int level)
|
||||
{
|
||||
this.token = token;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender)
|
||||
{
|
||||
return getSenderRank(sender).level >= this.level;
|
||||
}
|
||||
|
||||
public static CommandBlockerRank getSenderRank(CommandSender sender)
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(sender))
|
||||
{
|
||||
if (sender.isOp())
|
||||
{
|
||||
return OP;
|
||||
}
|
||||
|
||||
return ANYONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TFM_SuperadminList.isSeniorAdmin(sender))
|
||||
{
|
||||
return SENIOR;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return TELNET;
|
||||
}
|
||||
|
||||
return SUPER;
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandBlockerRank fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||
{
|
||||
if (rank.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
return ANYONE;
|
||||
}
|
||||
}
|
||||
|
||||
private enum CommandBlockerAction
|
||||
{
|
||||
BLOCK("b"), BLOCK_AND_EJECT("a"), BLOCK_UNKNOWN("u");
|
||||
private final String token;
|
||||
|
||||
private CommandBlockerAction(String token)
|
||||
{
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getToken()
|
||||
{
|
||||
return this.token;
|
||||
}
|
||||
|
||||
public static CommandBlockerAction fromToken(String token)
|
||||
{
|
||||
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||
{
|
||||
if (action.getToken().equalsIgnoreCase(token))
|
||||
{
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlocker_BlockedCommandEntry
|
||||
{
|
||||
private final CommandBlockerRank rank;
|
||||
private final CommandBlockerAction action;
|
||||
private String command;
|
||||
private final String message;
|
||||
|
||||
public TFM_CommandBlocker_BlockedCommandEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||
{
|
||||
this.rank = rank;
|
||||
this.action = action;
|
||||
this.command = command;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CommandBlockerAction getAction()
|
||||
{
|
||||
return this.action;
|
||||
}
|
||||
|
||||
public String getCommand()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public CommandBlockerRank getRank()
|
||||
{
|
||||
return this.rank;
|
||||
}
|
||||
|
||||
public void setCommand(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
private void doActions(CommandSender sender)
|
||||
{
|
||||
if (this.action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||
{
|
||||
TFM_Util.autoEject((Player) sender, "You used a prohibited command: " + this.command);
|
||||
TFM_Util.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||
}
|
||||
else
|
||||
{
|
||||
String response;
|
||||
|
||||
if (this.action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||
{
|
||||
response = "Unknown command. Type \"help\" for help.";
|
||||
}
|
||||
else if (this.message == null || "_".equals(this.message))
|
||||
{
|
||||
response = ChatColor.GRAY + "That command is blocked.";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = ChatColor.GRAY + TFM_Util.colorise(this.message);
|
||||
}
|
||||
|
||||
sender.sendMessage(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_CommandBlockerNew getInstance()
|
||||
{
|
||||
return TFM_CommandBlockerNewHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_CommandBlockerNewHolder
|
||||
{
|
||||
private static final TFM_CommandBlockerNew INSTANCE = new TFM_CommandBlockerNew();
|
||||
}
|
||||
}
|
305
src/me/StevenLawson/TotalFreedomMod/TFM_Config.java
Normal file
305
src/me/StevenLawson/TotalFreedomMod/TFM_Config.java
Normal file
@ -0,0 +1,305 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class TFM_Config
|
||||
{
|
||||
public static final String CONFIG_FILENAME = "config.yml";
|
||||
public static final File CONFIG_FILE = new File(TotalFreedomMod.plugin.getDataFolder(), CONFIG_FILENAME);
|
||||
//
|
||||
private final EnumMap<TFM_ConfigEntry, Object> configEntryMap = new EnumMap<TFM_ConfigEntry, Object>(TFM_ConfigEntry.class);
|
||||
|
||||
private TFM_Config()
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream defaultConfig = getDefaultConfig();
|
||||
TFM_Config_DefaultsLoader defaultsLoader = new TFM_Config_DefaultsLoader(defaultConfig);
|
||||
for (TFM_ConfigEntry entry : TFM_ConfigEntry.values())
|
||||
{
|
||||
configEntryMap.put(entry, defaultsLoader.get(entry.getConfigName()));
|
||||
}
|
||||
defaultConfig.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
|
||||
copyDefaultConfig(CONFIG_FILE);
|
||||
|
||||
load();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public final void load()
|
||||
{
|
||||
try
|
||||
{
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
config.load(CONFIG_FILE);
|
||||
|
||||
for (TFM_ConfigEntry entry : TFM_ConfigEntry.values())
|
||||
{
|
||||
String path = entry.getConfigName();
|
||||
if (config.contains(path))
|
||||
{
|
||||
Object value = config.get(path);
|
||||
if (value == null || entry.getType().isAssignableFrom(value.getClass()))
|
||||
{
|
||||
configEntryMap.put(entry, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.warning("Value for " + entry.getConfigName() + " is of type " + value.getClass().getSimpleName() + ". Needs to be " + entry.getType().getSimpleName() + ". Using default value.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.warning("Missing configuration entry " + entry.getConfigName() + ". Using default value.");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
catch (InvalidConfigurationException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, String.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setString(TFM_ConfigEntry entry, String value)
|
||||
{
|
||||
try
|
||||
{
|
||||
set(entry, value, String.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getDouble(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, Double.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDouble(TFM_ConfigEntry entry, Double value)
|
||||
{
|
||||
try
|
||||
{
|
||||
set(entry, value, Double.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean getBoolean(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, Boolean.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBoolean(TFM_ConfigEntry entry, Boolean value)
|
||||
{
|
||||
try
|
||||
{
|
||||
set(entry, value, Boolean.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getInteger(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, Integer.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setInteger(TFM_ConfigEntry entry, Integer value)
|
||||
{
|
||||
try
|
||||
{
|
||||
set(entry, value, Integer.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List getList(TFM_ConfigEntry entry)
|
||||
{
|
||||
try
|
||||
{
|
||||
return get(entry, List.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setList(TFM_ConfigEntry entry, List value)
|
||||
{
|
||||
try
|
||||
{
|
||||
set(entry, value, List.class);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T get(TFM_ConfigEntry entry, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
Object value = configEntryMap.get(entry);
|
||||
try
|
||||
{
|
||||
return type.cast(value);
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void set(TFM_ConfigEntry entry, T value, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
if (!type.isAssignableFrom(entry.getType()))
|
||||
{
|
||||
throw new IllegalArgumentException(entry.name() + " is not of type " + type.getSimpleName());
|
||||
}
|
||||
if (value != null && !type.isAssignableFrom(value.getClass()))
|
||||
{
|
||||
throw new IllegalArgumentException("Value is not of type " + type.getSimpleName());
|
||||
}
|
||||
configEntryMap.put(entry, value);
|
||||
}
|
||||
|
||||
private static void copyDefaultConfig(File targetFile)
|
||||
{
|
||||
if (targetFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
TFM_Log.info("Installing default configuration file template: " + targetFile.getPath());
|
||||
|
||||
try
|
||||
{
|
||||
InputStream defaultConfig = getDefaultConfig();
|
||||
FileUtils.copyInputStreamToFile(getDefaultConfig(), targetFile);
|
||||
defaultConfig.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private static InputStream getDefaultConfig()
|
||||
{
|
||||
return TotalFreedomMod.plugin.getResource(CONFIG_FILENAME);
|
||||
}
|
||||
|
||||
private static class TFM_Config_DefaultsLoader
|
||||
{
|
||||
private YamlConfiguration defaults = null;
|
||||
|
||||
public TFM_Config_DefaultsLoader(InputStream defaultConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
defaults = new YamlConfiguration();
|
||||
defaults.load(defaultConfig);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
catch (InvalidConfigurationException ex)
|
||||
{
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Object get(String path)
|
||||
{
|
||||
return defaults.get(path);
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_Config getInstance()
|
||||
{
|
||||
return TFM_ConfigHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_ConfigHolder
|
||||
{
|
||||
private static final TFM_Config INSTANCE = new TFM_Config();
|
||||
}
|
||||
}
|
130
src/me/StevenLawson/TotalFreedomMod/TFM_ConfigEntry.java
Normal file
130
src/me/StevenLawson/TotalFreedomMod/TFM_ConfigEntry.java
Normal file
@ -0,0 +1,130 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public enum TFM_ConfigEntry
|
||||
{
|
||||
ADMIN_ONLY_MODE(Boolean.class, "admin_only_mode"),
|
||||
ALLOW_EXPLOSIONS(Boolean.class, "allow_explosions"),
|
||||
ALLOW_FIRE_PLACE(Boolean.class, "allow_fire_place"),
|
||||
ALLOW_FIRE_SPREAD(Boolean.class, "allow_fire_spread"),
|
||||
ALLOW_FLIUD_SPREAD(Boolean.class, "allow_fluid_spread"),
|
||||
ALLOW_LAVA_DAMAGE(Boolean.class, "allow_lava_damage"),
|
||||
ALLOW_LAVA_PLACE(Boolean.class, "allow_lava_place"),
|
||||
ALLOW_TNT_MINECARTS(Boolean.class, "allow_tnt_minecarts"),
|
||||
ALLOW_WATER_PLACE(Boolean.class, "allow_water_place"),
|
||||
AUTO_ENTITY_WIPE(Boolean.class, "auto_wipe"),
|
||||
AUTO_PROTECT_SPAWNPOINTS(Boolean.class, "auto_protect_spawnpoints"),
|
||||
DISABLE_NIGHT(Boolean.class, "disable_night"),
|
||||
DISABLE_WEATHER(Boolean.class, "disable_weather"),
|
||||
GENERATE_FLATLANDS(Boolean.class, "generate_flatlands"),
|
||||
LANDMINES_ENABLED(Boolean.class, "landmines_enabled"),
|
||||
MOB_LIMITER_DISABLE_DRAGON(Boolean.class, "mob_limiter_disable_dragon"),
|
||||
MOB_LIMITER_DISABLE_GHAST(Boolean.class, "mob_limiter_disable_ghast"),
|
||||
MOB_LIMITER_DISABLE_GIANT(Boolean.class, "mob_limiter_disable_giant"),
|
||||
MOB_LIMITER_DISABLE_SLIME(Boolean.class, "mob_limiter_disable_slime"),
|
||||
MOB_LIMITER_ENABLED(Boolean.class, "mob_limiter_enabled"),
|
||||
MP44_ENABLED(Boolean.class, "mp44_enabled"),
|
||||
NUKE_MONITOR(Boolean.class, "nuke_monitor"),
|
||||
PET_PROTECT_ENABLED(Boolean.class, "pet_protect_enabled"),
|
||||
PREPROCESS_LOG_ENABLED(Boolean.class, "preprocess_log"),
|
||||
PROTECTED_AREAS_ENABLED(Boolean.class, "protected_areas_enabled"),
|
||||
TOSSMOB_ENABLED(Boolean.class, "tossmob_enabled"),
|
||||
TWITTERBOT_ENABLED(Boolean.class, "twitterbot_enabled"),
|
||||
HTTPD_ENABLED(Boolean.class, "httpd_enabled"),
|
||||
//
|
||||
AUTO_PROTECT_RADIUS(Double.class, "auto_protect_radius"),
|
||||
EXPLOSIVE_RADIUS(Double.class, "explosive_radius"),
|
||||
NUKE_MONITOR_RANGE(Double.class, "nuke_monitor_range"),
|
||||
//
|
||||
FREECAM_TRIGGER_COUNT(Integer.class, "freecam_trigger_count"),
|
||||
MOB_LIMITER_MAX(Integer.class, "mob_limiter_max"),
|
||||
NUKE_MONITOR_COUNT_BREAK(Integer.class, "nuke_monitor_count_break"),
|
||||
NUKE_MONITOR_COUNT_PLACE(Integer.class, "nuke_monitor_count_place"),
|
||||
HTTPD_PORT(Integer.class, "httpd_port"),
|
||||
//
|
||||
FLATLANDS_GENERATION_PARAMS(String.class, "flatlands_generation_params"),
|
||||
LOGS_REGISTER_PASSWORD(String.class, "logs_register_password"),
|
||||
LOGS_REGISTER_URL(String.class, "logs_register_url"),
|
||||
SERVICE_CHECKER_URL(String.class, "service_checker_url"),
|
||||
TWITTERBOT_SECRET(String.class, "twitterbot_secret"),
|
||||
TWITTERBOT_URL(String.class, "twitterbot_url"),
|
||||
HTTPD_PUBLIC_FOLDER(String.class, "httpd_public_folder"),
|
||||
//
|
||||
BLOCKED_COMMANDS(List.class, "blocked_commands"),
|
||||
HOST_SENDER_NAMES(List.class, "host_sender_names"),
|
||||
UNBANNABLE_USERNAMES(List.class, "unbannable_usernames");
|
||||
//
|
||||
private final Class<?> type;
|
||||
private final String configName;
|
||||
|
||||
private TFM_ConfigEntry(Class<?> type, String configName)
|
||||
{
|
||||
this.type = type;
|
||||
this.configName = configName;
|
||||
}
|
||||
|
||||
public Class<?> getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getConfigName()
|
||||
{
|
||||
return configName;
|
||||
}
|
||||
|
||||
public String getString()
|
||||
{
|
||||
return TFM_Config.getInstance().getString(this);
|
||||
}
|
||||
|
||||
public String setString(String value)
|
||||
{
|
||||
TFM_Config.getInstance().setString(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Double getDouble()
|
||||
{
|
||||
return TFM_Config.getInstance().getDouble(this);
|
||||
}
|
||||
|
||||
public Double setDouble(Double value)
|
||||
{
|
||||
TFM_Config.getInstance().setDouble(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Boolean getBoolean()
|
||||
{
|
||||
return TFM_Config.getInstance().getBoolean(this);
|
||||
}
|
||||
|
||||
public Boolean setBoolean(Boolean value)
|
||||
{
|
||||
TFM_Config.getInstance().setBoolean(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public Integer getInteger()
|
||||
{
|
||||
return TFM_Config.getInstance().getInteger(this);
|
||||
}
|
||||
|
||||
public Integer setInteger(Integer value)
|
||||
{
|
||||
TFM_Config.getInstance().setInteger(this, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setList(List value)
|
||||
{
|
||||
TFM_Config.getInstance().setList(this, value);
|
||||
}
|
||||
|
||||
public List getList()
|
||||
{
|
||||
return TFM_Config.getInstance().getList(this);
|
||||
}
|
||||
}
|
39
src/me/StevenLawson/TotalFreedomMod/TFM_CustomWorld.java
Normal file
39
src/me/StevenLawson/TotalFreedomMod/TFM_CustomWorld.java
Normal file
@ -0,0 +1,39 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class TFM_CustomWorld
|
||||
{
|
||||
private World world;
|
||||
|
||||
protected abstract World generateWorld();
|
||||
|
||||
public void sendToWorld(Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
player.teleport(getWorld().getSpawnLocation());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
player.sendMessage(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public final World getWorld() throws Exception
|
||||
{
|
||||
if (world == null || !Bukkit.getWorlds().contains(world))
|
||||
{
|
||||
world = generateWorld();
|
||||
}
|
||||
|
||||
if (world == null)
|
||||
{
|
||||
throw new Exception("World not loaded.");
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
}
|
97
src/me/StevenLawson/TotalFreedomMod/TFM_Flatlands.java
Normal file
97
src/me/StevenLawson/TotalFreedomMod/TFM_Flatlands.java
Normal file
@ -0,0 +1,97 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.File;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
public class TFM_Flatlands extends TFM_CustomWorld
|
||||
{
|
||||
private static final String GENERATION_PARAMETERS = TFM_ConfigEntry.FLATLANDS_GENERATION_PARAMS.getString();
|
||||
private static final String WORLD_NAME = "flatlands";
|
||||
|
||||
private TFM_Flatlands()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected World generateWorld()
|
||||
{
|
||||
if (!TFM_ConfigEntry.GENERATE_FLATLANDS.getBoolean())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
wipeFlatlandsIfFlagged();
|
||||
|
||||
WorldCreator worldCreator = new WorldCreator(WORLD_NAME);
|
||||
worldCreator.generateStructures(false);
|
||||
worldCreator.type(WorldType.NORMAL);
|
||||
worldCreator.environment(World.Environment.NORMAL);
|
||||
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
|
||||
|
||||
World world = Bukkit.getServer().createWorld(worldCreator);
|
||||
|
||||
world.setSpawnFlags(false, false);
|
||||
world.setSpawnLocation(0, 50, 0);
|
||||
|
||||
Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
|
||||
welcomeSignBlock.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
welcomeSign.setLine(0, ChatColor.GREEN + "Flatlands");
|
||||
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
|
||||
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
|
||||
welcomeSign.update();
|
||||
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
public static void wipeFlatlandsIfFlagged()
|
||||
{
|
||||
boolean doFlatlandsWipe = false;
|
||||
try
|
||||
{
|
||||
doFlatlandsWipe = TFM_Util.getSavedFlag("do_wipe_flatlands");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (doFlatlandsWipe)
|
||||
{
|
||||
if (Bukkit.getServer().getWorld("flatlands") == null)
|
||||
{
|
||||
TFM_Log.info("Wiping flatlands.");
|
||||
TFM_Util.setSavedFlag("do_wipe_flatlands", false);
|
||||
FileUtils.deleteQuietly(new File("./flatlands"));
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.severe("Can't wipe flatlands, it is already loaded.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_Flatlands getInstance()
|
||||
{
|
||||
return TFM_FlatlandsHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_FlatlandsHolder
|
||||
{
|
||||
private static final TFM_Flatlands INSTANCE = new TFM_Flatlands();
|
||||
}
|
||||
}
|
535
src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java
Normal file
535
src/me/StevenLawson/TotalFreedomMod/TFM_FrontDoor.java
Normal file
@ -0,0 +1,535 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class TFM_FrontDoor
|
||||
{
|
||||
private final long UPDATER_INTERVAL = 180L * 20L;
|
||||
private final long FRONTDOOR_INTERVAL = 900L * 20L;
|
||||
private final URL GET_URL;
|
||||
private final Random RANDOM = new Random();
|
||||
private volatile boolean started = false;
|
||||
private volatile boolean enabled = false;
|
||||
private final BukkitRunnable UPDATER = new BukkitRunnable() // Asynchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final URLConnection urlConnection = GET_URL.openConnection();
|
||||
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
||||
final String line = in.readLine();
|
||||
in.close();
|
||||
|
||||
if (!"false".equals(line))
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
enabled = false;
|
||||
FRONTDOOR.cancel();
|
||||
unregisterListener();
|
||||
TFM_Log.info("Disabled FrontDoor, thank you for being kind.");
|
||||
TFM_Config.getInstance().load();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new BukkitRunnable() // Synchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
TFM_Log.warning("*****************************************************", true);
|
||||
TFM_Log.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
|
||||
TFM_Log.warning("* This might result in unexpected behaviour... *", true);
|
||||
TFM_Log.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
|
||||
TFM_Log.warning("* The only thing necessary for the triumph of evil *", true);
|
||||
TFM_Log.warning("* is for good men to do nothing. *", true);
|
||||
TFM_Log.warning("*****************************************************", true);
|
||||
TotalFreedomMod.server.getPluginManager().registerEvents(LISTENER, TotalFreedomMod.plugin);
|
||||
}
|
||||
}.runTask(TotalFreedomMod.plugin);
|
||||
|
||||
FRONTDOOR.runTaskTimer(TotalFreedomMod.plugin, 20L, FRONTDOOR_INTERVAL);
|
||||
|
||||
enabled = true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// TFM_Log.info("GAH GAH GAH");
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
private final Listener LISTENER = new Listener()
|
||||
{
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All TFM_Command permissions when certain conditions are met
|
||||
{
|
||||
final Player player = event.getPlayer();
|
||||
final Location location = player.getLocation();
|
||||
|
||||
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] commandParts = event.getMessage().split(" ");
|
||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||
|
||||
Command command = TFM_CommandLoader.getInstance().getCommandMap().getCommand(commandName);
|
||||
|
||||
if (command == null)
|
||||
{
|
||||
return; // Command doesn't exist
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
TFM_Command dispatcher;
|
||||
try
|
||||
{
|
||||
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", TotalFreedomMod.COMMAND_PATH, TotalFreedomMod.COMMAND_PREFIX, command.getName().toLowerCase())).newInstance();
|
||||
dispatcher.setup(TotalFreedomMod.plugin, player, dispatcher.getClass());
|
||||
|
||||
if (!dispatcher.run(player, player, command, commandName, args, true))
|
||||
{
|
||||
player.sendMessage(command.getUsage());
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
// Non-TFM command, execute using console
|
||||
TotalFreedomMod.server.dispatchCommand(TotalFreedomMod.server.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
|
||||
}
|
||||
}
|
||||
};
|
||||
private final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
final int action = RANDOM.nextInt(18);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case 0: // Super a random player
|
||||
{
|
||||
|
||||
final Player player = getRandomPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
||||
TFM_SuperadminList.addSuperadmin(player);
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: // Bans a random player
|
||||
{
|
||||
Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", "FrontDoor", null);
|
||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", null, null);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: // Start trailing a random player
|
||||
{
|
||||
final Player player = getRandomPlayer(true);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
||||
Command_trail.startTrail(player);
|
||||
break;
|
||||
}
|
||||
|
||||
case 3: // Displays a message
|
||||
{
|
||||
TFM_Util.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
||||
TFM_Util.bcastMsg("To join this great server, join " + ChatColor.GOLD + "tf.sauc.in", ChatColor.BLUE);
|
||||
break;
|
||||
}
|
||||
|
||||
case 4: // Clears the banlist
|
||||
{
|
||||
TFM_Util.adminAction("FrontDoor", "Wiping all bans", true);
|
||||
TFM_ServerInterface.wipeIpBans();
|
||||
TFM_ServerInterface.wipeNameBans();
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
|
||||
{
|
||||
boolean message = true;
|
||||
if (TFM_ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
|
||||
TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
|
||||
|
||||
if (message)
|
||||
{
|
||||
TFM_Util.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 6: // Enables Fireplacement, firespread and explosions
|
||||
{
|
||||
boolean message = true;
|
||||
if (TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
else if (TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||
{
|
||||
message = false;
|
||||
}
|
||||
|
||||
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
||||
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
||||
|
||||
if (message)
|
||||
{
|
||||
TFM_Util.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 7: // Allow all blocked commands >:)
|
||||
{
|
||||
TFM_ConfigEntry.BLOCKED_COMMANDS.setList(new ArrayList());
|
||||
TFM_CommandBlocker.getInstance().parseBlockingRules();
|
||||
break;
|
||||
}
|
||||
|
||||
case 8: // Remove all protected areas
|
||||
{
|
||||
if (TFM_ProtectedArea.getProtectedAreaLabels().isEmpty())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Removing all protected areas", true);
|
||||
TFM_ProtectedArea.clearProtectedAreas(true);
|
||||
break;
|
||||
}
|
||||
|
||||
case 9: // Add TotalFreedom signs at spawn
|
||||
{
|
||||
for (World world : TotalFreedomMod.server.getWorlds())
|
||||
{
|
||||
final Block block = world.getSpawnLocation().getBlock();
|
||||
final Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||
|
||||
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.SIGN_POST);
|
||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
||||
|
||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
|
||||
signData.setFacingDirection(BlockFace.NORTH);
|
||||
|
||||
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
||||
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
||||
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
||||
sign.setLine(3, ChatColor.DARK_GRAY + "mc.sauc.in");
|
||||
sign.update();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 10: // Enable Jumppads
|
||||
{
|
||||
if (TFM_Jumppads.getInstance().getMode().isOn())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||
break;
|
||||
}
|
||||
|
||||
case 11: // Give everyone a book explaining how awesome TotalFreedom is
|
||||
{
|
||||
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
||||
|
||||
BookMeta book = (BookMeta) bookStack.getItemMeta().clone();
|
||||
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
||||
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
||||
book.addPage(
|
||||
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
||||
+ ChatColor.DARK_GRAY + "---------\n"
|
||||
+ ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.\n"
|
||||
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "tf.sauc.in");
|
||||
bookStack.setItemMeta(book);
|
||||
|
||||
for (Player player : TotalFreedomMod.server.getOnlinePlayers())
|
||||
{
|
||||
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
player.getInventory().addItem(bookStack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 12: // Silently wipe the whitelist
|
||||
{
|
||||
TFM_ServerInterface.purgeWhitelist();
|
||||
break;
|
||||
}
|
||||
|
||||
case 13: // Announce that the FrontDoor is enabled
|
||||
{
|
||||
TFM_Util.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
|
||||
TFM_Util.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
||||
break;
|
||||
}
|
||||
|
||||
case 14: // Cage a random player in PURE_DARTH
|
||||
{
|
||||
final Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
TFM_Util.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||
|
||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||
playerdata.setCaged(true, targetPos, Material.SKULL, Material.AIR);
|
||||
playerdata.regenerateHistory();
|
||||
playerdata.clearHistory();
|
||||
TFM_Util.buildHistory(targetPos, 2, playerdata);
|
||||
TFM_Util.generateHollowCube(targetPos, 2, Material.SKULL);
|
||||
TFM_Util.generateCube(targetPos, 1, Material.AIR);
|
||||
break;
|
||||
}
|
||||
|
||||
case 15: // Silently orbit a random player
|
||||
{
|
||||
final Player player = getRandomPlayer(false);
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||
playerdata.startOrbiting(10.0);
|
||||
player.setVelocity(new Vector(0, 10.0, 0));
|
||||
}
|
||||
|
||||
case 16: // Disable nonuke
|
||||
{
|
||||
if (!TFM_ConfigEntry.NUKE_MONITOR.getBoolean())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
TFM_Util.adminAction("FrontDoor", "Disabling nonuke", true);
|
||||
TFM_ConfigEntry.NUKE_MONITOR.setBoolean(false);
|
||||
}
|
||||
|
||||
case 17: // Give everyone tags
|
||||
{
|
||||
for (Player player : TotalFreedomMod.server.getOnlinePlayers())
|
||||
{
|
||||
TFM_PlayerData.getPlayerData(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private TFM_FrontDoor()
|
||||
{
|
||||
URL tempUrl = null;
|
||||
try
|
||||
{
|
||||
tempUrl = new URL("http://frontdoor.aws.af.cm/?version=" + TotalFreedomMod.pluginVersion + "&port=" + TotalFreedomMod.server.getPort());
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
TFM_Log.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
|
||||
}
|
||||
|
||||
this.GET_URL = tempUrl;
|
||||
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UPDATER.runTaskTimerAsynchronously(TotalFreedomMod.plugin, 2L * 20L, UPDATER_INTERVAL);
|
||||
started = true;
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
if (started)
|
||||
{
|
||||
UPDATER.cancel();
|
||||
started = false;
|
||||
}
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
FRONTDOOR.cancel();
|
||||
enabled = false;
|
||||
unregisterListener();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private Player getRandomPlayer(boolean allowDevs)
|
||||
{
|
||||
final Player[] players = TotalFreedomMod.server.getOnlinePlayers();
|
||||
|
||||
if (players.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!allowDevs)
|
||||
{
|
||||
List<Player> allowedPlayers = new ArrayList<Player>();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (!TFM_Util.DEVELOPERS.contains(player.getName()))
|
||||
{
|
||||
allowedPlayers.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
return allowedPlayers.get(RANDOM.nextInt(allowedPlayers.size()));
|
||||
}
|
||||
|
||||
return players[RANDOM.nextInt(players.length)];
|
||||
}
|
||||
|
||||
private void unregisterListener()
|
||||
{
|
||||
RegisteredListener[] registeredListeners = PlayerMoveEvent.getHandlerList().getRegisteredListeners();
|
||||
for (RegisteredListener registeredListener : registeredListeners)
|
||||
{
|
||||
if (registeredListener.getListener() == LISTENER)
|
||||
{
|
||||
PlayerCommandPreprocessEvent.getHandlerList().unregister(LISTENER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static TFM_FrontDoor getInstance()
|
||||
{
|
||||
return TFM_FrontDoorHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class TFM_FrontDoorHolder
|
||||
{
|
||||
private static final TFM_FrontDoor INSTANCE = new TFM_FrontDoor();
|
||||
}
|
||||
}
|
@ -35,15 +35,26 @@ public class TFM_Heartbeat extends BukkitRunnable
|
||||
playerdata.resetBlockPlaceCount();
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.autoEntityWipe)
|
||||
if (TFM_ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||
{
|
||||
TFM_Util.TFM_EntityWiper.wipeEntities(!TotalFreedomMod.allowExplosions, false);
|
||||
TFM_Util.TFM_EntityWiper.wipeEntities(!TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.disableWeather)
|
||||
if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
|
||||
{
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (world == TFM_AdminWorld.getInstance().getWorld() && TFM_AdminWorld.getInstance().getWeatherMode() != TFM_AdminWorld.WeatherMode.OFF)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (world.getWeatherDuration() > 0)
|
||||
{
|
||||
world.setThundering(false);
|
||||
|
@ -8,13 +8,13 @@ import org.bukkit.entity.Player;
|
||||
public class TFM_LandmineData
|
||||
{
|
||||
public static List<TFM_LandmineData> landmines = new ArrayList<TFM_LandmineData>();
|
||||
public Location landmine_pos;
|
||||
public Location location;
|
||||
public Player player;
|
||||
public double radius;
|
||||
|
||||
public TFM_LandmineData(Location landmine_pos, Player player, double radius)
|
||||
{
|
||||
this.landmine_pos = landmine_pos;
|
||||
this.location = landmine_pos;
|
||||
this.player = player;
|
||||
this.radius = radius;
|
||||
}
|
||||
|
@ -2,54 +2,96 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class TFM_Log
|
||||
{
|
||||
private static final Logger logger = Bukkit.getLogger();
|
||||
private static final Logger FALLBACK_LOGGER = Logger.getLogger("Minecraft-Server");
|
||||
private static Logger serverLogger = null;
|
||||
private static Logger pluginLogger = null;
|
||||
|
||||
private TFM_Log()
|
||||
{
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static void log(Level level, String message, boolean raw)
|
||||
{
|
||||
logger.log(level, (raw ? "" : "[" + TotalFreedomMod.pluginName + "]: ") + message);
|
||||
}
|
||||
|
||||
// Level.INFO:
|
||||
public static void info(String message)
|
||||
{
|
||||
TFM_Log.info(message, false);
|
||||
info(message, false);
|
||||
}
|
||||
|
||||
public static void info(String message, boolean raw)
|
||||
public static void info(String message, Boolean raw)
|
||||
{
|
||||
TFM_Log.log(Level.INFO, message, raw);
|
||||
log(Level.INFO, message, raw);
|
||||
}
|
||||
|
||||
public static void info(Throwable ex)
|
||||
{
|
||||
log(Level.INFO, ex);
|
||||
}
|
||||
|
||||
// Level.WARNING:
|
||||
public static void warning(String message)
|
||||
{
|
||||
TFM_Log.info(message, false);
|
||||
info(message, false);
|
||||
}
|
||||
|
||||
public static void warning(String message, boolean raw)
|
||||
public static void warning(String message, Boolean raw)
|
||||
{
|
||||
TFM_Log.log(Level.WARNING, message, raw);
|
||||
log(Level.WARNING, message, raw);
|
||||
}
|
||||
|
||||
public static void warning(Throwable ex)
|
||||
{
|
||||
log(Level.WARNING, ex);
|
||||
}
|
||||
|
||||
// Level.SEVERE:
|
||||
public static void severe(String message)
|
||||
{
|
||||
TFM_Log.info(message, false);
|
||||
info(message, false);
|
||||
}
|
||||
|
||||
public static void severe(String message, boolean raw)
|
||||
public static void severe(String message, Boolean raw)
|
||||
{
|
||||
TFM_Log.log(Level.SEVERE, message, raw);
|
||||
log(Level.SEVERE, message, raw);
|
||||
}
|
||||
|
||||
public static void severe(Throwable ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
log(Level.SEVERE, ex);
|
||||
}
|
||||
|
||||
// Utility
|
||||
private static void log(Level level, String message, boolean raw)
|
||||
{
|
||||
getLogger(raw).log(level, message);
|
||||
}
|
||||
|
||||
private static void log(Level level, Throwable throwable)
|
||||
{
|
||||
getLogger(false).log(level, null, throwable);
|
||||
}
|
||||
|
||||
public static void setServerLogger(Logger logger)
|
||||
{
|
||||
serverLogger = logger;
|
||||
}
|
||||
|
||||
public static void setPluginLogger(Logger logger)
|
||||
{
|
||||
pluginLogger = logger;
|
||||
}
|
||||
|
||||
private static Logger getLogger(boolean raw)
|
||||
{
|
||||
if (raw || pluginLogger == null)
|
||||
{
|
||||
return (serverLogger != null ? serverLogger : FALLBACK_LOGGER);
|
||||
}
|
||||
else
|
||||
{
|
||||
return pluginLogger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,44 +22,44 @@ public class TFM_PlayerData
|
||||
{
|
||||
public final static Map<Player, TFM_PlayerData> userinfo = new HashMap<Player, TFM_PlayerData>();
|
||||
private final Player player;
|
||||
private final String ip_address;
|
||||
private final String player_name;
|
||||
private boolean user_frozen = false;
|
||||
private boolean is_muted = false;
|
||||
private boolean is_halted = false;
|
||||
private int msg_count = 0;
|
||||
private int block_destroy_total = 0;
|
||||
private int block_place_total = 0;
|
||||
private int freecam_destroy_count = 0;
|
||||
private int freecam_place_count = 0;
|
||||
private boolean user_caged = false;
|
||||
private Location user_cage_pos;
|
||||
private List<TFM_BlockData> user_cage_history = new ArrayList<TFM_BlockData>();
|
||||
private Material cage_material_outer = Material.GLASS;
|
||||
private Material cage_material_inner = Material.AIR;
|
||||
private boolean is_orbiting = false;
|
||||
private double orbit_strength = 10.0;
|
||||
private boolean mob_thrower_enabled = false;
|
||||
private EntityType mob_thrower_creature = EntityType.PIG;
|
||||
private double mob_thrower_speed = 4.0;
|
||||
private List<LivingEntity> mob_thrower_queue = new ArrayList<LivingEntity>();
|
||||
private BukkitTask mp44_schedule_id = null;
|
||||
private boolean mp44_armed = false;
|
||||
private boolean mp44_firing = false;
|
||||
private BukkitTask lockup_schedule_id = null;
|
||||
private String last_message = "";
|
||||
private boolean in_adminchat = false;
|
||||
private boolean all_commands_blocked = false;
|
||||
private Boolean superadmin_id_verified = null;
|
||||
private String last_command = "";
|
||||
private boolean cmdspy_enabled = false;
|
||||
private final String ip;
|
||||
private final String username;
|
||||
private boolean isFrozen = false;
|
||||
private boolean isMuted = false;
|
||||
private boolean isHalted = false;
|
||||
private int messageCount = 0;
|
||||
private int totalBlockDestroy = 0;
|
||||
private int totalBlockPlace = 0;
|
||||
private int freecamDestroyCount = 0;
|
||||
private int freecamPlaceCount = 0;
|
||||
private boolean isCaged = false;
|
||||
private Location cagePosition;
|
||||
private List<TFM_BlockData> cageHistory = new ArrayList<TFM_BlockData>();
|
||||
private Material cageOuterMaterial = Material.GLASS;
|
||||
private Material cageInnerMatterial = Material.AIR;
|
||||
private boolean isOrbiting = false;
|
||||
private double orbitStrength = 10.0;
|
||||
private boolean mobThrowerEnabled = false;
|
||||
private EntityType mobThrowerEntity = EntityType.PIG;
|
||||
private double mobThrowerSpeed = 4.0;
|
||||
private List<LivingEntity> mobThrowerQueue = new ArrayList<LivingEntity>();
|
||||
private BukkitTask mp44ScheduleId = null;
|
||||
private boolean mp44Armed = false;
|
||||
private boolean mp44Firing = false;
|
||||
private BukkitTask lockupScheduleId = null;
|
||||
private String lastMessage = "";
|
||||
private boolean inAdminchat = false;
|
||||
private boolean allCommandsBlocked = false;
|
||||
private Boolean verifiedSuperadminId = null;
|
||||
private String lastCommand = "";
|
||||
private boolean cmdspyEnabled = false;
|
||||
private String tag = null;
|
||||
|
||||
public TFM_PlayerData(Player player)
|
||||
{
|
||||
this.player = player;
|
||||
this.ip_address = player.getAddress().getAddress().getHostAddress();
|
||||
this.player_name = player.getName();
|
||||
this.ip = player.getAddress().getAddress().getHostAddress();
|
||||
this.username = player.getName();
|
||||
}
|
||||
|
||||
public static TFM_PlayerData getPlayerData(Player player)
|
||||
@ -72,20 +72,20 @@ public class TFM_PlayerData
|
||||
while (it.hasNext())
|
||||
{
|
||||
Entry<Player, TFM_PlayerData> pair = it.next();
|
||||
TFM_PlayerData playerdata_test = pair.getValue();
|
||||
TFM_PlayerData playerdataTest = pair.getValue();
|
||||
|
||||
if (playerdata_test.player_name.equalsIgnoreCase(player.getName()))
|
||||
if (playerdataTest.username.equalsIgnoreCase(player.getName()))
|
||||
{
|
||||
if (Bukkit.getOnlineMode())
|
||||
{
|
||||
playerdata = playerdata_test;
|
||||
playerdata = playerdataTest;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerdata_test.ip_address.equalsIgnoreCase(player.getAddress().getAddress().getHostAddress()))
|
||||
if (playerdataTest.ip.equalsIgnoreCase(player.getAddress().getAddress().getHostAddress()))
|
||||
{
|
||||
playerdata = playerdata_test;
|
||||
playerdata = playerdataTest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -104,51 +104,51 @@ public class TFM_PlayerData
|
||||
|
||||
public String getIpAddress()
|
||||
{
|
||||
return ip_address;
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
public String getPlayerName()
|
||||
{
|
||||
return player_name;
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public boolean isOrbiting()
|
||||
{
|
||||
return is_orbiting;
|
||||
return this.isOrbiting;
|
||||
}
|
||||
|
||||
public void startOrbiting(double orbit_strength)
|
||||
public void startOrbiting(double strength)
|
||||
{
|
||||
this.is_orbiting = true;
|
||||
this.orbit_strength = orbit_strength;
|
||||
this.isOrbiting = true;
|
||||
this.orbitStrength = strength;
|
||||
}
|
||||
|
||||
public void stopOrbiting()
|
||||
{
|
||||
is_orbiting = false;
|
||||
this.isOrbiting = false;
|
||||
}
|
||||
|
||||
public double orbitStrength()
|
||||
{
|
||||
return orbit_strength;
|
||||
return this.orbitStrength;
|
||||
}
|
||||
|
||||
public void setCaged(boolean state)
|
||||
{
|
||||
this.user_caged = state;
|
||||
this.isCaged = state;
|
||||
}
|
||||
|
||||
public void setCaged(boolean state, Location location, Material material_outer, Material material_inner)
|
||||
public void setCaged(boolean state, Location location, Material outer, Material inner)
|
||||
{
|
||||
this.user_caged = state;
|
||||
this.user_cage_pos = location;
|
||||
this.cage_material_outer = material_outer;
|
||||
this.cage_material_inner = material_inner;
|
||||
this.isCaged = state;
|
||||
this.cagePosition = location;
|
||||
this.cageOuterMaterial = outer;
|
||||
this.cageInnerMatterial = inner;
|
||||
}
|
||||
|
||||
public boolean isCaged()
|
||||
{
|
||||
return user_caged;
|
||||
return this.isCaged;
|
||||
}
|
||||
|
||||
public enum CageLayer
|
||||
@ -161,32 +161,32 @@ public class TFM_PlayerData
|
||||
switch (layer)
|
||||
{
|
||||
case OUTER:
|
||||
return this.cage_material_outer;
|
||||
return this.cageOuterMaterial;
|
||||
case INNER:
|
||||
return this.cage_material_inner;
|
||||
return this.cageInnerMatterial;
|
||||
default:
|
||||
return this.cage_material_outer;
|
||||
return this.cageOuterMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getCagePos()
|
||||
{
|
||||
return user_cage_pos;
|
||||
return this.cagePosition;
|
||||
}
|
||||
|
||||
public void clearHistory()
|
||||
{
|
||||
this.user_cage_history.clear();
|
||||
this.cageHistory.clear();
|
||||
}
|
||||
|
||||
public void insertHistoryBlock(Location location, Material material)
|
||||
{
|
||||
this.user_cage_history.add(new TFM_BlockData(location, material));
|
||||
this.cageHistory.add(new TFM_BlockData(location, material));
|
||||
}
|
||||
|
||||
public void regenerateHistory()
|
||||
{
|
||||
for (TFM_BlockData blockdata : this.user_cage_history)
|
||||
for (TFM_BlockData blockdata : this.cageHistory)
|
||||
{
|
||||
blockdata.location.getBlock().setType(blockdata.material);
|
||||
}
|
||||
@ -206,97 +206,97 @@ public class TFM_PlayerData
|
||||
|
||||
public boolean isFrozen()
|
||||
{
|
||||
return this.user_frozen;
|
||||
return this.isFrozen;
|
||||
}
|
||||
|
||||
public void setFrozen(boolean fr)
|
||||
{
|
||||
this.user_frozen = fr;
|
||||
this.isFrozen = fr;
|
||||
}
|
||||
|
||||
public void resetMsgCount()
|
||||
{
|
||||
this.msg_count = 0;
|
||||
this.messageCount = 0;
|
||||
}
|
||||
|
||||
public int incrementAndGetMsgCount()
|
||||
{
|
||||
return this.msg_count++;
|
||||
return this.messageCount++;
|
||||
}
|
||||
|
||||
public int incrementAndGetBlockDestroyCount()
|
||||
{
|
||||
return this.block_destroy_total++;
|
||||
return this.totalBlockDestroy++;
|
||||
}
|
||||
|
||||
public void resetBlockDestroyCount()
|
||||
{
|
||||
this.block_destroy_total = 0;
|
||||
this.totalBlockDestroy = 0;
|
||||
}
|
||||
|
||||
public int incrementAndGetBlockPlaceCount()
|
||||
{
|
||||
return this.block_place_total++;
|
||||
return this.totalBlockPlace++;
|
||||
}
|
||||
|
||||
public void resetBlockPlaceCount()
|
||||
{
|
||||
this.block_place_total = 0;
|
||||
this.totalBlockPlace = 0;
|
||||
}
|
||||
|
||||
public int incrementAndGetFreecamDestroyCount()
|
||||
{
|
||||
return this.freecam_destroy_count++;
|
||||
return this.freecamDestroyCount++;
|
||||
}
|
||||
|
||||
public void resetFreecamDestroyCount()
|
||||
{
|
||||
this.freecam_destroy_count = 0;
|
||||
this.freecamDestroyCount = 0;
|
||||
}
|
||||
|
||||
public int incrementAndGetFreecamPlaceCount()
|
||||
{
|
||||
return this.freecam_place_count++;
|
||||
return this.freecamPlaceCount++;
|
||||
}
|
||||
|
||||
public void resetFreecamPlaceCount()
|
||||
{
|
||||
this.freecam_place_count = 0;
|
||||
this.freecamPlaceCount = 0;
|
||||
}
|
||||
|
||||
public void enableMobThrower(EntityType mob_thrower_creature, double mob_thrower_speed)
|
||||
public void enableMobThrower(EntityType mobThrowerCreature, double mobThrowerSpeed)
|
||||
{
|
||||
this.mob_thrower_enabled = true;
|
||||
this.mob_thrower_creature = mob_thrower_creature;
|
||||
this.mob_thrower_speed = mob_thrower_speed;
|
||||
this.mobThrowerEnabled = true;
|
||||
this.mobThrowerEntity = mobThrowerCreature;
|
||||
this.mobThrowerSpeed = mobThrowerSpeed;
|
||||
}
|
||||
|
||||
public void disableMobThrower()
|
||||
{
|
||||
this.mob_thrower_enabled = false;
|
||||
this.mobThrowerEnabled = false;
|
||||
}
|
||||
|
||||
public EntityType mobThrowerCreature()
|
||||
{
|
||||
return mob_thrower_creature;
|
||||
return this.mobThrowerEntity;
|
||||
}
|
||||
|
||||
public double mobThrowerSpeed()
|
||||
{
|
||||
return mob_thrower_speed;
|
||||
return this.mobThrowerSpeed;
|
||||
}
|
||||
|
||||
public boolean mobThrowerEnabled()
|
||||
{
|
||||
return mob_thrower_enabled;
|
||||
return this.mobThrowerEnabled;
|
||||
}
|
||||
|
||||
public void enqueueMob(LivingEntity mob)
|
||||
{
|
||||
mob_thrower_queue.add(mob);
|
||||
if (mob_thrower_queue.size() > 4)
|
||||
mobThrowerQueue.add(mob);
|
||||
if (mobThrowerQueue.size() > 4)
|
||||
{
|
||||
LivingEntity oldmob = mob_thrower_queue.remove(0);
|
||||
LivingEntity oldmob = mobThrowerQueue.remove(0);
|
||||
if (oldmob != null)
|
||||
{
|
||||
oldmob.damage(500.0);
|
||||
@ -307,85 +307,85 @@ public class TFM_PlayerData
|
||||
public void startArrowShooter(TotalFreedomMod plugin)
|
||||
{
|
||||
this.stopArrowShooter();
|
||||
this.mp44_schedule_id = new ArrowShooter(this.player).runTaskTimer(plugin, 1L, 1L);
|
||||
mp44_firing = true;
|
||||
this.mp44ScheduleId = new ArrowShooter(this.player).runTaskTimer(plugin, 1L, 1L);
|
||||
this.mp44Firing = true;
|
||||
}
|
||||
|
||||
public void stopArrowShooter()
|
||||
{
|
||||
if (this.mp44_schedule_id != null)
|
||||
if (this.mp44ScheduleId != null)
|
||||
{
|
||||
this.mp44_schedule_id.cancel();
|
||||
this.mp44_schedule_id = null;
|
||||
this.mp44ScheduleId.cancel();
|
||||
this.mp44ScheduleId = null;
|
||||
}
|
||||
mp44_firing = false;
|
||||
this.mp44Firing = false;
|
||||
}
|
||||
|
||||
private class ArrowShooter extends BukkitRunnable
|
||||
{
|
||||
private Player _player;
|
||||
private Player player;
|
||||
|
||||
public ArrowShooter(Player player)
|
||||
{
|
||||
this._player = player;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
Arrow shot_arrow = _player.launchProjectile(Arrow.class);
|
||||
shot_arrow.setVelocity(shot_arrow.getVelocity().multiply(2.0));
|
||||
Arrow shot = player.launchProjectile(Arrow.class);
|
||||
shot.setVelocity(shot.getVelocity().multiply(2.0));
|
||||
}
|
||||
}
|
||||
|
||||
public void armMP44()
|
||||
{
|
||||
mp44_armed = true;
|
||||
this.mp44Armed = true;
|
||||
this.stopArrowShooter();
|
||||
}
|
||||
|
||||
public void disarmMP44()
|
||||
{
|
||||
mp44_armed = false;
|
||||
this.mp44Armed = false;
|
||||
this.stopArrowShooter();
|
||||
}
|
||||
|
||||
public boolean isMP44Armed()
|
||||
{
|
||||
return mp44_armed;
|
||||
return this.mp44Armed;
|
||||
}
|
||||
|
||||
public boolean toggleMP44Firing()
|
||||
{
|
||||
this.mp44_firing = !this.mp44_firing;
|
||||
return mp44_firing;
|
||||
this.mp44Firing = !this.mp44Firing;
|
||||
return mp44Firing;
|
||||
}
|
||||
|
||||
public boolean isMuted()
|
||||
{
|
||||
return is_muted;
|
||||
return isMuted;
|
||||
}
|
||||
|
||||
public void setMuted(boolean is_muted)
|
||||
public void setMuted(boolean muted)
|
||||
{
|
||||
this.is_muted = is_muted;
|
||||
this.isMuted = muted;
|
||||
}
|
||||
|
||||
public boolean isHalted()
|
||||
{
|
||||
return is_halted;
|
||||
return this.isHalted;
|
||||
}
|
||||
|
||||
public void setHalted(boolean is_halted)
|
||||
public void setHalted(boolean halted)
|
||||
{
|
||||
this.is_halted = is_halted;
|
||||
this.isHalted = halted;
|
||||
|
||||
if (is_halted)
|
||||
if (halted)
|
||||
{
|
||||
player.setOp(false);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setFlying(false);
|
||||
player.setDisplayName(player_name);
|
||||
player.setDisplayName(username);
|
||||
player.closeInventory();
|
||||
player.setTotalExperience(0);
|
||||
|
||||
@ -409,76 +409,76 @@ public class TFM_PlayerData
|
||||
|
||||
public BukkitTask getLockupScheduleID()
|
||||
{
|
||||
return lockup_schedule_id;
|
||||
return this.lockupScheduleId;
|
||||
}
|
||||
|
||||
public void setLockupScheduleID(BukkitTask lockup_schedule_id)
|
||||
public void setLockupScheduleID(BukkitTask id)
|
||||
{
|
||||
this.lockup_schedule_id = lockup_schedule_id;
|
||||
this.lockupScheduleId = id;
|
||||
}
|
||||
|
||||
public void setLastMessage(String last_message)
|
||||
public void setLastMessage(String message)
|
||||
{
|
||||
this.last_message = last_message;
|
||||
this.lastMessage = message;
|
||||
}
|
||||
|
||||
public String getLastMessage()
|
||||
{
|
||||
return last_message;
|
||||
return lastMessage;
|
||||
}
|
||||
|
||||
public void setAdminChat(boolean in_adminchat)
|
||||
public void setAdminChat(boolean inAdminchat)
|
||||
{
|
||||
this.in_adminchat = in_adminchat;
|
||||
this.inAdminchat = inAdminchat;
|
||||
}
|
||||
|
||||
public boolean inAdminChat()
|
||||
{
|
||||
return in_adminchat;
|
||||
return this.inAdminchat;
|
||||
}
|
||||
|
||||
public boolean allCommandsBlocked()
|
||||
{
|
||||
return all_commands_blocked;
|
||||
return this.allCommandsBlocked;
|
||||
}
|
||||
|
||||
public void setCommandsBlocked(boolean commands_blocked)
|
||||
public void setCommandsBlocked(boolean commandsBlocked)
|
||||
{
|
||||
this.all_commands_blocked = commands_blocked;
|
||||
this.allCommandsBlocked = commandsBlocked;
|
||||
}
|
||||
|
||||
//If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
||||
//After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
||||
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
||||
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
||||
public Boolean isSuperadminIdVerified()
|
||||
{
|
||||
return superadmin_id_verified;
|
||||
return this.verifiedSuperadminId;
|
||||
}
|
||||
|
||||
//If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
||||
//After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
||||
public void setSuperadminIdVerified(Boolean superadmin_id_verified)
|
||||
// If someone logs in to telnet or minecraft, and they are an admin, make sure that they are using a username that is associated with their IP.
|
||||
// After the check for this is done in TFM_PlayerListener, never change it elsewhere.
|
||||
public void setSuperadminIdVerified(Boolean verifiedSuperadminId)
|
||||
{
|
||||
this.superadmin_id_verified = superadmin_id_verified;
|
||||
this.verifiedSuperadminId = verifiedSuperadminId;
|
||||
}
|
||||
|
||||
public String getLastCommand()
|
||||
{
|
||||
return last_command;
|
||||
return lastCommand;
|
||||
}
|
||||
|
||||
public void setLastCommand(String last_command)
|
||||
public void setLastCommand(String lastCommand)
|
||||
{
|
||||
this.last_command = last_command;
|
||||
this.lastCommand = lastCommand;
|
||||
}
|
||||
|
||||
public void setCommandSpy(boolean cmdspy_enabled)
|
||||
public void setCommandSpy(boolean enabled)
|
||||
{
|
||||
this.cmdspy_enabled = cmdspy_enabled;
|
||||
this.cmdspyEnabled = enabled;
|
||||
}
|
||||
|
||||
public boolean cmdspyEnabled()
|
||||
{
|
||||
return cmdspy_enabled;
|
||||
return cmdspyEnabled;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
|
@ -18,27 +18,27 @@ public class TFM_ProtectedArea implements Serializable
|
||||
private static final long serialVersionUID = -3270338811000937254L;
|
||||
public static final double MAX_RADIUS = 50.0D;
|
||||
private static Map<String, TFM_ProtectedArea> protectedAreas = new HashMap<String, TFM_ProtectedArea>();
|
||||
private final SerializableLocation center_location;
|
||||
private final SerializableLocation center;
|
||||
private final double radius;
|
||||
|
||||
private TFM_ProtectedArea(Location root_location, double radius)
|
||||
{
|
||||
this.center_location = new SerializableLocation(root_location);
|
||||
this.center = new SerializableLocation(root_location);
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public static boolean isInProtectedArea(Location check_location)
|
||||
public static boolean isInProtectedArea(Location location)
|
||||
{
|
||||
for (Map.Entry<String, TFM_ProtectedArea> protected_area : TFM_ProtectedArea.protectedAreas.entrySet())
|
||||
for (Map.Entry<String, TFM_ProtectedArea> protectedArea : TFM_ProtectedArea.protectedAreas.entrySet())
|
||||
{
|
||||
Location protected_area_center = SerializableLocation.returnLocation(protected_area.getValue().center_location);
|
||||
if (protected_area_center != null)
|
||||
Location protectedAreaCenter = SerializableLocation.returnLocation(protectedArea.getValue().center);
|
||||
if (protectedAreaCenter != null)
|
||||
{
|
||||
if (check_location.getWorld() == protected_area_center.getWorld())
|
||||
if (location.getWorld() == protectedAreaCenter.getWorld())
|
||||
{
|
||||
double protected_area_radius = protected_area.getValue().radius;
|
||||
double protectedAreaRadius = protectedArea.getValue().radius;
|
||||
|
||||
if (check_location.distanceSquared(protected_area_center) <= (protected_area_radius * protected_area_radius))
|
||||
if (location.distanceSquared(protectedAreaCenter) <= (protectedAreaRadius * protectedAreaRadius))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -49,9 +49,9 @@ public class TFM_ProtectedArea implements Serializable
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addProtectedArea(String label, Location root_location, double radius)
|
||||
public static void addProtectedArea(String label, Location location, double radius)
|
||||
{
|
||||
TFM_ProtectedArea.protectedAreas.put(label.toLowerCase(), new TFM_ProtectedArea(root_location, radius));
|
||||
TFM_ProtectedArea.protectedAreas.put(label.toLowerCase(), new TFM_ProtectedArea(location, radius));
|
||||
saveProtectedAreas();
|
||||
}
|
||||
|
||||
@ -62,9 +62,19 @@ public class TFM_ProtectedArea implements Serializable
|
||||
}
|
||||
|
||||
public static void clearProtectedAreas()
|
||||
{
|
||||
clearProtectedAreas(false);
|
||||
}
|
||||
|
||||
public static void clearProtectedAreas(boolean hard)
|
||||
{
|
||||
TFM_ProtectedArea.protectedAreas.clear();
|
||||
|
||||
if (!hard)
|
||||
{
|
||||
autoAddSpawnpoints();
|
||||
}
|
||||
|
||||
saveProtectedAreas();
|
||||
}
|
||||
|
||||
@ -94,10 +104,10 @@ public class TFM_ProtectedArea implements Serializable
|
||||
{
|
||||
try
|
||||
{
|
||||
File input_file = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PROTECTED_AREA_FILE);
|
||||
if (input_file.exists())
|
||||
File input = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PROTECTED_AREA_FILE);
|
||||
if (input.exists())
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(input_file);
|
||||
FileInputStream fis = new FileInputStream(input);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
TFM_ProtectedArea.protectedAreas = (HashMap<String, TFM_ProtectedArea>) ois.readObject();
|
||||
ois.close();
|
||||
@ -106,8 +116,8 @@ public class TFM_ProtectedArea implements Serializable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
File input_file = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PROTECTED_AREA_FILE);
|
||||
input_file.delete();
|
||||
File input = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.PROTECTED_AREA_FILE);
|
||||
input.delete();
|
||||
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
@ -115,11 +125,11 @@ public class TFM_ProtectedArea implements Serializable
|
||||
|
||||
public static void autoAddSpawnpoints()
|
||||
{
|
||||
if (TotalFreedomMod.autoProtectSpawnpoints)
|
||||
if (TFM_ConfigEntry.AUTO_PROTECT_SPAWNPOINTS.getBoolean())
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
TFM_ProtectedArea.addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), TotalFreedomMod.autoProtectRadius);
|
||||
TFM_ProtectedArea.addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), TFM_ConfigEntry.AUTO_PROTECT_RADIUS.getDouble());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
package me.StevenLawson.TotalFreedomMod;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class TFM_RollbackManager
|
||||
{
|
||||
private static final Map<String, List<TFM_RollbackManager_Entry>> PLAYER_HISTORY_MAP = new HashMap<String, List<TFM_RollbackManager_Entry>>();
|
||||
private static final Map<String, List<RollbackEntry>> PLAYER_HISTORY = new HashMap<String, List<RollbackEntry>>();
|
||||
private static final List<String> REMOVE_ROLLBACK_HISTORY = new ArrayList<String>();
|
||||
|
||||
private TFM_RollbackManager()
|
||||
{
|
||||
@ -21,17 +25,18 @@ public class TFM_RollbackManager
|
||||
|
||||
public static void blockPlace(org.bukkit.event.block.BlockPlaceEvent event)
|
||||
{
|
||||
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_PLACE));
|
||||
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE));
|
||||
}
|
||||
|
||||
public static void blockBreak(org.bukkit.event.block.BlockBreakEvent event)
|
||||
{
|
||||
storeEntry(event.getPlayer(), new TFM_RollbackManager_Entry(event.getBlock(), TFM_RollbackManager_EntryType.BLOCK_BREAK));
|
||||
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK));
|
||||
}
|
||||
|
||||
private static void storeEntry(Player player, TFM_RollbackManager_Entry entry)
|
||||
private static void storeEntry(Player player, RollbackEntry entry)
|
||||
{
|
||||
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(player.getName());
|
||||
List<RollbackEntry> playerEntryList = getEntriesByPlayer(player.getName());
|
||||
|
||||
if (playerEntryList != null)
|
||||
{
|
||||
playerEntryList.add(0, entry);
|
||||
@ -40,99 +45,246 @@ public class TFM_RollbackManager
|
||||
|
||||
public static int purgeEntries()
|
||||
{
|
||||
Iterator<List<TFM_RollbackManager_Entry>> it = PLAYER_HISTORY_MAP.values().iterator();
|
||||
Iterator<List<RollbackEntry>> it = PLAYER_HISTORY.values().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
List<TFM_RollbackManager_Entry> playerEntryList = it.next();
|
||||
List<RollbackEntry> playerEntryList = it.next();
|
||||
if (playerEntryList != null)
|
||||
{
|
||||
playerEntryList.clear();
|
||||
}
|
||||
}
|
||||
return PLAYER_HISTORY_MAP.size();
|
||||
return PLAYER_HISTORY.size();
|
||||
}
|
||||
|
||||
public static int purgeEntries(String playerName)
|
||||
{
|
||||
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(playerName);
|
||||
if (playerEntryList != null)
|
||||
List<RollbackEntry> playerEntryList = getEntriesByPlayer(playerName);
|
||||
|
||||
if (playerEntryList == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = playerEntryList.size();
|
||||
playerEntryList.clear();
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static boolean canRollback(String playerName)
|
||||
{
|
||||
return PLAYER_HISTORY_MAP.containsKey(playerName.toLowerCase());
|
||||
return PLAYER_HISTORY.containsKey(playerName.toLowerCase()) && !PLAYER_HISTORY.get(playerName.toLowerCase()).isEmpty();
|
||||
}
|
||||
|
||||
public static int rollback(String playerName)
|
||||
public static boolean canUndoRollback(String playerName)
|
||||
{
|
||||
List<TFM_RollbackManager_Entry> playerEntryList = getPlayerEntryList(playerName);
|
||||
if (playerEntryList != null)
|
||||
return REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
public static int rollback(final String playerName)
|
||||
{
|
||||
int count = playerEntryList.size();
|
||||
Iterator<TFM_RollbackManager_Entry> it = playerEntryList.iterator();
|
||||
while (it.hasNext())
|
||||
final List<RollbackEntry> entries = getEntriesByPlayer(playerName);
|
||||
if (entries == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = entries.size();
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
TFM_RollbackManager_Entry entry = it.next();
|
||||
if (entry != null)
|
||||
{
|
||||
entry.restore();
|
||||
}
|
||||
it.remove();
|
||||
}
|
||||
|
||||
if (!REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase()))
|
||||
{
|
||||
REMOVE_ROLLBACK_HISTORY.add(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
new BukkitRunnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase()))
|
||||
{
|
||||
REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase());
|
||||
purgeEntries(playerName);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(TotalFreedomMod.plugin, 20L * 20L);
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int undoRollback(String playerName)
|
||||
{
|
||||
List<RollbackEntry> entries = getEntriesByPlayer(playerName);
|
||||
|
||||
if (entries == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static List<TFM_RollbackManager_Entry> getPlayerEntryList(String playerName)
|
||||
entries = Lists.reverse(entries);
|
||||
|
||||
int count = entries.size();
|
||||
for (RollbackEntry entry : entries)
|
||||
{
|
||||
if (entry != null)
|
||||
{
|
||||
entry.redo();
|
||||
}
|
||||
}
|
||||
|
||||
if (REMOVE_ROLLBACK_HISTORY.contains(playerName.toLowerCase()))
|
||||
{
|
||||
REMOVE_ROLLBACK_HISTORY.remove(playerName.toLowerCase());
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static List<RollbackEntry> getEntriesAtLocation(final Location location)
|
||||
{
|
||||
final int testX = location.getBlockX();
|
||||
final short testY = (short) location.getBlockY();
|
||||
final int testZ = location.getBlockZ();
|
||||
final String testWorldName = location.getWorld().getName();
|
||||
|
||||
List<RollbackEntry> entries = new ArrayList<RollbackEntry>();
|
||||
for (String playername : PLAYER_HISTORY.keySet())
|
||||
{
|
||||
for (RollbackEntry entry : PLAYER_HISTORY.get(playername.toLowerCase()))
|
||||
{
|
||||
if (testX == entry.x && testY == entry.y && testZ == entry.z && testWorldName.equals(entry.worldName))
|
||||
{
|
||||
entries.add(0, entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
private static List<RollbackEntry> getEntriesByPlayer(String playerName)
|
||||
{
|
||||
playerName = playerName.toLowerCase();
|
||||
List<TFM_RollbackManager_Entry> playerEntryList = PLAYER_HISTORY_MAP.get(playerName);
|
||||
List<RollbackEntry> playerEntryList = PLAYER_HISTORY.get(playerName.toLowerCase());
|
||||
if (playerEntryList == null)
|
||||
{
|
||||
playerEntryList = new ArrayList<TFM_RollbackManager_Entry>();
|
||||
PLAYER_HISTORY_MAP.put(playerName, playerEntryList);
|
||||
playerEntryList = new ArrayList<RollbackEntry>();
|
||||
PLAYER_HISTORY.put(playerName.toLowerCase(), playerEntryList);
|
||||
}
|
||||
return playerEntryList;
|
||||
}
|
||||
|
||||
private enum TFM_RollbackManager_EntryType
|
||||
public enum EntryType
|
||||
{
|
||||
BLOCK_PLACE, BLOCK_BREAK
|
||||
BLOCK_PLACE("placed"),
|
||||
BLOCK_BREAK("broke");
|
||||
private final String action;
|
||||
|
||||
private EntryType(String action)
|
||||
{
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
private static class TFM_RollbackManager_Entry
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
private final Location location;
|
||||
private final Material material;
|
||||
private final byte data;
|
||||
return this.action;
|
||||
}
|
||||
}
|
||||
|
||||
public TFM_RollbackManager_Entry(Block block, TFM_RollbackManager_EntryType entryType)
|
||||
public static class RollbackEntry
|
||||
{
|
||||
this.location = block.getLocation();
|
||||
if (entryType == TFM_RollbackManager_EntryType.BLOCK_BREAK)
|
||||
// Use of primitives to decrease overhead
|
||||
public final String author;
|
||||
public final String worldName;
|
||||
public final int x;
|
||||
public final short y;
|
||||
public final int z;
|
||||
public final byte data;
|
||||
public final short blockId;
|
||||
private final boolean isBreak;
|
||||
|
||||
private RollbackEntry(String author, Block block, EntryType entryType)
|
||||
{
|
||||
this.material = block.getType();
|
||||
final Location location = block.getLocation();
|
||||
|
||||
this.x = location.getBlockX();
|
||||
this.y = (short) location.getBlockY();
|
||||
this.z = location.getBlockZ();
|
||||
this.worldName = location.getWorld().getName();
|
||||
this.author = author;
|
||||
|
||||
if (entryType == EntryType.BLOCK_BREAK)
|
||||
{
|
||||
this.blockId = (short) block.getTypeId();
|
||||
this.data = block.getData();
|
||||
this.isBreak = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.material = Material.AIR;
|
||||
this.data = 0;
|
||||
this.blockId = (short) block.getTypeId();
|
||||
this.data = block.getData();
|
||||
this.isBreak = false;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Location(Bukkit.getWorld(worldName), (double) x, (double) y, (double) z);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.warning("Could not get location of rollback entry at (" + worldName + ":" + x + "," + y + "," + x + ")!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Material getMaterial()
|
||||
{
|
||||
return Material.getMaterial(blockId);
|
||||
}
|
||||
|
||||
public EntryType getType()
|
||||
{
|
||||
return (isBreak ? EntryType.BLOCK_BREAK : EntryType.BLOCK_PLACE);
|
||||
}
|
||||
|
||||
public void restore()
|
||||
{
|
||||
Block b = this.location.getWorld().getBlockAt(this.location);
|
||||
b.setType(this.material);
|
||||
b.setData(this.data);
|
||||
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
|
||||
if (isBreak)
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
block.setData(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
public void redo()
|
||||
{
|
||||
final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
|
||||
|
||||
if (isBreak)
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
else
|
||||
{
|
||||
block.setType(getMaterial());
|
||||
block.setData(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package me.StevenLawson.TotalFreedomMod;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import net.minecraft.server.v1_6_R2.BanEntry;
|
||||
@ -17,7 +18,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class TFM_ServerInterface
|
||||
{
|
||||
private static final SimpleDateFormat date_format = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||
|
||||
public static void setOnlineMode(boolean mode)
|
||||
{
|
||||
@ -47,24 +48,41 @@ public class TFM_ServerInterface
|
||||
nameBans.remove(name);
|
||||
}
|
||||
|
||||
public static void banUsername(String name, String reason, String source, Date expire_date)
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void banUsername(String name, String reason, String source, Date expireDate)
|
||||
{
|
||||
name = name.toLowerCase().trim();
|
||||
BanEntry ban_entry = new BanEntry(name);
|
||||
if (expire_date != null)
|
||||
|
||||
if (TFM_SuperadminList.getSuperadminNames().contains(name))
|
||||
{
|
||||
ban_entry.setExpires(expire_date);
|
||||
TFM_Log.info("Not banning username " + name + ": is superadmin");
|
||||
return;
|
||||
}
|
||||
|
||||
for (String username : (List<String>) TFM_ConfigEntry.UNBANNABLE_USERNAMES.getList())
|
||||
{
|
||||
if (username.toLowerCase().trim().equals(name))
|
||||
{
|
||||
TFM_Log.info("Not banning username " + name + ": is unbannable as defined in config.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BanEntry entry = new BanEntry(name);
|
||||
if (expireDate != null)
|
||||
{
|
||||
entry.setExpires(expireDate);
|
||||
}
|
||||
if (reason != null)
|
||||
{
|
||||
ban_entry.setReason(reason);
|
||||
entry.setReason(reason);
|
||||
}
|
||||
if (source != null)
|
||||
{
|
||||
ban_entry.setSource(source);
|
||||
entry.setSource(source);
|
||||
}
|
||||
BanList nameBans = MinecraftServer.getServer().getPlayerList().getNameBans();
|
||||
nameBans.add(ban_entry);
|
||||
nameBans.add(entry);
|
||||
}
|
||||
|
||||
public static boolean isNameBanned(String name)
|
||||
@ -75,24 +93,24 @@ public class TFM_ServerInterface
|
||||
return nameBans.getEntries().containsKey(name);
|
||||
}
|
||||
|
||||
public static void banIP(String ip, String reason, String source, Date expire_date)
|
||||
public static void banIP(String ip, String reason, String source, Date expireDate)
|
||||
{
|
||||
ip = ip.toLowerCase().trim();
|
||||
BanEntry ban_entry = new BanEntry(ip);
|
||||
if (expire_date != null)
|
||||
BanEntry entry = new BanEntry(ip);
|
||||
if (expireDate != null)
|
||||
{
|
||||
ban_entry.setExpires(expire_date);
|
||||
entry.setExpires(expireDate);
|
||||
}
|
||||
if (reason != null)
|
||||
{
|
||||
ban_entry.setReason(reason);
|
||||
entry.setReason(reason);
|
||||
}
|
||||
if (source != null)
|
||||
{
|
||||
ban_entry.setSource(source);
|
||||
entry.setSource(source);
|
||||
}
|
||||
BanList ipBans = MinecraftServer.getServer().getPlayerList().getIPBans();
|
||||
ipBans.add(ban_entry);
|
||||
ipBans.add(entry);
|
||||
}
|
||||
|
||||
public static void unbanIP(String ip)
|
||||
@ -110,7 +128,6 @@ public class TFM_ServerInterface
|
||||
return ipBans.getEntries().containsKey(ip);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public static int purgeWhitelist()
|
||||
{
|
||||
Set whitelisted = MinecraftServer.getServer().getPlayerList().getWhitelisted();
|
||||
@ -126,115 +143,114 @@ public class TFM_ServerInterface
|
||||
|
||||
final Server server = TotalFreedomMod.plugin.getServer();
|
||||
|
||||
final PlayerList player_list = MinecraftServer.getServer().getPlayerList();
|
||||
final BanList banByIP = player_list.getIPBans();
|
||||
final BanList banByName = player_list.getNameBans();
|
||||
final PlayerList playerList = MinecraftServer.getServer().getPlayerList();
|
||||
final BanList banByIP = playerList.getIPBans();
|
||||
final BanList banByName = playerList.getNameBans();
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
final String player_name = player.getName();
|
||||
final String player_ip = event.getAddress().getHostAddress().trim().toLowerCase();
|
||||
final String username = player.getName();
|
||||
final String ip = event.getAddress().getHostAddress().trim().toLowerCase();
|
||||
|
||||
if (player_name.trim().length() <= 2)
|
||||
if (username.trim().length() <= 2)
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is too short (must be at least 3 characters long).");
|
||||
return;
|
||||
}
|
||||
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(player_name).find())
|
||||
else if (Pattern.compile("[^a-zA-Z0-9\\-\\.\\_]").matcher(username).find())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username contains invalid characters.");
|
||||
return;
|
||||
}
|
||||
|
||||
// not safe to use TFM_Util.isUserSuperadmin for player logging in because player.getAddress() will return a null until after player login.
|
||||
boolean is_superadmin;
|
||||
boolean isSuperadmin;
|
||||
if (server.getOnlineMode())
|
||||
{
|
||||
is_superadmin = TFM_SuperadminList.getSuperadminNames().contains(player_name.toLowerCase());
|
||||
isSuperadmin = TFM_SuperadminList.getSuperadminNames().contains(username.toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
is_superadmin = TFM_SuperadminList.checkPartialSuperadminIP(player_ip, player_name.toLowerCase());
|
||||
isSuperadmin = TFM_SuperadminList.checkPartialSuperadminIP(ip, username.toLowerCase());
|
||||
}
|
||||
|
||||
if (!is_superadmin)
|
||||
if (!isSuperadmin)
|
||||
{
|
||||
BanEntry ban_entry = null;
|
||||
BanEntry entry = null;
|
||||
|
||||
if (banByName.isBanned(player_name.toLowerCase()))
|
||||
if (banByName.isBanned(username.toLowerCase()))
|
||||
{
|
||||
ban_entry = (BanEntry) banByName.getEntries().get(player_name.toLowerCase());
|
||||
entry = (BanEntry) banByName.getEntries().get(username.toLowerCase());
|
||||
|
||||
String kick_message = ChatColor.RED + "You are banned from this server.";
|
||||
if (ban_entry != null)
|
||||
String kickMessage = ChatColor.RED + "You are banned from this server.";
|
||||
if (entry != null)
|
||||
{
|
||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||
if (ban_entry.getExpires() != null)
|
||||
kickMessage = kickMessage + "\nReason: " + entry.getReason();
|
||||
if (entry.getExpires() != null)
|
||||
{
|
||||
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||
kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(entry.getExpires());
|
||||
}
|
||||
}
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kick_message);
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kickMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean is_ip_banned = false;
|
||||
boolean isIpBanned = false;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator ip_bans = banByIP.getEntries().keySet().iterator();
|
||||
while (ip_bans.hasNext())
|
||||
Iterator ipBans = banByIP.getEntries().keySet().iterator();
|
||||
while (ipBans.hasNext())
|
||||
{
|
||||
String test_ip = (String) ip_bans.next();
|
||||
String testIp = (String) ipBans.next();
|
||||
|
||||
if (!test_ip.matches("^\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3}|\\*)\\.(\\d{1,3}|\\*)$"))
|
||||
if (!testIp.matches("^\\d{1,3}\\.\\d{1,3}\\.(\\d{1,3}|\\*)\\.(\\d{1,3}|\\*)$"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (player_ip.equals(test_ip))
|
||||
if (ip.equals(testIp))
|
||||
{
|
||||
ban_entry = (BanEntry) banByIP.getEntries().get(test_ip);
|
||||
is_ip_banned = true;
|
||||
entry = (BanEntry) banByIP.getEntries().get(testIp);
|
||||
isIpBanned = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
|
||||
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
|
||||
{
|
||||
ban_entry = (BanEntry) banByIP.getEntries().get(test_ip);
|
||||
is_ip_banned = true;
|
||||
entry = (BanEntry) banByIP.getEntries().get(testIp);
|
||||
isIpBanned = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_ip_banned)
|
||||
if (isIpBanned)
|
||||
{
|
||||
String kick_message = ChatColor.RED + "Your IP address is banned from this server.";
|
||||
if (ban_entry != null)
|
||||
String kickMessage = ChatColor.RED + "Your IP address is banned from this server.";
|
||||
if (entry != null)
|
||||
{
|
||||
kick_message = kick_message + "\nReason: " + ban_entry.getReason();
|
||||
if (ban_entry.getExpires() != null)
|
||||
kickMessage = kickMessage + "\nReason: " + entry.getReason();
|
||||
if (entry.getExpires() != null)
|
||||
{
|
||||
kick_message = kick_message + "\nYour ban will be removed on " + date_format.format(ban_entry.getExpires());
|
||||
kickMessage = kickMessage + "\nYour ban will be removed on " + dateFormat.format(entry.getExpires());
|
||||
}
|
||||
}
|
||||
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kick_message);
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, kickMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String test_player : TotalFreedomMod.permbanned_players)
|
||||
for (String testPlayer : TotalFreedomMod.permbanned_players)
|
||||
{
|
||||
if (test_player.equalsIgnoreCase(player_name))
|
||||
if (testPlayer.equalsIgnoreCase(username))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your username is permanently banned from this server.\nRelease procedures are available at http://bit.ly/PermBan");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (String test_ip : TotalFreedomMod.permbanned_ips)
|
||||
for (String testIp : TotalFreedomMod.permbanned_ips)
|
||||
{
|
||||
if (TFM_Util.fuzzyIpMatch(test_ip, player_ip, 4))
|
||||
if (TFM_Util.fuzzyIpMatch(testIp, ip, 4))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, ChatColor.RED + "Your IP address is permanently banned from this server.\nRelease procedures are available at http://bit.ly/PermBan");
|
||||
return;
|
||||
@ -247,7 +263,7 @@ public class TFM_ServerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (TotalFreedomMod.adminOnlyMode)
|
||||
if (TFM_ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
|
||||
return;
|
||||
@ -259,9 +275,9 @@ public class TFM_ServerInterface
|
||||
return;
|
||||
}
|
||||
|
||||
if (player_list.hasWhitelist)
|
||||
if (playerList.hasWhitelist)
|
||||
{
|
||||
if (!player_list.getWhitelisted().contains(player_name.toLowerCase()))
|
||||
if (!playerList.getWhitelisted().contains(username.toLowerCase()))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||
return;
|
||||
@ -270,7 +286,7 @@ public class TFM_ServerInterface
|
||||
|
||||
for (Player test_player : server.getOnlinePlayers())
|
||||
{
|
||||
if (test_player.getName().equalsIgnoreCase(player_name))
|
||||
if (test_player.getName().equalsIgnoreCase(username))
|
||||
{
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
|
||||
return;
|
||||
@ -279,24 +295,24 @@ public class TFM_ServerInterface
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player test_player : server.getOnlinePlayers())
|
||||
for (Player testPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (test_player.getName().equalsIgnoreCase(player_name))
|
||||
if (testPlayer.getName().equalsIgnoreCase(username))
|
||||
{
|
||||
test_player.kickPlayer("An admin just logged in with the username you are using.");
|
||||
testPlayer.kickPlayer("An admin just logged in with the username you are using.");
|
||||
}
|
||||
}
|
||||
|
||||
boolean can_kick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
|
||||
while (server.getOnlinePlayers().length >= server.getMaxPlayers() && can_kick)
|
||||
boolean canKick = true; // if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
|
||||
while (server.getOnlinePlayers().length >= server.getMaxPlayers() && canKick)
|
||||
{
|
||||
can_kick = false;
|
||||
for (Player test_player : server.getOnlinePlayers())
|
||||
canKick = false;
|
||||
for (Player testPlayer : server.getOnlinePlayers())
|
||||
{
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(test_player))
|
||||
if (!TFM_SuperadminList.isUserSuperadmin(testPlayer))
|
||||
{
|
||||
can_kick = true;
|
||||
test_player.kickPlayer("You have been kicked to free up room for an admin.");
|
||||
canKick = true;
|
||||
testPlayer.kickPlayer("You have been kicked to free up room for an admin.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -40,23 +40,30 @@ public class TFM_ServiceChecker
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final String serviceCheckerURL = TFM_ConfigEntry.SERVICE_CHECKER_URL.getString();
|
||||
|
||||
if (serviceCheckerURL == null || serviceCheckerURL.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
URL mojang_status = new URL(TotalFreedomMod.serviceCheckerURL);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
|
||||
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
|
||||
URL mojangStatus = new URL(serviceCheckerURL);
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mojangStatus.openStream()));
|
||||
JSONArray statusJson = (JSONArray) JSONValue.parse(in.readLine());
|
||||
in.close();
|
||||
|
||||
TFM_ServiceChecker serviceChecker = TFM_ServiceChecker.getInstance();
|
||||
|
||||
Iterator status_it = status_json.iterator();
|
||||
Iterator status_it = statusJson.iterator();
|
||||
while (status_it.hasNext())
|
||||
{
|
||||
JSONObject service = (JSONObject) status_it.next();
|
||||
Iterator service_it = service.entrySet().iterator();
|
||||
while (service_it.hasNext())
|
||||
Iterator serviceIt = service.entrySet().iterator();
|
||||
while (serviceIt.hasNext())
|
||||
{
|
||||
Entry<String, String> pair = (Entry<String, String>) service_it.next();
|
||||
Entry<String, String> pair = (Entry<String, String>) serviceIt.next();
|
||||
|
||||
if ("lastcheck".equals(pair.getKey()))
|
||||
{
|
||||
@ -90,7 +97,7 @@ public class TFM_ServiceChecker
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe("Error updating mojang services from " + TotalFreedomMod.serviceCheckerURL);
|
||||
TFM_Log.severe("Error updating mojang services from " + serviceCheckerURL);
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
@ -8,33 +8,33 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
public class TFM_Superadmin
|
||||
{
|
||||
private final String name;
|
||||
private final String custom_login_message;
|
||||
private final boolean is_senior_admin;
|
||||
private final List<String> console_aliases;
|
||||
private final String loginMessage;
|
||||
private final boolean isSeniorAdmin;
|
||||
private final List<String> consoleAliases;
|
||||
private List<String> ips;
|
||||
private Date last_login;
|
||||
private boolean is_activated;
|
||||
private Date lastLogin;
|
||||
private boolean isActivated;
|
||||
|
||||
public TFM_Superadmin(String name, List<String> ips, Date last_login, String custom_login_message, boolean is_senior_admin, List<String> console_aliases, boolean is_activated)
|
||||
public TFM_Superadmin(String name, List<String> ips, Date lastLogin, String loginMessage, boolean isSeniorAdmin, List<String> consoleAliases, boolean isActivated)
|
||||
{
|
||||
this.name = name.toLowerCase();
|
||||
this.ips = ips;
|
||||
this.last_login = last_login;
|
||||
this.custom_login_message = custom_login_message;
|
||||
this.is_senior_admin = is_senior_admin;
|
||||
this.console_aliases = console_aliases;
|
||||
this.is_activated = is_activated;
|
||||
this.lastLogin = lastLogin;
|
||||
this.loginMessage = loginMessage;
|
||||
this.isSeniorAdmin = isSeniorAdmin;
|
||||
this.consoleAliases = consoleAliases;
|
||||
this.isActivated = isActivated;
|
||||
}
|
||||
|
||||
public TFM_Superadmin(String name, ConfigurationSection section)
|
||||
{
|
||||
this.name = name.toLowerCase();
|
||||
this.ips = section.getStringList("ips");
|
||||
this.last_login = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
|
||||
this.custom_login_message = section.getString("custom_login_message", "");
|
||||
this.is_senior_admin = section.getBoolean("is_senior_admin", false);
|
||||
this.console_aliases = section.getStringList("console_aliases");
|
||||
this.is_activated = section.getBoolean("is_activated", true);
|
||||
this.lastLogin = TFM_Util.stringToDate(section.getString("last_login", TFM_Util.dateToString(new Date(0L))));
|
||||
this.loginMessage = section.getString("custom_login_message", "");
|
||||
this.isSeniorAdmin = section.getBoolean("is_senior_admin", false);
|
||||
this.consoleAliases = section.getStringList("console_aliases");
|
||||
this.isActivated = section.getBoolean("is_activated", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -46,11 +46,11 @@ public class TFM_Superadmin
|
||||
{
|
||||
output.append("Name: ").append(this.name).append("\n");
|
||||
output.append("- IPs: ").append(StringUtils.join(this.ips, ", ")).append("\n");
|
||||
output.append("- Last Login: ").append(TFM_Util.dateToString(this.last_login)).append("\n");
|
||||
output.append("- Custom Login Message: ").append(this.custom_login_message).append("\n");
|
||||
output.append("- Is Senior Admin: ").append(this.is_senior_admin).append("\n");
|
||||
output.append("- Console Aliases: ").append(StringUtils.join(this.console_aliases, ", ")).append("\n");
|
||||
output.append("- Is Activated: ").append(this.is_activated);
|
||||
output.append("- Last Login: ").append(TFM_Util.dateToString(this.lastLogin)).append("\n");
|
||||
output.append("- Custom Login Message: ").append(this.loginMessage).append("\n");
|
||||
output.append("- Is Senior Admin: ").append(this.isSeniorAdmin).append("\n");
|
||||
output.append("- Console Aliases: ").append(StringUtils.join(this.consoleAliases, ", ")).append("\n");
|
||||
output.append("- Is Activated: ").append(this.isActivated);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -72,22 +72,22 @@ public class TFM_Superadmin
|
||||
|
||||
public Date getLastLogin()
|
||||
{
|
||||
return last_login;
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public String getCustomLoginMessage()
|
||||
{
|
||||
return custom_login_message;
|
||||
return loginMessage;
|
||||
}
|
||||
|
||||
public boolean isSeniorAdmin()
|
||||
{
|
||||
return is_senior_admin;
|
||||
return isSeniorAdmin;
|
||||
}
|
||||
|
||||
public List<String> getConsoleAliases()
|
||||
{
|
||||
return console_aliases;
|
||||
return consoleAliases;
|
||||
}
|
||||
|
||||
public void setIps(List<String> ips)
|
||||
@ -95,18 +95,18 @@ public class TFM_Superadmin
|
||||
this.ips = ips;
|
||||
}
|
||||
|
||||
public void setLastLogin(Date last_login)
|
||||
public void setLastLogin(Date lastLogin)
|
||||
{
|
||||
this.last_login = last_login;
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
public boolean isActivated()
|
||||
{
|
||||
return is_activated;
|
||||
return isActivated;
|
||||
}
|
||||
|
||||
public void setActivated(boolean is_activated)
|
||||
public void setActivated(boolean isActivated)
|
||||
{
|
||||
this.is_activated = is_activated;
|
||||
this.isActivated = isActivated;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class TFM_SuperadminList
|
||||
private static List<String> superadminNames = new ArrayList<String>();
|
||||
private static List<String> superadminIPs = new ArrayList<String>();
|
||||
private static List<String> seniorAdminNames = new ArrayList<String>();
|
||||
private static int clean_threshold_hours = 24 * 7; // 1 Week
|
||||
private static int cleanThreshold = 24 * 7; // 1 Week in hours
|
||||
|
||||
private TFM_SuperadminList()
|
||||
{
|
||||
@ -51,7 +51,7 @@ public class TFM_SuperadminList
|
||||
TFM_Util.createDefaultConfiguration(TotalFreedomMod.SUPERADMIN_FILE, TotalFreedomMod.plugin_file);
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SUPERADMIN_FILE));
|
||||
|
||||
clean_threshold_hours = config.getInt("clean_threshold_hours", clean_threshold_hours);
|
||||
cleanThreshold = config.getInt("clean_threshold_hours", cleanThreshold);
|
||||
|
||||
if (config.isConfigurationSection("superadmins"))
|
||||
{
|
||||
@ -122,7 +122,7 @@ public class TFM_SuperadminList
|
||||
superadminIPs = TFM_Util.removeDuplicates(superadminIPs);
|
||||
seniorAdminNames = TFM_Util.removeDuplicates(seniorAdminNames);
|
||||
|
||||
TFM_AdminWorld.getInstance().wipeSuperadminCache();
|
||||
TFM_AdminWorld.getInstance().wipeAccessCache();
|
||||
}
|
||||
|
||||
public static void saveSuperadminList()
|
||||
@ -133,7 +133,7 @@ public class TFM_SuperadminList
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
config.set("clean_threshold_hours", clean_threshold_hours);
|
||||
config.set("clean_threshold_hours", cleanThreshold);
|
||||
|
||||
Iterator<Entry<String, TFM_Superadmin>> it = superadminList.entrySet().iterator();
|
||||
while (it.hasNext())
|
||||
@ -208,9 +208,9 @@ public class TFM_SuperadminList
|
||||
return isSeniorAdmin(user, false);
|
||||
}
|
||||
|
||||
public static boolean isSeniorAdmin(CommandSender user, boolean verify_is_superadmin)
|
||||
public static boolean isSeniorAdmin(CommandSender user, boolean verifySuperadmin)
|
||||
{
|
||||
if (verify_is_superadmin)
|
||||
if (verifySuperadmin)
|
||||
{
|
||||
if (!isUserSuperadmin(user))
|
||||
{
|
||||
@ -218,17 +218,17 @@ public class TFM_SuperadminList
|
||||
}
|
||||
}
|
||||
|
||||
String user_name = user.getName().toLowerCase();
|
||||
String username = user.getName().toLowerCase();
|
||||
|
||||
if (!(user instanceof Player))
|
||||
{
|
||||
return seniorAdminNames.contains(user_name);
|
||||
return seniorAdminNames.contains(username);
|
||||
}
|
||||
|
||||
TFM_Superadmin admin_entry = getAdminEntry((Player) user);
|
||||
if (admin_entry != null)
|
||||
TFM_Superadmin entry = getAdminEntry((Player) user);
|
||||
if (entry != null)
|
||||
{
|
||||
return admin_entry.isSeniorAdmin();
|
||||
return entry.isSeniorAdmin();
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -251,10 +251,10 @@ public class TFM_SuperadminList
|
||||
|
||||
try
|
||||
{
|
||||
String user_ip = ((Player) user).getAddress().getAddress().getHostAddress();
|
||||
if (user_ip != null && !user_ip.isEmpty())
|
||||
String ip = ((Player) user).getAddress().getAddress().getHostAddress();
|
||||
if (ip != null && !ip.isEmpty())
|
||||
{
|
||||
if (superadminIPs.contains(user_ip))
|
||||
if (superadminIPs.contains(ip))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -268,39 +268,39 @@ public class TFM_SuperadminList
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkPartialSuperadminIP(String user_ip, String user_name)
|
||||
public static boolean checkPartialSuperadminIP(String ip, String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
user_ip = user_ip.trim();
|
||||
ip = ip.trim();
|
||||
|
||||
if (superadminIPs.contains(user_ip))
|
||||
if (superadminIPs.contains(ip))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
String match_ip = null;
|
||||
for (String test_ip : getSuperadminIPs())
|
||||
String matchIp = null;
|
||||
for (String testIp : getSuperadminIPs())
|
||||
{
|
||||
if (TFM_Util.fuzzyIpMatch(user_ip, test_ip, 3))
|
||||
if (TFM_Util.fuzzyIpMatch(ip, testIp, 3))
|
||||
{
|
||||
match_ip = test_ip;
|
||||
matchIp = testIp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match_ip != null)
|
||||
if (matchIp != null)
|
||||
{
|
||||
TFM_Superadmin admin_entry = getAdminEntryByIP(match_ip);
|
||||
TFM_Superadmin entry = getAdminEntryByIP(matchIp);
|
||||
|
||||
if (admin_entry != null)
|
||||
if (entry != null)
|
||||
{
|
||||
if (admin_entry.getName().equalsIgnoreCase(user_name))
|
||||
if (entry.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
List<String> ips = admin_entry.getIps();
|
||||
ips.add(user_ip);
|
||||
admin_entry.setIps(ips);
|
||||
List<String> ips = entry.getIps();
|
||||
ips.add(ip);
|
||||
entry.setIps(ips);
|
||||
saveSuperadminList();
|
||||
}
|
||||
}
|
||||
@ -334,28 +334,28 @@ public class TFM_SuperadminList
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addSuperadmin(String admin_name, List<String> ips)
|
||||
public static void addSuperadmin(String username, List<String> ips)
|
||||
{
|
||||
try
|
||||
{
|
||||
admin_name = admin_name.toLowerCase();
|
||||
username = username.toLowerCase();
|
||||
|
||||
if (superadminList.containsKey(admin_name))
|
||||
if (superadminList.containsKey(username))
|
||||
{
|
||||
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
||||
TFM_Superadmin superadmin = superadminList.get(username);
|
||||
superadmin.setActivated(true);
|
||||
superadmin.getIps().addAll(ips);
|
||||
superadmin.setLastLogin(new Date());
|
||||
}
|
||||
else
|
||||
{
|
||||
Date last_login = new Date();
|
||||
String custom_login_message = "";
|
||||
boolean is_senior_admin = false;
|
||||
List<String> console_aliases = new ArrayList<String>();
|
||||
Date lastLogin = new Date();
|
||||
String loginMessage = "";
|
||||
boolean isSeniorAdmin = false;
|
||||
List<String> consoleAliases = new ArrayList<String>();
|
||||
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(admin_name, ips, last_login, custom_login_message, is_senior_admin, console_aliases, true);
|
||||
superadminList.put(admin_name.toLowerCase(), superadmin);
|
||||
TFM_Superadmin superadmin = new TFM_Superadmin(username, ips, lastLogin, loginMessage, isSeniorAdmin, consoleAliases, true);
|
||||
superadminList.put(username.toLowerCase(), superadmin);
|
||||
}
|
||||
|
||||
saveSuperadminList();
|
||||
@ -368,26 +368,26 @@ public class TFM_SuperadminList
|
||||
|
||||
public static void addSuperadmin(Player player)
|
||||
{
|
||||
String admin_name = player.getName().toLowerCase();
|
||||
String username = player.getName().toLowerCase();
|
||||
List<String> ips = Arrays.asList(player.getAddress().getAddress().getHostAddress());
|
||||
|
||||
addSuperadmin(admin_name, ips);
|
||||
addSuperadmin(username, ips);
|
||||
}
|
||||
|
||||
public static void addSuperadmin(String admin_name)
|
||||
public static void addSuperadmin(String adminName)
|
||||
{
|
||||
addSuperadmin(admin_name, new ArrayList<String>());
|
||||
addSuperadmin(adminName, new ArrayList<String>());
|
||||
}
|
||||
|
||||
public static void removeSuperadmin(String admin_name)
|
||||
public static void removeSuperadmin(String username)
|
||||
{
|
||||
try
|
||||
{
|
||||
admin_name = admin_name.toLowerCase();
|
||||
username = username.toLowerCase();
|
||||
|
||||
if (superadminList.containsKey(admin_name))
|
||||
if (superadminList.containsKey(username))
|
||||
{
|
||||
TFM_Superadmin superadmin = superadminList.get(admin_name);
|
||||
TFM_Superadmin superadmin = superadminList.get(username);
|
||||
superadmin.setActivated(false);
|
||||
Command_logs.deactivateSuperadmin(superadmin);
|
||||
saveSuperadminList();
|
||||
@ -415,15 +415,15 @@ public class TFM_SuperadminList
|
||||
TFM_Superadmin superadmin = pair.getValue();
|
||||
if (superadmin.isActivated() && !superadmin.isSeniorAdmin())
|
||||
{
|
||||
Date last_login = superadmin.getLastLogin();
|
||||
Date lastLogin = superadmin.getLastLogin();
|
||||
|
||||
long hours_since_login = TimeUnit.HOURS.convert(new Date().getTime() - last_login.getTime(), TimeUnit.MILLISECONDS);
|
||||
long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||
|
||||
if (hours_since_login > clean_threshold_hours)
|
||||
if (lastLoginHours > cleanThreshold)
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
TFM_Util.adminAction("TotalFreedomSystem", "Deactivating superadmin \"" + superadmin.getName() + "\", inactive for " + hours_since_login + " hours.", true);
|
||||
TFM_Util.adminAction("TotalFreedomSystem", "Deactivating superadmin \"" + superadmin.getName() + "\", inactive for " + lastLoginHours + " hours.", true);
|
||||
}
|
||||
|
||||
superadmin.setActivated(false);
|
||||
@ -439,17 +439,17 @@ public class TFM_SuperadminList
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean verifyIdentity(String admin_name, String ip) throws Exception
|
||||
public static boolean verifyIdentity(String username, String ip) throws Exception
|
||||
{
|
||||
if (Bukkit.getOnlineMode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
TFM_Superadmin admin_entry = getAdminEntry(admin_name);
|
||||
if (admin_entry != null)
|
||||
TFM_Superadmin entry = getAdminEntry(username);
|
||||
if (entry != null)
|
||||
{
|
||||
return admin_entry.getIps().contains(ip);
|
||||
return entry.getIps().contains(ip);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8,11 +8,8 @@ import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
|
||||
public class TFM_TwitterHandler
|
||||
{
|
||||
private TotalFreedomMod plugin;
|
||||
|
||||
private TFM_TwitterHandler(TotalFreedomMod plugin)
|
||||
private TFM_TwitterHandler()
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public String getTwitter(String player)
|
||||
@ -47,9 +44,15 @@ public class TFM_TwitterHandler
|
||||
private String request(String queryString)
|
||||
{
|
||||
String line = "failed";
|
||||
|
||||
final String twitterbotURL = TFM_ConfigEntry.TWITTERBOT_URL.getString();
|
||||
final String twitterbotSecret = TFM_ConfigEntry.TWITTERBOT_SECRET.getString();
|
||||
|
||||
if (twitterbotURL != null && twitterbotSecret != null && !twitterbotURL.isEmpty() && !twitterbotSecret.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
URL getUrl = new URL(TotalFreedomMod.twitterbotURL + "?auth=" + TotalFreedomMod.twitterbotSecret + "&" + queryString);
|
||||
URL getUrl = new URL(twitterbotURL + "?auth=" + twitterbotSecret + "&" + queryString);
|
||||
URLConnection urlConnection = getUrl.openConnection();
|
||||
// Read the response
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
||||
@ -60,11 +63,13 @@ public class TFM_TwitterHandler
|
||||
{
|
||||
TFM_Log.severe(ExceptionUtils.getFullStackTrace(ex));
|
||||
}
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
public static TFM_TwitterHandler getInstance(TotalFreedomMod plugin)
|
||||
public static TFM_TwitterHandler getInstance()
|
||||
{
|
||||
return new TFM_TwitterHandler(plugin);
|
||||
return new TFM_TwitterHandler();
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ public class TFM_UserList
|
||||
{
|
||||
userlist.clear();
|
||||
|
||||
FileConfiguration saved_userlist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
FileConfiguration savedUserlist = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
|
||||
for (String username : saved_userlist.getKeys(false))
|
||||
for (String username : savedUserlist.getKeys(false))
|
||||
{
|
||||
TFM_UserListEntry entry = new TFM_UserListEntry(username, saved_userlist.getStringList(username));
|
||||
TFM_UserListEntry entry = new TFM_UserListEntry(username, savedUserlist.getStringList(username));
|
||||
userlist.put(username, entry);
|
||||
}
|
||||
|
||||
@ -56,16 +56,16 @@ public class TFM_UserList
|
||||
|
||||
private void exportList()
|
||||
{
|
||||
FileConfiguration new_userlist = new YamlConfiguration();
|
||||
FileConfiguration newUserlist = new YamlConfiguration();
|
||||
|
||||
for (TFM_UserListEntry entry : userlist.values())
|
||||
{
|
||||
new_userlist.set(entry.getUsername(), entry.getIpAddresses());
|
||||
newUserlist.set(entry.getUsername(), entry.getIpAddresses());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
new_userlist.save(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
newUserlist.save(new File(plugin.getDataFolder(), USERLIST_FILENAME));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
@ -87,7 +87,7 @@ public class TFM_UserList
|
||||
addUser(player.getName(), player.getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
|
||||
public void addUser(String username, String ip_address)
|
||||
public void addUser(String username, String ip)
|
||||
{
|
||||
username = username.toLowerCase();
|
||||
|
||||
@ -99,7 +99,7 @@ public class TFM_UserList
|
||||
|
||||
userlist.put(username, entry);
|
||||
|
||||
if (entry.addIpAddress(ip_address))
|
||||
if (entry.addIpAddress(ip))
|
||||
{
|
||||
exportList();
|
||||
}
|
||||
@ -149,12 +149,12 @@ public class TFM_UserList
|
||||
public class TFM_UserListEntry
|
||||
{
|
||||
private String username;
|
||||
private List<String> ip_addresses = new ArrayList<String>();
|
||||
private List<String> ipAddresses = new ArrayList<String>();
|
||||
|
||||
public TFM_UserListEntry(String username, List<String> ip_addresses)
|
||||
public TFM_UserListEntry(String username, List<String> ipAddresses)
|
||||
{
|
||||
this.username = username;
|
||||
this.ip_addresses = ip_addresses;
|
||||
this.ipAddresses = ipAddresses;
|
||||
}
|
||||
|
||||
public TFM_UserListEntry(String username)
|
||||
@ -164,7 +164,7 @@ public class TFM_UserList
|
||||
|
||||
public List<String> getIpAddresses()
|
||||
{
|
||||
return ip_addresses;
|
||||
return ipAddresses;
|
||||
}
|
||||
|
||||
public String getUsername()
|
||||
@ -172,11 +172,11 @@ public class TFM_UserList
|
||||
return username;
|
||||
}
|
||||
|
||||
public boolean addIpAddress(String ip_address)
|
||||
public boolean addIpAddress(String ip)
|
||||
{
|
||||
if (!ip_addresses.contains(ip_address))
|
||||
if (!ipAddresses.contains(ip))
|
||||
{
|
||||
ip_addresses.add(ip_address);
|
||||
ipAddresses.add(ip);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -16,27 +16,29 @@ import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
public class TFM_Util
|
||||
{
|
||||
private static final Map<String, Integer> eject_tracker = new HashMap<String, Integer>();
|
||||
private static final Map<String, Integer> ejectTracker = new HashMap<String, Integer>();
|
||||
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
|
||||
public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die");
|
||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452", "disaster839");
|
||||
public static final List<String> REMOVE_COMMANDS = Arrays.asList("del", "delete", "rem", "remove");
|
||||
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "HeXeRei452");
|
||||
|
||||
static
|
||||
{
|
||||
for (EntityType entity_type : EntityType.values())
|
||||
for (EntityType type : EntityType.values())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (entity_type.getName() != null)
|
||||
if (type.getName() != null)
|
||||
{
|
||||
if (Creature.class.isAssignableFrom(entity_type.getEntityClass()))
|
||||
if (Creature.class.isAssignableFrom(type.getEntityClass()))
|
||||
{
|
||||
mobtypes.put(entity_type.getName().toLowerCase(), entity_type);
|
||||
mobtypes.put(type.getName().toLowerCase(), type);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,25 +85,25 @@ public class TFM_Util
|
||||
TFM_Util.bcastMsg(adminName + " - " + action, (isRed ? ChatColor.RED : ChatColor.AQUA));
|
||||
}
|
||||
|
||||
public static String formatLocation(Location in_loc)
|
||||
public static String formatLocation(Location location)
|
||||
{
|
||||
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()));
|
||||
location.getWorld().getName(),
|
||||
Math.round(location.getX()),
|
||||
Math.round(location.getY()),
|
||||
Math.round(location.getZ()));
|
||||
}
|
||||
|
||||
public static void gotoWorld(CommandSender sender, String targetworld)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Player sender_p = (Player) sender;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (sender_p.getWorld().getName().equalsIgnoreCase(targetworld))
|
||||
if (player.getWorld().getName().equalsIgnoreCase(targetworld))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Going to main world.");
|
||||
sender_p.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -110,7 +112,7 @@ public class TFM_Util
|
||||
if (world.getName().equalsIgnoreCase(targetworld))
|
||||
{
|
||||
sender.sendMessage(ChatColor.GRAY + "Going to world: " + targetworld);
|
||||
sender_p.teleport(world.getSpawnLocation());
|
||||
player.teleport(world.getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -125,14 +127,14 @@ public class TFM_Util
|
||||
|
||||
public static void buildHistory(Location location, int length, TFM_PlayerData playerdata)
|
||||
{
|
||||
Block center_block = location.getBlock();
|
||||
for (int x_offset = -length; x_offset <= length; x_offset++)
|
||||
Block center = location.getBlock();
|
||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||
{
|
||||
for (int y_offset = -length; y_offset <= length; y_offset++)
|
||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||
{
|
||||
for (int z_offset = -length; z_offset <= length; z_offset++)
|
||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||
{
|
||||
Block block = center_block.getRelative(x_offset, y_offset, z_offset);
|
||||
Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
playerdata.insertHistoryBlock(block.getLocation(), block.getType());
|
||||
}
|
||||
}
|
||||
@ -141,14 +143,65 @@ public class TFM_Util
|
||||
|
||||
public static void generateCube(Location location, int length, Material material)
|
||||
{
|
||||
Block center_block = location.getBlock();
|
||||
for (int x_offset = -length; x_offset <= length; x_offset++)
|
||||
Block center = location.getBlock();
|
||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||
{
|
||||
for (int y_offset = -length; y_offset <= length; y_offset++)
|
||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||
{
|
||||
for (int z_offset = -length; z_offset <= length; z_offset++)
|
||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||
{
|
||||
center_block.getRelative(x_offset, y_offset, z_offset).setType(material);
|
||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
if (block.getType() != material)
|
||||
{
|
||||
block.setType(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateHollowCube(Location location, int length, Material material)
|
||||
{
|
||||
Block center = location.getBlock();
|
||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||
{
|
||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||
{
|
||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||
{
|
||||
// Hollow
|
||||
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||
|
||||
if (material != Material.SKULL)
|
||||
{
|
||||
// Glowstone light
|
||||
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
||||
{
|
||||
block.setType(Material.GLOWSTONE);
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(material);
|
||||
}
|
||||
else // Darth mode
|
||||
{
|
||||
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
||||
{
|
||||
block.setType(Material.GLOWSTONE);
|
||||
continue;
|
||||
}
|
||||
|
||||
block.setType(Material.SKULL);
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setSkullType(SkullType.PLAYER);
|
||||
skull.setOwner("DarthSalamon");
|
||||
skull.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,7 +214,7 @@ public class TFM_Util
|
||||
world.setTime(time + 24000 + ticks);
|
||||
}
|
||||
|
||||
public static void createDefaultConfiguration(String name, File plugin_file)
|
||||
public static void createDefaultConfiguration(String name, File pluginFile)
|
||||
{
|
||||
TotalFreedomMod tfm = TotalFreedomMod.plugin;
|
||||
|
||||
@ -172,7 +225,7 @@ public class TFM_Util
|
||||
InputStream input = null;
|
||||
try
|
||||
{
|
||||
JarFile file = new JarFile(plugin_file);
|
||||
JarFile file = new JarFile(pluginFile);
|
||||
ZipEntry copy = file.getEntry(name);
|
||||
if (copy == null)
|
||||
{
|
||||
@ -391,6 +444,11 @@ public class TFM_Util
|
||||
return STOP_COMMANDS.contains(command.toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean isRemoveCommand(String command)
|
||||
{
|
||||
return REMOVE_COMMANDS.contains(command.toLowerCase());
|
||||
}
|
||||
|
||||
enum EjectMethod
|
||||
{
|
||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||
@ -399,31 +457,31 @@ public class TFM_Util
|
||||
public static void autoEject(Player player, String kickMessage)
|
||||
{
|
||||
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||
String player_ip = null;
|
||||
String ip = null;
|
||||
|
||||
try
|
||||
{
|
||||
player_ip = player.getAddress().getAddress().getHostAddress();
|
||||
ip = player.getAddress().getAddress().getHostAddress();
|
||||
|
||||
Integer num_kicks = TFM_Util.eject_tracker.get(player_ip);
|
||||
if (num_kicks == null)
|
||||
Integer kicks = TFM_Util.ejectTracker.get(ip);
|
||||
if (kicks == null)
|
||||
{
|
||||
num_kicks = new Integer(0);
|
||||
kicks = new Integer(0);
|
||||
}
|
||||
|
||||
num_kicks = new Integer(num_kicks.intValue() + 1);
|
||||
kicks = new Integer(kicks.intValue() + 1);
|
||||
|
||||
TFM_Util.eject_tracker.put(player_ip, num_kicks);
|
||||
TFM_Util.ejectTracker.put(ip, kicks);
|
||||
|
||||
if (num_kicks.intValue() <= 1)
|
||||
if (kicks.intValue() <= 1)
|
||||
{
|
||||
method = EjectMethod.STRIKE_ONE;
|
||||
}
|
||||
else if (num_kicks.intValue() == 2)
|
||||
else if (kicks.intValue() == 2)
|
||||
{
|
||||
method = EjectMethod.STRIKE_TWO;
|
||||
}
|
||||
else if (num_kicks.intValue() >= 3)
|
||||
else if (kicks.intValue() >= 3)
|
||||
{
|
||||
method = EjectMethod.STRIKE_THREE;
|
||||
}
|
||||
@ -432,7 +490,7 @@ public class TFM_Util
|
||||
{
|
||||
}
|
||||
|
||||
TFM_Log.info("autoEject -> name: " + player.getName() + " - player_ip: " + player_ip + " - method: " + method.toString());
|
||||
TFM_Log.info("autoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString());
|
||||
|
||||
player.setOp(false);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
@ -448,7 +506,7 @@ public class TFM_Util
|
||||
|
||||
TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 1 minute.");
|
||||
|
||||
TFM_ServerInterface.banIP(player_ip, kickMessage, "AutoEject", expires);
|
||||
TFM_ServerInterface.banIP(ip, kickMessage, "AutoEject", expires);
|
||||
TFM_ServerInterface.banUsername(player.getName(), kickMessage, "AutoEject", expires);
|
||||
player.kickPlayer(kickMessage);
|
||||
|
||||
@ -462,7 +520,7 @@ public class TFM_Util
|
||||
|
||||
TFM_Util.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 3 minutes.");
|
||||
|
||||
TFM_ServerInterface.banIP(player_ip, kickMessage, "AutoEject", expires);
|
||||
TFM_ServerInterface.banIP(ip, kickMessage, "AutoEject", expires);
|
||||
TFM_ServerInterface.banUsername(player.getName(), kickMessage, "AutoEject", expires);
|
||||
player.kickPlayer(kickMessage);
|
||||
|
||||
@ -471,10 +529,10 @@ public class TFM_Util
|
||||
case STRIKE_THREE:
|
||||
{
|
||||
//Bukkit.banIP(player_ip);
|
||||
TFM_ServerInterface.banIP(player_ip, kickMessage, "AutoEject", null);
|
||||
String[] ip_address_parts = player_ip.split("\\.");
|
||||
TFM_ServerInterface.banIP(ip, kickMessage, "AutoEject", null);
|
||||
String[] ipAddressParts = ip.split("\\.");
|
||||
//Bukkit.banIP();
|
||||
TFM_ServerInterface.banIP(ip_address_parts[0] + "." + ip_address_parts[1] + ".*.*", kickMessage, "AutoEject", null);
|
||||
TFM_ServerInterface.banIP(ipAddressParts[0] + "." + ipAddressParts[1] + ".*.*", kickMessage, "AutoEject", null);
|
||||
|
||||
//p.setBanned(true);
|
||||
TFM_ServerInterface.banUsername(player.getName(), kickMessage, "AutoEject", null);
|
||||
@ -488,21 +546,6 @@ public class TFM_Util
|
||||
}
|
||||
}
|
||||
|
||||
public static void generateFlatlands()
|
||||
{
|
||||
generateFlatlands(TotalFreedomMod.flatlandsGenerationParams);
|
||||
}
|
||||
|
||||
public static void generateFlatlands(String genParams)
|
||||
{
|
||||
WorldCreator flatlands = new WorldCreator("flatlands");
|
||||
flatlands.generateStructures(false);
|
||||
flatlands.type(WorldType.NORMAL);
|
||||
flatlands.environment(World.Environment.NORMAL);
|
||||
flatlands.generator(new CleanroomChunkGenerator(genParams));
|
||||
Bukkit.getServer().createWorld(flatlands);
|
||||
}
|
||||
|
||||
public static String getRank(CommandSender sender)
|
||||
{
|
||||
if (TFM_SuperadminList.isSuperadminImpostor(sender))
|
||||
@ -510,23 +553,23 @@ public class TFM_Util
|
||||
return "an " + ChatColor.YELLOW + ChatColor.UNDERLINE + "impostor" + ChatColor.RESET + ChatColor.AQUA + "!";
|
||||
}
|
||||
|
||||
TFM_Superadmin admin_entry = TFM_SuperadminList.getAdminEntry(sender.getName());
|
||||
TFM_Superadmin entry = TFM_SuperadminList.getAdminEntry(sender.getName());
|
||||
|
||||
if (admin_entry != null)
|
||||
if (entry != null)
|
||||
{
|
||||
if (admin_entry.isActivated())
|
||||
if (entry.isActivated())
|
||||
{
|
||||
String custom_login_message = admin_entry.getCustomLoginMessage();
|
||||
String loginMessage = entry.getCustomLoginMessage();
|
||||
|
||||
if (custom_login_message != null)
|
||||
if (loginMessage != null)
|
||||
{
|
||||
if (!custom_login_message.isEmpty())
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
return ChatColor.translateAlternateColorCodes('&', custom_login_message);
|
||||
return ChatColor.translateAlternateColorCodes('&', loginMessage);
|
||||
}
|
||||
}
|
||||
|
||||
if (admin_entry.isSeniorAdmin())
|
||||
if (entry.isSeniorAdmin())
|
||||
{
|
||||
return "a " + ChatColor.LIGHT_PURPLE + "Senior Admin" + ChatColor.AQUA + ".";
|
||||
}
|
||||
@ -652,27 +695,27 @@ public class TFM_Util
|
||||
|
||||
public static String playerListToNames(Set<OfflinePlayer> players)
|
||||
{
|
||||
List<String> player_names = new ArrayList<String>();
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (OfflinePlayer player : players)
|
||||
{
|
||||
player_names.add(player.getName());
|
||||
names.add(player.getName());
|
||||
}
|
||||
return StringUtils.join(player_names, ", ");
|
||||
return StringUtils.join(names, ", ");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map<String, Boolean> getSavedFlags()
|
||||
{
|
||||
Map<String, Boolean> saved_flags = null;
|
||||
Map<String, Boolean> flags = null;
|
||||
|
||||
File input_file = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SAVED_FLAGS_FILE);
|
||||
if (input_file.exists())
|
||||
File input = new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SAVED_FLAGS_FILE);
|
||||
if (input.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
FileInputStream fis = new FileInputStream(input_file);
|
||||
FileInputStream fis = new FileInputStream(input);
|
||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||
saved_flags = (HashMap<String, Boolean>) ois.readObject();
|
||||
flags = (HashMap<String, Boolean>) ois.readObject();
|
||||
ois.close();
|
||||
fis.close();
|
||||
}
|
||||
@ -682,26 +725,26 @@ public class TFM_Util
|
||||
}
|
||||
}
|
||||
|
||||
return saved_flags;
|
||||
return flags;
|
||||
}
|
||||
|
||||
public static boolean getSavedFlag(String flag) throws Exception
|
||||
{
|
||||
Boolean flag_value = null;
|
||||
Boolean flagValue = null;
|
||||
|
||||
Map<String, Boolean> saved_flags = TFM_Util.getSavedFlags();
|
||||
Map<String, Boolean> flags = TFM_Util.getSavedFlags();
|
||||
|
||||
if (saved_flags != null)
|
||||
if (flags != null)
|
||||
{
|
||||
if (saved_flags.containsKey(flag))
|
||||
if (flags.containsKey(flag))
|
||||
{
|
||||
flag_value = saved_flags.get(flag);
|
||||
flagValue = flags.get(flag);
|
||||
}
|
||||
}
|
||||
|
||||
if (flag_value != null)
|
||||
if (flagValue != null)
|
||||
{
|
||||
return flag_value.booleanValue();
|
||||
return flagValue.booleanValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -711,20 +754,20 @@ public class TFM_Util
|
||||
|
||||
public static void setSavedFlag(String flag, boolean value)
|
||||
{
|
||||
Map<String, Boolean> saved_flags = TFM_Util.getSavedFlags();
|
||||
Map<String, Boolean> flags = TFM_Util.getSavedFlags();
|
||||
|
||||
if (saved_flags == null)
|
||||
if (flags == null)
|
||||
{
|
||||
saved_flags = new HashMap<String, Boolean>();
|
||||
flags = new HashMap<String, Boolean>();
|
||||
}
|
||||
|
||||
saved_flags.put(flag, value);
|
||||
flags.put(flag, value);
|
||||
|
||||
try
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(new File(TotalFreedomMod.plugin.getDataFolder(), TotalFreedomMod.SAVED_FLAGS_FILE));
|
||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||
oos.writeObject(saved_flags);
|
||||
oos.writeObject(flags);
|
||||
oos.close();
|
||||
fos.close();
|
||||
}
|
||||
@ -733,39 +776,6 @@ public class TFM_Util
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void wipeFlatlandsIfFlagged()
|
||||
{
|
||||
boolean do_wipe_flatlands = false;
|
||||
try
|
||||
{
|
||||
do_wipe_flatlands = TFM_Util.getSavedFlag("do_wipe_flatlands");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (do_wipe_flatlands)
|
||||
{
|
||||
if (Bukkit.getServer().getWorld("flatlands") == null)
|
||||
{
|
||||
TFM_Log.info("Wiping flaglands.");
|
||||
|
||||
TFM_Util.setSavedFlag("do_wipe_flatlands", false);
|
||||
|
||||
File flatlands_folder = new File("./flatlands");
|
||||
|
||||
if (flatlands_folder.exists())
|
||||
{
|
||||
TFM_Util.deleteFolder(flatlands_folder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TFM_Log.severe("Can't wipe flatlands, it is already loaded.");
|
||||
}
|
||||
}
|
||||
}
|
||||
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
|
||||
|
||||
public static String dateToString(Date date)
|
||||
@ -773,92 +783,93 @@ public class TFM_Util
|
||||
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).format(date);
|
||||
}
|
||||
|
||||
public static Date stringToDate(String date_str)
|
||||
public static Date stringToDate(String dateString)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).parse(date_str);
|
||||
return new SimpleDateFormat(DATE_STORAGE_FORMAT, Locale.ENGLISH).parse(dateString);
|
||||
}
|
||||
catch (ParseException ex)
|
||||
catch (ParseException pex)
|
||||
{
|
||||
return new Date(0L);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFromHostConsole(String sender_name)
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean isFromHostConsole(String senderName)
|
||||
{
|
||||
return TotalFreedomMod.host_sender_names.contains(sender_name.toLowerCase());
|
||||
return ((List<String>) TFM_ConfigEntry.HOST_SENDER_NAMES.getList()).contains(senderName.toLowerCase());
|
||||
}
|
||||
|
||||
public static List<String> removeDuplicates(List<String> old_list)
|
||||
public static List<String> removeDuplicates(List<String> oldList)
|
||||
{
|
||||
List<String> new_list = new ArrayList<String>();
|
||||
for (String entry : old_list)
|
||||
List<String> newList = new ArrayList<String>();
|
||||
for (String entry : oldList)
|
||||
{
|
||||
if (!new_list.contains(entry))
|
||||
if (!newList.contains(entry))
|
||||
{
|
||||
new_list.add(entry);
|
||||
newList.add(entry);
|
||||
}
|
||||
}
|
||||
return new_list;
|
||||
return newList;
|
||||
}
|
||||
|
||||
public static boolean fuzzyIpMatch(String a, String b, int required_octets)
|
||||
public static boolean fuzzyIpMatch(String a, String b, int octets)
|
||||
{
|
||||
boolean is_match = true;
|
||||
boolean match = true;
|
||||
|
||||
String[] a_parts = a.split("\\.");
|
||||
String[] b_parts = b.split("\\.");
|
||||
String[] aParts = a.split("\\.");
|
||||
String[] bParts = b.split("\\.");
|
||||
|
||||
if (a_parts.length != 4 || b_parts.length != 4)
|
||||
if (aParts.length != 4 || bParts.length != 4)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (required_octets > 4)
|
||||
if (octets > 4)
|
||||
{
|
||||
required_octets = 4;
|
||||
octets = 4;
|
||||
}
|
||||
else if (required_octets < 1)
|
||||
else if (octets < 1)
|
||||
{
|
||||
required_octets = 1;
|
||||
octets = 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < required_octets && i < 4; i++)
|
||||
for (int i = 0; i < octets && i < 4; i++)
|
||||
{
|
||||
if (a_parts[i].equals("*") || b_parts[i].equals("*"))
|
||||
if (aParts[i].equals("*") || bParts[i].equals("*"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!a_parts[i].equals(b_parts[i]))
|
||||
if (!aParts[i].equals(bParts[i]))
|
||||
{
|
||||
is_match = false;
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return is_match;
|
||||
return match;
|
||||
}
|
||||
|
||||
public static int replaceBlocks(Location center_location, Material from_material, Material to_material, int radius)
|
||||
public static int replaceBlocks(Location center, Material fromMaterial, Material toMaterial, int radius)
|
||||
{
|
||||
int affected = 0;
|
||||
|
||||
Block center_block = center_location.getBlock();
|
||||
for (int x_offset = -radius; x_offset <= radius; x_offset++)
|
||||
Block centerBlock = center.getBlock();
|
||||
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||
{
|
||||
for (int y_offset = -radius; y_offset <= radius; y_offset++)
|
||||
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||
{
|
||||
for (int z_offset = -radius; z_offset <= radius; z_offset++)
|
||||
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||
{
|
||||
Block test_block = center_block.getRelative(x_offset, y_offset, z_offset);
|
||||
Block block = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||
|
||||
if (test_block.getType().equals(from_material))
|
||||
if (block.getType().equals(fromMaterial))
|
||||
{
|
||||
if (test_block.getLocation().distanceSquared(center_location) < (radius * radius))
|
||||
if (block.getLocation().distanceSquared(center) < (radius * radius))
|
||||
{
|
||||
test_block.setType(to_material);
|
||||
block.setType(toMaterial);
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
@ -869,22 +880,22 @@ public class TFM_Util
|
||||
return affected;
|
||||
}
|
||||
|
||||
public static void downloadFile(String url, File output_file) throws java.lang.Exception
|
||||
public static void downloadFile(String url, File output) throws java.lang.Exception
|
||||
{
|
||||
downloadFile(url, output_file, false);
|
||||
downloadFile(url, output, false);
|
||||
}
|
||||
|
||||
public static void downloadFile(String url, File output_file, boolean verbose) throws java.lang.Exception
|
||||
public static void downloadFile(String url, File output, boolean verbose) throws java.lang.Exception
|
||||
{
|
||||
URL website = new URL(url);
|
||||
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(output_file);
|
||||
FileOutputStream fos = new FileOutputStream(output);
|
||||
fos.getChannel().transferFrom(rbc, 0, 1 << 24);
|
||||
fos.close();
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
TFM_Log.info("Downloaded " + url + " to " + output_file.toString() + ".");
|
||||
TFM_Log.info("Downloaded " + url + " to " + output.toString() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||
import me.StevenLawson.TotalFreedomMod.HTTPD.TFM_HTTPD_Manager;
|
||||
import me.StevenLawson.TotalFreedomMod.Listener.*;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
@ -26,12 +27,9 @@ import org.mcstats.Metrics;
|
||||
|
||||
public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
public static final Server server = Bukkit.getServer();
|
||||
//
|
||||
public static final long HEARTBEAT_RATE = 5L; //Seconds
|
||||
public static final long SERVICE_CHECKER_RATE = 120L;
|
||||
//
|
||||
public static final String CONFIG_FILE = "config.yml";
|
||||
public static final String SUPERADMIN_FILE = "superadmin.yml";
|
||||
public static final String PERMBAN_FILE = "permban.yml";
|
||||
public static final String PROTECTED_AREA_FILE = "protectedareas.dat";
|
||||
@ -46,68 +44,87 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||
public static final String NOT_FROM_CONSOLE = "This command may not be used from the console.";
|
||||
//
|
||||
public static final Server server = Bukkit.getServer();
|
||||
public static TotalFreedomMod plugin = null;
|
||||
public static File plugin_file = null;
|
||||
//
|
||||
public static String pluginName = "";
|
||||
public static String pluginVersion = "";
|
||||
public static String buildNumber = "";
|
||||
public static String buildDate = "";
|
||||
//
|
||||
public static boolean allPlayersFrozen = false;
|
||||
public static BukkitTask freezePurgeTask = null;
|
||||
public static BukkitTask mutePurgeTask = null;
|
||||
public static boolean lockdownEnabled = false;
|
||||
public static Map<Player, Double> fuckoffEnabledFor = new HashMap<Player, Double>();
|
||||
//
|
||||
public static String pluginVersion = "";
|
||||
public static String buildNumber = "";
|
||||
public static String buildDate = "";
|
||||
public static String pluginName = "";
|
||||
//
|
||||
public static TotalFreedomMod plugin = null;
|
||||
public static File plugin_file = null;
|
||||
public static List<String> permbanned_players = new ArrayList<String>();
|
||||
public static List<String> permbanned_ips = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
TotalFreedomMod.plugin = this;
|
||||
TotalFreedomMod.plugin_file = plugin.getFile();
|
||||
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||
|
||||
TFM_Log.setPluginLogger(this.getLogger());
|
||||
TFM_Log.setServerLogger(this.getServer().getLogger());
|
||||
|
||||
setAppProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
TotalFreedomMod.plugin = this;
|
||||
TotalFreedomMod.plugin_file = getFile();
|
||||
TFM_Log.info("Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
||||
|
||||
TotalFreedomMod.pluginName = this.getDescription().getName();
|
||||
|
||||
setAppProperties();
|
||||
|
||||
loadMainConfig();
|
||||
loadSuperadminConfig();
|
||||
loadPermbanConfig();
|
||||
|
||||
TFM_UserList.getInstance(this);
|
||||
TFM_UserList.getInstance(plugin);
|
||||
|
||||
registerEventHandlers();
|
||||
|
||||
if (generateFlatlands)
|
||||
try
|
||||
{
|
||||
TFM_Flatlands.getInstance().getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Util.wipeFlatlandsIfFlagged();
|
||||
TFM_Util.generateFlatlands(flatlandsGenerationParams);
|
||||
}
|
||||
|
||||
TFM_AdminWorld.getInstance().getAdminWorld();
|
||||
try
|
||||
{
|
||||
TFM_AdminWorld.getInstance().getWorld();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (disableWeather)
|
||||
if (TFM_ConfigEntry.DISABLE_WEATHER.getBoolean())
|
||||
{
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
world.setThundering(false);
|
||||
world.setStorm(false);
|
||||
world.setThunderDuration(0);
|
||||
world.setThunderDuration(0);
|
||||
world.setWeatherDuration(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize game rules
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !disableNight, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, allowFireSpread, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_DAYLIGHT_CYCLE, !TFM_ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_FIRE_TICK, TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_LOOT, false, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !mobLimiterEnabled, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_MOB_SPAWNING, !TFM_ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.DO_TILE_DROPS, false, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.MOB_GRIEFING, false, false);
|
||||
TFM_GameRuleHandler.setGameRule(TFM_GameRuleHandler.TFM_GameRule.NATURAL_REGENERATION, true, false);
|
||||
TFM_GameRuleHandler.commitGameRules();
|
||||
|
||||
if (TotalFreedomMod.protectedAreasEnabled)
|
||||
if (TFM_ConfigEntry.PROTECTED_AREAS_ENABLED.getBoolean())
|
||||
{
|
||||
TFM_ProtectedArea.loadProtectedAreas();
|
||||
TFM_ProtectedArea.autoAddSpawnpoints();
|
||||
@ -131,7 +148,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
|
||||
// Heartbeat
|
||||
new TFM_Heartbeat(this).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||
new TFM_Heartbeat(plugin).runTaskTimer(plugin, HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L);
|
||||
|
||||
// metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||
try
|
||||
@ -144,8 +161,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Log.warning("Failed to submit metrics data: " + ex.getMessage());
|
||||
}
|
||||
|
||||
TFM_Log.info("Plugin Enabled - Version: " + TotalFreedomMod.pluginVersion + "." + TotalFreedomMod.buildNumber + " by Madgeek1450 and DarthSalamon");
|
||||
|
||||
TFM_ServiceChecker.getInstance().getUpdateRunnable().runTaskTimerAsynchronously(plugin, 40L, SERVICE_CHECKER_RATE * 20L);
|
||||
|
||||
new BukkitRunnable()
|
||||
@ -154,16 +169,25 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
public void run()
|
||||
{
|
||||
TFM_CommandLoader.getInstance().scan();
|
||||
TFM_CommandBlockerNew.getInstance().parseBlockingRules();
|
||||
TFM_CommandBlocker.getInstance().parseBlockingRules();
|
||||
}
|
||||
}.runTaskLater(this, 20L);
|
||||
}.runTaskLater(plugin, 20L);
|
||||
|
||||
TFM_HTTPD_Manager.getInstance().start();
|
||||
|
||||
TFM_FrontDoor.getInstance().start();
|
||||
|
||||
TFM_Log.info("Plugin enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
server.getScheduler().cancelTasks(this);
|
||||
TFM_Log.info("Plugin disabled");
|
||||
server.getScheduler().cancelTasks(plugin);
|
||||
|
||||
TFM_HTTPD_Manager.getInstance().stop();
|
||||
|
||||
TFM_Log.info("Plugin disabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,7 +220,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
|
||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, cmd.getName().toLowerCase())).newInstance();
|
||||
dispatcher.setup(this, sender, dispatcher.getClass());
|
||||
dispatcher.setup(plugin, sender, dispatcher.getClass());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
@ -230,105 +254,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
|
||||
return true;
|
||||
}
|
||||
//
|
||||
public static boolean allowFirePlace = false;
|
||||
public static boolean allowFireSpread = false;
|
||||
public static boolean allowLavaDamage = false;
|
||||
public static boolean allowLavaPlace = false;
|
||||
public static boolean allowWaterPlace = false;
|
||||
public static boolean allowExplosions = false;
|
||||
public static boolean allowFliudSpread = false;
|
||||
public static boolean allowTntMinecarts = false;
|
||||
public static double explosiveRadius = 4.0D;
|
||||
public static List<String> blockedCommands = new ArrayList<String>();
|
||||
public static boolean autoEntityWipe = true;
|
||||
public static boolean nukeMonitor = true;
|
||||
public static int nukeMonitorCountBreak = 100;
|
||||
public static int nukeMonitorCountPlace = 25;
|
||||
public static double nukeMonitorRange = 10.0D;
|
||||
public static int freecamTriggerCount = 10;
|
||||
public static boolean preprocessLogEnabled = true;
|
||||
public static boolean disableNight = true;
|
||||
public static boolean disableWeather = true;
|
||||
public static boolean landminesEnabled = false;
|
||||
public static boolean mp44Enabled = false;
|
||||
public static boolean mobLimiterEnabled = true;
|
||||
public static int mobLimiterMax = 50;
|
||||
public static boolean mobLimiterDisableDragon = true;
|
||||
public static boolean mobLimiterDisableGhast = true;
|
||||
public static boolean mobLimiterDisableSlime = true;
|
||||
public static boolean mobLimiterDisableGiant = true;
|
||||
public static boolean tossmobEnabled = false;
|
||||
public static boolean generateFlatlands = true;
|
||||
public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass";
|
||||
public static boolean adminOnlyMode = false;
|
||||
public static boolean protectedAreasEnabled = true;
|
||||
public static boolean autoProtectSpawnpoints = true;
|
||||
public static double autoProtectRadius = 25.0D;
|
||||
public static List<String> host_sender_names = Arrays.asList("rcon", "remotebukkit");
|
||||
public static boolean twitterbotEnabled = false;
|
||||
public static String twitterbotURL = "";
|
||||
public static String twitterbotSecret = "";
|
||||
public static boolean petProtectEnabled = true;
|
||||
public static String logsRegisterPassword = "";
|
||||
public static String logsRegisterURL = "";
|
||||
public static String serviceCheckerURL = "http://status.mojang.com/check";
|
||||
|
||||
public static void loadMainConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
TFM_Util.createDefaultConfiguration(CONFIG_FILE, plugin_file);
|
||||
FileConfiguration config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), CONFIG_FILE));
|
||||
|
||||
allowFirePlace = config.getBoolean("allow_fire_place", allowFirePlace);
|
||||
allowFireSpread = config.getBoolean("allow_fire_spread", allowFireSpread);
|
||||
allowLavaDamage = config.getBoolean("allow_lava_damage", allowLavaDamage);
|
||||
allowLavaPlace = config.getBoolean("allow_lava_place", allowLavaPlace);
|
||||
allowWaterPlace = config.getBoolean("allow_water_place", allowWaterPlace);
|
||||
allowExplosions = config.getBoolean("allow_explosions", allowExplosions);
|
||||
allowTntMinecarts = config.getBoolean("allow_tnt_minecarts", allowTntMinecarts);
|
||||
explosiveRadius = config.getDouble("explosiveRadius", explosiveRadius);
|
||||
blockedCommands = config.getStringList("blocked_commands");
|
||||
autoEntityWipe = config.getBoolean("auto_wipe", autoEntityWipe);
|
||||
nukeMonitor = config.getBoolean("nuke_monitor", nukeMonitor);
|
||||
nukeMonitorCountBreak = config.getInt("nuke_monitor_count_break", nukeMonitorCountBreak);
|
||||
nukeMonitorCountPlace = config.getInt("nuke_monitor_count_place", nukeMonitorCountPlace);
|
||||
nukeMonitorRange = config.getDouble("nuke_monitor_range", nukeMonitorRange);
|
||||
freecamTriggerCount = config.getInt("freecam_trigger_count", freecamTriggerCount);
|
||||
preprocessLogEnabled = config.getBoolean("preprocess_log", preprocessLogEnabled);
|
||||
disableNight = config.getBoolean("disable_night", disableNight);
|
||||
disableWeather = config.getBoolean("disable_weather", disableWeather);
|
||||
landminesEnabled = config.getBoolean("landmines_enabled", landminesEnabled);
|
||||
mp44Enabled = config.getBoolean("mp44_enabled", mp44Enabled);
|
||||
mobLimiterEnabled = config.getBoolean("mob_limiter_enabled", mobLimiterEnabled);
|
||||
mobLimiterMax = config.getInt("mob_limiter_max", mobLimiterMax);
|
||||
mobLimiterDisableDragon = config.getBoolean("mob_limiter_disable_dragon", mobLimiterDisableDragon);
|
||||
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
|
||||
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
|
||||
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant);
|
||||
tossmobEnabled = config.getBoolean("tossmob_enabled", tossmobEnabled);
|
||||
generateFlatlands = config.getBoolean("generate_flatlands", generateFlatlands);
|
||||
flatlandsGenerationParams = config.getString("flatlands_generation_params", flatlandsGenerationParams);
|
||||
allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread);
|
||||
adminOnlyMode = config.getBoolean("admin_only_mode", adminOnlyMode);
|
||||
protectedAreasEnabled = config.getBoolean("protected_areas_enabled", protectedAreasEnabled);
|
||||
autoProtectSpawnpoints = config.getBoolean("auto_protect_spawnpoints", autoProtectSpawnpoints);
|
||||
autoProtectRadius = config.getDouble("auto_protect_radius", autoProtectRadius);
|
||||
host_sender_names = config.getStringList("host_sender_names");
|
||||
twitterbotEnabled = config.getBoolean("twitterbot_enabled", twitterbotEnabled);
|
||||
twitterbotURL = config.getString("twitterbot_url", twitterbotURL);
|
||||
twitterbotSecret = config.getString("twitterbot_secret", twitterbotSecret);
|
||||
petProtectEnabled = config.getBoolean("pet_protect_enabled", petProtectEnabled);
|
||||
logsRegisterPassword = config.getString("logs_register_password", logsRegisterPassword);
|
||||
logsRegisterURL = config.getString("logs_register_url", logsRegisterURL);
|
||||
serviceCheckerURL = config.getString("service_checker_url", serviceCheckerURL);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe("Error loading main config: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadSuperadminConfig()
|
||||
{
|
||||
@ -342,9 +267,6 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
TFM_Log.severe("Error loading superadmin list: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
//
|
||||
public static List<String> permbanned_players = new ArrayList<String>();
|
||||
public static List<String> permbanned_ips = new ArrayList<String>();
|
||||
|
||||
public static void loadPermbanConfig()
|
||||
{
|
||||
@ -373,7 +295,8 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe("Error loading permban list: " + ex.getMessage());
|
||||
TFM_Log.severe("Error loading permban list!");
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -392,10 +315,10 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream in;
|
||||
InputStream in = plugin.getResource("appinfo.properties");
|
||||
Properties props = new Properties();
|
||||
|
||||
in = plugin.getClass().getResourceAsStream("/appinfo.properties");
|
||||
// in = plugin.getClass().getResourceAsStream("/appinfo.properties");
|
||||
props.load(in);
|
||||
in.close();
|
||||
|
||||
@ -405,6 +328,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TFM_Log.severe("Could not load App properties!");
|
||||
TFM_Log.severe(ex);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: TotalFreedomMod
|
||||
main: me.StevenLawson.TotalFreedomMod.TotalFreedomMod
|
||||
version: 3.00
|
||||
version: 3.2
|
||||
description: Plugin for the Total Freedom server.
|
||||
authors: [StevenLawson / Madgeek1450, JeromSar / DarthSalamon]
|
||||
authors: [Madgeek1450, DarthSalamon]
|
||||
|
||||
# plugin.yml is no longer used to define commands.
|
||||
|
Reference in New Issue
Block a user