Merge pull request #751 from Aaron1011/update-spongeapi

git@github.com:Aaron1011/PlotSquared.gitUpdate for SpongeAPI changes
This commit is contained in:
Jesse Boyd 2015-11-26 14:45:39 +11:00
commit ef327434cd
4 changed files with 188 additions and 191 deletions

View File

@ -80,6 +80,7 @@ import com.plotsquared.sponge.util.SpongeUtil;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler; import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
import org.spongepowered.api.world.WorldBuilder;
/** /**
* Created by robin on 01/11/2014 * Created by robin on 01/11/2014
@ -88,60 +89,60 @@ import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit") @Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit")
public class SpongeMain implements IPlotMain, PluginContainer { public class SpongeMain implements IPlotMain, PluginContainer {
public static SpongeMain THIS; public static SpongeMain THIS;
@Inject @Inject
private Logger logger; private Logger logger;
@Inject @Inject
private Game game; private Game game;
private Server server; private Server server;
private GameProfileResolver resolver; private GameProfileResolver resolver;
private WorldModify modify; private WorldModify modify;
private Object plugin; private Object plugin;
// stuff // // stuff //
public Logger getLogger() { public Logger getLogger() {
return logger; return logger;
} }
public Game getGame() { public Game getGame() {
return game; return game;
} }
public Server getServer() { public Server getServer() {
return server; return server;
} }
public GameProfileResolver getResolver() { public GameProfileResolver getResolver() {
return resolver; return resolver;
} }
public Object getPlugin() { public Object getPlugin() {
return plugin; return plugin;
} }
public Text getText(final String m) { public Text getText(final String m) {
return Texts.of(m); return Texts.of(m);
} }
public Translatable getTranslation(final String m) { public Translatable getTranslation(final String m) {
return new Translatable() { return new Translatable() {
@Override @Override
public Translation getTranslation() { public Translation getTranslation() {
return new Translation() { return new Translation() {
@Override @Override
public String getId() { public String getId() {
return m; return m;
} }
@Override @Override
public String get(final Locale l, final Object... args) { public String get(final Locale l, final Object... args) {
return m; return m;
} }
@Override @Override
public String get(final Locale l) { public String get(final Locale l) {
return m; return m;
@ -150,11 +151,11 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
}; };
} }
private final PlotBlock NULL_BLOCK = new PlotBlock((short) 0, (byte) 0); private final PlotBlock NULL_BLOCK = new PlotBlock((short) 0, (byte) 0);
private BlockState[][] blockMap; private BlockState[][] blockMap;
private Map<BlockState, PlotBlock> blockMapReverse; private Map<BlockState, PlotBlock> blockMapReverse;
public BlockState getBlockState(final PlotBlock block) { public BlockState getBlockState(final PlotBlock block) {
if (blockMap[block.id] == null) { if (blockMap[block.id] == null) {
log("UNKNOWN BLOCK: " + block.toString()); log("UNKNOWN BLOCK: " + block.toString());
@ -165,15 +166,15 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
return blockMap[block.id][block.data]; return blockMap[block.id][block.data];
} }
public BlockState getBlockState(final int id) { public BlockState getBlockState(final int id) {
return blockMap[id][0]; return blockMap[id][0];
} }
public Collection<BlockState> getAllStates() { public Collection<BlockState> getAllStates() {
return blockMapReverse.keySet(); return blockMapReverse.keySet();
} }
public PlotBlock getPlotBlock(final BlockState state) { public PlotBlock getPlotBlock(final BlockState state) {
final PlotBlock val = blockMapReverse.get(state); final PlotBlock val = blockMapReverse.get(state);
if (val == null) { if (val == null) {
@ -181,25 +182,25 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
return val; return val;
} }
///////// /////////
////////////////////// SPONGE PLUGIN REGISTRATION //////////////////// ////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
@Override @Override
public String getId() { public String getId() {
return "PlotSquared"; return "PlotSquared";
} }
@Override @Override
public Object getInstance() { public Object getInstance() {
return THIS; return THIS;
} }
@Override @Override
public String getName() { public String getName() {
return "PlotSquared"; return "PlotSquared";
} }
@Override @Override
public String getVersion() { public String getVersion() {
final int[] version = PS.get().getVersion(); final int[] version = PS.get().getVersion();
@ -211,35 +212,35 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
return result; return result;
} }
/////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////
///////////////////// ON ENABLE ///////////////////// ///////////////////// ON ENABLE /////////////////////
@Listener @Listener
public void init(final GameInitializationEvent event) { public void init(final GameInitializationEvent event) {
log("P^2 INIT"); log("P^2 INIT");
} }
@Listener @Listener
public void onInit(final GamePreInitializationEvent event) { public void onInit(final GamePreInitializationEvent event) {
log("P^2 PRE INIT"); log("P^2 PRE INIT");
} }
@Listener @Listener
public void onServerAboutToStart(final GameAboutToStartServerEvent event) { public void onServerAboutToStart(final GameAboutToStartServerEvent event) {
log("P^2 ABOUT START"); log("P^2 ABOUT START");
THIS = this; THIS = this;
// //
resolver = game.getServiceManager().provide(GameProfileResolver.class).get(); resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
plugin = this; plugin = this;
server = game.getServer(); server = game.getServer();
// //
new PS(this, "Sponge"); new PS(this, "Sponge");
registerBlocks(); registerBlocks();
final ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds"); final ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
if (worldSection != null) { if (worldSection != null) {
for (final String world : worldSection.getKeys(false)) { for (final String world : worldSection.getKeys(false)) {
@ -247,7 +248,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
} }
} }
public World createWorldFromConfig(final String world) { public World createWorldFromConfig(final String world) {
final SpongeBasicGen generator = new SpongeBasicGen(world); final SpongeBasicGen generator = new SpongeBasicGen(world);
final PlotWorld plotworld = generator.getNewPlotWorld(world); final PlotWorld plotworld = generator.getNewPlotWorld(world);
@ -263,7 +264,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
case 0: { case 0: {
modify = new WorldModify(generator, false); modify = new WorldModify(generator, false);
game.getRegistry().registerWorldGeneratorModifier(modify); game.getRegistry().registerWorldGeneratorModifier(modify);
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD) final Optional<World> builder = game.getRegistry().createBuilder(WorldBuilder.class).name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.FLAT).usesMapFeatures(false).generatorModifiers(modify).build(); .generator(GeneratorTypes.FLAT).usesMapFeatures(false).generatorModifiers(modify).build();
return builder.get(); return builder.get();
} }
@ -271,13 +272,13 @@ public class SpongeMain implements IPlotMain, PluginContainer {
default: { default: {
modify = new WorldModify(generator, true); modify = new WorldModify(generator, true);
game.getRegistry().registerWorldGeneratorModifier(modify); game.getRegistry().registerWorldGeneratorModifier(modify);
final Optional<World> builder = game.getRegistry().createWorldBuilder().name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD) final Optional<World> builder = game.getRegistry().createBuilder(WorldBuilder.class).name(world).enabled(true).loadsOnStartup(true).keepsSpawnLoaded(true).dimensionType(DimensionTypes.OVERWORLD)
.generator(GeneratorTypes.OVERWORLD).usesMapFeatures(false).generatorModifiers(modify).build(); .generator(GeneratorTypes.OVERWORLD).usesMapFeatures(false).generatorModifiers(modify).build();
return builder.get(); return builder.get();
} }
} }
} }
public void registerBlock(final PlotBlock block, final BlockState state) { public void registerBlock(final PlotBlock block, final BlockState state) {
final BlockState[] val = blockMap[block.id]; final BlockState[] val = blockMap[block.id];
if (val == null) { if (val == null) {
@ -290,7 +291,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
blockMap[block.id][block.data] = state; blockMap[block.id][block.data] = state;
blockMapReverse.put(state, block); blockMapReverse.put(state, block);
} }
public PlotBlock registerBlock(final BlockState state) { public PlotBlock registerBlock(final BlockState state) {
final PlotBlock val = blockMapReverse.get(state); final PlotBlock val = blockMapReverse.get(state);
if (val != null) { if (val != null) {
@ -307,23 +308,23 @@ public class SpongeMain implements IPlotMain, PluginContainer {
registerBlock(block, state); registerBlock(block, state);
return block; return block;
} }
public void registerBlocks() { public void registerBlocks() {
blockMap = new BlockState[256][]; blockMap = new BlockState[256][];
blockMapReverse = new HashMap<BlockState, PlotBlock>(); blockMapReverse = new HashMap<BlockState, PlotBlock>();
final HashMap<String, BlockState> states = new HashMap<>(); final HashMap<String, BlockState> states = new HashMap<>();
PS.get().copyFile("ids.txt", "config"); PS.get().copyFile("ids.txt", "config");
PS.get().copyFile("data.txt", "config"); PS.get().copyFile("data.txt", "config");
try { try {
final File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt"); final File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt");
final List<String> id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8); final List<String> id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8);
final File data_file = new File(getDirectory(), "config" + File.separator + "data.txt"); final File data_file = new File(getDirectory(), "config" + File.separator + "data.txt");
final List<String> data_lines = Files.readAllLines(data_file.toPath(), StandardCharsets.UTF_8); final List<String> data_lines = Files.readAllLines(data_file.toPath(), StandardCharsets.UTF_8);
Field[] fields = BlockTypes.class.getDeclaredFields(); Field[] fields = BlockTypes.class.getDeclaredFields();
for (final Field field : fields) { for (final Field field : fields) {
final BlockType type = (BlockType) field.get(null); final BlockType type = (BlockType) field.get(null);
@ -350,7 +351,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
} catch (final Throwable e) {} } catch (final Throwable e) {}
} }
PlotBlock block = null; PlotBlock block = null;
for (int i = 0; i < id_lines.size(); i++) { for (int i = 0; i < id_lines.size(); i++) {
final String line = id_lines.get(i).trim(); final String line = id_lines.get(i).trim();
@ -380,7 +381,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
e.printStackTrace(); e.printStackTrace();
} }
} }
@Override @Override
public void log(String message) { public void log(String message) {
message = C.format(message, C.replacements); message = C.format(message, C.replacements);
@ -393,23 +394,23 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
server.getConsole().sendMessage(Texts.of(message)); server.getConsole().sendMessage(Texts.of(message));
} }
@Override @Override
public File getDirectory() { public File getDirectory() {
return new File("mods/PlotSquared"); return new File("mods/PlotSquared");
} }
@Override @Override
public File getWorldContainer() { public File getWorldContainer() {
return new File("world"); return new File("world");
} }
@Override @Override
public void disable() { public void disable() {
PS.get().disable(); PS.get().disable();
THIS = null; THIS = null;
} }
@Override @Override
public int[] getPluginVersion() { public int[] getPluginVersion() {
final PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get(); final PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get();
@ -418,7 +419,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
final String[] split = version.split("\\."); final String[] split = version.split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 }; return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
} }
@Override @Override
public int[] getServerVersion() { public int[] getServerVersion() {
log("Checking minecraft version: Sponge: "); log("Checking minecraft version: Sponge: ");
@ -426,12 +427,12 @@ public class SpongeMain implements IPlotMain, PluginContainer {
final String[] split = version.split("\\."); final String[] split = version.split("\\.");
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 }; return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
} }
@Override @Override
public InventoryUtil initInventoryUtil() { public InventoryUtil initInventoryUtil() {
return new SpongeInventoryUtil(); return new SpongeInventoryUtil();
} }
@Override @Override
public SpongeGeneratorWrapper getGenerator(final String world, final String name) { public SpongeGeneratorWrapper getGenerator(final String world, final String name) {
if (name == null) { if (name == null) {
@ -443,82 +444,82 @@ public class SpongeMain implements IPlotMain, PluginContainer {
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
} }
} }
@Override @Override
public EconHandler getEconomyHandler() { public EconHandler getEconomyHandler() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
// Nothing like Vault exists yet // Nothing like Vault exists yet
return new SpongeEconHandler(); return new SpongeEconHandler();
} }
@Override @Override
public BlockManager initBlockManager() { public BlockManager initBlockManager() {
return new SpongeBlockManager(); return new SpongeBlockManager();
} }
@Override @Override
public EventUtil initEventUtil() { public EventUtil initEventUtil() {
return new SpongeEventUtil(); return new SpongeEventUtil();
} }
@Override @Override
public ChunkManager initChunkManager() { public ChunkManager initChunkManager() {
return new SpongeChunkManager(); return new SpongeChunkManager();
} }
@Override @Override
public SetupUtils initSetupUtils() { public SetupUtils initSetupUtils() {
return new SpongeSetupUtils(); return new SpongeSetupUtils();
} }
@Override @Override
public HybridUtils initHybridUtils() { public HybridUtils initHybridUtils() {
return new SpongeHybridUtils(); return new SpongeHybridUtils();
} }
@Override @Override
public SchematicHandler initSchematicHandler() { public SchematicHandler initSchematicHandler() {
return new SpongeSchematicHandler(); return new SpongeSchematicHandler();
} }
@Override @Override
public TaskManager getTaskManager() { public TaskManager getTaskManager() {
return new SpongeTaskManager(); return new SpongeTaskManager();
} }
@Override @Override
public void runEntityTask() { public void runEntityTask() {
new KillRoadMobs().run(); new KillRoadMobs().run();
} }
@Override @Override
public void registerCommands() { public void registerCommands() {
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" }); getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" });
} }
@Override @Override
public void registerPlayerEvents() { public void registerPlayerEvents() {
game.getEventManager().registerListeners(this, new MainListener()); game.getEventManager().registerListeners(this, new MainListener());
} }
@Override @Override
public void registerInventoryEvents() { public void registerInventoryEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log("registerInventoryEvents is not implemented!"); log("registerInventoryEvents is not implemented!");
} }
@Override @Override
public void registerPlotPlusEvents() { public void registerPlotPlusEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log("registerPlotPlusEvents is not implemented!"); log("registerPlotPlusEvents is not implemented!");
} }
@Override @Override
public void registerForceFieldEvents() { public void registerForceFieldEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log("registerForceFieldEvents is not implemented!"); log("registerForceFieldEvents is not implemented!");
} }
@Override @Override
public boolean initWorldEdit() { public boolean initWorldEdit() {
try { try {
@ -529,7 +530,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
return false; return false;
} }
} }
@Override @Override
public UUIDHandlerImplementation initUUIDHandler() { public UUIDHandlerImplementation initUUIDHandler() {
UUIDWrapper wrapper; UUIDWrapper wrapper;
@ -540,37 +541,37 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
return new SpongeUUIDHandler(wrapper); return new SpongeUUIDHandler(wrapper);
} }
@Override @Override
public boolean initPlotMeConverter() { public boolean initPlotMeConverter() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
PS.log("initPlotMeConverter NOT IMPLEMENTED YET"); PS.log("initPlotMeConverter NOT IMPLEMENTED YET");
return false; return false;
} }
@Override @Override
public void unregister(final PlotPlayer player) { public void unregister(final PlotPlayer player) {
SpongeUtil.removePlayer(player.getName()); SpongeUtil.removePlayer(player.getName());
} }
@Override @Override
public void registerChunkProcessor() { public void registerChunkProcessor() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
PS.log("registerChunkProcessor NOT IMPLEMENTED YET"); PS.log("registerChunkProcessor NOT IMPLEMENTED YET");
} }
@Override @Override
public void registerWorldEvents() { public void registerWorldEvents() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
PS.log("registerWorldEvents NOT IMPLEMENTED YET"); PS.log("registerWorldEvents NOT IMPLEMENTED YET");
} }
@Override @Override
public String getServerName() { public String getServerName() {
// TODO FIXME // TODO FIXME
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
} }
@Override @Override
public void startMetrics() { public void startMetrics() {
try { try {
@ -581,17 +582,17 @@ public class SpongeMain implements IPlotMain, PluginContainer {
log(C.PREFIX.s() + "&cFailed to load up metrics."); log(C.PREFIX.s() + "&cFailed to load up metrics.");
} }
} }
@Override @Override
public void setGenerator(final String world) { public void setGenerator(final String world) {
// TODO THIS IS DONE DURING STARTUP ALREADY // TODO THIS IS DONE DURING STARTUP ALREADY
} }
@Override @Override
public AbstractTitle initTitleManager() { public AbstractTitle initTitleManager() {
return new SpongeTitleManager(); return new SpongeTitleManager();
} }
@Override @Override
public PlotPlayer wrapPlayer(final Object obj) { public PlotPlayer wrapPlayer(final Object obj) {
if (obj instanceof Player) { if (obj instanceof Player) {
@ -607,12 +608,12 @@ public class SpongeMain implements IPlotMain, PluginContainer {
} }
return null; return null;
} }
@Override @Override
public String getNMSPackage() { public String getNMSPackage() {
return "1_8_R3"; return "1_8_R3";
} }
@Override @Override
public ChatManager<?> initChatManager() { public ChatManager<?> initChatManager() {
return new SpongeChatManager(); return new SpongeChatManager();

View File

@ -6,9 +6,7 @@ import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.ItemType;
import org.spongepowered.api.item.ItemTypes; import org.spongepowered.api.item.ItemTypes;
import org.spongepowered.api.item.inventory.Carrier; import org.spongepowered.api.item.inventory.Carrier;
import org.spongepowered.api.item.inventory.Inventories;
import org.spongepowered.api.item.inventory.ItemStack; import org.spongepowered.api.item.inventory.ItemStack;
import org.spongepowered.api.item.inventory.ItemStackBuilder;
import org.spongepowered.api.item.inventory.custom.CustomInventory; import org.spongepowered.api.item.inventory.custom.CustomInventory;
import org.spongepowered.api.item.inventory.property.SlotIndex; import org.spongepowered.api.item.inventory.property.SlotIndex;
import org.spongepowered.api.item.inventory.type.CarriedInventory; import org.spongepowered.api.item.inventory.type.CarriedInventory;
@ -21,20 +19,20 @@ import com.plotsquared.sponge.SpongeMain;
import com.plotsquared.sponge.object.SpongePlayer; import com.plotsquared.sponge.object.SpongePlayer;
public class SpongeInventoryUtil extends InventoryUtil { public class SpongeInventoryUtil extends InventoryUtil {
public ItemStackBuilder builder; public ItemStack.Builder builder;
public SpongeInventoryUtil() { public SpongeInventoryUtil() {
builder = SpongeMain.THIS.getGame().getRegistry().createItemBuilder(); builder = SpongeMain.THIS.getGame().getRegistry().createBuilder(ItemStack.Builder.class);
} }
@Override @Override
public void open(final PlotInventory inv) { public void open(final PlotInventory inv) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
final SpongePlayer sp = (SpongePlayer) inv.player; final SpongePlayer sp = (SpongePlayer) inv.player;
final Player player = sp.player; final Player player = sp.player;
final CustomInventory inventory = Inventories.customInventoryBuilder().name(SpongeMain.THIS.getTranslation(inv.getTitle())).size(inv.size).build(); final CustomInventory inventory = SpongeMain.THIS.getGame().getRegistry().createBuilder(CustomInventory.Builder.class).name(SpongeMain.THIS.getTranslation(inv.getTitle()).getTranslation()).size(inv.size).build();
final PlotItemStack[] items = inv.getItems(); final PlotItemStack[] items = inv.getItems();
for (int i = 0; i < (inv.size * 9); i++) { for (int i = 0; i < (inv.size * 9); i++) {
final PlotItemStack item = items[i]; final PlotItemStack item = items[i];
@ -45,12 +43,12 @@ public class SpongeInventoryUtil extends InventoryUtil {
inv.player.setMeta("inventory", inv); inv.player.setMeta("inventory", inv);
player.openInventory(inventory); player.openInventory(inventory);
} }
public ItemStack getItem(final PlotItemStack item) { public ItemStack getItem(final PlotItemStack item) {
// FIXME item type, item data, item name, item lore // FIXME item type, item data, item name, item lore
return builder.itemType(ItemTypes.SPONGE).quantity(item.amount).build(); return builder.itemType(ItemTypes.SPONGE).quantity(item.amount).build();
} }
@Override @Override
public void close(final PlotInventory inv) { public void close(final PlotInventory inv) {
if (!inv.isOpen()) { if (!inv.isOpen()) {
@ -60,7 +58,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
final SpongePlayer sp = (SpongePlayer) inv.player; final SpongePlayer sp = (SpongePlayer) inv.player;
sp.player.closeInventory(); sp.player.closeInventory();
} }
@Override @Override
public void setItem(final PlotInventory inv, final int index, final PlotItemStack item) { public void setItem(final PlotInventory inv, final int index, final PlotItemStack item) {
if (!inv.isOpen()) { if (!inv.isOpen()) {
@ -70,9 +68,9 @@ public class SpongeInventoryUtil extends InventoryUtil {
final Player player = sp.player; final Player player = sp.player;
player.getOpenInventory().get(); player.getOpenInventory().get();
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
} }
public PlotItemStack getItem(final ItemStack item) { public PlotItemStack getItem(final ItemStack item) {
if (item == null) { if (item == null) {
return null; return null;
@ -83,18 +81,18 @@ public class SpongeInventoryUtil extends InventoryUtil {
// TODO name / lore // TODO name / lore
return new PlotItemStack(id, amount, null); return new PlotItemStack(id, amount, null);
} }
@Override @Override
public PlotItemStack[] getItems(final PlotPlayer player) { public PlotItemStack[] getItems(final PlotPlayer player) {
final SpongePlayer sp = (SpongePlayer) player; final SpongePlayer sp = (SpongePlayer) player;
sp.player.getInventory(); sp.player.getInventory();
new ArrayList<PlotItemStack>(); new ArrayList<PlotItemStack>();
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
// return list.toArray(); // return list.toArray();
} }
@Override @Override
public boolean isOpen(final PlotInventory inv) { public boolean isOpen(final PlotInventory inv) {
if (!inv.isOpen()) { if (!inv.isOpen()) {
@ -108,5 +106,5 @@ public class SpongeInventoryUtil extends InventoryUtil {
} }
return false; return false;
} }
} }

View File

@ -52,118 +52,117 @@ import ninja.leaping.configurate.loader.ConfigurationLoader;
import org.spongepowered.api.Game; import org.spongepowered.api.Game;
import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.plugin.PluginContainer;
import org.spongepowered.api.service.scheduler.Task; import org.spongepowered.api.service.scheduler.Task;
import org.spongepowered.api.service.scheduler.TaskBuilder;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
public class SpongeMetrics { public class SpongeMetrics {
/** /**
* The current revision number * The current revision number
*/ */
private final static int REVISION = 7; private final static int REVISION = 7;
/** /**
* The base url of the metrics domain * The base url of the metrics domain
*/ */
private static final String BASE_URL = "http://report.mcstats.org"; private static final String BASE_URL = "http://report.mcstats.org";
/** /**
* The url used to report a server's status * The url used to report a server's status
*/ */
private static final String REPORT_URL = "/plugin/%s"; private static final String REPORT_URL = "/plugin/%s";
/** /**
* Interval of time to ping (in minutes) * Interval of time to ping (in minutes)
*/ */
private static final int PING_INTERVAL = 15; private static final int PING_INTERVAL = 15;
/** /**
* The game data is being sent for * The game data is being sent for
*/ */
private final Game game; private final Game game;
/** /**
* The plugin this metrics submits for * The plugin this metrics submits for
*/ */
private final PluginContainer plugin; private final PluginContainer plugin;
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
private CommentedConfigurationNode config; private CommentedConfigurationNode config;
/** /**
* The configuration loader * The configuration loader
*/ */
private ConfigurationLoader<CommentedConfigurationNode> configurationLoader; private ConfigurationLoader<CommentedConfigurationNode> configurationLoader;
/** /**
* The plugin configuration file * The plugin configuration file
*/ */
private File configurationFile; private File configurationFile;
/** /**
* Unique server id * Unique server id
*/ */
private String guid; private String guid;
/** /**
* Debug mode * Debug mode
*/ */
private boolean debug; private boolean debug;
/** /**
* Lock for synchronization * Lock for synchronization
*/ */
private final Object optOutLock = new Object(); private final Object optOutLock = new Object();
/** /**
* The scheduled task * The scheduled task
*/ */
private volatile Task task = null; private volatile Task task = null;
@Inject @Inject
public SpongeMetrics(final Game game, final PluginContainer plugin) throws IOException { public SpongeMetrics(final Game game, final PluginContainer plugin) throws IOException {
if (plugin == null) { if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null"); throw new IllegalArgumentException("Plugin cannot be null");
} }
this.game = game; this.game = game;
this.plugin = plugin; this.plugin = plugin;
loadConfiguration(); loadConfiguration();
} }
/** /**
* Loads the configuration * Loads the configuration
*/ */
private void loadConfiguration() { private void loadConfiguration() {
configurationFile = getConfigFile(); configurationFile = getConfigFile();
configurationLoader = HoconConfigurationLoader.builder().setFile(configurationFile).build(); configurationLoader = HoconConfigurationLoader.builder().setFile(configurationFile).build();
try { try {
if (!configurationFile.exists()) { if (!configurationFile.exists()) {
configurationFile.createNewFile(); configurationFile.createNewFile();
config = configurationLoader.load(); config = configurationLoader.load();
config.setComment("This contains settings for MCStats: http://mcstats.org"); config.setComment("This contains settings for MCStats: http://mcstats.org");
config.getNode("mcstats.guid").setValue(UUID.randomUUID().toString()); config.getNode("mcstats.guid").setValue(UUID.randomUUID().toString());
config.getNode("mcstats.opt-out").setValue(false); config.getNode("mcstats.opt-out").setValue(false);
config.getNode("mcstats.debug").setValue(false); config.getNode("mcstats.debug").setValue(false);
configurationLoader.save(config); configurationLoader.save(config);
} else { } else {
config = configurationLoader.load(); config = configurationLoader.load();
} }
guid = config.getNode("mcstats.guid").getString(); guid = config.getNode("mcstats.guid").getString();
debug = config.getNode("mcstats.debug").getBoolean(); debug = config.getNode("mcstats.debug").getBoolean();
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the * Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200 * initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
@ -177,18 +176,18 @@ public class SpongeMetrics {
if (isOptOut()) { if (isOptOut()) {
return false; return false;
} }
// Is metrics already running? // Is metrics already running?
if (task != null) { if (task != null) {
return true; return true;
} }
// Begin hitting the server with glorious data // Begin hitting the server with glorious data
final TaskBuilder builder = game.getScheduler().createTaskBuilder(); final Task.Builder builder = game.getScheduler().createTaskBuilder();
builder.async().interval(PING_INTERVAL, TimeUnit.MINUTES).execute(new Runnable() { builder.async().interval(PING_INTERVAL, TimeUnit.MINUTES).execute(new Runnable() {
private boolean firstPost = true; private boolean firstPost = true;
@Override @Override
public void run() { public void run() {
try { try {
@ -200,12 +199,12 @@ public class SpongeMetrics {
task = null; task = null;
} }
} }
// We use the inverse of firstPost because if it is the first time we are posting, // We use the inverse of firstPost because if it is the first time we are posting,
// it is not a interval ping, so it evaluates to FALSE // it is not a interval ping, so it evaluates to FALSE
// Each time thereafter it will evaluate to TRUE, i.e PING! // Each time thereafter it will evaluate to TRUE, i.e PING!
postPlugin(!firstPost); postPlugin(!firstPost);
// After the first post we set firstPost to false // After the first post we set firstPost to false
// Each post thereafter will be a ping // Each post thereafter will be a ping
firstPost = false; firstPost = false;
@ -219,7 +218,7 @@ public class SpongeMetrics {
return true; return true;
} }
} }
/** /**
* Has the server owner denied plugin metrics? * Has the server owner denied plugin metrics?
* *
@ -228,11 +227,11 @@ public class SpongeMetrics {
public boolean isOptOut() { public boolean isOptOut() {
synchronized (optOutLock) { synchronized (optOutLock) {
loadConfiguration(); loadConfiguration();
return config.getNode("mcstats.opt-out").getBoolean(); return config.getNode("mcstats.opt-out").getBoolean();
} }
} }
/** /**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task. * Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
* *
@ -246,14 +245,14 @@ public class SpongeMetrics {
config.getNode("mcstats.opt-out").setValue(false); config.getNode("mcstats.opt-out").setValue(false);
configurationLoader.save(config); configurationLoader.save(config);
} }
// Enable Task, if it is not running // Enable Task, if it is not running
if (task == null) { if (task == null) {
start(); start();
} }
} }
} }
/** /**
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task. * Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
* *
@ -267,7 +266,7 @@ public class SpongeMetrics {
config.getNode("mcstats.opt-out").setValue(true); config.getNode("mcstats.opt-out").setValue(true);
configurationLoader.save(config); configurationLoader.save(config);
} }
// Disable Task, if it is running // Disable Task, if it is running
if (task != null) { if (task != null) {
task.cancel(); task.cancel();
@ -275,7 +274,7 @@ public class SpongeMetrics {
} }
} }
} }
/** /**
* Gets the File object of the config file that should be used to store data such as the GUID and opt-out status * Gets the File object of the config file that should be used to store data such as the GUID and opt-out status
* *
@ -284,10 +283,10 @@ public class SpongeMetrics {
public File getConfigFile() { public File getConfigFile() {
// TODO configDir // TODO configDir
final File configFolder = new File("config"); final File configFolder = new File("config");
return new File(configFolder, "PluginMetrics.conf"); return new File(configFolder, "PluginMetrics.conf");
} }
/** /**
* Generic method that posts a plugin to the metrics website * Generic method that posts a plugin to the metrics website
* *
@ -301,52 +300,52 @@ public class SpongeMetrics {
// TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1 // TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion()); final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
final int playersOnline = game.getServer().getOnlinePlayers().size(); final int playersOnline = game.getServer().getOnlinePlayers().size();
// END server software specific section -- all code below does not use any code outside of this class / Java // END server software specific section -- all code below does not use any code outside of this class / Java
// Construct the post data // Construct the post data
final StringBuilder json = new StringBuilder(1024); final StringBuilder json = new StringBuilder(1024);
json.append('{'); json.append('{');
// The plugin's description file containg all of the plugin data such as name, version, author, etc // The plugin's description file containg all of the plugin data such as name, version, author, etc
appendJSONPair(json, "guid", guid); appendJSONPair(json, "guid", guid);
appendJSONPair(json, "plugin_version", pluginVersion); appendJSONPair(json, "plugin_version", pluginVersion);
appendJSONPair(json, "server_version", serverVersion); appendJSONPair(json, "server_version", serverVersion);
appendJSONPair(json, "players_online", Integer.toString(playersOnline)); appendJSONPair(json, "players_online", Integer.toString(playersOnline));
// New data as of R6 // New data as of R6
final String osname = System.getProperty("os.name"); final String osname = System.getProperty("os.name");
String osarch = System.getProperty("os.arch"); String osarch = System.getProperty("os.arch");
final String osversion = System.getProperty("os.version"); final String osversion = System.getProperty("os.version");
final String java_version = System.getProperty("java.version"); final String java_version = System.getProperty("java.version");
final int coreCount = Runtime.getRuntime().availableProcessors(); final int coreCount = Runtime.getRuntime().availableProcessors();
// normalize os arch .. amd64 -> x86_64 // normalize os arch .. amd64 -> x86_64
if (osarch.equals("amd64")) { if (osarch.equals("amd64")) {
osarch = "x86_64"; osarch = "x86_64";
} }
appendJSONPair(json, "osname", osname); appendJSONPair(json, "osname", osname);
appendJSONPair(json, "osarch", osarch); appendJSONPair(json, "osarch", osarch);
appendJSONPair(json, "osversion", osversion); appendJSONPair(json, "osversion", osversion);
appendJSONPair(json, "cores", Integer.toString(coreCount)); appendJSONPair(json, "cores", Integer.toString(coreCount));
appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0"); appendJSONPair(json, "auth_mode", onlineMode ? "1" : "0");
appendJSONPair(json, "java_version", java_version); appendJSONPair(json, "java_version", java_version);
// If we're pinging, append it // If we're pinging, append it
if (isPing) { if (isPing) {
appendJSONPair(json, "ping", "1"); appendJSONPair(json, "ping", "1");
} }
// close json // close json
json.append('}'); json.append('}');
// Create the url // Create the url
final URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName))); final URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
// Connect to the website // Connect to the website
URLConnection connection; URLConnection connection;
// Mineshafter creates a socks proxy, so we can safely bypass it // Mineshafter creates a socks proxy, so we can safely bypass it
// It does not reroute POST requests so we need to go around it // It does not reroute POST requests so we need to go around it
if (isMineshafterPresent()) { if (isMineshafterPresent()) {
@ -354,10 +353,10 @@ public class SpongeMetrics {
} else { } else {
connection = url.openConnection(); connection = url.openConnection();
} }
final byte[] uncompressed = json.toString().getBytes(); final byte[] uncompressed = json.toString().getBytes();
final byte[] compressed = gzip(json.toString()); final byte[] compressed = gzip(json.toString());
// Headers // Headers
connection.addRequestProperty("User-Agent", "MCStats/" + REVISION); connection.addRequestProperty("User-Agent", "MCStats/" + REVISION);
connection.addRequestProperty("Content-Type", "application/json"); connection.addRequestProperty("Content-Type", "application/json");
@ -365,37 +364,37 @@ public class SpongeMetrics {
connection.addRequestProperty("Content-Length", Integer.toString(compressed.length)); connection.addRequestProperty("Content-Length", Integer.toString(compressed.length));
connection.addRequestProperty("Accept", "application/json"); connection.addRequestProperty("Accept", "application/json");
connection.addRequestProperty("Connection", "close"); connection.addRequestProperty("Connection", "close");
connection.setDoOutput(true); connection.setDoOutput(true);
if (debug) { if (debug) {
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
} }
// Write the data // Write the data
final OutputStream os = connection.getOutputStream(); final OutputStream os = connection.getOutputStream();
os.write(compressed); os.write(compressed);
os.flush(); os.flush();
// Now read the response // Now read the response
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String response = reader.readLine(); String response = reader.readLine();
// close resources // close resources
os.close(); os.close();
reader.close(); reader.close();
if ((response == null) || response.startsWith("ERR") || response.startsWith("7")) { if ((response == null) || response.startsWith("ERR") || response.startsWith("7")) {
if (response == null) { if (response == null) {
response = "null"; response = "null";
} else if (response.startsWith("7")) { } else if (response.startsWith("7")) {
response = response.substring(response.startsWith("7,") ? 2 : 1); response = response.substring(response.startsWith("7,") ? 2 : 1);
} }
throw new IOException(response); throw new IOException(response);
} }
} }
/** /**
* GZip compress a string of bytes * GZip compress a string of bytes
* *
@ -405,7 +404,7 @@ public class SpongeMetrics {
public static byte[] gzip(final String input) { public static byte[] gzip(final String input) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gzos = null; GZIPOutputStream gzos = null;
try { try {
gzos = new GZIPOutputStream(baos); gzos = new GZIPOutputStream(baos);
gzos.write(input.getBytes("UTF-8")); gzos.write(input.getBytes("UTF-8"));
@ -418,10 +417,10 @@ public class SpongeMetrics {
} catch (final IOException ignore) {} } catch (final IOException ignore) {}
} }
} }
return baos.toByteArray(); return baos.toByteArray();
} }
/** /**
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests * Check if mineshafter is present. If it is, we need to bypass it to send POST requests
* *
@ -435,7 +434,7 @@ public class SpongeMetrics {
return false; return false;
} }
} }
/** /**
* Appends a json encoded key/value pair to the given string builder. * Appends a json encoded key/value pair to the given string builder.
* *
@ -446,7 +445,7 @@ public class SpongeMetrics {
*/ */
private static void appendJSONPair(final StringBuilder json, final String key, final String value) throws UnsupportedEncodingException { private static void appendJSONPair(final StringBuilder json, final String key, final String value) throws UnsupportedEncodingException {
boolean isValueNumeric = false; boolean isValueNumeric = false;
try { try {
if (value.equals("0") || !value.endsWith("0")) { if (value.equals("0") || !value.endsWith("0")) {
Double.parseDouble(value); Double.parseDouble(value);
@ -455,21 +454,21 @@ public class SpongeMetrics {
} catch (final NumberFormatException e) { } catch (final NumberFormatException e) {
isValueNumeric = false; isValueNumeric = false;
} }
if (json.charAt(json.length() - 1) != '{') { if (json.charAt(json.length() - 1) != '{') {
json.append(','); json.append(',');
} }
json.append(escapeJSON(key)); json.append(escapeJSON(key));
json.append(':'); json.append(':');
if (isValueNumeric) { if (isValueNumeric) {
json.append(value); json.append(value);
} else { } else {
json.append(escapeJSON(value)); json.append(escapeJSON(value));
} }
} }
/** /**
* Escape a string to create a valid JSON string * Escape a string to create a valid JSON string
* *
@ -478,11 +477,11 @@ public class SpongeMetrics {
*/ */
private static String escapeJSON(final String text) { private static String escapeJSON(final String text) {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append('"'); builder.append('"');
for (int index = 0; index < text.length(); index++) { for (int index = 0; index < text.length(); index++) {
final char chr = text.charAt(index); final char chr = text.charAt(index);
switch (chr) { switch (chr) {
case '"': case '"':
case '\\': case '\\':
@ -512,10 +511,10 @@ public class SpongeMetrics {
} }
} }
builder.append('"'); builder.append('"');
return builder.toString(); return builder.toString();
} }
/** /**
* Encode text as UTF-8 * Encode text as UTF-8
* *
@ -525,5 +524,5 @@ public class SpongeMetrics {
private static String urlEncode(final String text) throws UnsupportedEncodingException { private static String urlEncode(final String text) throws UnsupportedEncodingException {
return URLEncoder.encode(text, "UTF-8"); return URLEncoder.encode(text, "UTF-8");
} }
} }

View File

@ -4,61 +4,60 @@ import java.util.HashMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.spongepowered.api.service.scheduler.Task; import org.spongepowered.api.service.scheduler.Task;
import org.spongepowered.api.service.scheduler.TaskBuilder;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.SpongeMain;
public class SpongeTaskManager extends TaskManager { public class SpongeTaskManager extends TaskManager {
private final AtomicInteger i = new AtomicInteger(); private final AtomicInteger i = new AtomicInteger();
private final HashMap<Integer, Task> tasks = new HashMap<>(); private final HashMap<Integer, Task> tasks = new HashMap<>();
@Override @Override
public int taskRepeat(final Runnable r, final int interval) { public int taskRepeat(final Runnable r, final int interval) {
final int val = i.incrementAndGet(); final int val = i.incrementAndGet();
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
final TaskBuilder built = builder.delayTicks(interval).intervalTicks(interval).execute(r); final Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(r);
final Task task = built.submit(SpongeMain.THIS.getPlugin()); final Task task = built.submit(SpongeMain.THIS.getPlugin());
tasks.put(val, task); tasks.put(val, task);
return val; return val;
} }
@Override @Override
public int taskRepeatAsync(final Runnable r, final int interval) { public int taskRepeatAsync(final Runnable r, final int interval) {
final int val = i.incrementAndGet(); final int val = i.incrementAndGet();
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
final TaskBuilder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(r); final Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(r);
final Task task = built.submit(SpongeMain.THIS.getPlugin()); final Task task = built.submit(SpongeMain.THIS.getPlugin());
tasks.put(val, task); tasks.put(val, task);
return val; return val;
} }
@Override @Override
public void taskAsync(final Runnable r) { public void taskAsync(final Runnable r) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.async().execute(r).submit(SpongeMain.THIS.getPlugin()); builder.async().execute(r).submit(SpongeMain.THIS.getPlugin());
} }
@Override @Override
public void task(final Runnable r) { public void task(final Runnable r) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.execute(r).submit(SpongeMain.THIS.getPlugin()); builder.execute(r).submit(SpongeMain.THIS.getPlugin());
} }
@Override @Override
public void taskLater(final Runnable r, final int delay) { public void taskLater(final Runnable r, final int delay) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin()); builder.delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
} }
@Override @Override
public void taskLaterAsync(final Runnable r, final int delay) { public void taskLaterAsync(final Runnable r, final int delay) {
final TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); final Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
builder.async().delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin()); builder.async().delayTicks(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
} }
@Override @Override
public void cancelTask(final int i) { public void cancelTask(final int i) {
final Task task = tasks.remove(i); final Task task = tasks.remove(i);
@ -66,5 +65,5 @@ public class SpongeTaskManager extends TaskManager {
task.cancel(); task.cancel();
} }
} }
} }