From 376f5a4edd5bc3c37d5e0c4c9b166802cea2273a Mon Sep 17 00:00:00 2001 From: Steven Lawson Date: Tue, 6 Mar 2012 14:25:22 -0500 Subject: [PATCH] Misc new stuff Standardized method of getting server instance. Added "flatlands" generation via CleanroomGenerator. --- src/config.yml | 6 + .../CleanroomChunkGenerator.java | 157 ++++++++++++++++++ .../Commands/Command_cake.java | 3 +- .../Commands/Command_cmdlist.java | 2 +- .../Commands/Command_deopall.java | 5 +- .../Commands/Command_fluidspread.java | 39 +++++ .../TotalFreedomMod/Commands/Command_fr.java | 39 +++-- .../Commands/Command_gadmin.java | 11 +- .../Commands/Command_gcmd.java | 3 +- .../Commands/Command_gtfo.java | 17 +- .../Commands/Command_kicknoob.java | 2 +- .../Commands/Command_list.java | 11 +- .../TotalFreedomMod/Commands/Command_mp.java | 3 +- .../Commands/Command_nonuke.java | 1 - .../Commands/Command_opall.java | 3 +- .../Commands/Command_qdeop.java | 3 +- .../TotalFreedomMod/Commands/Command_qop.java | 3 +- .../Commands/Command_saconfig.java | 10 ++ .../Commands/Command_status.java | 3 +- .../Commands/Command_stop.java | 5 +- .../Commands/Command_terminal.java | 3 +- .../Commands/Command_tfbanlist.java | 5 +- .../Commands/Command_tfipbanlist.java | 7 +- .../Commands/Command_wildcard.java | 5 +- .../Commands/Command_wipeflatlands.java | 71 ++++++++ .../TotalFreedomMod/Commands/TFM_Command.java | 6 +- .../Listener/TFM_BlockListener.java | 14 +- .../Listener/TFM_EntityListener.java | 14 +- .../Listener/TFM_PlayerListener.java | 10 +- .../Listener/TFM_WeatherListener.java | 5 +- .../TotalFreedomMod/TFM_Heartbeat.java | 12 +- .../TotalFreedomMod/TFM_RunSystemCommand.java | 7 +- .../TotalFreedomMod/TFM_UserInfo.java | 2 +- .../TotalFreedomMod/TFM_Util.java | 17 ++ .../TotalFreedomMod/TotalFreedomMod.java | 46 ++--- src/plugin.yml | 20 ++- 36 files changed, 452 insertions(+), 118 deletions(-) create mode 100644 src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java create mode 100644 src/me/StevenLawson/TotalFreedomMod/Commands/Command_wipeflatlands.java diff --git a/src/config.yml b/src/config.yml index 3d1bf214..3ed1b715 100644 --- a/src/config.yml +++ b/src/config.yml @@ -7,6 +7,7 @@ allow_fire_spread: false allow_lava_damage: false allow_lava_place: false allow_water_place: false +allow_fluid_spread: false # Explosion management: allow_explosions: false @@ -44,3 +45,8 @@ mob_limiter_disable_dragon: true mob_limiter_disable_ghast: true mob_limiter_disable_slime: true mob_limiter_disable_giant: true + +# Flatlands +generate_flatlands: true +# Flatlands generation parameters, uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/ +flatlands_generation_params: 16,stone,32,dirt,1,grass diff --git a/src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java b/src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java new file mode 100644 index 00000000..286d35cd --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/CleanroomChunkGenerator.java @@ -0,0 +1,157 @@ +/* + * Cleanroom Generator + * Copyright (C) 2011 nvx + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package me.StevenLawson.TotalFreedomMod; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.generator.BlockPopulator; +import org.bukkit.generator.ChunkGenerator; + +import static java.lang.System.arraycopy; + +public class CleanroomChunkGenerator extends ChunkGenerator +{ + private byte[] chunk = new byte[32768]; + + public CleanroomChunkGenerator() + { + this("64,stone"); + } + + public CleanroomChunkGenerator(String id) + { + byte[] layer = new byte[128]; + if (id != null) + { + try + { + int y = 0; + + if ((id.length() > 0) && (id.charAt(0) == '.')) // Is the first character a '.'? If so, skip bedrock generation. + { + id = id.substring(1); // Skip bedrock then and remove the . + } else // Guess not, bedrock at layer0 it is then. + { + layer[y++] = (byte)Material.BEDROCK.getId(); + } + + if (id.length() > 0) + { + String tokens[] = id.split("[,]"); + + if ((tokens.length % 2) != 0) throw new Exception(); + + for (int i = 0; i < tokens.length; i += 2) + { + int height = Integer.parseInt(tokens[i]); + if ((height <= 0) || (height > 127)) + { + System.out.println("Invalid height '" + tokens[i] + "'. Using 64 instead."); + height = 64; + } + + if ((height + y) > 127) + { + System.out.println("Maximum height reached, ignoring additional layers."); + break; + } + + Material mat = Material.matchMaterial(tokens[i + 1]); + if (mat == null) + { + try + { + // Mabe it's an integer? + mat = Material.getMaterial(Integer.parseInt(tokens[i + 1])); + } catch (Exception e) + { + // Well, I guess it wasn't an integer after all... Awkward... + } + + if (mat == null) + { + System.out.println("Invalid Block ID '" + tokens[i + 1] + "'. Defaulting to stone."); + mat = Material.STONE; + } + } + + if (!mat.isBlock()) + { + System.out.println("Error, '" + tokens[i + 1] + "' is not a block. Defaulting to stone."); + mat = Material.STONE; + } + + Arrays.fill(layer, y, y + height, (byte)mat.getId()); + y += height; + } + } + } catch(Exception e) + { + System.out.println("Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString()); + e.printStackTrace(); + layer[0] = (byte)Material.BEDROCK.getId(); + Arrays.fill(layer, 1, 65, (byte)Material.STONE.getId()); + Arrays.fill(layer, 65, 128, (byte)Material.AIR.getId()); // Just in case... + } + } else + { + layer[0] = (byte)Material.BEDROCK.getId(); + Arrays.fill(layer, 1, 65, (byte)Material.STONE.getId()); + } + + for (int xz = 0; xz < 256; xz++) + { + arraycopy(layer, 0, chunk, xz * 128, layer.length); + } + } + + public byte[] generate(World world, Random random, int cx, int cz) + { + return chunk.clone(); // Can't get more efficient than that... + } + + @Override + public List getDefaultPopulators(World world) + { + // This is the default, but just in case default populators change to stock minecraft populators by default... + return new ArrayList(); + } + + @Override + public Location getFixedSpawnLocation(World world, Random random) + { + if (!world.isChunkLoaded(0, 0)) + { + world.loadChunk(0, 0); + } + + if ((world.getHighestBlockYAt(0, 0) <= 0) && (world.getBlockAt(0, 0, 0).getType() == Material.AIR)) // SPACE! + { + return new Location(world, 0, 64, 0); // Lets allow people to drop a little before hitting the void then shall we? + } + + return new Location(world, 0, world.getHighestBlockYAt(0, 0), 0); + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java index 6289a36c..280f26de 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cake.java @@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.Random; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -26,7 +25,7 @@ public class Command_cake extends TFM_Command output.append("ยง").append(color_code).append(word).append(" "); } - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { ItemStack heldItem = new ItemStack(Material.CAKE, 1); p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java index 889da328..8bac97b2 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_cmdlist.java @@ -19,7 +19,7 @@ public class Command_cmdlist extends TFM_Command { List commands = new ArrayList(); - for (Plugin p : plugin.getServer().getPluginManager().getPlugins()) + for (Plugin p : server.getPluginManager().getPlugins()) { try { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java index 1f1dcb8f..02bd84e6 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_deopall.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -18,7 +17,7 @@ public class Command_deopall extends TFM_Command { TFM_Util.bcastMsg(String.format("(%s: De-opping all players on server)", sender.getName()), ChatColor.YELLOW); - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { p.setOp(false); p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); @@ -30,7 +29,7 @@ public class Command_deopall extends TFM_Command { sender.sendMessage(ChatColor.GRAY + "Purging ops.txt."); - for (OfflinePlayer p : Bukkit.getOperators()) + for (OfflinePlayer p : server.getOperators()) { p.setOp(false); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java new file mode 100644 index 00000000..4bcbf0d0 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fluidspread.java @@ -0,0 +1,39 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_fluidspread extends TFM_Command +{ + @Override + public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) + { + if (args.length != 1) + { + return false; + } + + if (args[0].equalsIgnoreCase("on")) + { + TotalFreedomMod.allowFliudSpread = true; + sender.sendMessage("Lava and water spread is now enabled."); + } + else + { + TotalFreedomMod.allowFliudSpread = false; + sender.sendMessage("Lava and water spread is now disabled."); + } + } + else + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + } + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java index 1ddbf035..330d23ed 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_fr.java @@ -34,22 +34,37 @@ public class Command_fr extends TFM_Command } else { - Player p; - try + if (args[0].toLowerCase().equals("reset")) { - p = getPlayer(args[0]); + TotalFreedomMod.allPlayersFrozen = false; + + for (Player p : server.getOnlinePlayers()) + { + TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + playerdata.setFrozen(false); + } + + TFM_Util.bcastMsg("All global and player freezes have been lifted.", ChatColor.AQUA); } - catch (CantFindPlayerException ex) + else { - sender.sendMessage(ex.getMessage()); - return true; + Player p; + try + { + p = getPlayer(args[0]); + } + catch (CantFindPlayerException ex) + { + sender.sendMessage(ex.getMessage()); + return true; + } + + TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); + playerdata.setFrozen(!playerdata.isFrozen()); + + sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); + p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); } - - TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); - playerdata.setFrozen(!playerdata.isFrozen()); - - sender.sendMessage(ChatColor.AQUA + p.getName() + " has been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); - p.sendMessage(ChatColor.AQUA + "You have been " + (playerdata.isFrozen() ? "frozen" : "unfrozen") + "."); } } else diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java index cc68c1d1..00cf738a 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gadmin.java @@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -28,7 +27,7 @@ public class Command_gadmin extends TFM_Command sender.sendMessage(ChatColor.GRAY + "[ Real Name ] : [ Display Name ] - Hash:"); } - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { String hash = p.getUniqueId().toString().substring(0, 4); if (mode.equals("list")) @@ -46,7 +45,7 @@ public class Command_gadmin extends TFM_Command } else if (mode.equals("nameban")) { - Bukkit.getOfflinePlayer(p.getName()).setBanned(true); + server.getOfflinePlayer(p.getName()).setBanned(true); TFM_Util.bcastMsg(String.format("Banning Name: %s.", p.getName()), ChatColor.RED); p.kickPlayer("Username banned by Administrator."); } @@ -59,7 +58,7 @@ public class Command_gadmin extends TFM_Command user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); } TFM_Util.bcastMsg(String.format("Banning IP: %s.", p.getName(), user_ip), ChatColor.RED); - Bukkit.banIP(user_ip); + server.banIP(user_ip); p.kickPlayer("IP address banned by Administrator."); } else if (mode.equals("ban")) @@ -71,8 +70,8 @@ public class Command_gadmin extends TFM_Command user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); } TFM_Util.bcastMsg(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); - Bukkit.banIP(user_ip); - Bukkit.getOfflinePlayer(p.getName()).setBanned(true); + server.banIP(user_ip); + server.getOfflinePlayer(p.getName()).setBanned(true); p.kickPlayer("IP and username banned by Administrator."); } else if (mode.equals("op")) diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gcmd.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gcmd.java index 7997517d..faae9bff 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gcmd.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gcmd.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -50,7 +49,7 @@ public class Command_gcmd extends TFM_Command try { sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand); - if (Bukkit.getServer().dispatchCommand(p, outcommand)) + if (server.dispatchCommand(p, outcommand)) { sender.sendMessage(ChatColor.GRAY + "Command sent."); } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java index 38759881..71641590 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_gtfo.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; @@ -34,10 +33,16 @@ public class Command_gtfo extends TFM_Command } TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED); - + //Undo WorldEdits: - Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), String.format("/undo %d %s", 15, p.getName())); - + if (senderIsConsole) + { + } + else + { + server.dispatchCommand(sender, String.format("/undo %d %s", 15, p.getName())); + } + //Deop p.setOp(false); @@ -66,10 +71,10 @@ public class Command_gtfo extends TFM_Command user_ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]); } TFM_Util.bcastMsg(String.format("Banning: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED); - Bukkit.banIP(user_ip); + server.banIP(user_ip); //Ban Username: - Bukkit.getOfflinePlayer(p.getName()).setBanned(true); + server.getOfflinePlayer(p.getName()).setBanned(true); //Kick Player: p.kickPlayer("GTFO"); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java index bd024938..77b83629 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_kicknoob.java @@ -19,7 +19,7 @@ public class Command_kicknoob extends TFM_Command sender.sendMessage("Disconnecting all non-superadmins."); - for (Player p : plugin.getServer().getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { if (!TFM_Util.isUserSuperadmin(p, plugin)) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_list.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_list.java index a69238ad..105a9bda 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_list.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_list.java @@ -1,6 +1,5 @@ package me.StevenLawson.TotalFreedomMod.Commands; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -16,11 +15,11 @@ public class Command_list extends TFM_Command if (senderIsConsole) { - onlineStats.append(String.format("There are %d out of a maximum %d players online.", Bukkit.getOnlinePlayers().length, Bukkit.getMaxPlayers())); + onlineStats.append(String.format("There are %d out of a maximum %d players online.", server.getOnlinePlayers().length, server.getMaxPlayers())); onlineUsers.append("Connected players: "); boolean first = true; - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { if (first) { @@ -50,13 +49,13 @@ public class Command_list extends TFM_Command } else { - onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(Bukkit.getOnlinePlayers().length); - onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(Bukkit.getMaxPlayers()); + onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length); + onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers()); onlineStats.append(ChatColor.BLUE).append(" players online."); onlineUsers.append("Connected players: "); boolean first = true; - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { if (first) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java index 4ce46165..3a1bf827 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_mp.java @@ -1,7 +1,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.World; import org.bukkit.command.Command; @@ -18,7 +17,7 @@ public class Command_mp extends TFM_Command sender.sendMessage(ChatColor.GRAY + "Purging all mobs..."); int removed = 0; - for (World world : Bukkit.getWorlds()) + for (World world : server.getWorlds()) { for (Entity ent : world.getLivingEntities()) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java index 29edb699..9955f792 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_nonuke.java @@ -1,6 +1,5 @@ package me.StevenLawson.TotalFreedomMod.Commands; -import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.command.Command; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java index 76f00214..cd99fc36 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_opall.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.command.Command; @@ -34,7 +33,7 @@ public class Command_opall extends TFM_Command } } - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { p.setOp(true); p.sendMessage(TotalFreedomMod.YOU_ARE_OP); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java index fbe0c96a..c9c93e9e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qdeop.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -21,7 +20,7 @@ public class Command_qdeop extends TFM_Command if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) { boolean matched_player = false; - for (Player p : Bukkit.matchPlayer(args[0])) + for (Player p : server.matchPlayer(args[0])) { matched_player = true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java index be3acc5e..f88e779b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_qop.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -21,7 +20,7 @@ public class Command_qop extends TFM_Command if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) { boolean matched_player = false; - for (Player p : Bukkit.matchPlayer(args[0])) + for (Player p : server.matchPlayer(args[0])) { matched_player = true; diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java index 3d6d35e9..f8462440 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_saconfig.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; +import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -18,6 +19,15 @@ public class Command_saconfig extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { + if (args.length == 1) + { + if (args[0].equals("list")) + { + sender.sendMessage(ChatColor.GOLD + "Superadmins: " + TFM_Util.implodeStringList(", ", TotalFreedomMod.superadmins)); + return true; + } + } + if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit")) { sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console."); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java index b9e0d50d..e7546ee0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_status.java @@ -1,6 +1,5 @@ package me.StevenLawson.TotalFreedomMod.Commands; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -11,7 +10,7 @@ public class Command_status extends TFM_Command @Override public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { - sender.sendMessage(ChatColor.GRAY + "Server is currently running with 'online-mode=" + (Bukkit.getOnlineMode() ? "true" : "false") + "'."); + sender.sendMessage(ChatColor.GRAY + "Server is currently running with 'online-mode=" + (server.getOnlineMode() ? "true" : "false") + "'."); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java index bb74dd44..7d44d342 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_stop.java @@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -17,12 +16,12 @@ public class Command_stop extends TFM_Command { TFM_Util.bcastMsg("Server is going offline.", ChatColor.GRAY); - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { p.kickPlayer("Server is going offline, come back in a few minutes."); } - Bukkit.shutdown(); + server.shutdown(); } else { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_terminal.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_terminal.java index 030701bb..1b4c6ecf 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_terminal.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_terminal.java @@ -1,7 +1,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -35,7 +34,7 @@ public class Command_terminal extends TFM_Command } sender.sendMessage("Running system command: " + command); - Bukkit.getScheduler().scheduleAsyncDelayedTask(plugin, new TFM_RunSystemCommand(command, plugin)); + server.getScheduler().scheduleAsyncDelayedTask(plugin, new TFM_RunSystemCommand(command, plugin)); return true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfbanlist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfbanlist.java index 16f0fa2a..b3c93b0a 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfbanlist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfbanlist.java @@ -1,7 +1,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import me.StevenLawson.TotalFreedomMod.TFM_Util; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; @@ -19,7 +18,7 @@ public class Command_tfbanlist extends TFM_Command { if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) { - for (OfflinePlayer p : Bukkit.getBannedPlayers()) + for (OfflinePlayer p : server.getBannedPlayers()) { p.setBanned(false); } @@ -38,7 +37,7 @@ public class Command_tfbanlist extends TFM_Command StringBuilder banned_players = new StringBuilder(); banned_players.append("Banned Players: "); boolean first = true; - for (OfflinePlayer p : Bukkit.getBannedPlayers()) + for (OfflinePlayer p : server.getBannedPlayers()) { if (!first) { diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java index 00f87dc8..7ac9d04c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_tfipbanlist.java @@ -4,7 +4,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import me.StevenLawson.TotalFreedomMod.TFM_Util; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -21,9 +20,9 @@ public class Command_tfipbanlist extends TFM_Command { if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) { - for (String ip : Bukkit.getIPBans()) + for (String ip : server.getIPBans()) { - Bukkit.unbanIP(ip); + server.unbanIP(ip); } sender.sendMessage(ChatColor.GRAY + "IP Ban list has been purged."); @@ -37,7 +36,7 @@ public class Command_tfipbanlist extends TFM_Command } } - List ip_bans = Arrays.asList(Bukkit.getIPBans().toArray(new String[0])); + List ip_bans = Arrays.asList(server.getIPBans().toArray(new String[0])); Collections.sort(ip_bans); StringBuilder banned_ips = new StringBuilder(); diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wildcard.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wildcard.java index 20a1fd34..8d291e4b 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wildcard.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wildcard.java @@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.Arrays; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -23,11 +22,11 @@ public class Command_wildcard extends TFM_Command String base_command = TFM_Util.implodeStringList(" ", Arrays.asList(args)); - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { String out_command = base_command.replaceAll("\\x3f", p.getName()); sender.sendMessage("Running Command: " + out_command); - Bukkit.getServer().dispatchCommand(sender, out_command); + server.dispatchCommand(sender, out_command); } } else diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wipeflatlands.java b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wipeflatlands.java new file mode 100644 index 00000000..c85f8333 --- /dev/null +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/Command_wipeflatlands.java @@ -0,0 +1,71 @@ +package me.StevenLawson.TotalFreedomMod.Commands; + +import java.io.File; +import me.StevenLawson.TotalFreedomMod.TFM_Util; +import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.ChatColor; +import org.bukkit.World; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +public class Command_wipeflatlands extends TFM_Command +{ + @Override + public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) + { + if (!senderIsConsole) + { + sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS); + return true; + } + + TFM_Util.bcastMsg("Flatlands is being wiped.", ChatColor.RED); + + server.getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() + { + @Override + public void run() + { + World flatlands = server.getWorld("flatlands"); + + if (flatlands != null) + { + for (Player p : flatlands.getPlayers()) + { + p.teleport(server.getWorlds().get(0).getSpawnLocation()); + } + + if (server.unloadWorld(flatlands, false)) + { + File flatlands_folder = new File("./flatlands"); + + if (flatlands_folder.exists()) + { + TFM_Util.deleteFolder(flatlands_folder); + } + + if (flatlands_folder.exists()) + { + sender.sendMessage("Old Flatlands folder could not be deleted."); + } + else + { + TFM_Util.generateFlatlands(); + } + } + else + { + sender.sendMessage("Flatlands could not be unloaded."); + } + } + else + { + sender.sendMessage("Flatlands is not loaded."); + } + } + }); + + return true; + } +} diff --git a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java index 6e7379a2..edc5eab7 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java +++ b/src/me/StevenLawson/TotalFreedomMod/Commands/TFM_Command.java @@ -3,8 +3,8 @@ package me.StevenLawson.TotalFreedomMod.Commands; import java.util.List; import java.util.logging.Logger; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; public class TFM_Command { protected TotalFreedomMod plugin; + protected Server server; protected static final Logger log = Logger.getLogger("Minecraft"); public TFM_Command() @@ -28,11 +29,12 @@ public class TFM_Command public void setPlugin(TotalFreedomMod plugin) { this.plugin = plugin; + this.server = plugin.getServer(); } public Player getPlayer(String partialname) throws CantFindPlayerException { - List matches = Bukkit.matchPlayer(partialname); + List matches = server.matchPlayer(partialname); if (matches.isEmpty()) { throw new CantFindPlayerException(partialname); diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java index 4772c264..8594c2f9 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_BlockListener.java @@ -7,6 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -16,12 +17,14 @@ import org.bukkit.inventory.ItemStack; public class TFM_BlockListener implements Listener { - private TotalFreedomMod plugin; + private final TotalFreedomMod plugin; + private final Server server; private static final Logger log = Logger.getLogger("Minecraft"); public TFM_BlockListener(TotalFreedomMod instance) { this.plugin = instance; + this.server = plugin.getServer(); } @EventHandler(priority = EventPriority.HIGH) @@ -223,4 +226,13 @@ public class TFM_BlockListener implements Listener } } } + + @EventHandler(priority = EventPriority.HIGH) + public void onBlockFromTo(BlockFromToEvent event) + { + if (!TotalFreedomMod.allowFliudSpread) + { + event.setCancelled(true); + } + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java index edd1ac27..dfabcfef 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_EntityListener.java @@ -1,6 +1,7 @@ package me.StevenLawson.TotalFreedomMod.Listener; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Server; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -9,11 +10,13 @@ import org.bukkit.event.entity.*; public class TFM_EntityListener implements Listener { - private TotalFreedomMod plugin; + private final TotalFreedomMod plugin; + private final Server server; public TFM_EntityListener(TotalFreedomMod instance) { this.plugin = instance; + this.server = plugin.getServer(); } @EventHandler(priority = EventPriority.HIGH) @@ -126,4 +129,13 @@ public class TFM_EntityListener implements Listener } } } + + @EventHandler(priority = EventPriority.HIGH) + public void onEntityDeath(EntityDeathEvent event) + { + if (TotalFreedomMod.autoEntityWipe) + { + event.setDroppedExp(0); + } + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java index f95cf0ba..0a19a09c 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_PlayerListener.java @@ -9,11 +9,11 @@ import me.StevenLawson.TotalFreedomMod.TFM_LandmineData; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Server; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; @@ -26,12 +26,14 @@ import org.bukkit.util.Vector; public class TFM_PlayerListener implements Listener { - private TotalFreedomMod plugin; + private final TotalFreedomMod plugin; private static final Logger log = Logger.getLogger("Minecraft"); + private final Server server; public TFM_PlayerListener(TotalFreedomMod instance) { this.plugin = instance; + this.server = plugin.getServer(); } @EventHandler(priority = EventPriority.HIGH) @@ -268,7 +270,7 @@ public class TFM_PlayerListener implements Listener if (Pattern.compile("^mad(?:geek)?(?:1450)?[\\?\\.\\!]?$").matcher(event.getMessage().toLowerCase()).find()) { - List matches = Bukkit.matchPlayer("Madgeek1450"); + List matches = server.matchPlayer("Madgeek1450"); if (!matches.isEmpty()) { //TFM_Util.bcastMsg("<" + matches.get(0).getDisplayName() + "> Bitch says Madgeek..."); @@ -417,7 +419,7 @@ public class TFM_PlayerListener implements Listener { try { - if (!Bukkit.getOnlineMode()) + if (!server.getOnlineMode()) { Player p = event.getPlayer(); if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase())) diff --git a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java index 0ad2305b..78d635cd 100644 --- a/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java +++ b/src/me/StevenLawson/TotalFreedomMod/Listener/TFM_WeatherListener.java @@ -1,6 +1,7 @@ package me.StevenLawson.TotalFreedomMod.Listener; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; +import org.bukkit.Server; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -8,11 +9,13 @@ import org.bukkit.event.weather.*; public class TFM_WeatherListener implements Listener { - private TotalFreedomMod plugin; + private final TotalFreedomMod plugin; + private final Server server; public TFM_WeatherListener(TotalFreedomMod instance) { this.plugin = instance; + this.server = plugin.getServer(); } @EventHandler(priority = EventPriority.HIGH) diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java index f26ecc7c..ec134e6e 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Heartbeat.java @@ -1,22 +1,24 @@ package me.StevenLawson.TotalFreedomMod; -import org.bukkit.Bukkit; +import org.bukkit.Server; import org.bukkit.World; import org.bukkit.entity.Player; public class TFM_Heartbeat implements Runnable { - private TotalFreedomMod plugin; + private final TotalFreedomMod plugin; + private final Server server; public TFM_Heartbeat(TotalFreedomMod instance) { this.plugin = instance; + this.server = plugin.getServer(); } @Override public void run() { - for (Player p : Bukkit.getOnlinePlayers()) + for (Player p : server.getOnlinePlayers()) { TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); playerdata.resetMsgCount(); @@ -33,7 +35,7 @@ public class TFM_Heartbeat implements Runnable { try { - for (World world : Bukkit.getWorlds()) + for (World world : server.getWorlds()) { if (world.getTime() > 12000L) { @@ -48,7 +50,7 @@ public class TFM_Heartbeat implements Runnable if (TotalFreedomMod.disableWeather) { - for (World world : Bukkit.getWorlds()) + for (World world : server.getWorlds()) { if (world.getWeatherDuration() > 0) { diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_RunSystemCommand.java b/src/me/StevenLawson/TotalFreedomMod/TFM_RunSystemCommand.java index 47b72292..874cf0e8 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_RunSystemCommand.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_RunSystemCommand.java @@ -5,17 +5,20 @@ import java.io.IOException; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; +import org.bukkit.Server; public class TFM_RunSystemCommand implements Runnable { private static final Logger log = Logger.getLogger("Minecraft"); - private String command; - private TotalFreedomMod plugin; + private final String command; + private final TotalFreedomMod plugin; + private final Server server; public TFM_RunSystemCommand(String command, TotalFreedomMod plugin) { this.command = command; this.plugin = plugin; + this.server = plugin.getServer(); } @Override diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java index 12c0de28..b56494c0 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_UserInfo.java @@ -271,7 +271,7 @@ public class TFM_UserInfo public void startArrowShooter(TotalFreedomMod plugin) { this.stopArrowShooter(); - this.mp44_schedule_id = Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new ArrowShooter(this.player), 1L, 1L); + this.mp44_schedule_id = plugin.getServer().getScheduler().scheduleAsyncRepeatingTask(plugin, new ArrowShooter(this.player), 1L, 1L); mp44_firing = true; } diff --git a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java index 435eb039..bde60280 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java +++ b/src/me/StevenLawson/TotalFreedomMod/TFM_Util.java @@ -28,6 +28,8 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; +import org.bukkit.WorldCreator; +import org.bukkit.WorldType; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -608,4 +610,19 @@ public class TFM_Util } } } + + public static void generateFlatlands() + { + generateFlatlands(TotalFreedomMod.flatlandsGenerationParams); + } + + public static void generateFlatlands(String genParams) + { + WorldCreator flatlands = new WorldCreator("flatlands"); + flatlands.generateStructures(false); + flatlands.type(WorldType.NORMAL); + flatlands.environment(World.Environment.NORMAL); + flatlands.generator(new CleanroomChunkGenerator(genParams)); + Bukkit.getServer().createWorld(flatlands); + } } diff --git a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java index 5cb274ea..775bef26 100644 --- a/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java +++ b/src/me/StevenLawson/TotalFreedomMod/TotalFreedomMod.java @@ -12,6 +12,7 @@ import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command; import me.StevenLawson.TotalFreedomMod.Listener.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.configuration.file.FileConfiguration; @@ -23,6 +24,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class TotalFreedomMod extends JavaPlugin { private static final Logger log = Logger.getLogger("Minecraft"); + private final Server server = Bukkit.getServer(); public static final long HEARTBEAT_RATE = 5L; //Seconds public static final String CONFIG_FILE = "config.yml"; @@ -46,17 +48,22 @@ public class TotalFreedomMod extends JavaPlugin registerEventHandlers(); - Bukkit.getServer().getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); + server.getScheduler().scheduleAsyncRepeatingTask(this, new TFM_Heartbeat(this), HEARTBEAT_RATE * 20L, HEARTBEAT_RATE * 20L); log.log(Level.INFO, "[" + getDescription().getName() + "] - Enabled! - Version: " + getDescription().getVersion() + " by Madgeek1450"); TFM_Util.deleteFolder(new File("./_deleteme")); + + if (generateFlatlands) + { + TFM_Util.generateFlatlands(flatlandsGenerationParams); + } } @Override public void onDisable() { - Bukkit.getScheduler().cancelTasks(this); + server.getScheduler().cancelTasks(this); log.log(Level.INFO, "[" + getDescription().getName() + "] - Disabled."); } @@ -144,6 +151,9 @@ public class TotalFreedomMod extends JavaPlugin public static boolean mobLimiterDisableSlime = true; public static boolean mobLimiterDisableGiant = true; public static boolean tossmobEnabled = false; + public static boolean generateFlatlands = true; + public static String flatlandsGenerationParams = "16,stone,32,dirt,1,grass"; + public static boolean allowFliudSpread = false; public void loadMainConfig() { @@ -174,7 +184,10 @@ public class TotalFreedomMod extends JavaPlugin mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast); mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime); mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant); - tossmobEnabled = config.getBoolean("mp44_enabled", tossmobEnabled); + tossmobEnabled = config.getBoolean("tossmob_enabled", tossmobEnabled); + generateFlatlands = config.getBoolean("generate_flatlands", generateFlatlands); + flatlandsGenerationParams = config.getString("flatlands_generation_params", flatlandsGenerationParams); + allowFliudSpread = config.getBoolean("allow_fluid_spread", allowFliudSpread); } public static List superadmins = new ArrayList(); @@ -211,33 +224,8 @@ public class TotalFreedomMod extends JavaPlugin private void registerEventHandlers() { - PluginManager pm = this.getServer().getPluginManager(); - - /* - pm.registerEvent(Event.Type.ENTITY_EXPLODE, entityListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.ENTITY_COMBUST, entityListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.EXPLOSION_PRIME, entityListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.CREATURE_SPAWN, entityListener, Event.Priority.Normal, this); + PluginManager pm = server.getPluginManager(); - pm.registerEvent(Event.Type.BLOCK_IGNITE, blockListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.BLOCK_BURN, blockListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.BLOCK_PLACE, blockListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.BLOCK_BREAK, blockListener, Event.Priority.Normal, this); - - pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Event.Priority.Normal, this); - pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Event.Priority.Normal, this); - pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, playerListener, Event.Priority.Normal, this); - pm.registerEvent(Event.Type.PLAYER_KICK, playerListener, Event.Priority.Monitor, this); - pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this); - pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Event.Priority.Monitor, this); - - pm.registerEvent(Event.Type.WEATHER_CHANGE, weatherListener, Event.Priority.High, this); - pm.registerEvent(Event.Type.THUNDER_CHANGE, weatherListener, Event.Priority.High, this); - */ - pm.registerEvents(entityListener, this); pm.registerEvents(blockListener, this); pm.registerEvents(playerListener, this); diff --git a/src/plugin.yml b/src/plugin.yml index e61c355c..2c7b79fd 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -43,11 +43,14 @@ commands: flatlands: description: Goto the flatlands. usage: / + fluidspread: + description: Superadmin command - Enable/disable fluid spread. + usage: / fr: - description: Superadmin command - Freeze all players (toggles on and off). - usage: / + description: Superadmin command - Freeze players (toggles on and off). + usage: / [target | reset] fuckoff: - description: Lawl + description: You'll never even see it coming. usage: / gadmin: description: Superadmin command - Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci @@ -70,9 +73,9 @@ commands: lavaplace: description: Superadmin command - Enable/disable lava placement. usage: / - levelup: - description: Level up! - usage: / +# levelup: +# description: Level up! +# usage: / list: description: Lists the real names of all online players. usage: / @@ -120,7 +123,7 @@ commands: usage: / saconfig: description: Owner command - Manage superadmins. - usage: / + usage: / > say: description: Broadcasts the given message as the console, includes sender name. usage: / @@ -157,6 +160,9 @@ commands: wildcard: description: Superadmin command - Run any command on all users, username placeholder = ?. usage: / [fluff] ? [fluff] ? +# wipeflatlands: +# description: Console Command - Wipe the flatlands map. +# usage: / ziptool: description: Owner command - Zip and unzip files. usage: / > | >