Bulk pending cleanup.

By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
CraftBukkit/Spigot 2012-09-09 23:19:28 -05:00
parent bc59fff79a
commit 2a57bac117
24 changed files with 45 additions and 52 deletions

View file

@ -67,7 +67,7 @@ public class CraftArt {
return null; return null;
} }
{ static {
assert (EnumArt.values().length == 25); assert (EnumArt.values().length == 25);
assert (Art.values().length == 25); assert (Art.values().length == 25);
} }

View file

@ -20,9 +20,9 @@ import org.bukkit.ChunkSnapshot;
public class CraftChunk implements Chunk { public class CraftChunk implements Chunk {
private WeakReference<net.minecraft.server.Chunk> weakChunk; private WeakReference<net.minecraft.server.Chunk> weakChunk;
private WorldServer worldServer; private final WorldServer worldServer;
private int x; private final int x;
private int z; private final int z;
private static final byte[] emptyData = new byte[2048]; private static final byte[] emptyData = new byte[2048];
private static final short[] emptyBlockIDs = new short[4096]; private static final short[] emptyBlockIDs = new short[4096];
private static final byte[] emptySkyLight = new byte[2048]; private static final byte[] emptySkyLight = new byte[2048];

View file

@ -144,7 +144,7 @@ public final class CraftServer implements Server {
private YamlConfiguration configuration; private YamlConfiguration configuration;
private final Yaml yaml = new Yaml(new SafeConstructor()); private final Yaml yaml = new Yaml(new SafeConstructor());
private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap(); private final Map<String, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap();
private AutoUpdater updater; private final AutoUpdater updater;
private final EntityMetadataStore entityMetadata = new EntityMetadataStore(); private final EntityMetadataStore entityMetadata = new EntityMetadataStore();
private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore(); private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
private final WorldMetadataStore worldMetadata = new WorldMetadataStore(); private final WorldMetadataStore worldMetadata = new WorldMetadataStore();
@ -353,7 +353,7 @@ public final class CraftServer implements Server {
matchedPlayers.add(iterPlayer); matchedPlayers.add(iterPlayer);
break; break;
} }
if (iterPlayerName.toLowerCase().indexOf(partialName.toLowerCase()) != -1) { if (iterPlayerName.toLowerCase().contains(partialName.toLowerCase())) {
// Partial match // Partial match
matchedPlayers.add(iterPlayer); matchedPlayers.add(iterPlayer);
} }
@ -911,7 +911,7 @@ public final class CraftServer implements Server {
commands = ImmutableList.<String>of(section.getString(key)); commands = ImmutableList.<String>of(section.getString(key));
} }
result.put(key, commands.toArray(new String[0])); result.put(key, commands.toArray(new String[commands.size()]));
} }
} }
@ -1146,8 +1146,8 @@ public final class CraftServer implements Server {
String[] files = storage.getPlayerDir().list(new DatFileFilter()); String[] files = storage.getPlayerDir().list(new DatFileFilter());
Set<OfflinePlayer> players = new HashSet<OfflinePlayer>(); Set<OfflinePlayer> players = new HashSet<OfflinePlayer>();
for (int i = 0; i < files.length; i++) { for (String file : files) {
players.add(getOfflinePlayer(files[i].substring(0, files[i].length() - 4))); players.add(getOfflinePlayer(file.substring(0, file.length() - 4)));
} }
players.addAll(Arrays.asList(getOnlinePlayers())); players.addAll(Arrays.asList(getOnlinePlayers()));

View file

@ -437,7 +437,7 @@ public class CraftWorld implements World {
} }
public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { public boolean createExplosion(double x, double y, double z, float power, boolean setFire) {
return world.createExplosion(null, x, y, z, power, setFire).wasCanceled ? false : true; return !world.createExplosion(null, x, y, z, power, setFire).wasCanceled;
} }
public boolean createExplosion(Location loc, float power) { public boolean createExplosion(Location loc, float power) {

View file

@ -10,8 +10,7 @@ public class TextWrapper {
String[] lines = text.split("\n"); String[] lines = text.split("\n");
String lastColor = null; String lastColor = null;
for (int i = 0; i < lines.length; i++) { for (String line : lines) {
String line = lines[i];
if (lastColor != null) { if (lastColor != null) {
line = lastColor + line; line = lastColor + line;
} }
@ -22,4 +21,4 @@ public class TextWrapper {
return output; return output;
} }
} }

View file

@ -22,7 +22,7 @@ public class CraftBlockState implements BlockState {
private final int z; private final int z;
protected int type; protected int type;
protected MaterialData data; protected MaterialData data;
protected byte light; protected final byte light;
public CraftBlockState(final Block block) { public CraftBlockState(final Block block) {
this.world = (CraftWorld) block.getWorld(); this.world = (CraftWorld) block.getWorld();

View file

@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.conversations.ConversationTracker;
*/ */
public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender { public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender {
protected ConversationTracker conversationTracker = new ConversationTracker(); protected final ConversationTracker conversationTracker = new ConversationTracker();
protected CraftConsoleCommandSender() { protected CraftConsoleCommandSender() {
super(); super();

View file

@ -16,8 +16,7 @@ public class CraftCreature extends CraftLivingEntity implements Creature {
if (target == null) { if (target == null) {
entity.target = null; entity.target = null;
} else if (target instanceof CraftLivingEntity) { } else if (target instanceof CraftLivingEntity) {
EntityLiving victim = ((CraftLivingEntity) target).getHandle(); entity.target = ((CraftLivingEntity) target).getHandle();
entity.target = victim;
entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F, true, false, false, true); entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F, true, false, false, true);
} }
} }

View file

@ -36,7 +36,7 @@ import org.bukkit.plugin.Plugin;
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
private CraftInventoryPlayer inventory; private CraftInventoryPlayer inventory;
private CraftInventory enderChest; private final CraftInventory enderChest;
protected final PermissibleBase perm = new PermissibleBase(this); protected final PermissibleBase perm = new PermissibleBase(this);
private boolean op; private boolean op;
private GameMode mode; private GameMode mode;

View file

@ -10,7 +10,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
public class CraftItem extends CraftEntity implements Item { public class CraftItem extends CraftEntity implements Item {
private EntityItem item; private final EntityItem item;
public CraftItem(CraftServer server, Entity entity, EntityItem item) { public CraftItem(CraftServer server, Entity entity, EntityItem item) {
super(server, entity); super(server, entity);

View file

@ -31,8 +31,7 @@ public class CraftPainting extends CraftEntity implements Painting {
public boolean setArt(Art art, boolean force) { public boolean setArt(Art art, boolean force) {
EntityPainting painting = this.getHandle(); EntityPainting painting = this.getHandle();
EnumArt oldArt = painting.art; EnumArt oldArt = painting.art;
EnumArt newArt = CraftArt.BukkitToNotch(art); painting.art = CraftArt.BukkitToNotch(art);
painting.art = newArt;
painting.setDirection(painting.direction); painting.setDirection(painting.direction);
if (!force && !painting.survives()) { if (!force && !painting.survives()) {
// Revert painting since it doesn't fit // Revert painting since it doesn't fit

View file

@ -53,9 +53,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private long firstPlayed = 0; private long firstPlayed = 0;
private long lastPlayed = 0; private long lastPlayed = 0;
private boolean hasPlayedBefore = false; private boolean hasPlayedBefore = false;
private ConversationTracker conversationTracker = new ConversationTracker(); private final ConversationTracker conversationTracker = new ConversationTracker();
private Set<String> channels = new HashSet<String>(); private final Set<String> channels = new HashSet<String>();
private Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap(); private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
private int hash = 0; private int hash = 0;
public CraftPlayer(CraftServer server, EntityPlayer entity) { public CraftPlayer(CraftServer server, EntityPlayer entity) {

View file

@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.StorageMinecart; import org.bukkit.entity.StorageMinecart;
public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart { public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart {
private CraftInventory inventory; private final CraftInventory inventory;
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) { public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
super(server, entity); super(server, entity);

View file

@ -9,7 +9,7 @@ import org.bukkit.help.HelpTopic;
*/ */
public class CustomHelpTopic extends HelpTopic { public class CustomHelpTopic extends HelpTopic {
private String permissionNode; private final String permissionNode;
public CustomHelpTopic(String name, String shortText, String fullText, String permissionNode) { public CustomHelpTopic(String name, String shortText, String fullText, String permissionNode) {
this.permissionNode = permissionNode; this.permissionNode = permissionNode;

View file

@ -13,7 +13,7 @@ import java.util.List;
*/ */
public class CustomIndexHelpTopic extends IndexHelpTopic { public class CustomIndexHelpTopic extends IndexHelpTopic {
private List<String> futureTopics; private List<String> futureTopics;
private HelpMap helpMap; private final HelpMap helpMap;
public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) { public CustomIndexHelpTopic(HelpMap helpMap, String name, String shortText, String permission, List<String> futureTopics, String preamble) {
super(name, shortText, permission, new HashSet<HelpTopic>(), preamble); super(name, shortText, permission, new HashSet<HelpTopic>(), preamble);

View file

@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.help;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import org.bukkit.ChatColor;
import org.bukkit.command.*; import org.bukkit.command.*;
import org.bukkit.command.defaults.BukkitCommand; import org.bukkit.command.defaults.BukkitCommand;
import org.bukkit.command.defaults.VanillaCommand; import org.bukkit.command.defaults.VanillaCommand;
@ -107,7 +106,7 @@ public class SimpleHelpMap implements HelpMap {
// Initialize help topics from the server's command map // Initialize help topics from the server's command map
outer: for (Command command : server.getCommandMap().getCommands()) { outer: for (Command command : server.getCommandMap().getCommands()) {
if (commandInIgnoredPlugin(command, ignoredPlugins)) { if (commandInIgnoredPlugin(command, ignoredPlugins)) {
continue outer; continue;
} }
// Register a topic // Register a topic

View file

@ -13,10 +13,10 @@ import net.minecraft.server.Packet100OpenWindow;
import net.minecraft.server.Slot; import net.minecraft.server.Slot;
public class CraftContainer extends Container { public class CraftContainer extends Container {
private InventoryView view; private final InventoryView view;
private InventoryType cachedType; private InventoryType cachedType;
private String cachedTitle; private String cachedTitle;
private int cachedSize; private final int cachedSize;
public CraftContainer(InventoryView view, int id) { public CraftContainer(InventoryView view, int id) {
this.view = view; this.view = view;

View file

@ -10,7 +10,7 @@ import org.bukkit.inventory.Recipe;
import org.bukkit.util.Java15Compat; import org.bukkit.util.Java15Compat;
public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory { public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory {
private IInventory resultInventory; private final IInventory resultInventory;
public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) { public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) {
super(inventory); super(inventory);
@ -135,4 +135,4 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe; IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe;
return recipe == null ? null : recipe.toBukkitRecipe(); return recipe == null ? null : recipe.toBukkitRecipe();
} }
} }

View file

@ -26,12 +26,12 @@ public class CraftInventoryCustom extends CraftInventory {
} }
static class MinecraftInventory implements IInventory { static class MinecraftInventory implements IInventory {
private ItemStack[] items; private final ItemStack[] items;
private int maxStack = MAX_STACK; private int maxStack = MAX_STACK;
private List<HumanEntity> viewers; private final List<HumanEntity> viewers;
private String title; private final String title;
private InventoryType type; private InventoryType type;
private InventoryHolder owner; private final InventoryHolder owner;
public MinecraftInventory(InventoryHolder owner, InventoryType type) { public MinecraftInventory(InventoryHolder owner, InventoryType type) {
this(owner, type.getDefaultSize(), type.getDefaultTitle()); this(owner, type.getDefaultSize(), type.getDefaultTitle());

View file

@ -8,7 +8,8 @@ import org.bukkit.inventory.ItemStack;
import net.minecraft.server.InventoryLargeChest; import net.minecraft.server.InventoryLargeChest;
public class CraftInventoryDoubleChest extends CraftInventory implements DoubleChestInventory { public class CraftInventoryDoubleChest extends CraftInventory implements DoubleChestInventory {
private CraftInventory left, right; private final CraftInventory left;
private final CraftInventory right;
public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) { public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) {
super(new InventoryLargeChest("Large chest", left.getInventory(), right.getInventory())); super(new InventoryLargeChest("Large chest", left.getInventory(), right.getInventory()));

View file

@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack;
import net.minecraft.server.Container; import net.minecraft.server.Container;
public class CraftInventoryView extends InventoryView { public class CraftInventoryView extends InventoryView {
private Container container; private final Container container;
private CraftHumanEntity player; private final CraftHumanEntity player;
private CraftInventory viewing; private final CraftInventory viewing;
public CraftInventoryView(HumanEntity player, Inventory viewing, Container container) { public CraftInventoryView(HumanEntity player, Inventory viewing, Container container) {
// TODO: Should we make sure it really IS a CraftHumanEntity first? And a CraftInventory? // TODO: Should we make sure it really IS a CraftHumanEntity first? And a CraftInventory?

View file

@ -286,9 +286,7 @@ public class CraftScheduler implements BukkitScheduler {
} }
final ArrayList<BukkitTask> pending = new ArrayList<BukkitTask>(); final ArrayList<BukkitTask> pending = new ArrayList<BukkitTask>();
final Iterator<CraftTask> it = runners.values().iterator(); for (CraftTask task : runners.values()) {
while (it.hasNext()) {
final CraftTask task = it.next();
if (task.getPeriod() >= -1l) { if (task.getPeriod() >= -1l) {
pending.add(task); pending.add(task);
} }

View file

@ -39,7 +39,7 @@ public class BukkitDLUpdaterService {
return "CraftBukkit/" + BukkitDLUpdaterService.class.getPackage().getImplementationVersion() + "/" + System.getProperty("java.version"); return "CraftBukkit/" + BukkitDLUpdaterService.class.getPackage().getImplementationVersion() + "/" + System.getProperty("java.version");
} }
public ArtifactDetails fetchArtifact(String slug) throws UnsupportedEncodingException, IOException { public ArtifactDetails fetchArtifact(String slug) throws IOException {
URL url = new URL("http", host, API_PREFIX_ARTIFACT + slug + "/"); URL url = new URL("http", host, API_PREFIX_ARTIFACT + slug + "/");
InputStreamReader reader = null; InputStreamReader reader = null;
@ -48,9 +48,7 @@ public class BukkitDLUpdaterService {
connection.setRequestProperty("User-Agent", getUserAgent()); connection.setRequestProperty("User-Agent", getUserAgent());
reader = new InputStreamReader(connection.getInputStream()); reader = new InputStreamReader(connection.getInputStream());
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create(); Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
ArtifactDetails fromJson = gson.fromJson(reader, ArtifactDetails.class); return gson.fromJson(reader, ArtifactDetails.class);
return fromJson;
} finally { } finally {
if (reader != null) { if (reader != null) {
reader.close(); reader.close();
@ -70,7 +68,7 @@ public class BukkitDLUpdaterService {
return null; return null;
} }
public ArtifactDetails.ChannelDetails fetchChannel(String slug) throws UnsupportedEncodingException, IOException { public ArtifactDetails.ChannelDetails fetchChannel(String slug) throws IOException {
URL url = new URL("http", host, API_PREFIX_CHANNEL + slug + "/"); URL url = new URL("http", host, API_PREFIX_CHANNEL + slug + "/");
InputStreamReader reader = null; InputStreamReader reader = null;

View file

@ -11,21 +11,21 @@ import org.junit.Test;
@Ignore ("useful tests, but not necessary to run on each compile") @Ignore ("useful tests, but not necessary to run on each compile")
public class BukkitDLUpdaterServiceTest { public class BukkitDLUpdaterServiceTest {
@Test(expected=IOException.class) @Test(expected=IOException.class)
public void testHostNotFound() throws UnsupportedEncodingException, IOException { public void testHostNotFound() throws IOException {
BukkitDLUpdaterService service = new BukkitDLUpdaterService("404.example.org"); BukkitDLUpdaterService service = new BukkitDLUpdaterService("404.example.org");
service.fetchArtifact("rb"); service.fetchArtifact("rb");
} }
@Test(expected=FileNotFoundException.class) @Test(expected=FileNotFoundException.class)
public void testArtifactNotFound() throws UnsupportedEncodingException, IOException { public void testArtifactNotFound() throws IOException {
BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org"); BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org");
service.fetchArtifact("meep"); service.fetchArtifact("meep");
} }
@Test @Test
public void testArtifactExists() throws UnsupportedEncodingException, IOException { public void testArtifactExists() throws IOException {
BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org"); BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org");
assertNotNull(service.fetchArtifact("latest-dev")); assertNotNull(service.fetchArtifact("latest-dev"));