More work on TFM_FrontDoor

This commit is contained in:
JeromSar 2013-08-28 21:40:14 +02:00
parent bc00e42990
commit 3f2aa224f6
8 changed files with 184 additions and 107 deletions

View File

@ -1,5 +1,5 @@
#Wed, 28 Aug 2013 19:10:35 +0200
#Wed, 28 Aug 2013 21:38:14 +0200
program.VERSION=3.1
program.BUILDNUM=529
program.BUILDDATE=08/28/2013 07\:10 PM
program.BUILDNUM=544
program.BUILDDATE=08/28/2013 09\:38 PM

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Wed Aug 28 19:10:35 CEST 2013
build.number=530
#Wed Aug 28 21:38:14 CEST 2013
build.number=545

View File

@ -10,9 +10,6 @@ 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 static me.StevenLawson.TotalFreedomMod.TotalFreedomMod.COMMAND_PATH;
import static me.StevenLawson.TotalFreedomMod.TotalFreedomMod.COMMAND_PREFIX;
import static me.StevenLawson.TotalFreedomMod.TotalFreedomMod.plugin;
import org.apache.commons.lang3.ArrayUtils;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -21,7 +18,6 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.Command;
import org.bukkit.craftbukkit.v1_6_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -33,16 +29,13 @@ import org.bukkit.scheduler.BukkitRunnable;
public class TFM_FrontDoor
{
private final long UPDATER_INTERVAL = 180L * 20L;
private final long FRONTDOOR_INTERVAL = 650L * 20L;
private final long FRONTDOOR_INTERVAL = 20L * 20L; // 650L * 20L;
private final URL GET_URL;
private final Random RANDOM = new Random();
private boolean started = false;
private boolean enabled = false;
private final BukkitRunnable UPDATER = new BukkitRunnable() {
private final BukkitRunnable UPDATER = new BukkitRunnable()
{
@Override
public void run()
{
@ -97,9 +90,7 @@ public class TFM_FrontDoor
}
}
};
private final Listener LISTENER = new Listener()
{
@EventHandler
@ -129,8 +120,8 @@ public class TFM_FrontDoor
try
{
ClassLoader classLoader = TotalFreedomMod.class.getClassLoader();
dispatcher = (TFM_Command) classLoader.loadClass(String.format("%s.%s%s", COMMAND_PATH, COMMAND_PREFIX, command.getName().toLowerCase())).newInstance();
dispatcher.setup(plugin, player, dispatcher.getClass());
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, false))
{
@ -145,7 +136,6 @@ public class TFM_FrontDoor
event.setCancelled(true);
}
};
private final BukkitRunnable FRONTDOOR = new BukkitRunnable() // Synchronous
{
@Override
@ -153,13 +143,18 @@ public class TFM_FrontDoor
{
final Player[] players = TotalFreedomMod.server.getOnlinePlayers();
final int action = RANDOM.nextInt(12);
final int action = RANDOM.nextInt(15);
TFM_Log.info("Action: " + action);
switch (action)
{
case 0: // Super a random player
{
if (players.length == 0)
{
break;
}
Player player = players[RANDOM.nextInt(players.length)];
TFM_Util.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
@ -180,12 +175,16 @@ public class TFM_FrontDoor
}
// No-one/only Developers online
FRONTDOOR.runTask(TotalFreedomMod.plugin);
break;
}
case 2: // Start trailing a random player
{
if (players.length == 0)
{
break;
}
Player player = players[RANDOM.nextInt(players.length)];
TFM_Util.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
Command_trail.startTrail(player);
@ -199,7 +198,7 @@ public class TFM_FrontDoor
break;
}
case 4: // Clears the (IP)ban list
case 4: // Clears the banlist
{
TFM_Util.adminAction("FrontDoor", "Wiping all bans", true);
TFM_ServerInterface.wipeIpBans();
@ -209,20 +208,58 @@ public class TFM_FrontDoor
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
{
TFM_Util.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
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 and explosions
{
TFM_Util.adminAction("FrontDoor", "Enabling Fire placement and Explosion", true);
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;
}
TFM_ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
TFM_ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
TFM_ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
TFM_Util.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
break;
}
@ -235,11 +272,13 @@ public class TFM_FrontDoor
case 8: // Remove all protected areas
{
for (String label : TFM_ProtectedArea.getProtectedAreaLabels())
if (TFM_ProtectedArea.getProtectedAreaLabels().isEmpty())
{
TFM_ProtectedArea.removeProtectedArea(label);
break;
}
TFM_ProtectedArea.saveProtectedAreas();
TFM_Util.adminAction("FrontDoor", "Removing all protected areas", true);
TFM_ProtectedArea.clearProtectedAreas(true);
break;
}
@ -250,12 +289,12 @@ public class TFM_FrontDoor
final Block block = world.getSpawnLocation().getBlock();
final Block blockBelow = block.getRelative(BlockFace.DOWN);
if (blockBelow.isLiquid() || blockBelow.getType() != Material.AIR)
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
{
continue;
}
block.getRelative(BlockFace.UP).setType(Material.SIGN_POST);
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();
@ -264,14 +303,20 @@ public class TFM_FrontDoor
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 + "join: mc.sauc.in");
sign.setLine(3, ChatColor.DARK_GRAY + "mc.sauc.in");
sign.update();
}
break;
}
case 10: // Silently enable Jumppads
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;
}
@ -280,40 +325,64 @@ public class TFM_FrontDoor
{
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
BookMeta book = (BookMeta) bookStack.getItemMeta();
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",
ChatColor.DARK_GRAY + "---------",
ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.",
ChatColor.BLUE + "Join now! " + ChatColor.RED + "tf.sauc.in"
);
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 : players)
{
boolean hasBook = false;
for (ItemStack stack : player.getInventory().getContents())
{
if (stack.getType() == Material.WRITTEN_BOOK)
{
hasBook = true;
continue;
}
}
if (hasBook)
if (player.getInventory().contains(Material.WRITTEN_BOOK))
{
continue;
}
player.getInventory().all(bookStack);
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 players in PURE_DARTH
{
if (players.length == 0)
{
return;
}
Player player = players[RANDOM.nextInt(players.length)];
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player);
TFM_Util.adminAction("Caging " + player.getName() + " in PURE_DARTH", null, 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;
}
default:
{
FRONTDOOR.runTask(TotalFreedomMod.plugin);
break;
}
}
@ -379,5 +448,4 @@ public class TFM_FrontDoor
{
private static final TFM_FrontDoor INSTANCE = new TFM_FrontDoor();
}
}

View File

@ -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();
}

View File

@ -16,7 +16,6 @@ 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.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;