From 7c345d4d8273fe2e6722394a716e10d9a65e1275 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Sat, 14 Jan 2012 23:02:10 +0100 Subject: [PATCH] Fix formatting. By: Erik Broes --- .../org/bukkit/craftbukkit/CraftChunk.java | 14 +- .../craftbukkit/CraftChunkSnapshot.java | 83 +---------- .../craftbukkit/CraftOfflinePlayer.java | 18 +-- .../org/bukkit/craftbukkit/CraftServer.java | 24 ++-- .../org/bukkit/craftbukkit/CraftWorld.java | 68 ++++----- .../craftbukkit/LoggerOutputStream.java | 1 - .../java/org/bukkit/craftbukkit/Main.java | 4 +- .../bukkit/craftbukkit/PortalTravelAgent.java | 4 - .../java/org/bukkit/craftbukkit/TrigMath.java | 2 +- .../bukkit/craftbukkit/block/CraftBlock.java | 90 ++++++------ .../craftbukkit/block/CraftBlockState.java | 60 -------- .../craftbukkit/block/CraftJukebox.java | 2 +- .../command/ServerCommandListener.java | 2 +- .../enchantments/CraftEnchantment.java | 132 +++++++++--------- .../bukkit/craftbukkit/entity/CraftArrow.java | 2 +- .../craftbukkit/entity/CraftEntity.java | 4 +- .../entity/CraftExperienceOrb.java | 1 - .../craftbukkit/entity/CraftHumanEntity.java | 1 - .../craftbukkit/entity/CraftLivingEntity.java | 8 +- .../craftbukkit/entity/CraftMagmaCube.java | 1 - .../craftbukkit/entity/CraftPainting.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 10 +- .../craftbukkit/entity/CraftProjectile.java | 4 +- .../craftbukkit/entity/CraftWeather.java | 1 - .../bukkit/craftbukkit/entity/CraftWolf.java | 6 +- .../craftbukkit/event/CraftEventFactory.java | 19 +-- .../generator/InternalChunkGenerator.java | 1 - .../craftbukkit/inventory/CraftInventory.java | 8 +- .../craftbukkit/inventory/CraftItemStack.java | 10 +- .../craftbukkit/map/CraftMapCanvas.java | 23 +-- .../craftbukkit/map/CraftMapRenderer.java | 8 +- .../bukkit/craftbukkit/map/CraftMapView.java | 28 ++-- .../bukkit/craftbukkit/map/RenderData.java | 6 +- .../bukkit/craftbukkit/util/EntryBase.java | 3 +- .../craftbukkit/util/LongBaseHashtable.java | 8 +- .../bukkit/craftbukkit/util/LongHashset.java | 10 +- .../craftbukkit/util/LongHashtable.java | 3 +- .../util/ServerShutdownThread.java | 1 - .../bukkit/craftbukkit/util/Versioning.java | 8 +- 39 files changed, 266 insertions(+), 414 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index c7aed33045..3ec77b3e9c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunk.java @@ -23,7 +23,7 @@ public class CraftChunk implements Chunk { private int z; public CraftChunk(net.minecraft.server.Chunk chunk) { - if(!(chunk instanceof EmptyChunk)) { + if (!(chunk instanceof EmptyChunk)) { this.weakChunk = new WeakReference(chunk); } worldServer = (WorldServer) getHandle().world; @@ -39,7 +39,7 @@ public class CraftChunk implements Chunk { net.minecraft.server.Chunk c = weakChunk.get(); if (c == null) { c = worldServer.getChunkAt(x, z); - if(!(c instanceof EmptyChunk)) { + if (!(c instanceof EmptyChunk)) { weakChunk = new WeakReference(c); } } @@ -76,7 +76,7 @@ public class CraftChunk implements Chunk { Entity[] entities = new Entity[count]; for (int i = 0; i < 8; i++) { - for (Object obj: chunk.entitySlices[i].toArray()) { + for (Object obj : chunk.entitySlices[i].toArray()) { if (!(obj instanceof net.minecraft.server.Entity)) { continue; } @@ -155,10 +155,10 @@ public class CraftChunk implements Chunk { biomeTemp = new double[256]; biomeRain = new double[256]; float[] dat = wcm.getTemperatures((float[]) null, getX() << 4, getZ() << 4, 16, 16); - for(int i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) biomeTemp[i] = dat[i]; dat = wcm.getWetness((float[]) null, getX() << 4, getZ() << 4, 16, 16); - for(int i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) biomeRain[i] = dat[i]; } } @@ -212,10 +212,10 @@ public class CraftChunk implements Chunk { biomeTemp = new double[256]; biomeRain = new double[256]; float[] dat = wcm.getTemperatures((float[]) null, x << 4, z << 4, 16, 16); - for(int i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) biomeTemp[i] = dat[i]; dat = wcm.getWetness((float[]) null, x << 4, z << 4, 16, 16); - for(int i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) biomeRain[i] = dat[i]; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java index 2b14f37ed3..6d0e8b1c88 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftChunkSnapshot.java @@ -5,6 +5,7 @@ import org.bukkit.block.Biome; import org.bukkit.craftbukkit.block.CraftBlock; import net.minecraft.server.BiomeBase; + /** * Represents a static, thread-safe snapshot of chunk of blocks * Purpose is to allow clean, efficient copy of a chunk data to be made, and then handed off for processing in another thread (e.g. map rendering) @@ -23,9 +24,6 @@ public class CraftChunkSnapshot implements ChunkSnapshot { private static final int BLOCKLIGHT_OFF = BLOCKDATA_OFF + 16384; private static final int SKYLIGHT_OFF = BLOCKLIGHT_OFF + 16384; - /** - * Constructor - */ CraftChunkSnapshot(int x, int z, String wname, long wtime, byte[] buf, byte[] hmap, BiomeBase[] biome, double[] biomeTemp, double[] biomeRain) { this.x = x; this.z = z; @@ -38,135 +36,56 @@ public class CraftChunkSnapshot implements ChunkSnapshot { this.biomeRain = biomeRain; } - /** - * Gets the X-coordinate of this chunk - * - * @return X-coordinate - */ public int getX() { return x; } - /** - * Gets the Z-coordinate of this chunk - * - * @return Z-coordinate - */ public int getZ() { return z; } - /** - * Gets name of the world containing this chunk - * - * @return Parent World Name - */ public String getWorldName() { return worldname; } - /** - * Get block type for block at corresponding coordinate in the chunk - * - * @param x 0-15 - * @param y 0-127 - * @param z 0-15 - * @return 0-255 - */ public int getBlockTypeId(int x, int y, int z) { return buf[x << 11 | z << 7 | y] & 255; } - /** - * Get block data for block at corresponding coordinate in the chunk - * - * @param x 0-15 - * @param y 0-127 - * @param z 0-15 - * @return 0-15 - */ public int getBlockData(int x, int y, int z) { int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKDATA_OFF; return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); } - /** - * Get sky light level for block at corresponding coordinate in the chunk - * - * @param x 0-15 - * @param y 0-127 - * @param z 0-15 - * @return 0-15 - */ public int getBlockSkyLight(int x, int y, int z) { int off = ((x << 10) | (z << 6) | (y >> 1)) + SKYLIGHT_OFF; return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); } - /** - * Get light level emitted by block at corresponding coordinate in the chunk - * - * @param x 0-15 - * @param y 0-127 - * @param z 0-15 - * @return 0-15 - */ public int getBlockEmittedLight(int x, int y, int z) { int off = ((x << 10) | (z << 6) | (y >> 1)) + BLOCKLIGHT_OFF; return ((y & 1) == 0) ? (buf[off] & 0xF) : ((buf[off] >> 4) & 0xF); } - /** - * Gets the highest non-air coordinate at the given coordinates - * - * @param x X-coordinate of the blocks - * @param z Z-coordinate of the blocks - * @return Y-coordinate of the highest non-air block - */ public int getHighestBlockYAt(int x, int z) { return hmap[z << 4 | x] & 255; } - /** - * Get biome at given coordinates - * - * @param x X-coordinate - * @param z Z-coordinate - * @return Biome at given coordinate - */ public Biome getBiome(int x, int z) { return CraftBlock.biomeBaseToBiome(biome[z << 4 | x]); } - /** - * Get raw biome temperature (0.0-1.0) at given coordinate - * - * @param x X-coordinate - * @param z Z-coordinate - * @return temperature at given coordinate - */ public double getRawBiomeTemperature(int x, int z) { return biomeTemp[z << 4 | x]; } - /** - * Get raw biome rainfall (0.0-1.0) at given coordinate - * - * @param x X-coordinate - * @param z Z-coordinate - * @return rainfall at given coordinate - */ public double getRawBiomeRainfall(int x, int z) { return biomeRain[z << 4 | x]; } - /** - * Get world full time when chunk snapshot was captured - * @return time in ticks - */ public long getCaptureFullTime() { return captureFulltime; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java index 4f8fd21d95..9534c587e5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java @@ -22,7 +22,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa protected CraftOfflinePlayer(CraftServer server, String name) { this.server = server; this.name = name; - this.storage = (WorldNBTStorage)(server.console.worlds.get(0).getDataManager()); + this.storage = (WorldNBTStorage) (server.console.worlds.get(0).getDataManager()); } public boolean isOnline() { @@ -77,14 +77,14 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa public Map serialize() { Map result = new LinkedHashMap(); - + result.put("name", name); - + return result; } - + public static OfflinePlayer deserialize(Map args) { - return Bukkit.getServer().getOfflinePlayer((String)args.get("name")); + return Bukkit.getServer().getOfflinePlayer((String) args.get("name")); } @Override @@ -93,13 +93,13 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa } public Player getPlayer() { - for (Object obj: server.getHandle().players) { - EntityPlayer player = (EntityPlayer)obj; + for (Object obj : server.getHandle().players) { + EntityPlayer player = (EntityPlayer) obj; if (player.name.equalsIgnoreCase(getName())) { return (player.netServerHandler != null) ? player.netServerHandler.getPlayer() : null; } } - + return null; } @@ -111,7 +111,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa if (!(obj instanceof OfflinePlayer)) { return false; } - OfflinePlayer other = (OfflinePlayer)obj; + OfflinePlayer other = (OfflinePlayer) obj; if ((this.getName() == null) || (other.getName() == null)) { return false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java index f4bf8afd55..c7462d2a34 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -135,7 +135,7 @@ public final class CraftServer implements Server { } private File getConfigFile() { - return (File)console.options.valueOf("bukkit-settings"); + return (File) console.options.valueOf("bukkit-settings"); } private void saveConfig() { @@ -372,7 +372,6 @@ public final class CraftServer implements Server { return server; } - // NOTE: Should only be called from MinecraftServer.b() public boolean dispatchCommand(CommandSender sender, ServerCommand serverCommand) { return dispatchCommand(sender, serverCommand.command); @@ -457,7 +456,7 @@ public final class CraftServer implements Server { Map> perms; try { - perms = (Map>)yaml.load(stream); + perms = (Map>) yaml.load(stream); } catch (MarkedYAMLException ex) { getLogger().log(Level.WARNING, "Server permissions file " + file + " is not valid YAML: " + ex.toString()); return; @@ -557,7 +556,7 @@ public final class CraftServer implements Server { } pluginManager.callEvent(new WorldInitEvent(internal.getWorld())); - System.out.print("Preparing start region for level " + (console.worlds.size() -1) + " (Seed: " + internal.getSeed() + ")"); + System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Seed: " + internal.getSeed() + ")"); if (internal.getWorld().getKeepSpawnInMemory()) { short short1 = 196; @@ -811,7 +810,7 @@ public final class CraftServer implements Server { for (Permissible permissible : permissibles) { if (permissible instanceof CommandSender) { - CommandSender user = (CommandSender)permissible; + CommandSender user = (CommandSender) permissible; user.sendMessage(message); count++; } @@ -854,7 +853,7 @@ public final class CraftServer implements Server { Set result = new HashSet(); for (Object name : server.banByName) { - result.add(getOfflinePlayer((String)name)); + result.add(getOfflinePlayer((String) name)); } return result; @@ -869,7 +868,7 @@ public final class CraftServer implements Server { Set result = new HashSet(); for (Object name : server.getWhitelisted()) { - result.add(getOfflinePlayer((String)name)); + result.add(getOfflinePlayer((String) name)); } return result; @@ -879,7 +878,7 @@ public final class CraftServer implements Server { Set result = new HashSet(); for (Object name : server.operators) { - result.add(getOfflinePlayer((String)name)); + result.add(getOfflinePlayer((String) name)); } return result; @@ -899,7 +898,7 @@ public final class CraftServer implements Server { } for (World world : getWorlds()) { - ((CraftWorld)world).getHandle().worldData.setGameType(mode.getValue()); + ((CraftWorld) world).getHandle().worldData.setGameType(mode.getValue()); } } @@ -910,16 +909,15 @@ public final class CraftServer implements Server { public void detectListNameConflict(EntityPlayer entityPlayer) { // Collisions will make for invisible people for (int i = 0; i < getHandle().players.size(); ++i) { - EntityPlayer testEntityPlayer = (EntityPlayer)getHandle().players.get(i); + EntityPlayer testEntityPlayer = (EntityPlayer) getHandle().players.get(i); // We have a problem! if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) { String oldName = entityPlayer.listName; int spaceLeft = 16 - oldName.length(); - if (spaceLeft <= 1) { // We also hit the list name length limit! - entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft) - + String.valueOf(System.currentTimeMillis() % 99); + if (spaceLeft <= 1) { // We also hit the list name length limit! + entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft) + String.valueOf(System.currentTimeMillis() % 99); } else { entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index e346fba1dc..b54870b60b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -46,7 +46,7 @@ import org.bukkit.plugin.messaging.StandardMessenger; public class CraftWorld implements World { private final WorldServer world; private Environment environment; - private final CraftServer server = (CraftServer)Bukkit.getServer(); + private final CraftServer server = (CraftServer) Bukkit.getServer(); private ConcurrentMap unloadedChunks = new MapMaker().weakValues().makeMap(); private final ChunkGenerator generator; private final List populators = new ArrayList(); @@ -78,7 +78,7 @@ public class CraftWorld implements World { } public int getHighestBlockYAt(int x, int z) { - if (!isChunkLoaded(x >> 4, z >> 4)){ + if (!isChunkLoaded(x >> 4, z >> 4)) { loadChunk(x >> 4, z >> 4); } @@ -221,7 +221,6 @@ public class CraftWorld implements World { return true; } - public boolean isChunkInUse(int x, int z) { Player[] players = server.getOnlinePlayers(); @@ -334,7 +333,7 @@ public class CraftWorld implements World { return null; } - return (LivingEntity)result; + return (LivingEntity) result; } public LightningStrike strikeLightning(Location loc) { @@ -355,17 +354,17 @@ public class CraftWorld implements World { public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { switch (type) { - case BIG_TREE: - return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); - case BIRCH: - return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); - case REDWOOD: - return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); - case TALL_REDWOOD: - return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - case TREE: - default: - return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); + case BIG_TREE: + return new WorldGenBigTree(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); + case BIRCH: + return new WorldGenForest(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); + case REDWOOD: + return new WorldGenTaiga2(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); + case TALL_REDWOOD: + return new WorldGenTaiga1().generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + case TREE: + default: + return new WorldGenTrees(false).generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), null, null, null); } } @@ -411,7 +410,7 @@ public class CraftWorld implements World { world.setTime(time); // Forces the client to update to the new time immediately - for (Player p: getPlayers()) { + for (Player p : getPlayers()) { CraftPlayer cp = (CraftPlayer) p; cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime())); } @@ -493,7 +492,7 @@ public class CraftWorld implements World { public List getEntities() { List list = new ArrayList(); - for (Object o: world.entityList) { + for (Object o : world.entityList) { if (o instanceof net.minecraft.server.Entity) { net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); @@ -511,7 +510,7 @@ public class CraftWorld implements World { public List getLivingEntities() { List list = new ArrayList(); - for (Object o: world.entityList) { + for (Object o : world.entityList) { if (o instanceof net.minecraft.server.Entity) { net.minecraft.server.Entity mcEnt = (net.minecraft.server.Entity) o; Entity bukkitEntity = mcEnt.getBukkitEntity(); @@ -790,20 +789,21 @@ public class CraftWorld implements World { face = BlockFace.SOUTH; } int dir; - switch(face) { - case EAST: - default: - dir = 0; - break; - case NORTH: - dir = 1; - break; - case WEST: - dir = 2; - break; - case SOUTH: - dir = 3;; - break; + switch (face) { + case EAST: + default: + dir = 0; + break; + case NORTH: + dir = 1; + break; + case WEST: + dir = 2; + break; + case SOUTH: + dir = 3; + ; + break; } entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir); if (!((EntityPainting) entity).survives()) { @@ -866,7 +866,7 @@ public class CraftWorld implements World { ChunkCoordinates chunkcoordinates = this.world.getSpawn(); int chunkCoordX = chunkcoordinates.x >> 4; int chunkCoordZ = chunkcoordinates.z >> 4; - // Cycle through the 25x25 Chunks around it to load/unload the chunks. + // Cycle through the 25x25 Chunks around it to load/unload the chunks. for (int x = -12; x <= 12; x++) { for (int z = -12; z <= 12; z++) { if (keepLoaded) { @@ -904,7 +904,7 @@ public class CraftWorld implements World { } public File getWorldFolder() { - return ((WorldNBTStorage)world.getDataManager()).getDirectory(); + return ((WorldNBTStorage) world.getDataManager()).getDirectory(); } public void explodeBlock(Block block, float yield) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java b/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java index d2637ad8e1..baa71416ec 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/LoggerOutputStream.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit; import java.io.ByteArrayOutputStream; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java index 4c3bb0c3a4..c5bfa3a299 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/Main.java @@ -94,7 +94,7 @@ public class Main { .describedAs("Yml file"); acceptsAll(asList("nojline"), "Disables jline and emulates the vanilla console"); - + acceptsAll(asList("noconsole"), "Disables the console"); acceptsAll(asList("v", "version"), "Show the CraftBukkit Version"); @@ -126,7 +126,7 @@ public class Main { System.setProperty("user.language", "en"); useJline = false; } - + if (options.has("noconsole")) { useConsole = false; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java b/paper-server/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java index cd91400b4f..0e3fbda805 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/PortalTravelAgent.java @@ -137,7 +137,6 @@ public class PortalTravelAgent implements TravelAgent { public boolean createPortal(Location location) { net.minecraft.server.World world = ((CraftWorld) location.getWorld()).getHandle(); - if (location.getWorld().getEnvironment() == Environment.THE_END) { int i = MathHelper.floor(location.getBlockX()); int j = MathHelper.floor(location.getBlockY()) - 1; @@ -401,9 +400,6 @@ public class PortalTravelAgent implements TravelAgent { return true; } - - - public TravelAgent setSearchRadius(int radius) { this.searchRadius = radius; return this; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/TrigMath.java b/paper-server/src/main/java/org/bukkit/craftbukkit/TrigMath.java index 8e7147a2bd..6d613c53c6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/TrigMath.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/TrigMath.java @@ -1,8 +1,8 @@ package org.bukkit.craftbukkit; + /** * Credits for this class goes to user aioobe on stackoverflow.com * Source: http://stackoverflow.com/questions/4454630/j2me-calculate-the-the-distance-between-2-latitude-and-longitude - * */ public class TrigMath { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index aa43aa0e29..d899b96bcc 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -175,21 +175,21 @@ public class CraftBlock implements Block { } public static int blockFaceToNotch(BlockFace face) { - switch(face) { - case DOWN: - return 0; - case UP: - return 1; - case EAST: - return 2; - case WEST: - return 3; - case NORTH: - return 4; - case SOUTH: - return 5; - default: - return 7; // Good as anything here, but technically invalid + switch (face) { + case DOWN: + return 0; + case UP: + return 1; + case EAST: + return 2; + case WEST: + return 3; + case NORTH: + return 4; + case SOUTH: + return 5; + default: + return 7; // Good as anything here, but technically invalid } } @@ -197,25 +197,25 @@ public class CraftBlock implements Block { Material material = getType(); switch (material) { - case SIGN: - case SIGN_POST: - case WALL_SIGN: - return new CraftSign(this); - case CHEST: - return new CraftChest(this); - case BURNING_FURNACE: - case FURNACE: - return new CraftFurnace(this); - case DISPENSER: - return new CraftDispenser(this); - case MOB_SPAWNER: - return new CraftCreatureSpawner(this); - case NOTE_BLOCK: - return new CraftNoteBlock(this); - case JUKEBOX: - return new CraftJukebox(this); - default: - return new CraftBlockState(this); + case SIGN: + case SIGN_POST: + case WALL_SIGN: + return new CraftSign(this); + case CHEST: + return new CraftChest(this); + case BURNING_FURNACE: + case FURNACE: + return new CraftFurnace(this); + case DISPENSER: + return new CraftDispenser(this); + case MOB_SPAWNER: + return new CraftCreatureSpawner(this); + case NOTE_BLOCK: + return new CraftNoteBlock(this); + case JUKEBOX: + return new CraftJukebox(this); + default: + return new CraftBlockState(this); } } @@ -245,27 +245,27 @@ public class CraftBlock implements Block { } else if (base == BiomeBase.OCEAN) { return Biome.OCEAN; } else if (base == BiomeBase.FROZEN_OCEAN) { - return Biome.FROZEN_OCEAN; + return Biome.FROZEN_OCEAN; } else if (base == BiomeBase.FROZEN_RIVER) { - return Biome.FROZEN_RIVER; + return Biome.FROZEN_RIVER; } else if (base == BiomeBase.ICE_PLAINS) { - return Biome.ICE_PLAINS; + return Biome.ICE_PLAINS; } else if (base == BiomeBase.ICE_MOUNTAINS) { - return Biome.ICE_MOUNTAINS; + return Biome.ICE_MOUNTAINS; } else if (base == BiomeBase.MUSHROOM_ISLAND) { - return Biome.MUSHROOM_ISLAND; + return Biome.MUSHROOM_ISLAND; } else if (base == BiomeBase.MUSHROOM_SHORE) { - return Biome.MUSHROOM_SHORE; + return Biome.MUSHROOM_SHORE; } else if (base == BiomeBase.BEACH) { - return Biome.BEACH; + return Biome.BEACH; } else if (base == BiomeBase.DESERT_HILLS) { - return Biome.DESERT_HILLS; + return Biome.DESERT_HILLS; } else if (base == BiomeBase.FOREST_HILLS) { - return Biome.FOREST_HILLS; + return Biome.FOREST_HILLS; } else if (base == BiomeBase.TAIGA_HILLS) { - return Biome.TAIGA_HILLS; + return Biome.TAIGA_HILLS; } else if (base == BiomeBase.SMALL_MOUNTAINS) { - return Biome.SMALL_MOUNTAINS; + return Biome.SMALL_MOUNTAINS; } return null; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java index b342ea2cf6..5519afea44 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java @@ -36,56 +36,26 @@ public class CraftBlockState implements BlockState { return new CraftBlockState(world.getWorld().getBlockAt(x, y, z)); } - /** - * Gets the world which contains this Block - * - * @return World containing this block - */ public World getWorld() { return world; } - /** - * Gets the x-coordinate of this block - * - * @return x-coordinate - */ public int getX() { return x; } - /** - * Gets the y-coordinate of this block - * - * @return y-coordinate - */ public int getY() { return y; } - /** - * Gets the z-coordinate of this block - * - * @return z-coordinate - */ public int getZ() { return z; } - /** - * Gets the chunk which contains this block - * - * @return Containing Chunk - */ public Chunk getChunk() { return chunk; } - /** - * Sets the metadata for this block - * - * @param data New block specific metadata - */ public void setData(final MaterialData data) { Material mat = getType(); @@ -101,29 +71,14 @@ public class CraftBlockState implements BlockState { } } - /** - * Gets the metadata for this block - * - * @return block specific metadata - */ public MaterialData getData() { return data; } - /** - * Sets the type of this block - * - * @param type Material to change this block to - */ public void setType(final Material type) { setTypeId(type.getId()); } - /** - * Sets the type-id of this block - * - * @param type Type-Id to change this block to - */ public boolean setTypeId(final int type) { this.type = type; @@ -131,29 +86,14 @@ public class CraftBlockState implements BlockState { return true; } - /** - * Gets the type of this block - * - * @return block type - */ public Material getType() { return Material.getMaterial(getTypeId()); } - /** - * Gets the type-id of this block - * - * @return block type-id - */ public int getTypeId() { return type; } - /** - * Gets the light level between 0-15 - * - * @return light level - */ public byte getLightLevel() { return light; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java index 576e7d759f..43421818b2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftJukebox.java @@ -44,7 +44,7 @@ public class CraftJukebox extends CraftBlockState implements Jukebox { public boolean eject() { boolean result = isPlaying(); - ((BlockJukeBox)net.minecraft.server.Block.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ()); + ((BlockJukeBox) net.minecraft.server.Block.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ()); return result; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java b/paper-server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java index 4fb3123092..0422cee9b8 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/command/ServerCommandListener.java @@ -13,7 +13,7 @@ public class ServerCommandListener implements ICommandListener { public ServerCommandListener(CommandSender commandSender) { this.commandSender = commandSender; String[] parts = commandSender.getClass().getName().split("\\."); - this.prefix = parts[parts.length-1]; + this.prefix = parts[parts.length - 1]; } public void sendMessage(String msg) { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index 3bca36076f..e4c68847c5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -27,26 +27,26 @@ public class CraftEnchantment extends Enchantment { @Override public EnchantmentTarget getItemTarget() { switch (target.slot) { - case ALL: - return EnchantmentTarget.ALL; - case ARMOR: - return EnchantmentTarget.ARMOR; - case ARMOR_FEET: - return EnchantmentTarget.ARMOR_FEET; - case ARMOR_HEAD: - return EnchantmentTarget.ARMOR_HEAD; - case ARMOR_LEGS: - return EnchantmentTarget.ARMOR_LEGS; - case ARMOR_TORSO: - return EnchantmentTarget.ARMOR_TORSO; - case DIGGER: - return EnchantmentTarget.TOOL; - case WEAPON: - return EnchantmentTarget.WEAPON; - case BOW: - return EnchantmentTarget.BOW; - default: - return null; + case ALL: + return EnchantmentTarget.ALL; + case ARMOR: + return EnchantmentTarget.ARMOR; + case ARMOR_FEET: + return EnchantmentTarget.ARMOR_FEET; + case ARMOR_HEAD: + return EnchantmentTarget.ARMOR_HEAD; + case ARMOR_LEGS: + return EnchantmentTarget.ARMOR_LEGS; + case ARMOR_TORSO: + return EnchantmentTarget.ARMOR_TORSO; + case DIGGER: + return EnchantmentTarget.TOOL; + case WEAPON: + return EnchantmentTarget.WEAPON; + case BOW: + return EnchantmentTarget.BOW; + default: + return null; } } @@ -58,60 +58,60 @@ public class CraftEnchantment extends Enchantment { @Override public String getName() { switch (target.id) { - case 0: - return "PROTECTION_ENVIRONMENTAL"; - case 1: - return "PROTECTION_FIRE"; - case 2: - return "PROTECTION_FALL"; - case 3: - return "PROTECTION_EXPLOSIONS"; - case 4: - return "PROTECTION_PROJECTILE"; - case 5: - return "OXYGEN"; - case 6: - return "WATER_WORKER"; - case 16: - return "DAMAGE_ALL"; - case 17: - return "DAMAGE_UNDEAD"; - case 18: - return "DAMAGE_ARTHROPODS"; - case 19: - return "KNOCKBACK"; - case 20: - return "FIRE_ASPECT"; - case 21: - return "LOOT_BONUS_MOBS"; - case 32: - return "DIG_SPEED"; - case 33: - return "SILK_TOUCH"; - case 34: - return "DURABILITY"; - case 35: - return "LOOT_BONUS_BLOCKS"; - case 48: - return "ARROW_DAMAGE"; - case 49: - return "ARROW_KNOCKBACK"; - case 50: - return "ARROW_FIRE"; - case 51: - return "ARROW_INFINITE"; - default: - return "UNKNOWN_ENCHANT_" + target.id; + case 0: + return "PROTECTION_ENVIRONMENTAL"; + case 1: + return "PROTECTION_FIRE"; + case 2: + return "PROTECTION_FALL"; + case 3: + return "PROTECTION_EXPLOSIONS"; + case 4: + return "PROTECTION_PROJECTILE"; + case 5: + return "OXYGEN"; + case 6: + return "WATER_WORKER"; + case 16: + return "DAMAGE_ALL"; + case 17: + return "DAMAGE_UNDEAD"; + case 18: + return "DAMAGE_ARTHROPODS"; + case 19: + return "KNOCKBACK"; + case 20: + return "FIRE_ASPECT"; + case 21: + return "LOOT_BONUS_MOBS"; + case 32: + return "DIG_SPEED"; + case 33: + return "SILK_TOUCH"; + case 34: + return "DURABILITY"; + case 35: + return "LOOT_BONUS_BLOCKS"; + case 48: + return "ARROW_DAMAGE"; + case 49: + return "ARROW_KNOCKBACK"; + case 50: + return "ARROW_FIRE"; + case 51: + return "ARROW_INFINITE"; + default: + return "UNKNOWN_ENCHANT_" + target.id; } } public static net.minecraft.server.Enchantment getRaw(Enchantment enchantment) { if (enchantment instanceof EnchantmentWrapper) { - enchantment = ((EnchantmentWrapper)enchantment).getEnchantment(); + enchantment = ((EnchantmentWrapper) enchantment).getEnchantment(); } if (enchantment instanceof CraftEnchantment) { - return ((CraftEnchantment)enchantment).target; + return ((CraftEnchantment) enchantment).target; } return null; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java index 275e849e75..1a9c87c741 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftArrow.java @@ -30,7 +30,7 @@ public class CraftArrow extends AbstractProjectile implements Arrow { } @Override - public EntityArrow getHandle(){ + public EntityArrow getHandle() { return (EntityArrow) entity; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index a2aea669c6..47854ae817 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -177,7 +177,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { List notchEntityList = entity.world.getEntities(entity, entity.boundingBox.grow(x, y, z)); List bukkitEntityList = new java.util.ArrayList(notchEntityList.size()); - for (Entity e: notchEntityList) { + for (Entity e : notchEntityList) { bukkitEntityList.add(e.getBukkitEntity()); } return bukkitEntityList; @@ -269,7 +269,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { CraftPlayer result = players.get(entity.name); if (result == null) { - result = new CraftPlayer((CraftServer)Bukkit.getServer(), entity); + result = new CraftPlayer((CraftServer) Bukkit.getServer(), entity); players.put(entity.name, result); } else { result.setHandle(entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java index df9a657e2a..75d0ea4c1c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftExperienceOrb.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityExperienceOrb; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index a5256e206d..7b5b37ca8e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit.entity; import java.util.Set; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 6cbf0158b4..e1e8b20406 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -47,7 +47,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { getHandle().setHealth(health); } - + public int getMaxHealth() { return getHandle().getMaxHealth(); } @@ -173,9 +173,9 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { DamageSource reason = DamageSource.GENERIC; if (source instanceof HumanEntity) { - reason = DamageSource.playerAttack(((CraftHumanEntity)source).getHandle()); + reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle()); } else if (source instanceof LivingEntity) { - reason = DamageSource.mobAttack(((CraftLivingEntity)source).getHandle()); + reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle()); } entity.damageEntity(reason, amount); @@ -226,6 +226,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } public Player getKiller() { - return getHandle().killer == null ? null : (Player)getHandle().killer.getBukkitEntity(); + return getHandle().killer == null ? null : (Player) getHandle().killer.getBukkitEntity(); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java index 50d3f98d2c..0c6683a53b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMagmaCube.java @@ -1,6 +1,5 @@ package org.bukkit.craftbukkit.entity; - import net.minecraft.server.EntityMagmaCube; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.MagmaCube; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java index 3634b85ddf..4762d57a14 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPainting.java @@ -102,7 +102,7 @@ public class CraftPainting extends CraftEntity implements Painting { } private void update() { - WorldServer world = ((CraftWorld)getWorld()).getHandle(); + WorldServer world = ((CraftWorld) getWorld()).getHandle(); EntityPainting painting = new EntityPainting(world); painting.x = getHandle().x; painting.y = getHandle().y; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 09584520e2..c86c8720ea 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -76,7 +76,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public boolean isOnline() { - for (Object obj: server.getHandle().players) { + for (Object obj : server.getHandle().players) { EntityPlayer player = (EntityPlayer) obj; if (player.name.equalsIgnoreCase(getName())) { return true; @@ -173,7 +173,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (!(obj instanceof OfflinePlayer)) { return false; } - OfflinePlayer other = (OfflinePlayer)obj; + OfflinePlayer other = (OfflinePlayer) obj; if ((this.getName() == null) || (other.getName() == null)) { return false; } @@ -485,7 +485,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public int getExperience() { - return (int)(getExp() * 100); + return (int) (getExp() * 100); } public void setExperience(int exp) { @@ -493,7 +493,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public int getLevel() { - return (int)getHandle().expLevel; + return (int) getHandle().expLevel; } public void setLevel(int level) { @@ -655,7 +655,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { for (String channel : listening) { try { stream.write(channel.getBytes("UTF8")); - stream.write((byte)0); + stream.write((byte) 0); } catch (IOException ex) { Logger.getLogger(CraftPlayer.class.getName()).log(Level.SEVERE, "Could not send Plugin Channel REGISTER to " + getName(), ex); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java index 7fea15e5c7..7c79928b20 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftProjectile.java @@ -13,7 +13,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj public LivingEntity getShooter() { if (getHandle().shooter instanceof EntityLiving) { - return (LivingEntity)getHandle().shooter.getBukkitEntity(); + return (LivingEntity) getHandle().shooter.getBukkitEntity(); } return null; @@ -21,7 +21,7 @@ public abstract class CraftProjectile extends AbstractProjectile implements Proj public void setShooter(LivingEntity shooter) { if (shooter instanceof CraftLivingEntity) { - getHandle().shooter = (EntityLiving)((CraftLivingEntity)shooter).entity; + getHandle().shooter = (EntityLiving) ((CraftLivingEntity) shooter).entity; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java index c937aac956..7d27e43f0a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWeather.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit.entity; import net.minecraft.server.EntityWeather; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java index 6aa91b2af7..304ca35bad 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWolf.java @@ -74,6 +74,7 @@ public class CraftWolf extends CraftAnimals implements Wolf { /** * The owner's name is how MC knows and persists the Wolf's owner. Since we choose to instead use an AnimalTamer, this functionality * is used only as a backup. If the animal tamer is a player, we will store their name, otherwise we store an empty string. + * * @return the owner's name, if they are a player; otherwise, the empty string or null. */ String getOwnerName() { @@ -87,6 +88,7 @@ public class CraftWolf extends CraftAnimals implements Wolf { /** * Only used internally at the moment, and there to set the path to null (that is stop the thing from running around) * TODO use this later to extend the API, when we have Path classes in Bukkit + * * @param pathentity currently the MC defined PathEntity class. Should be replaced with an API interface at some point. */ private void setPath(PathEntity pathentity) { @@ -99,12 +101,10 @@ public class CraftWolf extends CraftAnimals implements Wolf { private void playTamingAnimation(boolean successful){ getHandle().a(successful); } - */ + */ @Override public EntityWolf getHandle() { - // It's somewhat easier to override this here, as many internal methods rely on EntityWolf specific methods. - // Doing this has no impact on anything outside this class. return (EntityWolf) entity; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 887bbe4b91..be4a5a52e4 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java @@ -147,6 +147,7 @@ public class CraftEventFactory { } return callPlayerInteractEvent(who, action, 0, 255, 0, 0, itemstack); } + public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) { Player player = (who == null) ? null : (Player) who.getBukkitEntity(); CraftItemStack itemInHand = new CraftItemStack(itemstack); @@ -160,12 +161,12 @@ public class CraftEventFactory { if (clickedY == 255) { blockClicked = null; switch (action) { - case LEFT_CLICK_BLOCK: - action = Action.LEFT_CLICK_AIR; - break; - case RIGHT_CLICK_BLOCK: - action = Action.RIGHT_CLICK_AIR; - break; + case LEFT_CLICK_BLOCK: + action = Action.LEFT_CLICK_AIR; + break; + case RIGHT_CLICK_BLOCK: + action = Action.RIGHT_CLICK_AIR; + break; } } @@ -317,7 +318,7 @@ public class CraftEventFactory { victim.expToDrop = event.getDroppedExp(); - for (org.bukkit.inventory.ItemStack stack: event.getDrops()) { + for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { world.dropItemNaturally(entity.getLocation(), stack); } @@ -325,7 +326,7 @@ public class CraftEventFactory { } public static PlayerDeathEvent callPlayerDeathEvent(EntityPlayer victim, List drops, String deathMessage) { - CraftPlayer entity = (CraftPlayer)victim.getBukkitEntity(); + CraftPlayer entity = (CraftPlayer) victim.getBukkitEntity(); PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage); org.bukkit.World world = entity.getWorld(); Bukkit.getServer().getPluginManager().callEvent(event); @@ -337,7 +338,7 @@ public class CraftEventFactory { victim.expToDrop = event.getDroppedExp(); victim.newExp = event.getNewExp(); - for (org.bukkit.inventory.ItemStack stack: event.getDrops()) { + for (org.bukkit.inventory.ItemStack stack : event.getDrops()) { world.dropItemNaturally(entity.getLocation(), stack); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java index e5ee52b5cc..bafad5454c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/generator/InternalChunkGenerator.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit.generator; import net.minecraft.server.IChunkProvider; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java index 07d528a1f0..b8f045d083 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java @@ -63,7 +63,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { } public boolean contains(int materialId) { - for (ItemStack item: getContents()) { + for (ItemStack item : getContents()) { if (item != null && item.getTypeId() == materialId) { return true; } @@ -79,7 +79,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { if (item == null) { return false; } - for (ItemStack i: getContents()) { + for (ItemStack i : getContents()) { if (item.equals(i)) { return true; } @@ -89,7 +89,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { public boolean contains(int materialId, int amount) { int amt = 0; - for (ItemStack item: getContents()) { + for (ItemStack item : getContents()) { if (item != null && item.getTypeId() == materialId) { amt += item.getAmount(); } @@ -106,7 +106,7 @@ public class CraftInventory implements org.bukkit.inventory.Inventory { return false; } int amt = 0; - for (ItemStack i: getContents()) { + for (ItemStack i : getContents()) { if (item.equals(i)) { amt += item.getAmount(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 5e98c9d442..46e80e1da7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -175,10 +175,10 @@ public class CraftItemStack extends ItemStack { } for (int i = 0; i < list.size(); i++) { - short id = ((NBTTagCompound)list.get(i)).getShort("id"); - short level = ((NBTTagCompound)list.get(i)).getShort("lvl"); + short id = ((NBTTagCompound) list.get(i)).getShort("id"); + short level = ((NBTTagCompound) list.get(i)).getShort("lvl"); - result.put(Enchantment.getById(id), (int)level); + result.put(Enchantment.getById(id), (int) level); } return result; @@ -197,8 +197,8 @@ public class CraftItemStack extends ItemStack { for (Map.Entry entry : enchantments.entrySet()) { NBTTagCompound subtag = new NBTTagCompound(); - subtag.setShort("id", (short)entry.getKey().getId()); - subtag.setShort("lvl", (short)(int)entry.getValue()); + subtag.setShort("id", (short) entry.getKey().getId()); + subtag.setShort("lvl", (short) (int) entry.getValue()); list.add(subtag); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java index 901dcd5b43..b5e9e31095 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapCanvas.java @@ -9,12 +9,12 @@ import org.bukkit.map.MapFont.CharacterSprite; import org.bukkit.map.MapPalette; public class CraftMapCanvas implements MapCanvas { - + private final byte[] buffer = new byte[128 * 128]; private final CraftMapView mapView; private byte[] base; private MapCursorCollection cursors = new MapCursorCollection(); - + protected CraftMapCanvas(CraftMapView mapView) { this.mapView = mapView; Arrays.fill(buffer, (byte) -1); @@ -33,7 +33,8 @@ public class CraftMapCanvas implements MapCanvas { } public void setPixel(int x, int y, byte color) { - if (x < 0 || y < 0 || x >= 128 || y >= 128) return; + if (x < 0 || y < 0 || x >= 128 || y >= 128) + return; if (buffer[y * 128 + x] != color) { buffer[y * 128 + x] = color; mapView.worldMap.flagDirty(x, y, y); @@ -41,19 +42,21 @@ public class CraftMapCanvas implements MapCanvas { } public byte getPixel(int x, int y) { - if (x < 0 || y < 0 || x >= 128 || y >= 128) return 0; + if (x < 0 || y < 0 || x >= 128 || y >= 128) + return 0; return buffer[y * 128 + x]; } public byte getBasePixel(int x, int y) { - if (x < 0 || y < 0 || x >= 128 || y >= 128) return 0; + if (x < 0 || y < 0 || x >= 128 || y >= 128) + return 0; return base[y * 128 + x]; } - + protected void setBase(byte[] base) { this.base = base; } - + protected byte[] getBuffer() { return buffer; } @@ -73,7 +76,7 @@ public class CraftMapCanvas implements MapCanvas { if (!font.isValid(text)) { throw new IllegalArgumentException("text contains invalid characters"); } - + for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == '\n') { @@ -91,7 +94,7 @@ public class CraftMapCanvas implements MapCanvas { catch (NumberFormatException ex) {} } } - + CharacterSprite sprite = font.getChar(text.charAt(i)); for (int r = 0; r < font.getHeight(); ++r) { for (int c = 0; c < sprite.getWidth(); ++c) { @@ -103,5 +106,5 @@ public class CraftMapCanvas implements MapCanvas { x += sprite.getWidth() + 1; } } - + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java index 2819dfdfe0..b8230b184e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapRenderer.java @@ -10,7 +10,7 @@ import org.bukkit.map.MapView; import org.bukkit.map.MapCursorCollection; public class CraftMapRenderer extends MapRenderer { - + private final CraftMapView mapView; private final WorldMap worldMap; @@ -28,7 +28,7 @@ public class CraftMapRenderer extends MapRenderer { canvas.setPixel(x, y, worldMap.colors[y * 128 + x]); } } - + // Cursors MapCursorCollection cursors = canvas.getCursors(); while (cursors.size() > 0) { @@ -36,8 +36,8 @@ public class CraftMapRenderer extends MapRenderer { } for (int i = 0; i < worldMap.decorations.size(); ++i) { WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(i); - cursors.addCursor(decoration.locX, decoration.locY, (byte)(decoration.rotation & 15), (byte)(decoration.type)); + cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), (byte) (decoration.type)); } } - + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java index cb5b3fac5e..b28d6a3439 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/CraftMapView.java @@ -16,12 +16,12 @@ import org.bukkit.map.MapRenderer; import org.bukkit.map.MapView; public final class CraftMapView implements MapView { - + private final Map renderCache = new HashMap(); private final List renderers = new ArrayList(); private final Map> canvases = new HashMap>(); protected final WorldMap worldMap; - + public CraftMapView(WorldMap worldMap) { this.worldMap = worldMap; addRenderer(new CraftMapRenderer(this, worldMap)); @@ -52,7 +52,7 @@ public final class CraftMapView implements MapView { public void setScale(Scale scale) { worldMap.scale = scale.getValue(); } - + public World getWorld() { byte dimension = worldMap.map; for (World world : Bukkit.getServer().getWorlds()) { @@ -111,51 +111,51 @@ public final class CraftMapView implements MapView { return false; } } - + private boolean isContextual() { for (MapRenderer renderer : renderers) { if (renderer.isContextual()) return true; } return false; } - + public RenderData render(CraftPlayer player) { boolean context = isContextual(); RenderData render = renderCache.get(context ? player : null); - + if (render == null) { render = new RenderData(); renderCache.put(context ? player : null, render); } - + if (context && renderCache.containsKey(null)) { renderCache.remove(null); } - + Arrays.fill(render.buffer, (byte) 0); render.cursors.clear(); - + for (MapRenderer renderer : renderers) { CraftMapCanvas canvas = canvases.get(renderer).get(renderer.isContextual() ? player : null); if (canvas == null) { canvas = new CraftMapCanvas(this); canvases.get(renderer).put(renderer.isContextual() ? player : null, canvas); } - + canvas.setBase(render.buffer); renderer.render(this, canvas, player); - + byte[] buf = canvas.getBuffer(); for (int i = 0; i < buf.length; ++i) { if (buf[i] >= 0) render.buffer[i] = buf[i]; } - + for (int i = 0; i < canvas.getCursors().size(); ++i) { render.cursors.add(canvas.getCursors().getCursor(i)); } } - + return render; } - + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/paper-server/src/main/java/org/bukkit/craftbukkit/map/RenderData.java index 8f05fcc638..256a131781 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/map/RenderData.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/map/RenderData.java @@ -4,13 +4,13 @@ import java.util.ArrayList; import org.bukkit.map.MapCursor; public class RenderData { - + public final byte[] buffer; public final ArrayList cursors; - + public RenderData() { this.buffer = new byte[128 * 128]; this.cursors = new ArrayList(); } - + } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/EntryBase.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/EntryBase.java index 1167ce934e..4f71657b00 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/EntryBase.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/EntryBase.java @@ -1,7 +1,8 @@ package org.bukkit.craftbukkit.util; -public class EntryBase { +public class EntryBase { protected long key; + public EntryBase(long key) { this.key = key; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongBaseHashtable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongBaseHashtable.java index c478f50c97..c397e5d22b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongBaseHashtable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongBaseHashtable.java @@ -84,7 +84,7 @@ public class LongBaseHashtable extends LongHash { if (inner[i].key == key) { for (i++; i < inner.length; i++) { if (inner[i] == null) break; - inner[i-1] = inner[i]; + inner[i - 1] = inner[i]; } inner[i-1] = null; @@ -97,13 +97,13 @@ public class LongBaseHashtable extends LongHash { public synchronized ArrayList entries() { ArrayList ret = new ArrayList(); - for (EntryBase[][] outer: this.values) { + for (EntryBase[][] outer : this.values) { if (outer == null) continue; - for (EntryBase[] inner: outer) { + for (EntryBase[] inner : outer) { if (inner == null) continue; - for (EntryBase entry: inner) { + for (EntryBase entry : inner) { if (entry == null) break; ret.add(entry); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashset.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashset.java index 8c17e4f3b8..25563c4c70 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashset.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashset.java @@ -71,7 +71,7 @@ public class LongHashset extends LongHash { long[] inner = outer[(int) ((key >> 32) & 255)]; if (inner == null) return false; - for (long entry: inner) { + for (long entry : inner) { if (entry == key) return true; } return false; @@ -134,7 +134,7 @@ public class LongHashset extends LongHash { rl.lock(); try { long[] ret = new long[this.count]; - for (long[][] outer: this.values) { + for (long[][] outer : this.values) { if (outer == null) continue; for (int oIdx = outer.length - 1; oIdx >= 0; oIdx--) { @@ -159,13 +159,13 @@ public class LongHashset extends LongHash { rl.lock(); try { long[] ret = new long[this.count]; - for (long[][] outer: this.values) { + for (long[][] outer : this.values) { if (outer == null) continue; - for (long[] inner: outer) { + for (long[] inner : outer) { if (inner == null) continue; - for (long entry: inner) { + for (long entry : inner) { ret[index++] = entry; } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java index 154b877bb5..e9a5467e41 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/LongHashtable.java @@ -28,7 +28,7 @@ public class LongHashtable extends LongBaseHashtable { ArrayList entries = entries(); - for(EntryBase entry : entries) { + for (EntryBase entry : entries) { ret.add(((Entry) entry).value); } return ret; @@ -36,6 +36,7 @@ public class LongHashtable extends LongBaseHashtable { private class Entry extends EntryBase { V value; + Entry(long k, V v) { super(k); this.value = v; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java index 5e555d645c..ab6d992f86 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java @@ -1,4 +1,3 @@ - package org.bukkit.craftbukkit.util; import net.minecraft.server.MinecraftServer; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java index 157b532a0e..f905d17b6b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -10,20 +10,20 @@ import org.bukkit.Bukkit; public final class Versioning { public static String getBukkitVersion() { String result = "Unknown-Version"; - + InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.bukkit/bukkit/pom.properties"); Properties properties = new Properties(); - + if (stream != null) { try { properties.load(stream); - + result = properties.getProperty("version"); } catch (IOException ex) { Logger.getLogger(Versioning.class.getName()).log(Level.SEVERE, "Could not get Bukkit version!", ex); } } - + return result; } }