mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-26 02:34:42 +02:00
Make Sponge compile
It doesn't work but it allows the project to compile.
This commit is contained in:
@ -22,33 +22,36 @@ import java.util.UUID;
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@Override
|
||||
public CommandResult process(CommandSource cmd, String string) throws CommandException {
|
||||
public CommandResult process(CommandSource source, String arguments) throws CommandException {
|
||||
TaskManager.runTask(() -> {
|
||||
String id = cmd.getIdentifier();
|
||||
PlotPlayer pp;
|
||||
String id = source.getIdentifier();
|
||||
PlotPlayer plotPlayer = null;
|
||||
try {
|
||||
UUID uuid = UUID.fromString(id);
|
||||
Player player = SpongeMain.THIS.getServer().getPlayer(uuid).get();
|
||||
pp = SpongeUtil.getPlayer(player);
|
||||
|
||||
Optional<Player> player = SpongeMain.THIS.getServer().getPlayer(uuid);
|
||||
if (player.isPresent()) {
|
||||
plotPlayer = SpongeUtil.getPlayer(player.get());
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
pp = ConsolePlayer.getConsole();
|
||||
plotPlayer = ConsolePlayer.getConsole();
|
||||
}
|
||||
MainCommand.onCommand(pp, string.isEmpty() ? new String[]{} : string.split(" "));
|
||||
MainCommand.onCommand(plotPlayer, arguments.isEmpty() ? new String[]{} : arguments.split(" "));
|
||||
});
|
||||
return CommandResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(CommandSource source, String s) throws CommandException {
|
||||
public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
|
||||
if (!(source instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
PlotPlayer player = SpongeUtil.getPlayer((Player) source);
|
||||
String[] args = s.split(" ");
|
||||
String[] args = arguments.split(" ");
|
||||
if (args.length == 0) {
|
||||
return Collections.singletonList(MainCommand.getInstance().toString());
|
||||
}
|
||||
Collection objects = MainCommand.getInstance().tab(player, args, s.endsWith(" "));
|
||||
Collection objects = MainCommand.getInstance().tab(player, args, arguments.endsWith(" "));
|
||||
if (objects == null) {
|
||||
return null;
|
||||
}
|
||||
@ -60,22 +63,22 @@ public class SpongeCommand implements CommandCallable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission(CommandSource cmd) {
|
||||
public boolean testPermission(CommandSource source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Text> getShortDescription(CommandSource cmd) {
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
return Optional.of(Text.of("Shows plot help"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<? extends Text> getHelp(CommandSource cmd) {
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
return Optional.of(Text.of("/plot"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource cmd) {
|
||||
public Text getUsage(CommandSource source) {
|
||||
return Text.of("/plot <command>");
|
||||
}
|
||||
|
||||
|
@ -402,9 +402,7 @@ public class SpongeMetrics {
|
||||
// Server software specific section
|
||||
final String pluginName = plugin.getName();
|
||||
final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
final String pluginVersion = plugin.getVersion().get();
|
||||
// TODO no visible way to get MC version at the moment
|
||||
// TODO added by game.getPlatform().getMinecraftVersion() -- impl in 2.1
|
||||
final String pluginVersion = plugin.getVersion().orElse("unknown");
|
||||
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
|
||||
final int playersOnline = game.getServer().getOnlinePlayers().size();
|
||||
|
||||
|
@ -64,7 +64,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
schematic.put("WEOffsetY", new IntTag("WEOffsetY", 0));
|
||||
schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", 0));
|
||||
// Arrays of data types
|
||||
List<Tag> tileEntities = new ArrayList<Tag>();
|
||||
List<Tag> tileEntities = new ArrayList<>();
|
||||
byte[] blocks = new byte[width * height * length];
|
||||
byte[] blockData = new byte[width * height * length];
|
||||
// Queue
|
||||
@ -78,7 +78,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
public void run() {
|
||||
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
|
||||
schematic.put("Data", new ByteArrayTag("Data", blockData));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<Tag>()));
|
||||
schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList<>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
whenDone.value = new CompoundTag("Schematic", schematic);
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -105,7 +105,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
int sy = pos1.getY();
|
||||
int ey = pos2.getY();
|
||||
// Generate list of chunks
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||
ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
for (int x = bcx; x <= tcx; x++) {
|
||||
for (int z = bcz; z <= tcz; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
@ -270,7 +270,7 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
rawTag = null;
|
||||
}
|
||||
if (rawTag != null) {
|
||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.DimensionTypes;
|
||||
import org.spongepowered.api.world.GeneratorTypes;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.WorldCreationSettings;
|
||||
import org.spongepowered.api.world.WorldCreationSettings.Builder;
|
||||
import org.spongepowered.api.world.WorldArchetype;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||
import org.spongepowered.api.world.storage.WorldProperties;
|
||||
@ -24,6 +23,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SpongeSetupUtils extends SetupUtils {
|
||||
|
||||
@ -140,32 +140,44 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
if (object.setupGenerator != null) {
|
||||
// create world with generator
|
||||
GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator);
|
||||
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
||||
WorldArchetype wgm = (WorldArchetype) gw.getPlatformGenerator();
|
||||
|
||||
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
||||
.name(object.world)
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.OVERWORLD)
|
||||
.usesMapFeatures(false)
|
||||
.enabled(true)
|
||||
.generatorModifiers(wgm)
|
||||
.build();
|
||||
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get();
|
||||
World worldObj = Sponge.getServer().loadWorld(properties).get();
|
||||
//.generatorModifiers(wgm)
|
||||
.build("PS",object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
World worldObj;
|
||||
Optional<World> world1 = Sponge.getServer().loadWorld(properties);
|
||||
if (world1.isPresent()) {
|
||||
worldObj = world1.get();
|
||||
}
|
||||
} else {
|
||||
// create vanilla world
|
||||
WorldCreationSettings settings = Sponge.getRegistry().createBuilder(Builder.class)
|
||||
.name(object.world)
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.OVERWORLD)
|
||||
.usesMapFeatures(true)
|
||||
.enabled(true)
|
||||
.build();
|
||||
WorldProperties properties = Sponge.getServer().createWorldProperties(settings).get();
|
||||
.build("PS",object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
World worldObj = Sponge.getServer().loadWorld(properties).get();
|
||||
}
|
||||
return object.world;
|
||||
|
@ -18,8 +18,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
@ -42,6 +41,7 @@ import org.spongepowered.api.world.biome.BiomeType;
|
||||
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||
import org.spongepowered.api.world.extent.Extent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -113,7 +113,7 @@ public class SpongeUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static BiomeType getBiome(int index) {
|
||||
return (BiomeType) BiomeGenBase.getBiome(index);
|
||||
return (BiomeType) Biome.getBiome(index);
|
||||
}
|
||||
|
||||
public static Text getText(String m) {
|
||||
@ -349,9 +349,9 @@ public class SpongeUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawn(PlotPlayer pp) {
|
||||
throw new NotImplementedException("TODO IMPLEMENT THIS"); // TODO FIXME
|
||||
// Probably can call a respawn event and get the location from there
|
||||
public Location getSpawn(PlotPlayer plotPlayer) {
|
||||
World world = getWorld(plotPlayer.getLocation().getWorld());
|
||||
return SpongeUtil.getLocation(world.getSpawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -371,7 +371,12 @@ public class SpongeUtil extends WorldUtil {
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldName) {
|
||||
throw new NotImplementedException("TODO WIP"); // TODO FIXME
|
||||
try {
|
||||
SpongeUtil.getWorld(worldName).save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("Failed to save world.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,11 +8,11 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.BlockStateContainer;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -132,11 +132,11 @@ public class FastQueue extends SlowQueue {
|
||||
ExtendedBlockStorage section = sections[j];
|
||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||
section = new ExtendedBlockStorage(j << 4, flag);
|
||||
section.setData(newArray);
|
||||
//section.setData(newArray); //todo
|
||||
sections[j] = section;
|
||||
continue;
|
||||
}
|
||||
char[] currentArray = section.getData();
|
||||
BlockStateContainer currentArray = section.getData();
|
||||
boolean fill = true;
|
||||
for (int k = 0; k < newArray.length; k++) {
|
||||
char n = newArray[k];
|
||||
@ -146,10 +146,10 @@ public class FastQueue extends SlowQueue {
|
||||
continue;
|
||||
case 1:
|
||||
fill = false;
|
||||
currentArray[k] = 0;
|
||||
//currentArray[k] = 0; //todo
|
||||
continue;
|
||||
default:
|
||||
currentArray[k] = n;
|
||||
//currentArray[k] = n; //todo
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -226,10 +226,11 @@ public class FastQueue extends SlowQueue {
|
||||
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
|
||||
continue;
|
||||
}
|
||||
char[] array = section.getData();
|
||||
BlockStateContainer array = section.getData();
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
int i = array[k];
|
||||
for (int k = 0; k < array.getSerializedSize(); k++) {
|
||||
int i = 0;
|
||||
//i = array[k]; //todo
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
@ -285,7 +286,8 @@ public class FastQueue extends SlowQueue {
|
||||
}
|
||||
|
||||
public boolean isSolid(int i) {
|
||||
return i != 0 && Block.getBlockById(i).isOpaqueCube();
|
||||
//return i != 0 && Block.getBlockById(i).isOpaqueCube();
|
||||
throw new UnsupportedOperationException("Unsupported");
|
||||
}
|
||||
|
||||
public int getId(ExtendedBlockStorage[] sections, int x, int y, int z) {
|
||||
@ -300,9 +302,10 @@ public class FastQueue extends SlowQueue {
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
char[] array = section.getData();
|
||||
BlockStateContainer array = section.getData();
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
return array[j] >> 4;
|
||||
//return array[j] >> 4; //todo: fix for 1.9.4
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.play.server.S21PacketChunkData;
|
||||
import net.minecraft.network.play.server.SPacketChunkData;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
@ -81,9 +81,9 @@ public class SendChunk {
|
||||
continue;
|
||||
}
|
||||
chunks.remove(chunk);
|
||||
NetHandlerPlayServer con = nmsPlayerMP.playerNetServerHandler;
|
||||
NetHandlerPlayServer con = nmsPlayerMP.connection;
|
||||
net.minecraft.world.chunk.Chunk nmsChunk = (net.minecraft.world.chunk.Chunk) chunk;
|
||||
S21PacketChunkData packet = new S21PacketChunkData(nmsChunk, true, 65535);
|
||||
SPacketChunkData packet = new SPacketChunkData(nmsChunk, 65535);
|
||||
con.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user