Batch formatting fix.

This commit is contained in:
Steven Lawson 2013-07-02 14:31:22 -04:00
parent 44fb26b27f
commit ba22aedc58
20 changed files with 178 additions and 150 deletions

View File

@ -15,7 +15,6 @@
* 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.Random;
@ -26,6 +25,7 @@ import org.bukkit.generator.BlockPopulator;
public class CleanroomBlockPopulator extends BlockPopulator
{
byte[] layerDataValues;
protected CleanroomBlockPopulator(byte[] layerDataValues)
{
this.layerDataValues = layerDataValues;
@ -38,10 +38,13 @@ public class CleanroomBlockPopulator extends BlockPopulator
int x = chunk.getX() << 4;
int z = chunk.getZ() << 4;
for (int y = 0; y < layerDataValues.length ; y++)
for (int y = 0; y < layerDataValues.length; y++)
{
byte dataValue = layerDataValues[y];
if (dataValue == 0) continue;
if (dataValue == 0)
{
continue;
}
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)

View File

@ -15,7 +15,6 @@
* 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 static java.lang.System.arraycopy;
@ -55,16 +54,20 @@ public class CleanroomChunkGenerator extends ChunkGenerator
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.
}
else // Guess not, bedrock at layer0 it is then.
{
layer[y++] = (short)Material.BEDROCK.getId();
layer[y++] = (short) Material.BEDROCK.getId();
}
if (id.length() > 0)
{
String tokens[] = id.split("[,]");
if ((tokens.length % 2) != 0) throw new Exception();
if ((tokens.length % 2) != 0)
{
throw new Exception();
}
for (int i = 0; i < tokens.length; i += 2)
{
@ -83,7 +86,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
// Lets try to read the data value
dataValue = Byte.parseByte(materialTokens[1]);
} catch (Exception e)
}
catch (Exception e)
{
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
dataValue = 0;
@ -96,7 +100,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
// Mabe it's an integer?
mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
} catch (Exception e)
}
catch (Exception e)
{
// Well, I guess it wasn't an integer after all... Awkward...
}
@ -127,7 +132,7 @@ public class CleanroomChunkGenerator extends ChunkGenerator
}
}
Arrays.fill(layer, y, y + height, (short)mat.getId());
Arrays.fill(layer, y, y + height, (short) mat.getId());
if (dataValue != 0)
{
if (layerDataValues == null)
@ -153,21 +158,23 @@ public class CleanroomChunkGenerator extends ChunkGenerator
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
layerDataValues = newLayerDataValues;
}
} catch (Exception e)
}
catch (Exception e)
{
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
e.printStackTrace();
layerDataValues = null;
layer = new short[65];
layer[0] = (short)Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
}
} else
}
else
{
layerDataValues = null;
layer = new short[65];
layer[0] = (short)Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId());
layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
}
}
@ -200,8 +207,9 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{
if (layerDataValues != null)
{
return Arrays.asList((BlockPopulator)new CleanroomBlockPopulator(layerDataValues));
} else
return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues));
}
else
{
// This is the default, but just in case default populators change to stock minecraft populators by default...
return new ArrayList<BlockPopulator>();

View File

@ -33,11 +33,11 @@ public class Command_creative extends TFM_Command
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (!TFM_SuperadminList.isUserSuperadmin(sender))
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player player : server.getOnlinePlayers())
{
@ -63,7 +63,7 @@ public class Command_creative extends TFM_Command
sender.sendMessage(ex.getMessage());
return true;
}
}
playerMsg("Setting " + p.getName() + " to game mode 'Creative'.");

View File

