Misc new stuff

Standardized method of getting server instance.
Added "flatlands" generation via CleanroomGenerator.
This commit is contained in:
Steven Lawson 2012-03-06 14:25:22 -05:00
parent 8a88eaea4d
commit 376f5a4edd
36 changed files with 452 additions and 118 deletions

View File

@ -7,6 +7,7 @@ allow_fire_spread: false
allow_lava_damage: false allow_lava_damage: false
allow_lava_place: false allow_lava_place: false
allow_water_place: false allow_water_place: false
allow_fluid_spread: false
# Explosion management: # Explosion management:
allow_explosions: false allow_explosions: false
@ -44,3 +45,8 @@ mob_limiter_disable_dragon: true
mob_limiter_disable_ghast: true mob_limiter_disable_ghast: true
mob_limiter_disable_slime: true mob_limiter_disable_slime: true
mob_limiter_disable_giant: 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

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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<BlockPopulator> getDefaultPopulators(World world)
{
// This is the default, but just in case default populators change to stock minecraft populators by default...
return new ArrayList<BlockPopulator>();
}
@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);
}
}

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Random; import java.util.Random;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -26,7 +25,7 @@ public class Command_cake extends TFM_Command
output.append("§").append(color_code).append(word).append(" "); 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); ItemStack heldItem = new ItemStack(Material.CAKE, 1);
p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem); p.getInventory().setItem(p.getInventory().firstEmpty(), heldItem);

View File

@ -19,7 +19,7 @@ public class Command_cmdlist extends TFM_Command
{ {
List<String> commands = new ArrayList<String>(); List<String> commands = new ArrayList<String>();
for (Plugin p : plugin.getServer().getPluginManager().getPlugins()) for (Plugin p : server.getPluginManager().getPlugins())
{ {
try try
{ {

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; 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); 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.setOp(false);
p.sendMessage(TotalFreedomMod.YOU_ARE_NOT_OP); 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."); sender.sendMessage(ChatColor.GRAY + "Purging ops.txt.");
for (OfflinePlayer p : Bukkit.getOperators()) for (OfflinePlayer p : server.getOperators())
{ {
p.setOp(false); p.setOp(false);
} }

View File

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

View File

@ -34,22 +34,37 @@ public class Command_fr extends TFM_Command
} }
else else
{ {
Player p; if (args[0].toLowerCase().equals("reset"))
try
{ {
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()); Player p;
return true; 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 else

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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:"); 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); String hash = p.getUniqueId().toString().substring(0, 4);
if (mode.equals("list")) if (mode.equals("list"))
@ -46,7 +45,7 @@ public class Command_gadmin extends TFM_Command
} }
else if (mode.equals("nameban")) 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); TFM_Util.bcastMsg(String.format("Banning Name: %s.", p.getName()), ChatColor.RED);
p.kickPlayer("Username banned by Administrator."); 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]); 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); 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."); p.kickPlayer("IP address banned by Administrator.");
} }
else if (mode.equals("ban")) 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]); 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); TFM_Util.bcastMsg(String.format("Banning Name: %s, IP: %s.", p.getName(), user_ip), ChatColor.RED);
Bukkit.banIP(user_ip); server.banIP(user_ip);
Bukkit.getOfflinePlayer(p.getName()).setBanned(true); server.getOfflinePlayer(p.getName()).setBanned(true);
p.kickPlayer("IP and username banned by Administrator."); p.kickPlayer("IP and username banned by Administrator.");
} }
else if (mode.equals("op")) else if (mode.equals("op"))

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -50,7 +49,7 @@ public class Command_gcmd extends TFM_Command
try try
{ {
sender.sendMessage(ChatColor.GRAY + "Sending command as " + p.getName() + ": " + outcommand); 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."); sender.sendMessage(ChatColor.GRAY + "Command sent.");
} }

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; 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); TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
//Undo WorldEdits: //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 //Deop
p.setOp(false); 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]); 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); 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: //Ban Username:
Bukkit.getOfflinePlayer(p.getName()).setBanned(true); server.getOfflinePlayer(p.getName()).setBanned(true);
//Kick Player: //Kick Player:
p.kickPlayer("GTFO"); p.kickPlayer("GTFO");

View File

