mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 14:14:43 +02:00
Fixes
Progress towards #515 Fixes #512 Fixes #514 Fixes (possibly) #529 Fixes #535 Update to latest sponge
This commit is contained in:
src/main/java/com
@ -126,8 +126,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
PS.get().disable();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
THIS = null;
|
||||
}
|
||||
|
||||
|
@ -178,6 +178,8 @@ public class EntityWrapper {
|
||||
this.x = loc.getX();
|
||||
this.y = loc.getY();
|
||||
this.z = loc.getZ();
|
||||
System.out.print("ENTITY: " + entity.getType());
|
||||
System.out.print("ENTITY: " + entity.getType().getTypeId());
|
||||
this.id = entity.getType().getTypeId();
|
||||
if (depth == 0) {
|
||||
return;
|
||||
|
@ -494,12 +494,14 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
public static void restoreEntities(final World world, final int x_offset, final int z_offset) {
|
||||
for (final EntityWrapper entity : entities) {
|
||||
try {
|
||||
System.out.print("RESTORING ENTITIE!: " + EntityType.fromId(entity.id));
|
||||
entity.spawn(world, x_offset, z_offset);
|
||||
} catch (final Exception e) {
|
||||
PS.debug("Failed to restore entity (e): " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
entities.clear();
|
||||
}
|
||||
|
||||
public static void restoreBlocks(final World world, final int x_offset, final int z_offset) {
|
||||
|
@ -12,6 +12,7 @@ import org.bukkit.World;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefConstructor;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
@ -87,12 +88,20 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
if (unload) {
|
||||
try {
|
||||
chunk.unload(true, true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
chunk.unload(true, true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
String worldname = chunk.getWorld().getName();
|
||||
PS.debug("$4Could not save chunk: " + worldname + ";" + chunk.getX() + ";" + chunk.getZ());
|
||||
PS.debug("$3 - $4File may be open in another process (e.g. MCEdit)");
|
||||
PS.debug("$3 - $4" + worldname + "/level.dat or " + worldname + "level_old.dat may be corrupt (try repairing or removing these)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.spongepowered.api.Server;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
import org.spongepowered.api.data.manipulator.block.StoneData;
|
||||
import org.spongepowered.api.data.manipulator.mutable.block.StoneData;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.event.Subscribe;
|
||||
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
|
||||
@ -261,7 +261,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
case 0: {
|
||||
this.modify = new WorldModify(generator, false);
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
Optional<World> builder = game.getRegistry().getWorldBuilder()
|
||||
Optional<World> builder = game.getRegistry().createWorldBuilder()
|
||||
.name(world)
|
||||
.enabled(true)
|
||||
.loadsOnStartup(true)
|
||||
@ -277,7 +277,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
default: {
|
||||
this.modify = new WorldModify(generator, true);
|
||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||
Optional<World> builder = game.getRegistry().getWorldBuilder()
|
||||
Optional<World> builder = game.getRegistry().createWorldBuilder()
|
||||
.name(world)
|
||||
.enabled(true)
|
||||
.loadsOnStartup(true)
|
||||
@ -356,17 +356,16 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
for (int i = 0; i < data_lines.size(); i++) {
|
||||
String classname = packaze + data_lines.get(i).trim();
|
||||
try {
|
||||
Class<?> clazz = Class.forName(classname);
|
||||
fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
CatalogType type = (CatalogType) field.get(null);
|
||||
String minecraft_id = type.getId();
|
||||
BlockState state = states.get(minecraft_id + ":" + 0);
|
||||
if (state == null) {
|
||||
continue;
|
||||
Class<?> clazz = Class.forName(classname);
|
||||
fields = clazz.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
CatalogType type = (CatalogType) field.get(null);
|
||||
String minecraft_id = type.getId();
|
||||
BlockState state = states.get(minecraft_id + ":" + 0);
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
state.getManipulator(StoneData.class);
|
||||
}
|
||||
}
|
||||
catch (Throwable e) {}
|
||||
}
|
||||
|
@ -8,9 +8,13 @@ import java.util.Random;
|
||||
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
import org.spongepowered.api.util.DiscreteTransform3;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.extent.ImmutableBlockVolume;
|
||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||
import org.spongepowered.api.world.extent.StorageType;
|
||||
import org.spongepowered.api.world.extent.UnmodifiableBlockVolume;
|
||||
import org.spongepowered.api.world.gen.GeneratorPopulator;
|
||||
import org.spongepowered.api.world.gen.Populator;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
@ -283,6 +287,48 @@ public class AugmentedPopulator implements Populator {
|
||||
public void setBlockType(Vector3i v, BlockType t) {
|
||||
setBlockType(v.getX(), v.getY(), v.getZ(), t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableBlockVolume getBlockCopy() {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableBlockVolume getBlockCopy(StorageType arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableBlockVolume getImmutableBlockCopy() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnmodifiableBlockVolume getUnmodifiableBlockView() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableBlockVolume getBlockView(DiscreteTransform3 arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableBlockVolume getBlockView(Vector3i arg0, Vector3i arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableBlockVolume getRelativeBlockView() {
|
||||
// TODO Auto-generated method stub
|
||||
return this;
|
||||
}
|
||||
};
|
||||
this.populator.populate(world, blocks , null);
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import org.spongepowered.api.event.block.BlockMoveEvent;
|
||||
import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
|
||||
import org.spongepowered.api.event.block.FloraGrowEvent;
|
||||
import org.spongepowered.api.event.entity.EntityChangeBlockEvent;
|
||||
import org.spongepowered.api.event.entity.EntityExplosionEvent;
|
||||
import org.spongepowered.api.event.entity.EntitySpawnEvent;
|
||||
import org.spongepowered.api.event.entity.EntityTeleportEvent;
|
||||
import org.spongepowered.api.event.entity.player.PlayerBreakBlockEvent;
|
||||
@ -41,11 +40,13 @@ import org.spongepowered.api.event.entity.player.PlayerQuitEvent;
|
||||
import org.spongepowered.api.event.message.CommandEvent;
|
||||
import org.spongepowered.api.event.network.PlayerConnectionEvent;
|
||||
import org.spongepowered.api.event.world.ChunkPreGenerateEvent;
|
||||
import org.spongepowered.api.event.world.WorldOnExplosionEvent;
|
||||
import org.spongepowered.api.network.PlayerConnection;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.text.Texts;
|
||||
import org.spongepowered.api.util.command.CommandSource;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.explosion.Explosion;
|
||||
import org.spongepowered.api.world.extent.Extent;
|
||||
|
||||
import com.flowpowered.math.vector.Vector3d;
|
||||
@ -110,7 +111,8 @@ public class MainListener {
|
||||
}
|
||||
final Location loc = SpongeUtil.getLocation(event.getLocation());
|
||||
final String world = loc.getWorld();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
if (plotworld == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(loc);
|
||||
@ -132,7 +134,9 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
if (!plotworld.MOB_SPAWNING) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@ -164,7 +168,7 @@ public class MainListener {
|
||||
|
||||
@Subscribe
|
||||
public void onBlockMove(BlockMoveEvent event) {
|
||||
org.spongepowered.api.world.Location block = event.getBlocks().get(0);
|
||||
org.spongepowered.api.world.Location block = event.getLocations().get(0);
|
||||
Extent extent = block.getExtent();
|
||||
if (extent instanceof World) {
|
||||
World world = (World) extent;
|
||||
@ -172,7 +176,7 @@ public class MainListener {
|
||||
if (!PS.get().isPlotWorld(worldname)) {
|
||||
return;
|
||||
}
|
||||
event.filter(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
@Override
|
||||
public boolean apply(org.spongepowered.api.world.Location loc) {
|
||||
if (MainUtil.isPlotRoad(SpongeUtil.getLocation(worldname, loc))) {
|
||||
@ -186,7 +190,7 @@ public class MainListener {
|
||||
|
||||
@Subscribe
|
||||
public void onFloraGrow(FloraGrowEvent event) {
|
||||
org.spongepowered.api.world.Location block = event.getBlock();
|
||||
org.spongepowered.api.world.Location block = event.getLocation();
|
||||
Extent extent = block.getExtent();
|
||||
if (extent instanceof World) {
|
||||
World world = (World) extent;
|
||||
@ -258,16 +262,19 @@ public class MainListener {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onBigBoom(final EntityExplosionEvent event) {
|
||||
Location loc = SpongeUtil.getLocation(event.getExplosionLocation());
|
||||
final String world = loc.getWorld();
|
||||
public void onBigBoom(final WorldOnExplosionEvent event) {
|
||||
World worldObj = event.getWorld();
|
||||
final String world = worldObj.getName();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return;
|
||||
}
|
||||
Explosion explosion = event.getExplosion();
|
||||
Vector3d origin = explosion.getOrigin();
|
||||
Location loc = new Location(world, origin.getFloorX(), origin.getFloorY(), origin.getFloorZ());
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot != null) && plot.hasOwner()) {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
event.filter(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
@Override
|
||||
public boolean apply(org.spongepowered.api.world.Location loc) {
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
|
||||
@ -276,14 +283,35 @@ public class MainListener {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
event.filterEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean apply(Entity entity) {
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (MainUtil.isPlotArea(loc)) {
|
||||
event.setYield(0);
|
||||
explosion.shouldBreakBlocks(false);
|
||||
explosion.canCauseFire(false);
|
||||
explosion.setRadius(0);
|
||||
event.filterEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean apply(Entity entity) {
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
|
||||
event.filter(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
event.filterLocations(new Predicate<org.spongepowered.api.world.Location>() {
|
||||
@Override
|
||||
public boolean apply(org.spongepowered.api.world.Location loc) {
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(loc)))) {
|
||||
@ -292,6 +320,15 @@ public class MainListener {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
event.filterEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean apply(Entity entity) {
|
||||
if (!plot.equals(MainUtil.getPlot(SpongeUtil.getLocation(entity)))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -317,7 +354,7 @@ public class MainListener {
|
||||
|
||||
@Subscribe
|
||||
public void onRedstoneEvent(BlockRedstoneUpdateEvent event) {
|
||||
org.spongepowered.api.world.Location block = event.getBlock();
|
||||
org.spongepowered.api.world.Location block = event.getLocation();
|
||||
Location loc = SpongeUtil.getLocation(block);
|
||||
if (loc == null || !PS.get().isPlotWorld(loc.getWorld())) {
|
||||
return;
|
||||
@ -356,11 +393,11 @@ public class MainListener {
|
||||
Player player = event.getEntity();
|
||||
World world = player.getWorld();
|
||||
String worldname = world.getName();
|
||||
org.spongepowered.api.world.Location blockLoc = event.getBlock();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
|
||||
org.spongepowered.api.world.Location blockLoc = event.getLocation();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot != null) {
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (blockLoc.getY() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -403,11 +440,11 @@ public class MainListener {
|
||||
Player player = event.getEntity();
|
||||
World world = player.getWorld();
|
||||
String worldname = world.getName();
|
||||
org.spongepowered.api.world.Location blockLoc = event.getBlock();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
|
||||
org.spongepowered.api.world.Location blockLoc = event.getLocation();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot != null) {
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (blockLoc.getY() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -450,11 +487,11 @@ public class MainListener {
|
||||
Player player = event.getEntity();
|
||||
World world = player.getWorld();
|
||||
String worldname = world.getName();
|
||||
org.spongepowered.api.world.Location blockLoc = event.getBlock();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, event.getBlock());
|
||||
org.spongepowered.api.world.Location blockLoc = event.getLocation();
|
||||
final Location loc = SpongeUtil.getLocation(worldname, blockLoc);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot != null) {
|
||||
if (event.getBlock().getY() == 0) {
|
||||
if (blockLoc.getY() == 0) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
@ -1,8 +1,12 @@
|
||||
package com.plotsquared.sponge.object;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.data.key.Keys;
|
||||
import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData;
|
||||
import org.spongepowered.api.data.value.mutable.Value;
|
||||
import org.spongepowered.api.entity.player.Player;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameMode;
|
||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||
@ -47,7 +51,11 @@ public class SpongePlayer extends PlotPlayer {
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
return (long) (player.getJoinData().getLastPlayed().getSeconds()) * 1000;
|
||||
Value<Date> data = player.getJoinData().lastPlayed();
|
||||
if (data.exists()) {
|
||||
return last = data.get().getSeconds() * 1000;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -168,7 +176,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public PlotGamemode getGamemode() {
|
||||
// TODO Auto-generated method stub
|
||||
GameMode gamemode = player.getGameModeData().getValue();
|
||||
GameMode gamemode = player.getGameModeData().type().get();
|
||||
if (gamemode == GameModes.ADVENTURE) {
|
||||
return PlotGamemode.ADVENTURE;
|
||||
}
|
||||
@ -187,20 +195,20 @@ public class SpongePlayer extends PlotPlayer {
|
||||
@Override
|
||||
public void setGamemode(PlotGamemode gamemode) {
|
||||
// TODO Auto-generated method stub
|
||||
switch (gamemode) {
|
||||
case ADVENTURE:
|
||||
player.getGameModeData().setGameMode(GameModes.ADVENTURE);
|
||||
return;
|
||||
case CREATIVE:
|
||||
player.getGameModeData().setGameMode(GameModes.CREATIVE);
|
||||
return;
|
||||
case SPECTATOR:
|
||||
player.getGameModeData().setGameMode(GameModes.SPECTATOR);
|
||||
return;
|
||||
case SURVIVAL:
|
||||
player.getGameModeData().setGameMode(GameModes.SURVIVAL);
|
||||
return;
|
||||
}
|
||||
// switch (gamemode) {
|
||||
// case ADVENTURE:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
|
||||
// return;
|
||||
// case CREATIVE:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.CREATIVE);
|
||||
// return;
|
||||
// case SPECTATOR:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.SPECTATOR);
|
||||
// return;
|
||||
// case SURVIVAL:
|
||||
// player.offer(Keys.GAME_MODE, GameModes.SURVIVAL);
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,17 +1,21 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.block.BlockType;
|
||||
import org.spongepowered.api.block.BlockTypes;
|
||||
import org.spongepowered.api.block.tileentity.Sign;
|
||||
import org.spongepowered.api.data.manipulator.tileentity.SignData;
|
||||
import org.spongepowered.api.block.tileentity.TileEntity;
|
||||
import org.spongepowered.api.data.key.Keys;
|
||||
import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.world.World;
|
||||
import org.spongepowered.api.world.biome.BiomeType;
|
||||
import org.spongepowered.api.world.biome.BiomeTypes;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
@ -132,13 +136,22 @@ public class SpongeBlockManager extends BlockManager {
|
||||
|
||||
@Override
|
||||
public String[] getSign(Location loc) {
|
||||
BlockState block = SpongeUtil.getWorld(loc.getWorld()).getBlock(loc.getX(), loc.getY(), loc.getZ());
|
||||
if (!(block instanceof Sign)) {
|
||||
World world = SpongeUtil.getWorld(loc.getWorld());
|
||||
Optional<TileEntity> block = world.getTileEntity(loc.getX(), loc.getY(), loc.getZ());
|
||||
if (!block.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
TileEntity tile = block.get();
|
||||
if (!(tile instanceof Sign)) {
|
||||
return null;
|
||||
}
|
||||
Sign sign = (Sign) tile;
|
||||
Optional<List<Text>> optional = tile.get(Keys.SIGN_LINES);
|
||||
if (!optional.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
Sign sign = (Sign) block;
|
||||
String[] result = new String[4];
|
||||
List<Text> lines = sign.getData().get().getLines();
|
||||
List<Text> lines = optional.get();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
result[i] = lines.get(i).toString();
|
||||
}
|
||||
@ -161,15 +174,20 @@ public class SpongeBlockManager extends BlockManager {
|
||||
public void functionSetSign(String worldname, int x, int y, int z, String[] lines) {
|
||||
World world = SpongeUtil.getWorld(worldname);
|
||||
world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState());
|
||||
BlockState block = world.getBlock(x, y, z);
|
||||
if (!(block instanceof Sign)) {
|
||||
Optional<TileEntity> block = world.getTileEntity(x, y, z);
|
||||
if (!block.isPresent()) {
|
||||
return;
|
||||
}
|
||||
Sign sign = (Sign) block;
|
||||
SignData data = sign.getData().get();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
data.setLine(i, SpongeMain.THIS.getText(lines[i]));
|
||||
TileEntity tile = block.get();
|
||||
if (!(tile instanceof Sign)) {
|
||||
return;
|
||||
}
|
||||
Sign sign = (Sign) tile;
|
||||
List<Text> text = new ArrayList<>(4);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
text.add(SpongeMain.THIS.getText(lines[i]));
|
||||
}
|
||||
sign.offer(Keys.SIGN_LINES, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,7 +27,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
public ItemStackBuilder builder;
|
||||
|
||||
public SpongeInventoryUtil() {
|
||||
this.builder = SpongeMain.THIS.getGame().getRegistry().getItemBuilder();
|
||||
this.builder = SpongeMain.THIS.getGame().getRegistry().createItemBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -184,7 +184,7 @@ public class SpongeMetrics {
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
TaskBuilder builder = game.getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = game.getScheduler().createTaskBuilder();
|
||||
builder.async()
|
||||
.interval(TimeUnit.MINUTES.toMillis(PING_INTERVAL))
|
||||
.execute(new Runnable() {
|
||||
|
@ -18,7 +18,7 @@ public class SpongeTaskManager extends TaskManager {
|
||||
@Override
|
||||
public int taskRepeat(Runnable r, int interval) {
|
||||
int val = i.incrementAndGet();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
|
||||
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||
tasks.put(val, task);
|
||||
@ -28,7 +28,7 @@ public class SpongeTaskManager extends TaskManager {
|
||||
@Override
|
||||
public int taskRepeatAsync(Runnable r, int interval) {
|
||||
int val = i.incrementAndGet();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
TaskBuilder built = builder.delay(interval).async().interval(interval).execute(r);
|
||||
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||
tasks.put(val, task);
|
||||
@ -37,25 +37,25 @@ public class SpongeTaskManager extends TaskManager {
|
||||
|
||||
@Override
|
||||
public void taskAsync(Runnable r) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(Runnable r) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLater(Runnable r, int delay) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLaterAsync(Runnable r, int delay) {
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().delay(delay).execute(r).submit(SpongeMain.THIS.getPlugin());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user