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 * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import java.util.Random; import java.util.Random;
@ -26,6 +25,7 @@ import org.bukkit.generator.BlockPopulator;
public class CleanroomBlockPopulator extends BlockPopulator public class CleanroomBlockPopulator extends BlockPopulator
{ {
byte[] layerDataValues; byte[] layerDataValues;
protected CleanroomBlockPopulator(byte[] layerDataValues) protected CleanroomBlockPopulator(byte[] layerDataValues)
{ {
this.layerDataValues = layerDataValues; this.layerDataValues = layerDataValues;
@ -38,10 +38,13 @@ public class CleanroomBlockPopulator extends BlockPopulator
int x = chunk.getX() << 4; int x = chunk.getX() << 4;
int z = chunk.getZ() << 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]; byte dataValue = layerDataValues[y];
if (dataValue == 0) continue; if (dataValue == 0)
{
continue;
}
for (int xx = 0; xx < 16; xx++) for (int xx = 0; xx < 16; xx++)
{ {
for (int zz = 0; zz < 16; zz++) 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 * 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package me.StevenLawson.TotalFreedomMod; package me.StevenLawson.TotalFreedomMod;
import static java.lang.System.arraycopy; 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. 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 . 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) if (id.length() > 0)
{ {
String tokens[] = id.split("[,]"); 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) 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 // Lets try to read the data value
dataValue = Byte.parseByte(materialTokens[1]); dataValue = Byte.parseByte(materialTokens[1]);
} catch (Exception e) }
catch (Exception e)
{ {
log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0."); log.warning("[CleanroomGenerator] Invalid Data Value '" + materialTokens[1] + "'. Defaulting to 0.");
dataValue = 0; dataValue = 0;
@ -96,7 +100,8 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{ {
// Mabe it's an integer? // Mabe it's an integer?
mat = Material.getMaterial(Integer.parseInt(materialTokens[0])); mat = Material.getMaterial(Integer.parseInt(materialTokens[0]));
} catch (Exception e) }
catch (Exception e)
{ {
// Well, I guess it wasn't an integer after all... Awkward... // 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 (dataValue != 0)
{ {
if (layerDataValues == null) if (layerDataValues == null)
@ -153,21 +158,23 @@ public class CleanroomChunkGenerator extends ChunkGenerator
arraycopy(layerDataValues, 0, newLayerDataValues, 0, y); arraycopy(layerDataValues, 0, newLayerDataValues, 0, y);
layerDataValues = newLayerDataValues; layerDataValues = newLayerDataValues;
} }
} catch (Exception e) }
catch (Exception e)
{ {
log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString()); log.severe("[CleanroomGenerator] Error parsing CleanroomGenerator ID '" + id + "'. using defaults '64,1': " + e.toString());
e.printStackTrace(); e.printStackTrace();
layerDataValues = null; layerDataValues = null;
layer = new short[65]; layer = new short[65];
layer[0] = (short)Material.BEDROCK.getId(); layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId()); Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
} }
} else }
else
{ {
layerDataValues = null; layerDataValues = null;
layer = new short[65]; layer = new short[65];
layer[0] = (short)Material.BEDROCK.getId(); layer[0] = (short) Material.BEDROCK.getId();
Arrays.fill(layer, 1, 65, (short)Material.STONE.getId()); Arrays.fill(layer, 1, 65, (short) Material.STONE.getId());
} }
} }
@ -200,8 +207,9 @@ public class CleanroomChunkGenerator extends ChunkGenerator
{ {
if (layerDataValues != null) if (layerDataValues != null)
{ {
return Arrays.asList((BlockPopulator)new CleanroomBlockPopulator(layerDataValues)); return Arrays.asList((BlockPopulator) new CleanroomBlockPopulator(layerDataValues));
} else }
else
{ {
// This is the default, but just in case default populators change to stock minecraft populators by default... // This is the default, but just in case default populators change to stock minecraft populators by default...
return new ArrayList<BlockPopulator>(); return new ArrayList<BlockPopulator>();

View File

@ -10,10 +10,10 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shows (optionally smites) invisisible players", usage = "/<command> (smite)") @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 @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)
{ {
@ -35,7 +35,8 @@ public class Command_invis extends TFM_Command {
for (Player p : server.getOnlinePlayers()) for (Player p : server.getOnlinePlayers())
{ {
if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) { if (p.hasPotionEffect(PotionEffectType.INVISIBILITY))
{
players.add(p.getName()); players.add(p.getName());
if (smite && !TFM_SuperadminList.isUserSuperadmin(p)) 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"); TFM_Util.playerMsg(sender, "There are no invisible players");
return true; return true;
} }

View File

@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
@CommandParameters(description = "Shows the uptime of all minecraft services.", usage = "/<command>") @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 @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)
{ {
@ -21,5 +21,4 @@ public class Command_minecraft extends TFM_Command {
playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE); playerMsg("Version " + TFM_ServiceChecker.version + ", Last Checked: " + TFM_ServiceChecker.last_updated, ChatColor.BLUE);
return true; return true;
} }
} }

View File

@ -8,11 +8,10 @@ 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;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH, block_host_console = true) @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") @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 @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)
{ {
@ -48,7 +47,9 @@ public class Command_rollback extends TFM_Command {
if (!TFM_RollbackManager.canRollback(p.getName())) if (!TFM_RollbackManager.canRollback(p.getName()))
{ {
playerMsg("No rollback data found for that player", ChatColor.RED); playerMsg("No rollback data found for that player", ChatColor.RED);
} else { }
else
{
playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries."); playerMsg("Purged " + TFM_RollbackManager.purgeEntries(p.getName()) + " entries.");
return true; return true;
} }
@ -84,5 +85,4 @@ public class Command_rollback extends TFM_Command {
playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks"); playerMsg("Rolled back " + TFM_RollbackManager.rollback(p) + " blocks");
return true; return true;
} }
} }

View File

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

View File

@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH) @CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Temporarily bans a player for five minutes.", usage = "/<command> <partialname>", aliases = "nope") @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 @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)
{ {
@ -37,5 +37,4 @@ public class Command_tban extends TFM_Command {
return true; return true;
} }
} }

View File

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

View File

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

View File

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

View File

@ -14,23 +14,41 @@ import org.bukkit.ChatColor;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.JSONValue; 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[]>(); 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 check_url = "http://xpaw.ru/mcstatus/status.json";
public static String version = "1.0"; public static String version = "1.0";
public static String last_updated = ""; // On xpaw.ru public static String last_updated = ""; // On xpaw.ru
static static
{ {
// <"up", "down", "problem">, <"Online", "Quite Slow", "Error 505", etc>, <String (Uptime percentage)> // <"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("website", new String[]
SERVICE_MAP.put("session", new String[]{"up", "Online", "100.00"}); {
SERVICE_MAP.put("login", new String[]{"up", "Online", "100.00"}); "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("session", new String[]
SERVICE_MAP.put("realms", new String[]{"up", "Online", "100.00"}); {
"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() public static Runnable checker = new Runnable()
{ {
@Override @Override
@ -77,13 +95,15 @@ public class TFM_ServiceChecker {
last_updated = (String) service_json.get("last_updated"); last_updated = (String) service_json.get("last_updated");
JSONObject services = (JSONObject) service_json.get("report"); 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); 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("status"),
(String) service_info.get("title"), (String) service_info.get("title"),
(String) service_info.get("uptime")}); (String) service_info.get("uptime")
});
} }
} }
catch (Exception ex) catch (Exception ex)
@ -97,13 +117,13 @@ public class TFM_ServiceChecker {
public static String getFormattedStatus(String service_name) public static String getFormattedStatus(String service_name)
{ {
String[] service = SERVICE_MAP.get(service_name); String[] service = SERVICE_MAP.get(service_name);
String status = ("up".equals(service[0]) ? ChatColor.GREEN : String status = ("up".equals(service[0]) ? ChatColor.GREEN
("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString(); : ("down".equals(service[0]) ? ChatColor.RED : ChatColor.GOLD)).toString();
status += service[1] + ChatColor.GRAY + " ("; status += service[1] + ChatColor.GRAY + " (";
status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN : status += (Float.parseFloat(service[2]) >= 96.0 ? ChatColor.GREEN
(Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED)); : (Float.parseFloat(service[2]) > 90.0 ? ChatColor.GOLD : ChatColor.RED));
status += service[2] + "%" + ChatColor.GRAY + ")"; status += service[2] + "%" + ChatColor.GRAY + ")";
@ -119,23 +139,22 @@ public class TFM_ServiceChecker {
} }
return statuses; return statuses;
} }
} }
/* // Mojang status /* // 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 static
{ {
SERVICE_MAP.put("minecraft.net", "Minecraft.net"); SERVICE_MAP.put("minecraft.net", "Minecraft.net");
SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins"); SERVICE_MAP.put("login.minecraft.net", "Minecraft Logins");
SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions"); SERVICE_MAP.put("session.minecraft.net", "Minecraft Multiplayer Sessions");
SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website"); SERVICE_MAP.put("account.mojang.com", "Mojang Accounts Website");
SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login"); SERVICE_MAP.put("auth.mojang.com", "Mojang Accounts Login");
SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins"); SERVICE_MAP.put("skins.minecraft.net", "Minecraft Skins");
} }
server.getScheduler().runTaskAsynchronously(plugin, new Runnable() server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
{ {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public void run() public void run()
@ -185,5 +204,5 @@ server.getScheduler().runTaskAsynchronously(plugin, new Runnable()
TFM_Log.severe(ex); TFM_Log.severe(ex);
} }
} }
}); });
*/ */

View File

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