@ -34,17 +34,17 @@ public class Command_gtfo extends TFM_Command
TFM_Util.bcastMsg(p.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
// Op Player
p.setOp(true);
//Undo WorldEdits:
server.dispatchCommand(p, "/undo 15");
//rollback
server.dispatchCommand(sender, "rollback " + p.getName());
// deop
p.setOp(false);

View File

@ -10,10 +10,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)")
public class Command_invis extends TFM_Command {
public class Command_invis extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -35,7 +35,8 @@ public class Command_invis extends TFM_Command {
for (Player p : server.getOnlinePlayers())
{
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(p.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(p))
{
@ -45,7 +46,8 @@ public class Command_invis extends TFM_Command {
}
}
if (players.isEmpty()) {
if (players.isEmpty())
{
TFM_Util.playerMsg(sender, "There are no invisible players");
return true;
}

View File

@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/<command>")
public class Command_minecraft extends TFM_Command {
public class Command_minecraft extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -21,5 +21,4 @@ public class Command_minecraft extends TFM_Command {
playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE);
return true;
}
}

View File

@ -19,7 +19,7 @@ public class Command_purgeall extends TFM_Command
server.dispatchCommand(sender, "mp");
server.dispatchCommand(sender, "blockcmd purge");
server.dispatchCommand(sender, "halt purge");
//If I'm missing any, lemme know. Or just add it yourself.
return true;

View File

@ -8,11 +8,10 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true)
@CommandParameters(description = "Issues a rollback on a player", usage = "/<command> <[partialname] | purge [partialname] | purgeall>", aliases = "rb")
public class Command_rollback extends TFM_Command {
public class Command_rollback extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -48,7 +47,9 @@ public class Command_rollback extends TFM_Command {
if (!TFM_RollbackManager.canRollback(p.getName()))
{
playerMsg("No rollback data found for that player", ChatColor.RED);
} else {
}
else
{
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries.");
return true;
}
@ -84,5 +85,4 @@ public class Command_rollback extends TFM_Command {
playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks");
return true;
}
}

View File

@ -149,12 +149,12 @@ public class Command_saconfig extends TFM_Command
TFM_Util.adminAction(sender.getName(), "Removing " + target_name + " from the superadmin list", true);
TFM_SuperadminList.removeSuperadmin(target_name);
if (!TotalFreedomMod.twitterbotEnabled)
{
return true;
}
// Twitterbot
TFM_TwitterHandler twitterbot = TFM_TwitterHandler.getInstance(plugin);
String reply = twitterbot.delTwitter(target_name);

View File

@ -13,7 +13,7 @@ public class Command_setl extends TFM_Command
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
server.dispatchCommand(sender, "wildcard gcmd ? /limit 500");
TFM_Util.adminAction(sender.getName(), "Setting all online players block limit to 500.", true);
TFM_Util.adminAction(sender.getName(), "Setting all online players block limit to 500.", true);
return true;
}

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
@CommandParameters(description = "Show misc. server info.", usage = "/<command>")
public class Command_status extends TFM_Command
{
@Override
public boolean run(final CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{

View File

@ -27,7 +27,7 @@ public class Command_survival extends TFM_Command
}
Player p;
if (args.length == 0)
{
p = sender_p;
@ -36,11 +36,11 @@ public class Command_survival extends TFM_Command
{
if (args[0].equalsIgnoreCase("-a"))
{
if (!TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
if (!TFM_SuperadminList.isUserSuperadmin(sender) || senderIsConsole)
{
sender.sendMessage(TotalFreedomMod.MSG_NO_PERMS);
return true;
}
for (Player player : server.getOnlinePlayers())
{

View File

@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope")
public class Command_tban extends TFM_Command {
public class Command_tban extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
@ -37,5 +37,4 @@ public class Command_tban extends TFM_Command {
return true;
}
}

View File

@ -260,7 +260,6 @@ public class TFM_BlockListener implements Listener
{
TFM_RollbackManager.blockUpdate(event.getPlayer(), event.getBlock());
}
// @EventHandler(priority = EventPriority.NORMAL)
// public void onCommandBlockChangeEvent(CommandBlockChangeEvent event)
// {

View File

@ -72,7 +72,7 @@ public class TFM_PlayerListener implements Listener
event.setCancelled(true);
}
}
}
break;
}
@ -748,13 +748,13 @@ public class TFM_PlayerListener implements Listener
{
TFM_ServerInterface.handlePlayerLogin(event);
}
@EventHandler()
public void onServerPing(ServerListPingEvent event)
{
// Colorize :)
event.setMotd(ChatColor.translateAlternateColorCodes('&', event.getMotd()));
if (TFM_ServerInterface.isIPBanned(event.getAddress().getHostAddress()))
{
event.setMotd(ChatColor.RED + "You are banned!");

View File

@ -4,10 +4,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class TFM_RollbackEntry
{
private Location location;
private Material material;
private byte data;

View File

@ -13,7 +13,7 @@ public class TFM_RollbackManager
public static void blockUpdate(OfflinePlayer player, Block block)
{
List <TFM_RollbackEntry> e;
List<TFM_RollbackEntry> e;
if (entries.containsKey(player.getName()))
{
e = entries.get(player.getName());
@ -28,7 +28,7 @@ public class TFM_RollbackManager
public static void blockUpdate(OfflinePlayer player, TFM_RollbackEntry entry)
{
List <TFM_RollbackEntry> e;
List<TFM_RollbackEntry> e;
if (entries.containsKey(player.getName()))
{
e = entries.get(player.getName());
@ -83,4 +83,4 @@ public class TFM_RollbackManager
entries.remove(player);
return counter;
}
}
}

View File

@ -276,20 +276,20 @@ public class TFM_ServerInterface
}
}
else // if user is superadmin
{
{
// force-allow superadmins to log in
event.allow();
if (isIPBanned(player_ip))
{
unbanIP(player_ip);
}
if (isNameBanned(player_name))
{
unbanUsername(player_name);
}
for (Player test_player : server.getOnlinePlayers())
{
if (test_player.getName().equalsIgnoreCase(player_name))
@ -297,7 +297,7 @@ public class TFM_ServerInterface
test_player.kickPlayer("An admin just logged in with the username you are using.");
}
}
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
{
for (Player op : server.getOnlinePlayers())
@ -308,7 +308,7 @@ public class TFM_ServerInterface
return;
}
}
// if the server is full of superadmins, however unlikely that might be, this will prevent an infinite loop.
if (server.getOnlinePlayers().length >= server.getMaxPlayers())
{

View File

@ -14,23 +14,41 @@ import org.bukkit.ChatColor;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
public class TFM_ServiceChecker {
public class TFM_ServiceChecker
{
private static final Map<String, String[]> SERVICE_MAP = new HashMap<String, String[]>();
public static String check_url = "http://xpaw.ru/mcstatus/status.json";
public static String version = "1.0";
public static String last_updated = ""; // On xpaw.ru
static
{
// <"up", "down", "problem">, <"Online", "Quite Slow", "Error 505", etc>, <String (Uptime percentage)>
SERVICE_MAP.put("website", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("session", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("login", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("account", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("skins", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("realms", new String[]{"up", "Online", "100.00"});
SERVICE_MAP.put("website", new String[]
{
"up", "Online", "100.00"
});
SERVICE_MAP.put("session", new String[]
{
"up", "Online", "100.00"
});
SERVICE_MAP.put("login", new String[]
{
"up", "Online", "100.00"
});
SERVICE_MAP.put("account", new String[]
{
"up", "Online", "100.00"
});
SERVICE_MAP.put("skins", new String[]
{
"up", "Online", "100.00"
});
SERVICE_MAP.put("realms", new String[]
{
"up", "Online", "100.00"
});
}
public static Runnable checker = new Runnable()
{
@Override
@ -51,10 +69,10 @@ public class TFM_ServiceChecker {
{
/* // Nubcakes be 403'ing us >;o
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(check_url).openStream()));
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
in.close();
*/
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(check_url).openStream()));
JSONObject service_json = (JSONObject) JSONValue.parse(in.readLine());
in.close();
*/
// Well, lets bypass that! >:D
HttpURLConnection connection = (HttpURLConnection) new URL(check_url).openConnection();
@ -77,13 +95,15 @@ public class TFM_ServiceChecker {
last_updated = (String) service_json.get("last_updated");
JSONObject services = (JSONObject) service_json.get("report");
for (String service: SERVICE_MAP.keySet())
for (String service : SERVICE_MAP.keySet())
{
JSONObject service_info = (JSONObject) services.get(service);
SERVICE_MAP.put(service, new String[]{
SERVICE_MAP.put(service, new String[]
{
(String) service_info.get("status"),
(String) service_info.get("title"),
(String) service_info.get("uptime")});
(String) service_info.get("uptime")
});
}
}
catch (Exception ex)
@ -97,13 +117,13 @@ public class TFM_ServiceChecker {
public static String getFormattedStatus(String service_name)
{
String[] service = SERVICE_MAP.get(service_name);
String status = ("up".equals(service[0]) ? ChatColor.GREEN :
("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString();
String status = ("up".equals(service[0]) ? ChatColor.GREEN
: ("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString();
status += service[1] + ChatColor.GRAY + " (";
status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN :
(Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED));
status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN
: (Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED));
status += service[2] + "%" + ChatColor.GRAY + ")";
@ -119,71 +139,70 @@ public class TFM_ServiceChecker {
}
return statuses;
}
}
/* // Mojang status
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
public static final Map<String, String> SERVICE_MAP = new HashMap<String, String>();
static
{
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
}
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
{
@SuppressWarnings("unchecked")
@Override
public void run()
{
try
{
URL mojang_status = new URL("http://status.mojang.com/check");
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
in.close();
static
{
SERVICE_MAP.put("minecraft.net", "Minecraft.net");
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
}
server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
{
@SuppressWarnings("unchecked")
@Override
public void run()
{
try
{
URL mojang_status = new URL("http://status.mojang.com/check");
BufferedReader in = new BufferedReader(new InputStreamReader(mojang_status.openStream()));
JSONArray status_json = (JSONArray) JSONValue.parse(in.readLine());
in.close();
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
Map<String, Boolean> service_status = new HashMap<String, Boolean>();
Iterator status_it = status_json.iterator();
while (status_it.hasNext())
{
JSONObject service = (JSONObject) status_it.next();
Iterator service_it = service.entrySet().iterator();
while (service_it.hasNext())
{
Entry<String, String> pair = (Entry<String, String>) service_it.next();
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
}
}
Iterator status_it = status_json.iterator();
while (status_it.hasNext())
{
JSONObject service = (JSONObject) status_it.next();
Iterator service_it = service.entrySet().iterator();
while (service_it.hasNext())
{
Entry<String, String> pair = (Entry<String, String>) service_it.next();
service_status.put(pair.getKey(), (pair.getValue().equals("green") ? Boolean.TRUE : Boolean.FALSE));
}
}
List<String> status_output = new ArrayList<String>();
List<String> status_output = new ArrayList<String>();
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
while (output_it.hasNext())
{
Entry<String, Boolean> pair = output_it.next();
String service_name = pair.getKey();
boolean service_online = pair.getValue().booleanValue();
Iterator<Entry<String, Boolean>> output_it = service_status.entrySet().iterator();
while (output_it.hasNext())
{
Entry<String, Boolean> pair = output_it.next();
String service_name = pair.getKey();
boolean service_online = pair.getValue().booleanValue();
if (SERVICE_MAP.containsKey(service_name))
{
service_name = SERVICE_MAP.get(service_name);
}
if (SERVICE_MAP.containsKey(service_name))
{
service_name = SERVICE_MAP.get(service_name);
}
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
}
status_output.add(String.format("%s is %s", service_name, (service_online ? ChatColor.GREEN + "ONLINE" + ChatColor.GRAY : ChatColor.RED + "OFFLINE" + ChatColor.GRAY)));
}
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
});
playerMsg(String.format("Mojang Service Status: %s.", StringUtils.join(status_output, ", ")), ChatColor.GRAY);
}
catch (Exception ex)
{
TFM_Log.severe(ex);
}
}
});
*/

View File

@ -974,19 +974,21 @@ public class TFM_Util
}
}
}
public static String getPrefix(CommandSender sender, boolean senderIsConsole)
{
String prefix;
if (senderIsConsole) {
prefix = ChatColor.BLUE + "(Console)";
if (senderIsConsole)
{
prefix = ChatColor.BLUE + "(Console)";
}
else
{
if (TFM_SuperadminList.isSeniorAdmin(sender))
{
prefix = ChatColor.LIGHT_PURPLE + "(SrA)";
} else
}
else
{
prefix = ChatColor.GOLD + "(SA)";
}