mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Various Sponge changes
- many improvements - inventory utilities broke when updating to Sponge API 6.0.0
This commit is contained in:
parent
8d442f58d4
commit
62b353f82d
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<G
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biomes) {
|
||||
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeVolume biomes) {
|
||||
if (platformGenerator != this) {
|
||||
platformGenerator.populate(world, terrain, biomes);
|
||||
return;
|
||||
|
@ -3,7 +3,6 @@ package com.plotsquared.sponge.listener;
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -20,7 +19,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import org.spongepowered.api.block.BlockSnapshot;
|
||||
@ -39,7 +37,6 @@ import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.event.action.InteractEvent;
|
||||
import org.spongepowered.api.event.block.ChangeBlockEvent;
|
||||
import org.spongepowered.api.event.block.NotifyNeighborBlockEvent;
|
||||
import org.spongepowered.api.event.command.SendCommandEvent;
|
||||
import org.spongepowered.api.event.entity.BreedEntityEvent;
|
||||
import org.spongepowered.api.event.entity.MoveEntityEvent;
|
||||
import org.spongepowered.api.event.entity.SpawnEntityEvent;
|
||||
|
@ -1,24 +1,30 @@
|
||||
package com.plotsquared.sponge.object;
|
||||
|
||||
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||
import org.spongepowered.api.entity.living.player.User;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeOfflinePlayer implements OfflinePlotPlayer {
|
||||
|
||||
private User user;
|
||||
|
||||
public SpongeOfflinePlayer(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
@Override public UUID getUUID() {
|
||||
return null;
|
||||
return user.getUniqueId();
|
||||
}
|
||||
|
||||
@Override public long getLastPlayed() {
|
||||
return 0;
|
||||
return 0; //todo
|
||||
}
|
||||
|
||||
@Override public boolean isOnline() {
|
||||
return false;
|
||||
return user.isOnline();
|
||||
}
|
||||
|
||||
@Override public String getName() {
|
||||
return null;
|
||||
return user.getName();
|
||||
}
|
||||
}
|
||||
|
@ -159,9 +159,6 @@ public class SpongePlayer extends PlotPlayer {
|
||||
return;
|
||||
case NOT_SET:
|
||||
this.player.offer(Keys.GAME_MODE, GameModes.NOT_SET);
|
||||
return;
|
||||
default:
|
||||
this.player.offer(Keys.GAME_MODE, GameModes.NOT_SET);
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +183,8 @@ public class SpongePlayer extends PlotPlayer {
|
||||
public void playMusic(Location location, int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
this.player.playSound(null, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
//Placeholder because Sponge doesn't have a stopSound() implemented yet.
|
||||
this.player.playSound(SoundTypes.BLOCK_CLOTH_PLACE, SpongeUtil.getLocation(location).getPosition(), 0);
|
||||
break;
|
||||
case 2256:
|
||||
this.player.playSound(SoundTypes.RECORD_11, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
|
@ -11,6 +11,7 @@ import org.spongepowered.api.command.CommandResult;
|
||||
import org.spongepowered.api.command.CommandSource;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.world.Location;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,7 +44,7 @@ public class SpongeCommand implements CommandCallable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(CommandSource source, String arguments, org.spongepowered.api.world.Location<World> targetPosition)
|
||||
public List<String> getSuggestions(CommandSource source, String arguments, Location<World> targetPosition)
|
||||
throws CommandException {
|
||||
if (!(source instanceof Player)) {
|
||||
return null;
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)) {
|
||||
|
@ -2,67 +2,55 @@ 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<UserStorageService> 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> player = Sponge.getServer().getPlayer(name);
|
||||
if (player.isPresent()) {
|
||||
return player.get().getUniqueId();
|
||||
}
|
||||
return null;
|
||||
Optional<User> 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> 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> user = userStorageService.get(uuid);
|
||||
return user.map(SpongeOfflinePlayer::new).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,7 +60,12 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
Optional<Player> player = Sponge.getServer().getPlayer(name);
|
||||
if (player.isPresent()) {
|
||||
return new SpongeOfflinePlayer(player.get());
|
||||
}
|
||||
Optional<User> user = userStorageService.get(name);
|
||||
return user.map(SpongeOfflinePlayer::new).orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user