mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
Bulk pending cleanup.
By: Wesley Wolfe <weswolf@aol.com>
This commit is contained in:
parent
bc59fff79a
commit
2a57bac117
24 changed files with 45 additions and 52 deletions
|
@ -67,7 +67,7 @@ public class CraftArt {
|
|||
return null;
|
||||
}
|
||||
|
||||
{
|
||||
static {
|
||||
assert (EnumArt.values().length == 25);
|
||||
assert (Art.values().length == 25);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.bukkit.ChunkSnapshot;
|
|||
|
||||
public class CraftChunk implements Chunk {
|
||||
private WeakReference<net.minecraft.server.Chunk> weakChunk;
|
||||
private WorldServer worldServer;
|
||||
private int x;
|
||||
private int z;
|
||||
private final WorldServer worldServer;
|
||||
private final int x;
|
||||
private final int z;
|
||||
private static final byte[] emptyData = new byte[2048];
|
||||
private static final short[] emptyBlockIDs = new short[4096];
|
||||
private static final byte[] emptySkyLight = new byte[2048];
|
||||
|
|
|
@ -144,7 +144,7 @@ public final class CraftServer implements Server {
|
|||
private YamlConfiguration configuration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
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 PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
|
||||
private final WorldMetadataStore worldMetadata = new WorldMetadataStore();
|
||||
|
@ -353,7 +353,7 @@ public final class CraftServer implements Server {
|
|||
matchedPlayers.add(iterPlayer);
|
||||
break;
|
||||
}
|
||||
if (iterPlayerName.toLowerCase().indexOf(partialName.toLowerCase()) != -1) {
|
||||
if (iterPlayerName.toLowerCase().contains(partialName.toLowerCase())) {
|
||||
// Partial match
|
||||
matchedPlayers.add(iterPlayer);
|
||||
}
|
||||
|
@ -911,7 +911,7 @@ public final class CraftServer implements Server {
|
|||
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());
|
||||
Set<OfflinePlayer> players = new HashSet<OfflinePlayer>();
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
players.add(getOfflinePlayer(files[i].substring(0, files[i].length() - 4)));
|
||||
for (String file : files) {
|
||||
players.add(getOfflinePlayer(file.substring(0, file.length() - 4)));
|
||||
}
|
||||
players.addAll(Arrays.asList(getOnlinePlayers()));
|
||||
|
||||
|
|
|
@ -437,7 +437,7 @@ public class CraftWorld implements World {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -10,8 +10,7 @@ public class TextWrapper {
|
|||
String[] lines = text.split("\n");
|
||||
String lastColor = null;
|
||||
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String line = lines[i];
|
||||
for (String line : lines) {
|
||||
if (lastColor != null) {
|
||||
line = lastColor + line;
|
||||
}
|
||||
|
@ -22,4 +21,4 @@ public class TextWrapper {
|
|||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public class CraftBlockState implements BlockState {
|
|||
private final int z;
|
||||
protected int type;
|
||||
protected MaterialData data;
|
||||
protected byte light;
|
||||
protected final byte light;
|
||||
|
||||
public CraftBlockState(final Block block) {
|
||||
this.world = (CraftWorld) block.getWorld();
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.bukkit.craftbukkit.conversations.ConversationTracker;
|
|||
*/
|
||||
public class CraftConsoleCommandSender extends ServerCommandSender implements ConsoleCommandSender {
|
||||
|
||||
protected ConversationTracker conversationTracker = new ConversationTracker();
|
||||
protected final ConversationTracker conversationTracker = new ConversationTracker();
|
||||
|
||||
protected CraftConsoleCommandSender() {
|
||||
super();
|
||||
|
|
|
@ -16,8 +16,7 @@ public class CraftCreature extends CraftLivingEntity implements Creature {
|
|||
if (target == null) {
|
||||
entity.target = null;
|
||||
} else if (target instanceof CraftLivingEntity) {
|
||||
EntityLiving victim = ((CraftLivingEntity) target).getHandle();
|
||||
entity.target = victim;
|
||||
entity.target = ((CraftLivingEntity) target).getHandle();
|
||||
entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F, true, false, false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
private CraftInventoryPlayer inventory;
|
||||
private CraftInventory enderChest;
|
||||
private final CraftInventory enderChest;
|
||||
protected final PermissibleBase perm = new PermissibleBase(this);
|
||||
private boolean op;
|
||||
private GameMode mode;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
|||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class CraftItem extends CraftEntity implements Item {
|
||||
private EntityItem item;
|
||||
private final EntityItem item;
|
||||
|
||||
public CraftItem(CraftServer server, Entity entity, EntityItem item) {
|
||||
super(server, entity);
|
||||
|
|
|
@ -31,8 +31,7 @@ public class CraftPainting extends CraftEntity implements Painting {
|
|||
public boolean setArt(Art art, boolean force) {
|
||||
EntityPainting painting = this.getHandle();
|
||||
EnumArt oldArt = painting.art;
|
||||
EnumArt newArt = CraftArt.BukkitToNotch(art);
|
||||
painting.art = newArt;
|
||||
painting.art = CraftArt.BukkitToNotch(art);
|
||||
painting.setDirection(painting.direction);
|
||||
if (!force && !painting.survives()) {
|
||||
// Revert painting since it doesn't fit
|
||||
|
|
|
@ -53,9 +53,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
private long firstPlayed = 0;
|
||||
private long lastPlayed = 0;
|
||||
private boolean hasPlayedBefore = false;
|
||||
private ConversationTracker conversationTracker = new ConversationTracker();
|
||||
private Set<String> channels = new HashSet<String>();
|
||||
private Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
|
||||
private final ConversationTracker conversationTracker = new ConversationTracker();
|
||||
private final Set<String> channels = new HashSet<String>();
|
||||
private final Map<String, Player> hiddenPlayers = new MapMaker().softValues().makeMap();
|
||||
private int hash = 0;
|
||||
|
||||
public CraftPlayer(CraftServer server, EntityPlayer entity) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.craftbukkit.CraftServer;
|
|||
import org.bukkit.entity.StorageMinecart;
|
||||
|
||||
public class CraftStorageMinecart extends CraftMinecart implements StorageMinecart {
|
||||
private CraftInventory inventory;
|
||||
private final CraftInventory inventory;
|
||||
|
||||
public CraftStorageMinecart(CraftServer server, EntityMinecart entity) {
|
||||
super(server, entity);
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.help.HelpTopic;
|
|||
*/
|
||||
public class CustomHelpTopic extends HelpTopic {
|
||||
|
||||
private String permissionNode;
|
||||
private final String permissionNode;
|
||||
|
||||
public CustomHelpTopic(String name, String shortText, String fullText, String permissionNode) {
|
||||
this.permissionNode = permissionNode;
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
*/
|
||||
public class CustomIndexHelpTopic extends IndexHelpTopic {
|
||||
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) {
|
||||
super(name, shortText, permission, new HashSet<HelpTopic>(), preamble);
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.help;
|
|||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Collections2;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.command.defaults.VanillaCommand;
|
||||
|
@ -107,7 +106,7 @@ public class SimpleHelpMap implements HelpMap {
|
|||
// Initialize help topics from the server's command map
|
||||
outer: for (Command command : server.getCommandMap().getCommands()) {
|
||||
if (commandInIgnoredPlugin(command, ignoredPlugins)) {
|
||||
continue outer;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Register a topic
|
||||
|
|
|
@ -13,10 +13,10 @@ import net.minecraft.server.Packet100OpenWindow;
|
|||
import net.minecraft.server.Slot;
|
||||
|
||||
public class CraftContainer extends Container {
|
||||
private InventoryView view;
|
||||
private final InventoryView view;
|
||||
private InventoryType cachedType;
|
||||
private String cachedTitle;
|
||||
private int cachedSize;
|
||||
private final int cachedSize;
|
||||
|
||||
public CraftContainer(InventoryView view, int id) {
|
||||
this.view = view;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.inventory.Recipe;
|
|||
import org.bukkit.util.Java15Compat;
|
||||
|
||||
public class CraftInventoryCrafting extends CraftInventory implements CraftingInventory {
|
||||
private IInventory resultInventory;
|
||||
private final IInventory resultInventory;
|
||||
|
||||
public CraftInventoryCrafting(InventoryCrafting inventory, IInventory resultInventory) {
|
||||
super(inventory);
|
||||
|
@ -135,4 +135,4 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
|||
IRecipe recipe = ((InventoryCrafting)getInventory()).currentRecipe;
|
||||
return recipe == null ? null : recipe.toBukkitRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,12 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
}
|
||||
|
||||
static class MinecraftInventory implements IInventory {
|
||||
private ItemStack[] items;
|
||||
private final ItemStack[] items;
|
||||
private int maxStack = MAX_STACK;
|
||||
private List<HumanEntity> viewers;
|
||||
private String title;
|
||||
private final List<HumanEntity> viewers;
|
||||
private final String title;
|
||||
private InventoryType type;
|
||||
private InventoryHolder owner;
|
||||
private final InventoryHolder owner;
|
||||
|
||||
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
|
||||
this(owner, type.getDefaultSize(), type.getDefaultTitle());
|
||||
|
|
|
@ -8,7 +8,8 @@ import org.bukkit.inventory.ItemStack;
|
|||
import net.minecraft.server.InventoryLargeChest;
|
||||
|
||||
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) {
|
||||
super(new InventoryLargeChest("Large chest", left.getInventory(), right.getInventory()));
|
||||
|
|
|
@ -12,9 +12,9 @@ import org.bukkit.inventory.ItemStack;
|
|||
import net.minecraft.server.Container;
|
||||
|
||||
public class CraftInventoryView extends InventoryView {
|
||||
private Container container;
|
||||
private CraftHumanEntity player;
|
||||
private CraftInventory viewing;
|
||||
private final Container container;
|
||||
private final CraftHumanEntity player;
|
||||
private final CraftInventory viewing;
|
||||
|
||||
public CraftInventoryView(HumanEntity player, Inventory viewing, Container container) {
|
||||
// TODO: Should we make sure it really IS a CraftHumanEntity first? And a CraftInventory?
|
||||
|
|
|
@ -286,9 +286,7 @@ public class CraftScheduler implements BukkitScheduler {
|
|||
}
|
||||
|
||||
final ArrayList<BukkitTask> pending = new ArrayList<BukkitTask>();
|
||||
final Iterator<CraftTask> it = runners.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
final CraftTask task = it.next();
|
||||
for (CraftTask task : runners.values()) {
|
||||
if (task.getPeriod() >= -1l) {
|
||||
pending.add(task);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class BukkitDLUpdaterService {
|
|||
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 + "/");
|
||||
InputStreamReader reader = null;
|
||||
|
||||
|
@ -48,9 +48,7 @@ public class BukkitDLUpdaterService {
|
|||
connection.setRequestProperty("User-Agent", getUserAgent());
|
||||
reader = new InputStreamReader(connection.getInputStream());
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
|
||||
ArtifactDetails fromJson = gson.fromJson(reader, ArtifactDetails.class);
|
||||
|
||||
return fromJson;
|
||||
return gson.fromJson(reader, ArtifactDetails.class);
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
|
@ -70,7 +68,7 @@ public class BukkitDLUpdaterService {
|
|||
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 + "/");
|
||||
InputStreamReader reader = null;
|
||||
|
||||
|
|
|
@ -11,21 +11,21 @@ import org.junit.Test;
|
|||
@Ignore ("useful tests, but not necessary to run on each compile")
|
||||
public class BukkitDLUpdaterServiceTest {
|
||||
@Test(expected=IOException.class)
|
||||
public void testHostNotFound() throws UnsupportedEncodingException, IOException {
|
||||
public void testHostNotFound() throws IOException {
|
||||
BukkitDLUpdaterService service = new BukkitDLUpdaterService("404.example.org");
|
||||
|
||||
service.fetchArtifact("rb");
|
||||
}
|
||||
|
||||
@Test(expected=FileNotFoundException.class)
|
||||
public void testArtifactNotFound() throws UnsupportedEncodingException, IOException {
|
||||
public void testArtifactNotFound() throws IOException {
|
||||
BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org");
|
||||
|
||||
service.fetchArtifact("meep");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtifactExists() throws UnsupportedEncodingException, IOException {
|
||||
public void testArtifactExists() throws IOException {
|
||||
BukkitDLUpdaterService service = new BukkitDLUpdaterService("dl.bukkit.org");
|
||||
|
||||
assertNotNull(service.fetchArtifact("latest-dev"));
|
||||
|
|
Loading…
Reference in a new issue