From 07977ac2ceb5a97ea23a3fe65dc96a7a63b404d4 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 07:44:47 +1000 Subject: [PATCH 1/7] UUID cache changes --- .../bukkit/uuid/FileUUIDHandler.java | 37 +++++++++++-------- .../com/intellectualcrafters/plot/PS.java | 13 ++++--- .../plot/util/UUIDHandler.java | 19 ++++++---- 3 files changed, 40 insertions(+), 29 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index 07973e585..e9733c952 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -168,20 +168,23 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { } else { NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); String name = (String) bukkit.get("lastKnownName"); - long last = (long) bukkit.get("lastPlayed"); - if (Settings.UUID.OFFLINE) { - if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) { - uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name); - } else { - long most = (long) compound.get("UUIDMost"); - long least = (long) compound.get("UUIDLeast"); - uuid = new UUID(most, least); + StringWrapper wrap = new StringWrapper(name); + if (!toAdd.containsKey(wrap)) { + long last = (long) bukkit.get("lastPlayed"); + if (Settings.UUID.OFFLINE) { + if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) { + uuid = FileUUIDHandler.this.uuidWrapper.getUUID(name); + } else { + long most = (long) compound.get("UUIDMost"); + long least = (long) compound.get("UUIDLeast"); + uuid = new UUID(most, least); + } } + if (ExpireManager.IMP != null) { + ExpireManager.IMP.storeDate(uuid, last); + } + toAdd.put(wrap, uuid); } - if (ExpireManager.IMP != null) { - ExpireManager.IMP.storeDate(uuid, last); - } - toAdd.put(new StringWrapper(name), uuid); } } catch (Exception ignored) { PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat"); @@ -199,10 +202,12 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { if (last != 0) { String name = op.getName(); StringWrapper wrap = new StringWrapper(name); - UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op); - toAdd.put(wrap, uuid); - if (ExpireManager.IMP != null) { - ExpireManager.IMP.storeDate(uuid, last); + if (!toAdd.containsKey(wrap)) { + UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op); + toAdd.put(wrap, uuid); + if (ExpireManager.IMP != null) { + ExpireManager.IMP.storeDate(uuid, last); + } } } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 00c70d52d..575959576 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -370,13 +370,16 @@ public class PS { @Override public void run() { UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone); - for (Plot plot : getPlots()) { - if (plot.hasOwner() && plot.temp != -1) { - if (UUIDHandler.getName(plot.owner) == null) { - UUIDHandler.implementation.unknown.add(plot.owner); + foreachPlotRaw(new RunnableVal() { + @Override + public void run(Plot plot) { + if (plot.hasOwner() && plot.temp != -1) { + if (UUIDHandler.getName(plot.owner) == null) { + UUIDHandler.implementation.unknown.add(plot.owner); + } } } - } + }); startExpiryTasks(); startPlotMeConversion(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 0a23aa828..89e7edde3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -59,15 +59,18 @@ public class UUIDHandler { } public static HashSet getAllUUIDS() { - HashSet uuids = new HashSet<>(); - for (Plot plot : PS.get().getPlots()) { - if (plot.hasOwner()) { - uuids.add(plot.owner); - uuids.addAll(plot.getTrusted()); - uuids.addAll(plot.getMembers()); - uuids.addAll(plot.getDenied()); + final HashSet uuids = new HashSet<>(); + PS.get().foreachPlotRaw(new RunnableVal() { + @Override + public void run(Plot plot) { + if (plot.hasOwner()) { + uuids.add(plot.owner); + uuids.addAll(plot.getTrusted()); + uuids.addAll(plot.getMembers()); + uuids.addAll(plot.getDenied()); + } } - } + }); return uuids; } From 975a5765c12f3e86886fa25d2c8902bf640ea989 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 08:02:17 +1000 Subject: [PATCH 2/7] Possible fix + add guest-gamemode flag --- .../com/intellectualcrafters/plot/flag/Flags.java | 10 +++++----- .../java/com/plotsquared/listener/PlotListener.java | 13 ++++++++++++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java index 7b8247d25..235b3f74a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/Flags.java @@ -21,6 +21,7 @@ public final class Flags { public static final IntervalFlag FEED = new IntervalFlag("feed"); public static final IntervalFlag HEAL = new IntervalFlag("heal"); public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode"); + public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode"); public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve(); public static final BooleanFlag REDSTONE = new BooleanFlag("redstone"); public static final BooleanFlag FLY = new BooleanFlag("fly"); @@ -147,8 +148,8 @@ public final class Flags { } public static Flag getFlag(String flag) { - return flags.get(flag); - } + return flags.get(flag); +} public static void registerFlag(final Flag flag) { final Flag duplicate = flags.put(flag.getName(), flag); @@ -164,11 +165,10 @@ public final class Flags { }); PS.get().foreachPlotRaw(new RunnableVal() { @Override public void run(Plot value) { - Object remove = null; if (value.getFlags().containsKey(duplicate)) { - remove = value.getFlags().remove(duplicate); + Object remove = value.getFlags().remove(duplicate); + value.getFlags().put(flag,flag.parseValue("" + remove)); } - value.getFlags().put(flag,flag.parseValue("" + remove)); } }); } diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 5889d8a8d..a9ac3e5ab 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -94,6 +94,17 @@ public class PlotListener { } } } + Optional guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE); + if (gamemodeFlag.isPresent()) { + if (player.getGameMode() != gamemodeFlag.get() && !plot.isAdded(player.getUUID())) { + if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { + player.setGameMode(gamemodeFlag.get()); + } else { + MainUtil.sendMessage(player, + StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get())); + } + } + } Optional timeFlag = plot.getFlag(Flags.TIME); if (timeFlag.isPresent()) { try { @@ -171,7 +182,7 @@ public class PlotListener { if (pw == null) { return true; } - if (plot.getFlag(Flags.GAMEMODE).isPresent()) { + if (plot.getFlag(Flags.GAMEMODE).isPresent() || plot.getFlag(Flags.GUEST_GAMEMODE).isPresent()) { if (player.getGameMode() != pw.GAMEMODE) { if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) { player.setGameMode(pw.GAMEMODE); From 14b2b11bf37a9b5f22121fecd0e82e29ed00c69c Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 08:09:57 +1000 Subject: [PATCH 3/7] Remove metrics depend --- Bukkit/build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 0d77e6983..5b759bf95 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -7,7 +7,6 @@ repositories { dependencies { compile project(':Core') compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT' - compile 'org.mcstats.bukkit:metrics:R7' compile 'net.milkbowl.vault:VaultAPI:1.6' } @@ -29,7 +28,6 @@ jar.enabled = false shadowJar { dependencies { include(dependency(':Core')) - include(dependency('org.mcstats.bukkit:metrics:R7')) } relocate('org.mcstats', 'com.plotsquared.stats') archiveName = "${parent.name}-${project.name}-${parent.version}.jar" From 770b9be1607207412915d550161a71d27e88d4ea Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:23:20 +1000 Subject: [PATCH 4/7] Minor uuid cache changes --- .../java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java | 3 +-- .../sponge/generator/SpongeAugmentedGenerator.java | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index e9733c952..a7c048572 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -80,8 +80,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { e.printStackTrace(); } } + HashBiMap toAdd = HashBiMap.create(new HashMap()); if (Settings.UUID.NATIVE_UUID_PROVIDER) { - HashBiMap toAdd = HashBiMap.create(new HashMap()); HashSet all = UUIDHandler.getAllUUIDS(); PS.debug("&aFast mode UUID caching enabled!"); File playerDataFolder = new File(container, world + File.separator + "playerdata"); @@ -124,7 +124,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { PS.debug("Failed to cache: " + all.size() + " uuids - slowly processing all files"); } } - HashBiMap toAdd = HashBiMap.create(new HashMap()); HashSet worlds = Sets.newHashSet(world, "world"); HashSet uuids = new HashSet<>(); HashSet names = new HashSet<>(); 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 f71317949..99660f1a9 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -4,9 +4,12 @@ import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import java.util.List; import org.spongepowered.api.block.BlockState; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; import org.spongepowered.api.world.extent.MutableBlockVolume; @@ -33,6 +36,8 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { populators.add(generator); return generator; } + + private Cause cause = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); @Override public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) { @@ -44,7 +49,7 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { AugmentedUtils.generate(world.getName(), cx, cz, new DelegateLocalBlockQueue(null) { @Override public boolean setBlock(int x, int y, int z, int id, int data) { - terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data)); + terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), cause); return true; } From b91eab2f0cfde435882ba19c7eb5c71312f902cc Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:47:49 +1000 Subject: [PATCH 5/7] Minor sponge fixes --- Sponge/build.gradle | 4 ++-- Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java | 3 +++ .../sponge/generator/SpongeAugmentedGenerator.java | 6 +----- .../main/java/com/plotsquared/sponge/util/SpongeUtil.java | 3 ++- .../java/com/plotsquared/sponge/util/block/GenChunk.java | 3 ++- .../com/plotsquared/sponge/util/block/SpongeLocalQueue.java | 3 ++- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Sponge/build.gradle b/Sponge/build.gradle index 8b036dc26..4295fe4e7 100644 --- a/Sponge/build.gradle +++ b/Sponge/build.gradle @@ -14,7 +14,7 @@ buildscript { } } -apply plugin: 'net.minecrell.vanilla.server.library' +apply plugin: 'net.minecraftforge.gradle.forge' dependencies { compile project(':Core') @@ -35,7 +35,7 @@ repositories { } } minecraft { - version = "1.10.2" + version = "2014" mappings = "snapshot_20160629" runDir = 'run' } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 0ceef43dc..d62792e94 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -58,6 +58,8 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; @@ -80,6 +82,7 @@ import java.util.stream.Collectors; public class SpongeMain implements IPlotMain { public static SpongeMain THIS; + public static final Cause CAUSE = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); @Inject public PluginContainer plugin; 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 99660f1a9..8597d4300 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -8,8 +8,6 @@ import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import java.util.List; import org.spongepowered.api.block.BlockState; -import org.spongepowered.api.event.cause.Cause; -import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.ImmutableBiomeArea; import org.spongepowered.api.world.extent.MutableBlockVolume; @@ -37,8 +35,6 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { return generator; } - private Cause cause = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); - @Override public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeArea biome) { Vector3i min = terrain.getBlockMin(); @@ -49,7 +45,7 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { AugmentedUtils.generate(world.getName(), cx, cz, new DelegateLocalBlockQueue(null) { @Override public boolean setBlock(int x, int y, int z, int id, int data) { - terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), cause); + terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), SpongeMain.CAUSE); return true; } 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 e84d5f89a..f3fb6920c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; 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.Biome; @@ -429,7 +430,7 @@ public class SpongeUtil extends WorldUtil { @Override public void setSign(String worldName, int x, int y, int z, String[] lines) { World world = SpongeUtil.getWorld(worldName); - world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState()); + world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState(), SpongeMain.CAUSE); Optional block = world.getTileEntity(x, y, z); if (!block.isPresent()) { return; 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 361258217..a89860302 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,6 +4,7 @@ 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; @@ -52,7 +53,7 @@ public class GenChunk extends ScopedLocalBlockQueue { @Override public boolean setBlock(int x, int y, int z, int id, int data) { modified = true; - this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data)); + this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data), SpongeMain.CAUSE); return true; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index 52aed64b9..a2a62634e 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import java.lang.reflect.Field; import java.util.Arrays; @@ -441,7 +442,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { World worldObj = getSpongeWorld(); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ()); char[][] ids = ((CharLocalChunk) lc).blocks; - MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(); + MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(SpongeMain.CAUSE); blockWorker.map(new BlockVolumeMapper() { @Override public BlockState map(UnmodifiableBlockVolume volume, int xx, int y, int zz) { From 30d18c917d61c88ab924cbe8234309d56c98cc6c Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 25 Jul 2016 09:54:35 +1000 Subject: [PATCH 6/7] *should use this cause instead --- .../com/plotsquared/sponge/SpongeMain.java | 18 ++++++-------- .../generator/SpongeAugmentedGenerator.java | 3 +-- .../plotsquared/sponge/util/SpongeUtil.java | 24 +++++++++---------- .../sponge/util/block/GenChunk.java | 3 +-- .../sponge/util/block/SpongeLocalQueue.java | 3 +-- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index d62792e94..f43685b3d 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -51,6 +51,13 @@ import com.plotsquared.sponge.util.block.SpongeLocalQueue; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeUUIDHandler; +import java.io.File; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.UUID; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.spongepowered.api.Game; import org.spongepowered.api.Server; @@ -58,8 +65,6 @@ import org.spongepowered.api.Sponge; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.cause.Cause; -import org.spongepowered.api.event.cause.NamedCause; import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; @@ -69,20 +74,11 @@ import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; -import java.io.File; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; - @Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3") public class SpongeMain implements IPlotMain { public static SpongeMain THIS; - public static final Cause CAUSE = Cause.of(NamedCause.of("PlotSquared", SpongeMain.THIS)); @Inject public PluginContainer plugin; 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 8597d4300..172e2f7c1 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/generator/SpongeAugmentedGenerator.java @@ -4,7 +4,6 @@ import com.flowpowered.math.vector.Vector3i; import com.intellectualcrafters.plot.generator.AugmentedUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.block.DelegateLocalBlockQueue; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import java.util.List; import org.spongepowered.api.block.BlockState; @@ -45,7 +44,7 @@ public class SpongeAugmentedGenerator implements GenerationPopulator { AugmentedUtils.generate(world.getName(), cx, cz, new DelegateLocalBlockQueue(null) { @Override public boolean setBlock(int x, int y, int z, int id, int data) { - terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), SpongeMain.CAUSE); + terrain.setBlock(bx + x, y, bz + z, SpongeUtil.getBlockState(id, data), SpongeUtil.CAUSE); return true; } 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 f3fb6920c..b6784456c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -15,8 +15,17 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Optional; import net.minecraft.block.Block; import net.minecraft.world.biome.Biome; import org.spongepowered.api.Sponge; @@ -41,17 +50,6 @@ 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; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Optional; - public class SpongeUtil extends WorldUtil { public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared")); @@ -430,7 +428,7 @@ public class SpongeUtil extends WorldUtil { @Override public void setSign(String worldName, int x, int y, int z, String[] lines) { World world = SpongeUtil.getWorld(worldName); - world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState(), SpongeMain.CAUSE); + world.setBlock(x, y, z, BlockTypes.WALL_SIGN.getDefaultState(), CAUSE); Optional block = world.getTileEntity(x, y, z); if (!block.isPresent()) { return; 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 a89860302..be7c8fc9f 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,7 +4,6 @@ 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; @@ -53,7 +52,7 @@ public class GenChunk extends ScopedLocalBlockQueue { @Override public boolean setBlock(int x, int y, int z, int id, int data) { modified = true; - this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data), SpongeMain.CAUSE); + this.terrain.setBlock(this.bx + x, y, this.bz + z, SpongeUtil.getBlockState(id, data), SpongeUtil.CAUSE); return true; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java index a2a62634e..06d37177e 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SpongeLocalQueue.java @@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue; -import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; import java.lang.reflect.Field; import java.util.Arrays; @@ -442,7 +441,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue { World worldObj = getSpongeWorld(); org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ()); char[][] ids = ((CharLocalChunk) lc).blocks; - MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(SpongeMain.CAUSE); + MutableBlockVolumeWorker blockWorker = spongeChunk.getBlockWorker(SpongeUtil.CAUSE); blockWorker.map(new BlockVolumeMapper() { @Override public BlockState map(UnmodifiableBlockVolume volume, int xx, int y, int zz) { From ffddf5c18790f63a39fa9fa0d685ff5eb0bf3720 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 29 Jul 2016 12:12:28 +1000 Subject: [PATCH 7/7] Fix sponge generator cast --- .../bukkit/listeners/PlayerEvents.java | 3 + .../bukkit/uuid/FileUUIDHandler.java | 2 +- .../plot/commands/FlagCmd.java | 3 + .../plotsquared/sponge/SpongeSetupUtils.java | 81 ------------------- .../sponge/util/SpongeSetupUtils.java | 2 +- build.gradle | 2 +- pom.xml | 2 +- 7 files changed, 10 insertions(+), 85 deletions(-) delete mode 100644 Sponge/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 3cecf4b40..2f673a3b8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1375,6 +1375,9 @@ public class PlayerEvents extends PlotListener implements Listener { } public static boolean checkEntity(Plot plot, IntegerFlag... flags) { + if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(plot)) { + return true; + } int[] mobs = null; for (IntegerFlag flag : flags) { int i; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index a7c048572..fdd8a9816 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -97,7 +97,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation { ByteSource is = com.google.common.io.Files.asByteSource(file); NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION); if (!compound.containsKey("bukkit")) { - PS.debug("ERROR: Player data does not contain the the key \"bukkit\""); + PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\""); } else { NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit"); String name = (String) bukkit.get("lastKnownName"); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index a75cbff63..a2f127a71 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -166,6 +166,9 @@ public class FlagCmd extends SubCommand { return false; } } + if(flag == Flags.TIME) { + player.setTime(Long.MAX_VALUE); + } MainUtil.sendMessage(player, C.FLAG_REMOVED); return true; } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java deleted file mode 100644 index b5b33e7a8..000000000 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.plotsquared.sponge; - -import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.config.ConfigurationNode; -import com.intellectualcrafters.plot.generator.GeneratorWrapper; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.generator.PlotGenerator; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.SetupObject; -import com.intellectualcrafters.plot.util.SetupUtils; -import com.plotsquared.sponge.generator.SpongePlotGenerator; -import com.plotsquared.sponge.util.SpongeUtil; -import org.spongepowered.api.world.World; -import org.spongepowered.api.world.gen.WorldGenerator; - -import java.io.IOException; -import java.util.Map; - -public class SpongeSetupUtils extends SetupUtils { - - @Override - public void updateGenerators() { - if (!SetupUtils.generators.isEmpty()) { - return; - } - SetupUtils.generators.put("PlotSquared", new SpongePlotGenerator(new HybridGen())); - throw new UnsupportedOperationException("TODO FETCH EXTERNAL WorldGenerationModifiers"); - } - - @Override - public String getGenerator(final PlotArea plotArea) { - if (SetupUtils.generators.isEmpty()) { - updateGenerators(); - } - final World world = SpongeUtil.getWorld(plotArea.worldname); - if (world == null) { - return null; - } - final WorldGenerator generator = world.getWorldGenerator(); - if (!(generator instanceof SpongePlotGenerator)) { - return null; - } - for (final Map.Entry> entry : generators.entrySet()) { - GeneratorWrapper current = entry.getValue(); - if (current.equals(generator)) { - return entry.getKey(); - } - } - return null; - } - - @Override - public String setupWorld(final SetupObject object) { - SetupUtils.manager.updateGenerators(); - final ConfigurationNode[] steps = object.step; - final String world = object.world; - for (final ConfigurationNode step : steps) { - PS.get().worlds.set("worlds." + world + "." + step.getConstant(), step.getValue()); - } - if (object.type != 0) { - PS.get().worlds.set("worlds." + world + ".generator.type", object.type); - PS.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain); - PS.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager); - if ((object.setupGenerator != null) && !object.setupGenerator.equals(object.plotManager)) { - PS.get().worlds.set("worlds." + world + ".generator.init", object.setupGenerator); - } - final PlotGenerator gen = (PlotGenerator) generators.get(object.setupGenerator); - if ((gen != null) && (gen.generator instanceof SpongePlotGenerator)) { - object.setupGenerator = null; - } - } - try { - PS.get().worlds.save(PS.get().worldsFile); - } catch (final IOException e) { - e.printStackTrace(); - } - // TODO FIXME - throw new UnsupportedOperationException("NOT IMPLEMENTED YET: Create a new world here"); - // return object.world; - } -} diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java index a72b6574e..cea7fa5a3 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeSetupUtils.java @@ -140,7 +140,7 @@ public class SpongeSetupUtils extends SetupUtils { if (object.setupGenerator != null) { // create world with generator GeneratorWrapper gw = SetupUtils.generators.get(object.setupGenerator); - WorldArchetype wgm = (WorldArchetype) gw.getPlatformGenerator(); + WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator(); WorldArchetype settings = WorldArchetype.builder() .loadsOnStartup(true) diff --git a/build.gradle b/build.gradle index f8e70859e..c547fa0da 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ ext { git = Grgit.open() revision = "-${git.head().abbreviatedId}" } -version = "3.4.4-SNAPSHOT${revision}" +version = "3.4.5-SNAPSHOT${revision}" description = """PlotSquared""" subprojects { diff --git a/pom.xml b/pom.xml index a043d4ad1..789f1edb6 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ UTF-8 PlotSquared - 3.4.4-SNAPSHOT + 3.4.5-SNAPSHOT PlotSquared jar