diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java index 91f45bbe4..a00c0eb0a 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.world.World; -import org.spongepowered.api.world.extent.ImmutableBiomeArea; +import org.spongepowered.api.world.extent.ImmutableBiomeVolume; import org.spongepowered.api.world.extent.MutableBlockVolume; import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; @@ -36,7 +36,7 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { } @Override - public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) { + public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeVolume biome) { Vector3i min = terrain.getBlockMin(); int bx = min.getX(); int bz = min.getZ(); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java index 3233905ee..f62375427 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java @@ -1,6 +1,6 @@ package com.plotsquared.sponge.generator; -import com.flowpowered.math.vector.Vector2i; +import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; @@ -13,7 +13,7 @@ import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.world.biome.BiomeGenerationSettings; import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; -import org.spongepowered.api.world.extent.MutableBiomeArea; +import org.spongepowered.api.world.extent.MutableBiomeVolume; import org.spongepowered.api.world.gen.BiomeGenerator; import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; @@ -74,15 +74,15 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this.plotGenerator)); worldGenerator.setBiomeGenerator(new BiomeGenerator() { @Override - public void generateBiomes(MutableBiomeArea buffer) { + public void generateBiomes(MutableBiomeVolume buffer) { PlotArea area = PS.get().getPlotArea(worldName, null); if (area != null) { BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME); - Vector2i min = buffer.getBiomeMin(); - Vector2i max = buffer.getBiomeMax(); + Vector3i min = buffer.getBiomeMin(); + Vector3i max = buffer.getBiomeMax(); for (int x = min.getX(); x <= max.getX(); x++) { - for (int z = min.getY(); z <= max.getY(); z++) { - buffer.setBiome(x, z, biome); + for (int z = min.getZ(); z <= max.getZ(); z++) { + buffer.setBiome(x, 0, z, biome); } } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java index e9475d8d4..b802af441 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeTerrainGen.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.util.block.GenChunk; import org.spongepowered.api.world.World; -import org.spongepowered.api.world.extent.ImmutableBiomeArea; +import org.spongepowered.api.world.extent.ImmutableBiomeVolume; import org.spongepowered.api.world.extent.MutableBlockVolume; import org.spongepowered.api.world.gen.GenerationPopulator; @@ -38,7 +38,7 @@ public class SpongeTerrainGen implements GenerationPopulator, GeneratorWrapper getSuggestions(CommandSource source, String arguments, org.spongepowered.api.world.Location targetPosition) + public List getSuggestions(CommandSource source, String arguments, Location targetPosition) throws CommandException { if (!(source instanceof Player)) { return null; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java index da33cedc6..a120048e7 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java @@ -11,12 +11,11 @@ import org.spongepowered.api.item.ItemType; import org.spongepowered.api.item.ItemTypes; import org.spongepowered.api.item.inventory.Carrier; import org.spongepowered.api.item.inventory.ItemStack; -import org.spongepowered.api.item.inventory.custom.CustomInventory; -import org.spongepowered.api.item.inventory.property.SlotIndex; import org.spongepowered.api.item.inventory.type.CarriedInventory; import java.util.ArrayList; + public class SpongeInventoryUtil extends InventoryUtil { public ItemStack.Builder builder; @@ -27,11 +26,15 @@ public class SpongeInventoryUtil extends InventoryUtil { @Override public void open(final PlotInventory inv) { +/* // TODO Auto-generated method stub final SpongePlayer sp = (SpongePlayer) inv.player; final Player player = sp.player; - final CustomInventory inventory = SpongeMain.THIS.getGame().getRegistry().createBuilder(CustomInventory.Builder.class).name(SpongeUtil.getTranslation(inv.getTitle())).size(inv.size).build(); + final CustomInventory inventory = Inventory.builder().of(InventoryArchetypes.MENU_ROW)property("test", + InventoryTitle.of(org.spongepowered.api.text.Text.of(inv.getTitle()))) + .property("size",org.spongepowered.api.item.inventory.property.InventoryDimension.) + //name(SpongeUtil.getTranslation(inv.getTitle())).size(inv.size).build(); final PlotItemStack[] items = inv.getItems(); for (int i = 0; i < (inv.size * 9); i++) { final PlotItemStack item = items[i]; @@ -41,6 +44,9 @@ public class SpongeInventoryUtil extends InventoryUtil { } inv.player.setMeta("inventory", inv); player.openInventory(inventory, SpongeUtil.CAUSE); +*/ + throw new UnsupportedOperationException("Broken as of 1.11"); + } public ItemStack getItem(final PlotItemStack item) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java index a4628e409..c6ef2ab55 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java @@ -8,8 +8,8 @@ import org.spongepowered.api.text.title.Title; public class SpongeTitleManager extends AbstractTitle { @Override - public void sendTitle(final PlotPlayer player, final String head, final String sub, final int in, final int delay, final int out) { - final Title title = Title.builder().title(SpongeUtil.getText(head)).subtitle(SpongeUtil.getText(sub)).fadeIn(in * 20).stay(delay * 20).fadeOut(out * 20).build(); + public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) { + Title title = Title.builder().title(SpongeUtil.getText(head)).subtitle(SpongeUtil.getText(sub)).fadeIn(in * 20).stay(delay * 20).fadeOut(out * 20).build(); ((SpongePlayer) player).player.sendTitle(title); } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index 7abab8bcb..1d4357ba6 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -339,7 +339,7 @@ public class SpongeUtil extends WorldUtil { @Override public String getBiome(String world, int x, int z) { - return SpongeUtil.getWorld(world).getBiome(x, z).getName().toUpperCase(); + return SpongeUtil.getWorld(world).getBiome(x, 0, z).getName().toUpperCase(); } @Override @@ -454,7 +454,7 @@ public class SpongeUtil extends WorldUtil { BiomeType biome = SpongeUtil.getBiome(biomename); for (int x = region.minX; x <= region.maxX; x++) { for (int z = region.minZ; z <= region.maxZ; z++) { - world.setBiome(x, z, biome); + world.setBiome(x, 0, z, biome); } } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java index 3f844386e..95c2edf04 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/GenChunk.java @@ -4,23 +4,22 @@ import com.intellectualcrafters.plot.object.ChunkWrapper; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import org.spongepowered.api.world.biome.BiomeType; -import org.spongepowered.api.world.extent.MutableBiomeArea; +import org.spongepowered.api.world.extent.MutableBiomeVolume; import org.spongepowered.api.world.extent.MutableBlockVolume; public class GenChunk extends ScopedLocalBlockQueue { private final MutableBlockVolume terrain; - private final MutableBiomeArea biome; + private final MutableBiomeVolume biome; private final int bz; private final int bx; private final String world; public boolean modified = false; - public GenChunk(MutableBlockVolume terrain, MutableBiomeArea biome, ChunkWrapper wrap) { + public GenChunk(MutableBlockVolume terrain, MutableBiomeVolume biome, ChunkWrapper wrap) { super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15)); this.bx = wrap.x << 4; this.bz = wrap.z << 4; @@ -37,7 +36,7 @@ public class GenChunk extends ScopedLocalBlockQueue { BiomeType biome = SpongeUtil.getBiome(biomeName.toUpperCase()); for (int x = 0; x < 16; x++) { for (int z = 0; z < 16; z++) { - this.biome.setBiome(this.bx + x, this.bz + z, biome); + this.biome.setBiome(this.bx + x, 0,this.bz + z, biome); } } } @@ -46,7 +45,7 @@ public class GenChunk extends ScopedLocalBlockQueue { public boolean setBiome(int x, int z, String biomeName) { modified = true; BiomeType biome = SpongeUtil.getBiome(biomeName.toUpperCase()); - this.biome.setBiome(this.bx + x, this.bz + z, biome); + this.biome.setBiome(this.bx + x, 0, this.bz + z, biome); return true; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java index 8cc537d59..ea5b00ce4 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java @@ -42,7 +42,7 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper { } } if (name == null) { - for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) { + for (GameProfile profile : SpongeMain.THIS.getResolver().getCache().getProfiles()) { String tmp = profile.getName().orElse(null); if (tmp != null) { if (getUUID(name).equals(uuid)) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java index fe45ed968..5b2d19c9c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java @@ -2,77 +2,70 @@ package com.plotsquared.sponge.uuid; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import com.plotsquared.sponge.SpongeMain; +import com.plotsquared.sponge.object.SpongeOfflinePlayer; import com.plotsquared.sponge.object.SpongePlayer; +import org.spongepowered.api.Sponge; +import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.entity.living.player.User; +import org.spongepowered.api.service.user.UserStorageService; +import org.spongepowered.api.util.Identifiable; +import java.util.Optional; import java.util.UUID; -import java.util.concurrent.ExecutionException; public class SpongeOnlineUUIDWrapper extends UUIDWrapper { - + + private UserStorageService userStorageService; + public SpongeOnlineUUIDWrapper() { + Optional userStorage = Sponge.getServiceManager().provide(UserStorageService.class); + userStorage.ifPresent(userStorageService -> this.userStorageService = userStorageService); + + } + @Override - public UUID getUUID(final PlotPlayer player) { + public UUID getUUID(PlotPlayer player) { return ((SpongePlayer) player).player.getUniqueId(); } @Override - public UUID getUUID(final OfflinePlotPlayer player) { + public UUID getUUID(OfflinePlotPlayer player) { return player.getUUID(); } @Override - public UUID getUUID(final String name) { - try { - return SpongeMain.THIS.getResolver().get(name, true).get().getUniqueId(); - } catch (final Exception e) { - e.printStackTrace(); + public UUID getUUID(String name) { + Optional player = Sponge.getServer().getPlayer(name); + if (player.isPresent()) { + return player.get().getUniqueId(); } - return null; + Optional user = userStorageService.get(name); + return user.map(Identifiable::getUniqueId).orElse(null); } @Override - public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) { - String name; - try { - name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName().orElse(null); - } catch (InterruptedException | ExecutionException ignored) { - name = null; + public OfflinePlotPlayer getOfflinePlayer(UUID uuid) { + Optional player = Sponge.getServer().getPlayer(uuid); + if (player.isPresent()) { + return new SpongeOfflinePlayer(player.get()); } - final String username = name; - return new OfflinePlotPlayer() { - @Override - public boolean isOnline() { - return UUIDHandler.getPlayer(uuid) != null; - } - - @Override - public UUID getUUID() { - return uuid; - } - - @Override - public String getName() { - return username; - } - - @Override - public long getLastPlayed() { - // TODO FIXME - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); - } - }; + Optional user = userStorageService.get(uuid); + return user.map(SpongeOfflinePlayer::new).orElse(null); } @Override public OfflinePlotPlayer[] getOfflinePlayers() { throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - + @Override public OfflinePlotPlayer getOfflinePlayer(String name) { - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); + Optional player = Sponge.getServer().getPlayer(name); + if (player.isPresent()) { + return new SpongeOfflinePlayer(player.get()); + } + Optional user = userStorageService.get(name); + return user.map(SpongeOfflinePlayer::new).orElse(null); } }