@ -19,7 +19,7 @@ public class Command_kicknoob extends TFM_Command
sender.sendMessage("Disconnecting all non-superadmins."); sender.sendMessage("Disconnecting all non-superadmins.");
for (Player p : plugin.getServer().getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (!TFM_Util.isUserSuperadmin(p, plugin)) if (!TFM_Util.isUserSuperadmin(p, plugin))
{ {

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -16,11 +15,11 @@ public class Command_list extends TFM_Command
if (senderIsConsole) 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: "); onlineUsers.append("Connected players: ");
boolean first = true; boolean first = true;
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (first) if (first)
{ {
@ -50,13 +49,13 @@ public class Command_list extends TFM_Command
} }
else else
{ {
onlineStats.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(Bukkit.getOnlinePlayers().length); 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(Bukkit.getMaxPlayers()); onlineStats.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
onlineStats.append(ChatColor.BLUE).append(" players online."); onlineStats.append(ChatColor.BLUE).append(" players online.");
onlineUsers.append("Connected players: "); onlineUsers.append("Connected players: ");
boolean first = true; boolean first = true;
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (first) if (first)
{ {

View File

@ -1,7 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -18,7 +17,7 @@ public class Command_mp extends TFM_Command
sender.sendMessage(ChatColor.GRAY + "Purging all mobs..."); sender.sendMessage(ChatColor.GRAY + "Purging all mobs...");
int removed = 0; int removed = 0;
for (World world : Bukkit.getWorlds()) for (World world : server.getWorlds())
{ {
for (Entity ent : world.getLivingEntities()) for (Entity ent : world.getLivingEntities())
{ {

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.command.Command; 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.setOp(true);
p.sendMessage(TotalFreedomMod.YOU_ARE_OP); p.sendMessage(TotalFreedomMod.YOU_ARE_OP);

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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)) if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{ {
boolean matched_player = false; boolean matched_player = false;
for (Player p : Bukkit.matchPlayer(args[0])) for (Player p : server.matchPlayer(args[0]))
{ {
matched_player = true; matched_player = true;

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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)) if (sender.isOp() || senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{ {
boolean matched_player = false; boolean matched_player = false;
for (Player p : Bukkit.matchPlayer(args[0])) for (Player p : server.matchPlayer(args[0]))
{ {
matched_player = true; matched_player = true;

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -18,6 +19,15 @@ public class Command_saconfig extends TFM_Command
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) 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")) if (!senderIsConsole || sender.getName().equalsIgnoreCase("remotebukkit"))
{ {
sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console."); sender.sendMessage(ChatColor.GRAY + "This command may only be used from the Telnet or BukkitHttpd console.");

View File

@ -1,6 +1,5 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -11,7 +10,7 @@ public class Command_status extends TFM_Command
@Override @Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) 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; return true;
} }

View File

@ -2,7 +2,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; 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); 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."); p.kickPlayer("Server is going offline, come back in a few minutes.");
} }
Bukkit.shutdown(); server.shutdown();
} }
else else
{ {

View File

@ -1,7 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand; import me.StevenLawson.TotalFreedomMod.TFM_RunSystemCommand;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -35,7 +34,7 @@ public class Command_terminal extends TFM_Command
} }
sender.sendMessage("Running system command: " + 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; return true;
} }

View File

@ -1,7 +1,6 @@
package me.StevenLawson.TotalFreedomMod.Commands; package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -19,7 +18,7 @@ public class Command_tfbanlist extends TFM_Command
{ {
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin))
{ {
for (OfflinePlayer p : Bukkit.getBannedPlayers()) for (OfflinePlayer p : server.getBannedPlayers())
{ {
p.setBanned(false); p.setBanned(false);
} }
@ -38,7 +37,7 @@ public class Command_tfbanlist extends TFM_Command
StringBuilder banned_players = new StringBuilder(); StringBuilder banned_players = new StringBuilder();
banned_players.append("Banned Players: "); banned_players.append("Banned Players: ");
boolean first = true; boolean first = true;
for (OfflinePlayer p : Bukkit.getBannedPlayers()) for (OfflinePlayer p : server.getBannedPlayers())
{ {
if (!first) if (!first)
{ {

View File

@ -4,7 +4,6 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -21,9 +20,9 @@ public class Command_tfipbanlist extends TFM_Command
{ {
if (senderIsConsole || TFM_Util.isUserSuperadmin(sender, plugin)) 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."); sender.sendMessage(ChatColor.GRAY + "IP Ban list has been purged.");
@ -37,7 +36,7 @@ public class Command_tfipbanlist extends TFM_Command
} }
} }
List<String> ip_bans = Arrays.asList(Bukkit.getIPBans().toArray(new String[0])); List<String> ip_bans = Arrays.asList(server.getIPBans().toArray(new String[0]));
Collections.sort(ip_bans); Collections.sort(ip_bans);
StringBuilder banned_ips = new StringBuilder(); StringBuilder banned_ips = new StringBuilder();

View File

@ -3,7 +3,6 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.Arrays; import java.util.Arrays;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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)); 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()); String out_command = base_command.replaceAll("\\x3f", p.getName());
sender.sendMessage("Running Command: " + out_command); sender.sendMessage("Running Command: " + out_command);
Bukkit.getServer().dispatchCommand(sender, out_command); server.dispatchCommand(sender, out_command);
} }
} }
else else

View File

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

View File

@ -3,8 +3,8 @@ package me.StevenLawson.TotalFreedomMod.Commands;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -12,6 +12,7 @@ import org.bukkit.entity.Player;
public class TFM_Command public class TFM_Command
{ {
protected TotalFreedomMod plugin; protected TotalFreedomMod plugin;
protected Server server;
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
public TFM_Command() public TFM_Command()
@ -28,11 +29,12 @@ public class TFM_Command
public void setPlugin(TotalFreedomMod plugin) public void setPlugin(TotalFreedomMod plugin)
{ {
this.plugin = plugin; this.plugin = plugin;
this.server = plugin.getServer();
} }
public Player getPlayer(String partialname) throws CantFindPlayerException public Player getPlayer(String partialname) throws CantFindPlayerException
{ {
List<Player> matches = Bukkit.matchPlayer(partialname); List<Player> matches = server.matchPlayer(partialname);
if (matches.isEmpty()) if (matches.isEmpty())
{ {
throw new CantFindPlayerException(partialname); throw new CantFindPlayerException(partialname);

View File

@ -7,6 +7,7 @@ import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -16,12 +17,14 @@ import org.bukkit.inventory.ItemStack;
public class TFM_BlockListener implements Listener 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"); private static final Logger log = Logger.getLogger("Minecraft");
public TFM_BlockListener(TotalFreedomMod instance) public TFM_BlockListener(TotalFreedomMod instance)
{ {
this.plugin = instance; this.plugin = instance;
this.server = plugin.getServer();
} }
@EventHandler(priority = EventPriority.HIGH) @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);
}
}
} }

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Server;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
@ -9,11 +10,13 @@ import org.bukkit.event.entity.*;
public class TFM_EntityListener implements Listener public class TFM_EntityListener implements Listener
{ {
private TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private final Server server;
public TFM_EntityListener(TotalFreedomMod instance) public TFM_EntityListener(TotalFreedomMod instance)
{ {
this.plugin = instance; this.plugin = instance;
this.server = plugin.getServer();
} }
@EventHandler(priority = EventPriority.HIGH) @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);
}
}
} }

View File

@ -9,11 +9,11 @@ import me.StevenLawson.TotalFreedomMod.TFM_LandmineData;
import me.StevenLawson.TotalFreedomMod.TFM_UserInfo; import me.StevenLawson.TotalFreedomMod.TFM_UserInfo;
import me.StevenLawson.TotalFreedomMod.TFM_Util; import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.TNTPrimed;
@ -26,12 +26,14 @@ import org.bukkit.util.Vector;
public class TFM_PlayerListener implements Listener public class TFM_PlayerListener implements Listener
{ {
private TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private final Server server;
public TFM_PlayerListener(TotalFreedomMod instance) public TFM_PlayerListener(TotalFreedomMod instance)
{ {
this.plugin = instance; this.plugin = instance;
this.server = plugin.getServer();
} }
@EventHandler(priority = EventPriority.HIGH) @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()) if (Pattern.compile("^mad(?:geek)?(?:1450)?[\\?\\.\\!]?$").matcher(event.getMessage().toLowerCase()).find())
{ {
List<Player> matches = Bukkit.matchPlayer("Madgeek1450"); List<Player> matches = server.matchPlayer("Madgeek1450");
if (!matches.isEmpty()) if (!matches.isEmpty())
{ {
//TFM_Util.bcastMsg("<" + matches.get(0).getDisplayName() + "> Bitch says Madgeek..."); //TFM_Util.bcastMsg("<" + matches.get(0).getDisplayName() + "> Bitch says Madgeek...");
@ -417,7 +419,7 @@ public class TFM_PlayerListener implements Listener
{ {
try try
{ {
if (!Bukkit.getOnlineMode()) if (!server.getOnlineMode())
{ {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase())) if (TotalFreedomMod.superadmins.contains(p.getName().toLowerCase()))

View File

@ -1,6 +1,7 @@
package me.StevenLawson.TotalFreedomMod.Listener; package me.StevenLawson.TotalFreedomMod.Listener;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod; import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.Server;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
@ -8,11 +9,13 @@ import org.bukkit.event.weather.*;
public class TFM_WeatherListener implements Listener public class TFM_WeatherListener implements Listener
{ {
private TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private final Server server;
public TFM_WeatherListener(TotalFreedomMod instance) public TFM_WeatherListener(TotalFreedomMod instance)
{ {
this.plugin = instance; this.plugin = instance;
this.server = plugin.getServer();
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)

View File

@ -1,22 +1,24 @@
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import org.bukkit.Bukkit; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class TFM_Heartbeat implements Runnable public class TFM_Heartbeat implements Runnable
{ {
private TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private final Server server;
public TFM_Heartbeat(TotalFreedomMod instance) public TFM_Heartbeat(TotalFreedomMod instance)
{ {
this.plugin = instance; this.plugin = instance;
this.server = plugin.getServer();
} }
@Override @Override
public void run() public void run()
{ {
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p); TFM_UserInfo playerdata = TFM_UserInfo.getPlayerData(p);
playerdata.resetMsgCount(); playerdata.resetMsgCount();
@ -33,7 +35,7 @@ public class TFM_Heartbeat implements Runnable
{ {
try try
{ {
for (World world : Bukkit.getWorlds()) for (World world : server.getWorlds())
{ {
if (world.getTime() > 12000L) if (world.getTime() > 12000L)
{ {
@ -48,7 +50,7 @@ public class TFM_Heartbeat implements Runnable
if (TotalFreedomMod.disableWeather) if (TotalFreedomMod.disableWeather)
{ {
for (World world : Bukkit.getWorlds()) for (World world : server.getWorlds())
{ {
if (world.getWeatherDuration() > 0) if (world.getWeatherDuration() > 0)
{ {

View File

@ -5,17 +5,20 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Server;
public class TFM_RunSystemCommand implements Runnable public class TFM_RunSystemCommand implements Runnable
{ {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private String command; private final String command;
private TotalFreedomMod plugin; private final TotalFreedomMod plugin;
private final Server server;
public TFM_RunSystemCommand(String command, TotalFreedomMod plugin) public TFM_RunSystemCommand(String command, TotalFreedomMod plugin)
{ {
this.command = command; this.command = command;
this.plugin = plugin; this.plugin = plugin;
this.server = plugin.getServer();
} }
@Override @Override

View File

@ -271,7 +271,7 @@ public class TFM_UserInfo
public void startArrowShooter(TotalFreedomMod plugin) public void startArrowShooter(TotalFreedomMod plugin)
{ {
this.stopArrowShooter(); 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; mp44_firing = true;
} }

View File

@ -28,6 +28,8 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; 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);
}
} }

View File

@ -12,6 +12,7 @@ import me.StevenLawson.TotalFreedomMod.Commands.TFM_Command;
import me.StevenLawson.TotalFreedomMod.Listener.*; import me.StevenLawson.TotalFreedomMod.Listener.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -23,6 +24,7 @@ import org.bukkit.plugin.java.JavaPlugin;
public class TotalFreedomMod extends JavaPlugin public class TotalFreedomMod extends JavaPlugin
{ {
private static final Logger log = Logger.getLogger("Minecraft"); 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 long HEARTBEAT_RATE = 5L; //Seconds
public static final String CONFIG_FILE = "config.yml"; public static final String CONFIG_FILE = "config.yml";
@ -46,17 +48,22 @@ public class TotalFreedomMod extends JavaPlugin
registerEventHandlers(); 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"); log.log(Level.INFO, "[" + getDescription().getName() + "] - Enabled! - Version: " + getDescription().getVersion() + " by Madgeek1450");
TFM_Util.deleteFolder(new File("./_deleteme")); TFM_Util.deleteFolder(new File("./_deleteme"));
if (generateFlatlands)
{
TFM_Util.generateFlatlands(flatlandsGenerationParams);
}
} }
@Override @Override
public void onDisable() public void onDisable()
{ {
Bukkit.getScheduler().cancelTasks(this); server.getScheduler().cancelTasks(this);
log.log(Level.INFO, "[" + getDescription().getName() + "] - Disabled."); log.log(Level.INFO, "[" + getDescription().getName() + "] - Disabled.");
} }
@ -144,6 +151,9 @@ public class TotalFreedomMod extends JavaPlugin
public static boolean mobLimiterDisableSlime = true; public static boolean mobLimiterDisableSlime = true;
public static boolean mobLimiterDisableGiant = true; public static boolean mobLimiterDisableGiant = true;
public static boolean tossmobEnabled = false; 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() public void loadMainConfig()
{ {
@ -174,7 +184,10 @@ public class TotalFreedomMod extends JavaPlugin
mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast); mobLimiterDisableGhast = config.getBoolean("mob_limiter_disable_ghast", mobLimiterDisableGhast);
mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime); mobLimiterDisableSlime = config.getBoolean("mob_limiter_disable_slime", mobLimiterDisableSlime);
mobLimiterDisableGiant = config.getBoolean("mob_limiter_disable_giant", mobLimiterDisableGiant); 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<String> superadmins = new ArrayList<String>(); public static List<String> superadmins = new ArrayList<String>();
@ -211,33 +224,8 @@ public class TotalFreedomMod extends JavaPlugin
private void registerEventHandlers() private void registerEventHandlers()
{ {
PluginManager pm = this.getServer().getPluginManager(); PluginManager pm = server.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);
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(entityListener, this);
pm.registerEvents(blockListener, this); pm.registerEvents(blockListener, this);
pm.registerEvents(playerListener, this); pm.registerEvents(playerListener, this);

View File

@ -43,11 +43,14 @@ commands:
flatlands: flatlands:
description: Goto the flatlands. description: Goto the flatlands.
usage: /<command> usage: /<command>
fluidspread:
description: Superadmin command - Enable/disable fluid spread.
usage: /<command> <on | off>
fr: fr:
description: Superadmin command - Freeze all players (toggles on and off). description: Superadmin command - Freeze players (toggles on and off).
usage: /<command> usage: /<command> [target | reset]
fuckoff: fuckoff:
description: Lawl description: You'll never even see it coming.
usage: /<command> usage: /<command>
gadmin: 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 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: lavaplace:
description: Superadmin command - Enable/disable lava placement. description: Superadmin command - Enable/disable lava placement.
usage: /<command> <on | off> usage: /<command> <on | off>
levelup: # levelup:
description: Level up! # description: Level up!
usage: /<command> # usage: /<command>
list: list:
description: Lists the real names of all online players. description: Lists the real names of all online players.
usage: /<command> usage: /<command>
@ -120,7 +123,7 @@ commands:
usage: /<command> usage: /<command>
saconfig: saconfig:
description: Owner command - Manage superadmins. description: Owner command - Manage superadmins.
usage: /<command> <add|delete> <username> usage: /<command> <list | <add|delete> <username>>
say: say:
description: Broadcasts the given message as the console, includes sender name. description: Broadcasts the given message as the console, includes sender name.
usage: /<command> <message> usage: /<command> <message>
@ -157,6 +160,9 @@ commands:
wildcard: wildcard:
description: Superadmin command - Run any command on all users, username placeholder = ?. description: Superadmin command - Run any command on all users, username placeholder = ?.
usage: /<command> [fluff] ? [fluff] ? usage: /<command> [fluff] ? [fluff] ?
# wipeflatlands:
# description: Console Command - Wipe the flatlands map.
# usage: /<command>
ziptool: ziptool:
description: Owner command - Zip and unzip files. description: Owner command - Zip and unzip files.
usage: /<command> <zip <directory>> | <unzip <file>> usage: /<command> <zip <directory>> | <unzip <file>>