mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Reformat code
This commit is contained in:
@ -6,7 +6,7 @@ buildscript {
|
||||
name = "forge"
|
||||
url = "http://files.minecraftforge.net/maven"
|
||||
}
|
||||
maven {url = "http://repo.minecrell.net/releases"}
|
||||
maven { url = "http://repo.minecrell.net/releases" }
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
|
@ -19,44 +19,18 @@ import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||
import com.plotsquared.sponge.listener.ChunkProcessor;
|
||||
import com.plotsquared.sponge.listener.MainListener;
|
||||
import com.plotsquared.sponge.listener.WorldEvents;
|
||||
import com.plotsquared.sponge.util.KillRoadMobs;
|
||||
import com.plotsquared.sponge.util.SpongeChatManager;
|
||||
import com.plotsquared.sponge.util.SpongeChunkManager;
|
||||
import com.plotsquared.sponge.util.SpongeCommand;
|
||||
import com.plotsquared.sponge.util.SpongeEconHandler;
|
||||
import com.plotsquared.sponge.util.SpongeEventUtil;
|
||||
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
||||
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
||||
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
||||
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
||||
import com.plotsquared.sponge.util.SpongeTaskManager;
|
||||
import com.plotsquared.sponge.util.SpongeTitleManager;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import com.plotsquared.sponge.util.*;
|
||||
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.IOException;
|
||||
import net.minecrell.mcstats.SpongeStatsLite;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.api.Game;
|
||||
@ -77,6 +51,7 @@ import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -84,29 +59,18 @@ 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.5.0-SNAPSHOT")
|
||||
@Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT")
|
||||
public class SpongeMain implements IPlotMain {
|
||||
|
||||
public static SpongeMain THIS;
|
||||
|
||||
@Inject
|
||||
public PluginContainer plugin;
|
||||
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
@Inject
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
public SpongeStatsLite stats;
|
||||
|
||||
@Inject public PluginContainer plugin;
|
||||
@Inject public SpongeStatsLite stats;
|
||||
@Inject private Logger logger;
|
||||
@Inject private Game game;
|
||||
private Server server;
|
||||
|
||||
@Inject
|
||||
@ConfigDir(sharedRoot = false)
|
||||
private Path privateConfigDir;
|
||||
@Inject @ConfigDir(sharedRoot = false) private Path privateConfigDir;
|
||||
|
||||
private GameProfileManager resolver;
|
||||
|
||||
@ -133,23 +97,23 @@ public class SpongeMain implements IPlotMain {
|
||||
return THIS;
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onPreInitialize(GamePreInitializationEvent event) {
|
||||
getLogger().info("The metrics section in PlotSquared is ignored in favor of the actual metrics reporter configurations.");
|
||||
@Listener public void onPreInitialize(GamePreInitializationEvent event) {
|
||||
getLogger().info(
|
||||
"The metrics section in PlotSquared is ignored in favor of the actual metrics reporter configurations.");
|
||||
this.stats.start();
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
THIS = this;
|
||||
new PS(this, "Sponge");
|
||||
this.server = this.game.getServer();
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) PS.get().IMP.getDefaultGenerator().specify(null));
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new SingleWorldGenerator().specify(null));
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class,
|
||||
(WorldGeneratorModifier) PS.get().IMP.getDefaultGenerator().specify(null));
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class,
|
||||
(WorldGeneratorModifier) new SingleWorldGenerator().specify(null));
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
TaskManager.IMP.taskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
unload();
|
||||
}
|
||||
}, 20);
|
||||
@ -190,8 +154,7 @@ public class SpongeMain implements IPlotMain {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
@Override public void log(String message) {
|
||||
message = C.format(message, C.replacements);
|
||||
if (!Settings.Chat.CONSOLE_COLOR) {
|
||||
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
|
||||
@ -203,119 +166,102 @@ public class SpongeMain implements IPlotMain {
|
||||
this.server.getConsole().sendMessage(SpongeUtil.getText(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDirectory() {
|
||||
@Override public File getDirectory() {
|
||||
return privateConfigDir.toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorldContainer() {
|
||||
@Override public File getWorldContainer() {
|
||||
return new File(game.getSavesDirectory().toFile(), "world");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
@Override public void disable() {
|
||||
PS.get().disable();
|
||||
THIS = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPluginVersion() {
|
||||
@Override public int[] getPluginVersion() {
|
||||
String ver = this.plugin.getVersion().orElse("");
|
||||
String[] split = ver.split("[\\.|-]");
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
||||
Integer.parseInt(split[2])};
|
||||
}
|
||||
|
||||
@Override public String getPluginVersionString() {
|
||||
return this.plugin.getVersion().orElse("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
@Override public String getPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getServerVersion() {
|
||||
@Override public int[] getServerVersion() {
|
||||
PS.log("Checking minecraft version: Sponge: ");
|
||||
String version = this.game.getPlatform().getMinecraftVersion().getName();
|
||||
String[] split = version.split("\\.");
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
||||
split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryUtil initInventoryUtil() {
|
||||
@Override public InventoryUtil initInventoryUtil() {
|
||||
return new SpongeInventoryUtil();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EconHandler getEconomyHandler() {
|
||||
@Override public EconHandler getEconomyHandler() {
|
||||
SpongeEconHandler econ = new SpongeEconHandler();
|
||||
Sponge.getEventManager().registerListeners(this, econ);
|
||||
return econ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventUtil initEventUtil() {
|
||||
@Override public EventUtil initEventUtil() {
|
||||
return new SpongeEventUtil();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkManager initChunkManager() {
|
||||
@Override public ChunkManager initChunkManager() {
|
||||
return new SpongeChunkManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SetupUtils initSetupUtils() {
|
||||
@Override public SetupUtils initSetupUtils() {
|
||||
return new SpongeSetupUtils();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HybridUtils initHybridUtils() {
|
||||
@Override public HybridUtils initHybridUtils() {
|
||||
return new SpongeHybridUtils();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchematicHandler initSchematicHandler() {
|
||||
@Override public SchematicHandler initSchematicHandler() {
|
||||
return new SpongeSchematicHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
@Override public TaskManager getTaskManager() {
|
||||
return new SpongeTaskManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runEntityTask() {
|
||||
@Override public void runEntityTask() {
|
||||
new KillRoadMobs().run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
getGame().getCommandManager().register(THIS, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2");
|
||||
@Override public void registerCommands() {
|
||||
getGame().getCommandManager()
|
||||
.register(THIS, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2",
|
||||
"2");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlayerEvents() {
|
||||
@Override public void registerPlayerEvents() {
|
||||
Sponge.getEventManager().registerListeners(this, new MainListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerInventoryEvents() {
|
||||
@Override public void registerInventoryEvents() {
|
||||
// Part of PlayerEvents - can be moved if necessary
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerPlotPlusEvents() {
|
||||
@Override public void registerPlotPlusEvents() {
|
||||
PS.log("registerPlotPlusEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerForceFieldEvents() {
|
||||
@Override public void registerForceFieldEvents() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initWorldEdit() {
|
||||
@Override public boolean initWorldEdit() {
|
||||
try {
|
||||
Class.forName("com.sk89q.worldedit.WorldEdit");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
@ -324,8 +270,7 @@ public class SpongeMain implements IPlotMain {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUIDHandlerImplementation initUUIDHandler() {
|
||||
@Override public UUIDHandlerImplementation initUUIDHandler() {
|
||||
UUIDWrapper wrapper;
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
wrapper = new SpongeLowerOfflineUUIDWrapper();
|
||||
@ -335,36 +280,31 @@ public class SpongeMain implements IPlotMain {
|
||||
return new SpongeUUIDHandler(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initPlotMeConverter() {
|
||||
@Override public boolean initPlotMeConverter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(PlotPlayer player) {
|
||||
@Override public void unregister(PlotPlayer player) {
|
||||
SpongeUtil.removePlayer(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerChunkProcessor() {
|
||||
@Override public void registerChunkProcessor() {
|
||||
Sponge.getEventManager().registerListeners(this, new ChunkProcessor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerWorldEvents() {
|
||||
@Override public void registerWorldEvents() {
|
||||
Sponge.getEventManager().registerListeners(this, new WorldEvents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMetrics() {
|
||||
@Override public void startMetrics() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerator(String worldName) {
|
||||
@Override public void setGenerator(String worldName) {
|
||||
World world = SpongeUtil.getWorld(worldName);
|
||||
if (world == null) {
|
||||
// create world
|
||||
ConfigurationSection worldConfig = PS.get().worlds.getConfigurationSection("worlds." + worldName);
|
||||
ConfigurationSection worldConfig =
|
||||
PS.get().worlds.getConfigurationSection("worlds." + worldName);
|
||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||
String generator = worldConfig.getString("generator.init", manager);
|
||||
|
||||
@ -387,17 +327,16 @@ public class SpongeMain implements IPlotMain {
|
||||
if (gen instanceof GeneratorWrapper) {
|
||||
PS.get().loadWorld(worldName, (GeneratorWrapper) gen);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET2! " + worldName + " | " + gen);
|
||||
throw new UnsupportedOperationException(
|
||||
"NOT IMPLEMENTED YET2! " + worldName + " | " + gen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractTitle initTitleManager() {
|
||||
@Override public AbstractTitle initTitleManager() {
|
||||
return new SpongeTitleManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotPlayer wrapPlayer(Object player) {
|
||||
@Override public PlotPlayer wrapPlayer(Object player) {
|
||||
if (player instanceof Player) {
|
||||
return SpongeUtil.getPlayer((Player) player);
|
||||
} else if (UUIDHandler.implementation == null) {
|
||||
@ -411,33 +350,29 @@ public class SpongeMain implements IPlotMain {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNMSPackage() {
|
||||
@Override public String getNMSPackage() {
|
||||
return "";//TODO FIXME
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatManager<?> initChatManager() {
|
||||
@Override public ChatManager<?> initChatManager() {
|
||||
return new SpongeChatManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueProvider initBlockQueue() {
|
||||
@Override public QueueProvider initBlockQueue() {
|
||||
MainUtil.canSendChunk = true;
|
||||
return QueueProvider.of(SpongeLocalQueue.class, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldUtil initWorldUtil() {
|
||||
@Override public WorldUtil initWorldUtil() {
|
||||
return new SpongeUtil();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorWrapper<?> getGenerator(String world, String name) {
|
||||
@Override public GeneratorWrapper<?> getGenerator(String world, String name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
Collection<WorldGeneratorModifier> wgms = this.game.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||
Collection<WorldGeneratorModifier> wgms =
|
||||
this.game.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||
for (WorldGeneratorModifier wgm : wgms) {
|
||||
if (StringMan.isEqualIgnoreCaseToAny(name, wgm.getName(), wgm.getId())) {
|
||||
if (wgm instanceof GeneratorWrapper<?>) {
|
||||
@ -454,14 +389,13 @@ public class SpongeMain implements IPlotMain {
|
||||
return new SpongePlotGenerator(generator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginIds() {
|
||||
return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
@Override public List<String> getPluginIds() {
|
||||
return this.game.getPluginManager().getPlugins().stream()
|
||||
.map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndependentPlotGenerator getDefaultGenerator() {
|
||||
@Override public IndependentPlotGenerator getDefaultGenerator() {
|
||||
return new HybridGen();
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,22 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
|
||||
public class ClusterFlagRemoveEvent extends AbstractEvent implements Cancellable {
|
||||
|
||||
|
||||
private final PlotCluster cluster;
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
public ClusterFlagRemoveEvent(final Flag flag, final PlotCluster cluster) {
|
||||
this.cluster = cluster;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the cluster involved
|
||||
*
|
||||
@ -26,7 +25,7 @@ public class ClusterFlagRemoveEvent extends AbstractEvent implements Cancellable
|
||||
public PlotCluster getCluster() {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
@ -35,19 +34,16 @@ public class ClusterFlagRemoveEvent extends AbstractEvent implements Cancellable
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
|
||||
private final Plot plot;
|
||||
private final boolean auto;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerClaimPlotEvent: Called when a plot is claimed
|
||||
*
|
||||
@ -23,7 +22,7 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
this.plot = plot;
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
@ -32,26 +31,23 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
|
||||
public Plot getPlot() {
|
||||
return plot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if it was an automated claim, else false
|
||||
*/
|
||||
public boolean wasAuto() {
|
||||
return auto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
|
||||
|
||||
private final Plot plot;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerEnterPlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
@ -19,7 +18,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
@ -28,9 +27,8 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
|
||||
public Plot getPlot() {
|
||||
return plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -5,19 +5,18 @@ import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
public abstract class PlayerEvent extends AbstractEvent {
|
||||
|
||||
|
||||
public final Player player;
|
||||
|
||||
|
||||
public PlayerEvent(final Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
|
||||
|
||||
private final Plot plot;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerLeavePlotEvent: Called when a player leaves a plot
|
||||
*
|
||||
@ -18,7 +17,7 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
|
||||
super(player);
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot involved
|
||||
*
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
|
||||
|
||||
private final Player initiator;
|
||||
private final boolean added;
|
||||
private final UUID player;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerPlotDeniedEvent: Called when the denied UUID list is modified for a plot
|
||||
*
|
||||
@ -20,13 +19,14 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
* @param player Player that was denied/un-denied
|
||||
* @param added true of add to deny list, false if removed
|
||||
*/
|
||||
public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
public PlayerPlotDeniedEvent(final Player initiator, final Plot plot, final UUID player,
|
||||
final boolean added) {
|
||||
super(plot);
|
||||
this.initiator = initiator;
|
||||
this.added = added;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If a user was added
|
||||
*
|
||||
@ -35,7 +35,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
public boolean wasAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player added/removed
|
||||
*
|
||||
@ -44,7 +44,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerPlotHelperEvent extends PlotEvent {
|
||||
|
||||
|
||||
private final Player initiator;
|
||||
private final boolean added;
|
||||
private final UUID player;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerPlotHelperEvent: Called when a plot helper is added/removed
|
||||
*
|
||||
@ -20,13 +19,14 @@ public class PlayerPlotHelperEvent extends PlotEvent {
|
||||
* @param player Player that was added/removed from the helper list
|
||||
* @param added true of the player was added, false if the player was removed
|
||||
*/
|
||||
public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
public PlayerPlotHelperEvent(final Player initiator, final Plot plot, final UUID player,
|
||||
final boolean added) {
|
||||
super(plot);
|
||||
this.initiator = initiator;
|
||||
this.added = added;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If a user was added
|
||||
*
|
||||
@ -35,7 +35,7 @@ public class PlayerPlotHelperEvent extends PlotEvent {
|
||||
public boolean wasAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player added/removed
|
||||
*
|
||||
@ -44,7 +44,7 @@ public class PlayerPlotHelperEvent extends PlotEvent {
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
|
@ -1,17 +1,16 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||
|
||||
|
||||
private final Player initiator;
|
||||
private final boolean added;
|
||||
private final UUID player;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerPlotTrustedEvent: Called when a plot trusted user is added/removed
|
||||
*
|
||||
@ -20,13 +19,14 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||
* @param player Player that was added/removed from the trusted list
|
||||
* @param added true of the player was added, false if the player was removed
|
||||
*/
|
||||
public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player, final boolean added) {
|
||||
public PlayerPlotTrustedEvent(final Player initiator, final Plot plot, final UUID player,
|
||||
final boolean added) {
|
||||
super(plot);
|
||||
this.initiator = initiator;
|
||||
this.added = added;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If a user was added
|
||||
*
|
||||
@ -35,7 +35,7 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||
public boolean wasAdded() {
|
||||
return added;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player added/removed
|
||||
*
|
||||
@ -44,7 +44,7 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The player initiating the action
|
||||
*
|
||||
|
@ -6,24 +6,24 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
|
||||
private final Location from;
|
||||
private final Plot plot;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
/**
|
||||
* PlayerTeleportToPlotEvent: Called when a player teleports to a plot.
|
||||
*
|
||||
* @param player That was teleported
|
||||
* @param from Start location
|
||||
* @param plot Plot to which the player was teleported
|
||||
* @param from Start location
|
||||
* @param plot Plot to which the player was teleported
|
||||
*/
|
||||
public PlayerTeleportToPlotEvent(Player player, Location from, Plot plot) {
|
||||
super(player);
|
||||
this.from = from;
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the from location.
|
||||
*
|
||||
@ -32,7 +32,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plot involved.
|
||||
*
|
||||
@ -41,14 +41,12 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
|
||||
public Plot getPlot() {
|
||||
return this.plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable {
|
||||
public PlotId getPlotId() {
|
||||
return this.plot.getId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the world name.
|
||||
*
|
||||
@ -38,19 +38,16 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable {
|
||||
public String getWorld() {
|
||||
return this.plot.getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
public class PlotComponentSetEvent extends AbstractEvent {
|
||||
private final Plot plot;
|
||||
private final String component;
|
||||
@ -13,8 +12,8 @@ public class PlotComponentSetEvent extends AbstractEvent {
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot component is set
|
||||
*
|
||||
* @param plot The plot
|
||||
* @param component The component which was set
|
||||
* @param plot The plot
|
||||
* @param component The component which was set
|
||||
*/
|
||||
public PlotComponentSetEvent(Plot plot, String component) {
|
||||
this.plot = plot;
|
||||
@ -48,8 +47,7 @@ public class PlotComponentSetEvent extends AbstractEvent {
|
||||
return this.component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,22 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
|
||||
public class PlotDeleteEvent extends AbstractEvent {
|
||||
private final Plot plot;
|
||||
|
||||
/**
|
||||
* PlotDeleteEvent: Called when a plot is deleted
|
||||
*
|
||||
* @param plot The plot that was deleted
|
||||
* @param plot The plot that was deleted
|
||||
*/
|
||||
public PlotDeleteEvent(Plot plot) {
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the PlotId
|
||||
*
|
||||
@ -26,7 +25,7 @@ public class PlotDeleteEvent extends AbstractEvent {
|
||||
public PlotId getPlotId() {
|
||||
return plot.getId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the world name
|
||||
*
|
||||
@ -35,9 +34,8 @@ public class PlotDeleteEvent extends AbstractEvent {
|
||||
public String getWorld() {
|
||||
return plot.getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,22 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public abstract class PlotEvent extends AbstractEvent {
|
||||
|
||||
|
||||
private final Plot plot;
|
||||
|
||||
|
||||
public PlotEvent(final Plot plot) {
|
||||
this.plot = plot;
|
||||
}
|
||||
|
||||
|
||||
public final Plot getPlot() {
|
||||
return plot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
/**
|
||||
* PlotFlagAddEvent: Called when a Flag is added to a plot
|
||||
*
|
||||
@ -19,7 +18,7 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
super(plot);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
@ -28,14 +27,12 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
|
||||
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
private final Flag flag;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
/**
|
||||
* PlotFlagRemoveEvent: Called when a flag is removed from a plot
|
||||
*
|
||||
@ -19,7 +18,7 @@ public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
super(plot);
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the flag involved
|
||||
*
|
||||
@ -28,14 +27,12 @@ public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
|
||||
public Flag getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,20 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlotMergeEvent extends AbstractEvent implements Cancellable {
|
||||
private final ArrayList<PlotId> plots;
|
||||
private boolean cancelled;
|
||||
private Plot plot;
|
||||
private World world;
|
||||
|
||||
|
||||
/**
|
||||
* PlotMergeEvent: Called when plots are merged
|
||||
*
|
||||
@ -26,7 +25,7 @@ public class PlotMergeEvent extends AbstractEvent implements Cancellable {
|
||||
public PlotMergeEvent(final World world, final Plot plot, final ArrayList<PlotId> plots) {
|
||||
this.plots = plots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plots being added;
|
||||
*
|
||||
@ -35,7 +34,7 @@ public class PlotMergeEvent extends AbstractEvent implements Cancellable {
|
||||
public ArrayList<PlotId> getPlots() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the main plot
|
||||
*
|
||||
@ -44,23 +43,20 @@ public class PlotMergeEvent extends AbstractEvent implements Cancellable {
|
||||
public Plot getPlot() {
|
||||
return plot;
|
||||
}
|
||||
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -7,22 +7,22 @@ import com.intellectualcrafters.plot.object.Rating;
|
||||
public class PlotRateEvent extends PlotEvent {
|
||||
private final PlotPlayer rater;
|
||||
private Rating rating;
|
||||
|
||||
|
||||
public PlotRateEvent(final PlotPlayer rater, final Rating rating, final Plot plot) {
|
||||
super(plot);
|
||||
this.rater = rater;
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
|
||||
public PlotPlayer getRater() {
|
||||
return rater;
|
||||
}
|
||||
|
||||
public void setRating(final Rating rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
|
||||
|
||||
public Rating getRating() {
|
||||
return rating;
|
||||
}
|
||||
|
||||
public void setRating(final Rating rating) {
|
||||
this.rating = rating;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.plotsquared.sponge.events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.spongepowered.api.event.Cancellable;
|
||||
import org.spongepowered.api.event.cause.Cause;
|
||||
import org.spongepowered.api.event.impl.AbstractEvent;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PlotUnlinkEvent extends AbstractEvent implements Cancellable {
|
||||
private final ArrayList<PlotId> plots;
|
||||
private final World world;
|
||||
private boolean cancelled;
|
||||
|
||||
|
||||
/**
|
||||
* Called when a mega-plot is unlinked.
|
||||
*
|
||||
@ -24,7 +23,7 @@ public class PlotUnlinkEvent extends AbstractEvent implements Cancellable {
|
||||
this.plots = plots;
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the plots involved
|
||||
*
|
||||
@ -33,23 +32,20 @@ public class PlotUnlinkEvent extends AbstractEvent implements Cancellable {
|
||||
public ArrayList<PlotId> getPlots() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
|
||||
@Override public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancel) {
|
||||
|
||||
@Override public void setCancelled(final boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cause getCause() {
|
||||
|
||||
@Override public Cause getCause() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import java.util.List;
|
||||
|
||||
public class SpongeAugmentedGenerator implements GenerationPopulator {
|
||||
|
||||
|
||||
private static SpongeAugmentedGenerator generator;
|
||||
|
||||
private SpongeAugmentedGenerator() {}
|
||||
private SpongeAugmentedGenerator() {
|
||||
}
|
||||
|
||||
public static SpongeAugmentedGenerator get(World world) {
|
||||
WorldGenerator wg = world.getWorldGenerator();
|
||||
@ -43,25 +44,21 @@ public class SpongeAugmentedGenerator implements GenerationPopulator {
|
||||
int cx = bx >> 4;
|
||||
int cz = bz >> 4;
|
||||
AugmentedUtils.generate(world.getName(), cx, cz, new DelegateLocalBlockQueue(null) {
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int id, int data) {
|
||||
@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));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock getBlock(int x, int y, int z) {
|
||||
@Override public PlotBlock getBlock(int x, int y, int z) {
|
||||
BlockState block = terrain.getBlock(bx + x, y, bz + z);
|
||||
return SpongeUtil.getPlotBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, String biome) {
|
||||
@Override public boolean setBiome(int x, int z, String biome) {
|
||||
return false; // TODO ?
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorld() {
|
||||
@Override public String getWorld() {
|
||||
return world.getName();
|
||||
}
|
||||
});
|
||||
|
@ -23,22 +23,23 @@ import org.spongepowered.api.world.storage.WorldProperties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWrapper<WorldGeneratorModifier> {
|
||||
|
||||
public class SpongePlotGenerator
|
||||
implements WorldGeneratorModifier, GeneratorWrapper<WorldGeneratorModifier> {
|
||||
|
||||
private final IndependentPlotGenerator plotGenerator;
|
||||
private final List<GenerationPopulator> populators = new ArrayList<>();
|
||||
private final boolean loaded = false;
|
||||
private final WorldGeneratorModifier platformGenerator;
|
||||
private final boolean full;
|
||||
private PlotManager manager;
|
||||
|
||||
|
||||
public SpongePlotGenerator(IndependentPlotGenerator generator) {
|
||||
this.plotGenerator = generator;
|
||||
this.platformGenerator = this;
|
||||
this.full = true;
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
|
||||
public SpongePlotGenerator(WorldGeneratorModifier wgm) {
|
||||
this.plotGenerator = null;
|
||||
this.platformGenerator = wgm;
|
||||
@ -46,8 +47,7 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@Override public String getId() {
|
||||
if (this.plotGenerator == null) {
|
||||
if (this.platformGenerator != this) {
|
||||
return this.platformGenerator.getId();
|
||||
@ -56,9 +56,8 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
||||
}
|
||||
return this.plotGenerator.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@Override public String getName() {
|
||||
if (this.plotGenerator == null) {
|
||||
if (this.platformGenerator != this) {
|
||||
return this.platformGenerator.getName();
|
||||
@ -67,14 +66,13 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
||||
}
|
||||
return this.plotGenerator.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modifyWorldGenerator(WorldProperties world, DataContainer settings, WorldGenerator worldGenerator) {
|
||||
|
||||
@Override public void modifyWorldGenerator(WorldProperties world, DataContainer settings,
|
||||
WorldGenerator worldGenerator) {
|
||||
String worldName = world.getWorldName();
|
||||
worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this.plotGenerator));
|
||||
worldGenerator.setBiomeGenerator(new BiomeGenerator() {
|
||||
@Override
|
||||
public void generateBiomes(MutableBiomeVolume buffer) {
|
||||
@Override public void generateBiomes(MutableBiomeVolume buffer) {
|
||||
PlotArea area = PS.get().getPlotArea(worldName, null);
|
||||
if (area != null) {
|
||||
BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME);
|
||||
@ -83,40 +81,36 @@ public class SpongePlotGenerator implements WorldGeneratorModifier, GeneratorWra
|
||||
for (int x = min.getX(); x <= max.getX(); x++) {
|
||||
for (int z = min.getZ(); z <= max.getZ(); z++) {
|
||||
buffer.setBiome(x, 0, z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
for (BiomeType type : ReflectionUtils.<BiomeType> getStaticFields(BiomeTypes.class)) {
|
||||
for (BiomeType type : ReflectionUtils.<BiomeType>getStaticFields(BiomeTypes.class)) {
|
||||
BiomeGenerationSettings biomeSettings = worldGenerator.getBiomeSettings(type);
|
||||
biomeSettings.getGenerationPopulators().clear();
|
||||
biomeSettings.getPopulators().clear();
|
||||
biomeSettings.getGroundCoverLayers().clear();
|
||||
}
|
||||
}
|
||||
worldGenerator.getGenerationPopulators().clear();
|
||||
worldGenerator.getPopulators().clear();
|
||||
PS.get().loadWorld(worldName, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndependentPlotGenerator getPlotGenerator() {
|
||||
|
||||
@Override public IndependentPlotGenerator getPlotGenerator() {
|
||||
return this.plotGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldGeneratorModifier getPlatformGenerator() {
|
||||
|
||||
@Override public WorldGeneratorModifier getPlatformGenerator() {
|
||||
return this.platformGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void augment(PlotArea area) {
|
||||
|
||||
@Override public void augment(PlotArea area) {
|
||||
SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
|
||||
@Override public boolean isFull() {
|
||||
return this.full;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,13 +16,14 @@ import org.spongepowered.api.world.extent.ImmutableBiomeVolume;
|
||||
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||
import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||
|
||||
public class SpongeTerrainGen implements GenerationPopulator, GeneratorWrapper<GenerationPopulator> {
|
||||
|
||||
public class SpongeTerrainGen
|
||||
implements GenerationPopulator, GeneratorWrapper<GenerationPopulator> {
|
||||
|
||||
public final IndependentPlotGenerator child;
|
||||
private final boolean full;
|
||||
private final GenerationPopulator platformGenerator;
|
||||
private final PseudoRandom random = new PseudoRandom();
|
||||
|
||||
|
||||
public SpongeTerrainGen(IndependentPlotGenerator ipg) {
|
||||
this.child = ipg;
|
||||
this.full = true;
|
||||
@ -36,7 +37,7 @@ public class SpongeTerrainGen implements GenerationPopulator, GeneratorWrapper<G
|
||||
this.full = false;
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void populate(World world, MutableBlockVolume terrain, ImmutableBiomeVolume biomes) {
|
||||
if (platformGenerator != this) {
|
||||
@ -75,23 +76,19 @@ public class SpongeTerrainGen implements GenerationPopulator, GeneratorWrapper<G
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndependentPlotGenerator getPlotGenerator() {
|
||||
@Override public IndependentPlotGenerator getPlotGenerator() {
|
||||
return child;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenerationPopulator getPlatformGenerator() {
|
||||
@Override public GenerationPopulator getPlatformGenerator() {
|
||||
return platformGenerator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void augment(PlotArea area) {
|
||||
@Override public void augment(PlotArea area) {
|
||||
SpongeAugmentedGenerator.get(SpongeUtil.getWorld(area.worldname));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull() {
|
||||
@Override public boolean isFull() {
|
||||
return this.full;
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,12 @@ public class ForceFieldListener {
|
||||
|
||||
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) {
|
||||
for (Entity nearbyEntity : player
|
||||
.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) {
|
||||
Player nearbyPlayer = (Player) nearbyEntity;
|
||||
PlotPlayer plotPlayer;
|
||||
if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot
|
||||
.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
@ -34,10 +36,12 @@ public class ForceFieldListener {
|
||||
}
|
||||
|
||||
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
|
||||
for (Entity nearbyEntity : player.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) {
|
||||
for (Entity nearbyEntity : player
|
||||
.getNearbyEntities(entity -> entity.getType().equals(EntityTypes.PLAYER))) {
|
||||
Player nearbyPlayer = (Player) nearbyEntity;
|
||||
PlotPlayer plotPlayer;
|
||||
if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
if ((plotPlayer = SpongeUtil.getPlayer(nearbyPlayer)) == null || !plot
|
||||
.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
@ -83,7 +87,8 @@ public class ForceFieldListener {
|
||||
if (plot.isAdded(uuid)) {
|
||||
Set<PlotPlayer> players = getNearbyPlayers(player, plot);
|
||||
for (PlotPlayer oPlayer : players) {
|
||||
((SpongePlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
|
||||
((SpongePlayer) oPlayer).player
|
||||
.setVelocity(calculateVelocity(plotPlayer, oPlayer));
|
||||
}
|
||||
} else {
|
||||
PlotPlayer oPlayer = hasNearbyPermitted(player, plot);
|
||||
|
@ -3,32 +3,12 @@ package com.plotsquared.sponge.listener;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Predicate;
|
||||
import org.spongepowered.api.block.BlockSnapshot;
|
||||
import org.spongepowered.api.block.BlockState;
|
||||
import org.spongepowered.api.data.Transaction;
|
||||
@ -55,8 +35,12 @@ import org.spongepowered.api.event.world.ExplosionEvent.Detonate;
|
||||
import org.spongepowered.api.text.Text;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
@SuppressWarnings("Guava")
|
||||
public class MainListener {
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@SuppressWarnings("Guava") public class MainListener {
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
@ -83,8 +67,7 @@ public class MainListener {
|
||||
* - enderman harvest
|
||||
*/
|
||||
|
||||
@Listener
|
||||
public void onChat(MessageEvent event) {
|
||||
@Listener public void onChat(MessageEvent event) {
|
||||
// TODO
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
@ -96,7 +79,8 @@ public class MainListener {
|
||||
}
|
||||
PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
||||
PlotPlayer plr = SpongeUtil.getPlayer(player);
|
||||
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr.getMeta("chat"))) {
|
||||
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr
|
||||
.getMeta("chat"))) {
|
||||
return;
|
||||
}
|
||||
Location loc = SpongeUtil.getLocation(player);
|
||||
@ -111,7 +95,8 @@ public class MainListener {
|
||||
|
||||
String sender = player.getName();
|
||||
PlotId id = plot.getId();
|
||||
String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
String newMessage = StringMan
|
||||
.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
PlotPlayer user = entry.getValue();
|
||||
@ -140,8 +125,7 @@ public class MainListener {
|
||||
//event.setMessage(null);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBreedEntity(BreedEntityEvent.Breed event) {
|
||||
@Listener public void onBreedEntity(BreedEntityEvent.Breed event) {
|
||||
Location loc = SpongeUtil.getLocation(event.getTargetEntity());
|
||||
String world = loc.getWorld();
|
||||
PlotArea plotworld = PS.get().getPlotAreaByString(world);
|
||||
@ -160,8 +144,7 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
@Listener public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
event.filterEntities(entity -> {
|
||||
if (entity instanceof Player) {
|
||||
return true;
|
||||
@ -199,7 +182,8 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
if (entity instanceof Ambient || entity instanceof Animal) {
|
||||
com.google.common.base.Optional<Integer> animalFlag = plot.getFlag(Flags.ANIMAL_CAP);
|
||||
com.google.common.base.Optional<Integer> animalFlag =
|
||||
plot.getFlag(Flags.ANIMAL_CAP);
|
||||
if (animalFlag.isPresent()) {
|
||||
int cap = animalFlag.get();
|
||||
if (cap == 0) {
|
||||
@ -213,7 +197,8 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
} else if (entity instanceof Monster) {
|
||||
com.google.common.base.Optional<Integer> monsterFlag = plot.getFlag(Flags.HOSTILE_CAP);
|
||||
com.google.common.base.Optional<Integer> monsterFlag =
|
||||
plot.getFlag(Flags.HOSTILE_CAP);
|
||||
if (monsterFlag.isPresent()) {
|
||||
int cap = monsterFlag.get();
|
||||
if (cap == 0) {
|
||||
@ -229,7 +214,8 @@ public class MainListener {
|
||||
}
|
||||
return true;
|
||||
} else if (entity instanceof Minecart || entity instanceof Boat) {
|
||||
com.google.common.base.Optional<Integer> vehicleFlag = plot.getFlag(Flags.VEHICLE_CAP);
|
||||
com.google.common.base.Optional<Integer> vehicleFlag =
|
||||
plot.getFlag(Flags.VEHICLE_CAP);
|
||||
if (vehicleFlag.isPresent()) {
|
||||
int cap = vehicleFlag.get();
|
||||
if (cap == 0) {
|
||||
@ -297,8 +283,7 @@ public class MainListener {
|
||||
// });
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onInteract(InteractBlockEvent event) {
|
||||
@Listener public void onInteract(InteractBlockEvent event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
event.setCancelled(true);
|
||||
@ -334,7 +319,8 @@ public class MainListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> flag = plot.getFlag(Flags.USE);
|
||||
@ -348,8 +334,7 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onExplosion(ExplosionEvent e) {
|
||||
@Listener public void onExplosion(ExplosionEvent e) {
|
||||
if (e instanceof ExplosionEvent.Detonate) {
|
||||
ExplosionEvent.Detonate event = (Detonate) e;
|
||||
World world = event.getTargetWorld();
|
||||
@ -383,8 +368,11 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
|
||||
event.getAffectedLocations().removeIf(worldLocation -> currentPlot.equals(SpongeUtil.getLocation(worldLocation.getExtent().getName(), worldLocation).getPlot()));
|
||||
event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot()));
|
||||
event.getAffectedLocations().removeIf(worldLocation -> currentPlot.equals(
|
||||
SpongeUtil.getLocation(worldLocation.getExtent().getName(), worldLocation)
|
||||
.getPlot()));
|
||||
event.filterEntities(
|
||||
entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -410,23 +398,19 @@ public class MainListener {
|
||||
event.filter(loc1 -> !SpongeUtil.getLocation(worldName, loc1).isPlotRoad());
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockBreak(ChangeBlockEvent.Decay event) {
|
||||
@Listener public void onBlockBreak(ChangeBlockEvent.Decay event) {
|
||||
onChangeBlock(event);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockBreak(ChangeBlockEvent.Grow event) {
|
||||
@Listener public void onBlockBreak(ChangeBlockEvent.Grow event) {
|
||||
onChangeBlock(event);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockBreak(ChangeBlockEvent.Modify event) {
|
||||
@Listener public void onBlockBreak(ChangeBlockEvent.Modify event) {
|
||||
onChangeBlock(event);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockBreak(ChangeBlockEvent.Break event) {
|
||||
@Listener public void onBlockBreak(ChangeBlockEvent.Break event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
//SpongeUtil.printCause("break", event.getCause());
|
||||
@ -458,13 +442,16 @@ public class MainListener {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> destroy =
|
||||
plot.getFlag(Flags.BREAK);
|
||||
BlockState state = original.getState();
|
||||
if (!destroy.isPresent() || !destroy.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
if (!destroy.isPresent() || !destroy.get()
|
||||
.contains(SpongeUtil.getPlotBlock(state))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -486,8 +473,10 @@ public class MainListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (!plot1.isAdded(pp.getUUID()) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER, true)) {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> destroy = plot1.getFlag(Flags.BREAK);
|
||||
if (!plot1.isAdded(pp.getUUID()) && !Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER, true)) {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> destroy =
|
||||
plot1.getFlag(Flags.BREAK);
|
||||
BlockState state = l.getBlock();
|
||||
if (destroy.isPresent() && destroy.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
return true;
|
||||
@ -499,8 +488,7 @@ public class MainListener {
|
||||
});
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockPlace(ChangeBlockEvent.Pre event) {
|
||||
@Listener public void onBlockPlace(ChangeBlockEvent.Pre event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
return;
|
||||
@ -522,10 +510,12 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place =
|
||||
plot.getFlag(Flags.PLACE);
|
||||
BlockState state = first.getBlock();
|
||||
if (!place.isPresent() || !place.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
@ -543,8 +533,7 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockPlace(ChangeBlockEvent.Place event) {
|
||||
@Listener public void onBlockPlace(ChangeBlockEvent.Place event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
return;
|
||||
@ -568,13 +557,17 @@ public class MainListener {
|
||||
}
|
||||
} else if (transactions.size() == 1) {
|
||||
if (plot.hasOwner()) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place =
|
||||
plot.getFlag(Flags.PLACE);
|
||||
BlockState state = pos.getState();
|
||||
if (!place.isPresent() || !place.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
if (!place.isPresent() || !place.get()
|
||||
.contains(SpongeUtil.getPlotBlock(state))) {
|
||||
MainUtil
|
||||
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -589,12 +582,12 @@ public class MainListener {
|
||||
}
|
||||
} else {
|
||||
event.filter(new Predicate<org.spongepowered.api.world.Location<World>>() {
|
||||
@Override
|
||||
public boolean test(org.spongepowered.api.world.Location<World> l) {
|
||||
@Override public boolean test(org.spongepowered.api.world.Location<World> l) {
|
||||
Location loc = SpongeUtil.getLocation(worldName, l);
|
||||
Plot plot = loc.getPlot();
|
||||
if (plot == null) {
|
||||
return loc.getPlotArea() == null || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD, true);
|
||||
return loc.getPlotArea() == null || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD, true);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED, true)) {
|
||||
@ -602,15 +595,19 @@ public class MainListener {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true)) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true)) {
|
||||
return true;
|
||||
} else {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place =
|
||||
plot.getFlag(Flags.PLACE);
|
||||
BlockState state = l.getBlock();
|
||||
if (place.isPresent() && place.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
if (place.isPresent() && place.get()
|
||||
.contains(SpongeUtil.getPlotBlock(state))) {
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
MainUtil
|
||||
.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -618,8 +615,7 @@ public class MainListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onJoin(ClientConnectionEvent.Join event) {
|
||||
@Listener public void onJoin(ClientConnectionEvent.Join event) {
|
||||
Player player = event.getTargetEntity();
|
||||
SpongeUtil.getPlayer(player).unregister();
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
@ -646,15 +642,13 @@ public class MainListener {
|
||||
TaskManager.runTaskLaterAsync(() -> EventUtil.manager.doJoinTask(pp), 20);
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onQuit(ClientConnectionEvent.Disconnect event) {
|
||||
@Listener public void onQuit(ClientConnectionEvent.Disconnect event) {
|
||||
Player player = event.getTargetEntity();
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
pp.unregister();
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onMove(MoveEntityEvent event) {
|
||||
@Listener public void onMove(MoveEntityEvent event) {
|
||||
if (!(event.getTargetEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
@ -9,9 +9,8 @@ import org.spongepowered.api.world.gen.GenerationPopulator;
|
||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
|
||||
public class WorldEvents {
|
||||
|
||||
@Listener
|
||||
public void onLoadWorld(LoadWorldEvent event) {
|
||||
|
||||
@Listener public void onLoadWorld(LoadWorldEvent event) {
|
||||
final World world = event.getTargetWorld();
|
||||
final String name = world.getName();
|
||||
WorldGenerator generator = world.getWorldGenerator();
|
||||
@ -19,8 +18,7 @@ public class WorldEvents {
|
||||
if (terrain instanceof GeneratorWrapper) {
|
||||
GeneratorWrapper stg = (GeneratorWrapper) terrain;
|
||||
PS.get().loadWorld(name, stg);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
PS.get().loadWorld(name, null);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public class SpongeOfflinePlayer implements OfflinePlotPlayer {
|
||||
public SpongeOfflinePlayer(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override public UUID getUUID() {
|
||||
return user.getUniqueId();
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongePlayer extends PlotPlayer {
|
||||
|
||||
|
||||
public final Player player;
|
||||
private UUID uuid;
|
||||
private String name;
|
||||
@ -36,14 +36,12 @@ public class SpongePlayer extends PlotPlayer {
|
||||
this.player = player;
|
||||
super.populatePersistentMetaMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequiredType getSuperCaller() {
|
||||
|
||||
@Override public RequiredType getSuperCaller() {
|
||||
return RequiredType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
@Override public Location getLocation() {
|
||||
Location location = super.getLocation();
|
||||
if (location == null) {
|
||||
return SpongeUtil.getLocation(this.player);
|
||||
@ -51,14 +49,12 @@ public class SpongePlayer extends PlotPlayer {
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocationFull() {
|
||||
|
||||
@Override public Location getLocationFull() {
|
||||
return SpongeUtil.getLocationFull(this.player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
|
||||
@Override public UUID getUUID() {
|
||||
if (this.uuid == null) {
|
||||
this.uuid = UUIDHandler.getUUID(this);
|
||||
}
|
||||
@ -69,72 +65,69 @@ public class SpongePlayer extends PlotPlayer {
|
||||
return this.player.lastPlayed().get().toEpochMilli();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
@Override public boolean hasPermission(String permission) {
|
||||
return this.player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String permission) {
|
||||
Tristate state = this.player.getPermissionValue(this.player.getActiveContexts(), permission);
|
||||
@Override public boolean isPermissionSet(String permission) {
|
||||
Tristate state =
|
||||
this.player.getPermissionValue(this.player.getActiveContexts(), permission);
|
||||
return state != Tristate.UNDEFINED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
@Override public void sendMessage(String message) {
|
||||
if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
|
||||
System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||
setMeta("lastMessage", message);
|
||||
setMeta("lastMessageTime", System.currentTimeMillis());
|
||||
this.player.sendMessage(ChatTypes.CHAT, TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
|
||||
this.player.sendMessage(ChatTypes.CHAT,
|
||||
TextSerializers.LEGACY_FORMATTING_CODE.deserialize(message));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location location) {
|
||||
|
||||
@Override public void teleport(Location location) {
|
||||
if ((Math.abs(location.getX()) >= 30000000) || (Math.abs(location.getZ()) >= 30000000)) {
|
||||
return;
|
||||
}
|
||||
String world = this.player.getWorld().getName();
|
||||
if (!world.equals(location.getWorld())) {
|
||||
this.player.transferToWorld(location.getWorld(), new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
this.player.transferToWorld(location.getWorld(),
|
||||
new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
} else {
|
||||
org.spongepowered.api.world.Location<World> current = this.player.getLocation();
|
||||
current = current.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
current = current
|
||||
.setPosition(new Vector3d(location.getX(), location.getY(), location.getZ()));
|
||||
this.player.setLocation(current);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
|
||||
@Override public boolean isOnline() {
|
||||
return this.player.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@Override public String getName() {
|
||||
if (this.name == null) {
|
||||
this.name = this.player.getName();
|
||||
}
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location location) {
|
||||
|
||||
@Override public void setCompassTarget(Location location) {
|
||||
Optional<TargetedLocationData> target = this.player.getOrCreate(TargetedLocationData.class);
|
||||
if (target.isPresent()) {
|
||||
target.get().set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition());
|
||||
target.get()
|
||||
.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition());
|
||||
} else {
|
||||
PS.debug("Failed to set compass target.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWeather(PlotWeather weather) {
|
||||
@Override public void setWeather(PlotWeather weather) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotGameMode getGameMode() {
|
||||
|
||||
@Override public PlotGameMode getGameMode() {
|
||||
GameMode gamemode = this.player.getGameModeData().type().get();
|
||||
if (gamemode == GameModes.ADVENTURE) {
|
||||
return PlotGameMode.ADVENTURE;
|
||||
@ -148,9 +141,8 @@ public class SpongePlayer extends PlotPlayer {
|
||||
return PlotGameMode.NOT_SET;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(PlotGameMode gameMode) {
|
||||
|
||||
@Override public void setGameMode(PlotGameMode gameMode) {
|
||||
switch (gameMode) {
|
||||
case ADVENTURE:
|
||||
this.player.offer(Keys.GAME_MODE, GameModes.ADVENTURE);
|
||||
@ -168,72 +160,82 @@ public class SpongePlayer extends PlotPlayer {
|
||||
this.player.offer(Keys.GAME_MODE, GameModes.NOT_SET);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTime(long time) {
|
||||
|
||||
@Override public void setTime(long time) {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFlight() {
|
||||
|
||||
@Override public boolean getFlight() {
|
||||
Optional<Boolean> flying = player.get(Keys.CAN_FLY);
|
||||
return flying.isPresent() && flying.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlight(boolean fly) {
|
||||
@Override public void setFlight(boolean fly) {
|
||||
this.player.offer(Keys.IS_FLYING, fly);
|
||||
this.player.offer(Keys.CAN_FLY, fly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playMusic(Location location, int id) {
|
||||
@Override public void playMusic(Location location, int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
//Placeholder because Sponge doesn't have a stopSound() implemented yet.
|
||||
this.player.playSound(SoundTypes.BLOCK_CLOTH_PLACE, SpongeUtil.getLocation(location).getPosition(), 0);
|
||||
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);
|
||||
this.player
|
||||
.playSound(SoundTypes.RECORD_11, SpongeUtil.getLocation(location).getPosition(),
|
||||
1);
|
||||
break;
|
||||
case 2257:
|
||||
this.player.playSound(SoundTypes.RECORD_13, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player
|
||||
.playSound(SoundTypes.RECORD_13, SpongeUtil.getLocation(location).getPosition(),
|
||||
1);
|
||||
break;
|
||||
case 2258:
|
||||
this.player.playSound(SoundTypes.RECORD_BLOCKS, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_BLOCKS,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2259:
|
||||
this.player.playSound(SoundTypes.RECORD_CAT, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_CAT,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2260:
|
||||
this.player.playSound(SoundTypes.RECORD_CHIRP, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_CHIRP,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2261:
|
||||
this.player.playSound(SoundTypes.RECORD_FAR, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_FAR,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2262:
|
||||
this.player.playSound(SoundTypes.RECORD_MALL, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_MALL,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2263:
|
||||
this.player.playSound(SoundTypes.RECORD_MELLOHI, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_MELLOHI,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2264:
|
||||
this.player.playSound(SoundTypes.RECORD_STAL, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_STAL,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2265:
|
||||
this.player.playSound(SoundTypes.RECORD_STRAD, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_STRAD,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2266:
|
||||
this.player.playSound(SoundTypes.RECORD_WAIT, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_WAIT,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
case 2267:
|
||||
this.player.playSound(SoundTypes.RECORD_WARD, SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
this.player.playSound(SoundTypes.RECORD_WARD,
|
||||
SpongeUtil.getLocation(location).getPosition(), 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kick(String message) {
|
||||
|
||||
@Override public void kick(String message) {
|
||||
this.player.kick(SpongeUtil.getText(message));
|
||||
}
|
||||
|
||||
@ -241,8 +243,7 @@ public class SpongePlayer extends PlotPlayer {
|
||||
//Not Implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
@Override public boolean isBanned() {
|
||||
Optional<BanService> service = Sponge.getServiceManager().provide(BanService.class);
|
||||
return service.isPresent() && service.get().isBanned(this.player.getProfile());
|
||||
}
|
||||
|
@ -17,13 +17,11 @@ import java.util.List;
|
||||
|
||||
public class SpongeChatManager extends ChatManager<Text.Builder> {
|
||||
|
||||
@Override
|
||||
public Text.Builder builder() {
|
||||
@Override public Text.Builder builder() {
|
||||
return Text.builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void color(PlotMessage message, String color) {
|
||||
@Override public void color(PlotMessage message, String color) {
|
||||
TextColor tc = null;
|
||||
TextStyle ts = null;
|
||||
switch (color.charAt(1)) {
|
||||
@ -114,8 +112,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
||||
m.$(this).append(builder.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
||||
@Override public void tooltip(PlotMessage message, PlotMessage... tooltips) {
|
||||
Text.Builder builder = Text.builder();
|
||||
boolean lb = false;
|
||||
for (PlotMessage tooltip : tooltips) {
|
||||
@ -128,18 +125,15 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
||||
apply(message, getChild(message).onHover(TextActions.showText(builder.toText())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void command(PlotMessage message, String command) {
|
||||
@Override public void command(PlotMessage message, String command) {
|
||||
apply(message, getChild(message).onClick(TextActions.runCommand(command)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void text(PlotMessage message, String text) {
|
||||
@Override public void text(PlotMessage message, String text) {
|
||||
message.$(this).append(SpongeUtil.getText(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(PlotMessage plotMessage, PlotPlayer player) {
|
||||
@Override public void send(PlotMessage plotMessage, PlotPlayer player) {
|
||||
if (player instanceof ConsolePlayer || !Settings.Chat.INTERACTIVE) {
|
||||
player.sendMessage(plotMessage.$(this).build().toPlain());
|
||||
} else {
|
||||
@ -147,8 +141,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suggest(PlotMessage plotMessage, String command) {
|
||||
@Override public void suggest(PlotMessage plotMessage, String command) {
|
||||
apply(plotMessage, getChild(plotMessage).onClick(TextActions.suggestCommand(command)));
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import org.spongepowered.api.entity.Entity;
|
||||
import org.spongepowered.api.entity.living.Living;
|
||||
import org.spongepowered.api.entity.living.animal.Animal;
|
||||
@ -16,10 +13,13 @@ import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.world.Chunk;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class SpongeChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public int[] countEntities(Plot plot) {
|
||||
|
||||
@Override public int[] countEntities(Plot plot) {
|
||||
Location pos1 = plot.getBottomAbs();
|
||||
Location pos2 = plot.getTopAbs();
|
||||
World world = SpongeUtil.getWorld(pos1.getWorld());
|
||||
@ -49,18 +49,16 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
|
||||
|
||||
@Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
|
||||
World worldObj = SpongeUtil.getWorld(world);
|
||||
return worldObj.loadChunk(loc.x << 4, 0, loc.z << 4, force).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkLoc> getChunkChunks(String world) {
|
||||
|
||||
@Override public Set<ChunkLoc> getChunkChunks(String world) {
|
||||
// TODO save world;
|
||||
return super.getChunkChunks(world);
|
||||
}
|
||||
@ -71,9 +69,8 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
TaskManager.runTask(whenDone);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearAllEntities(Location pos1, Location pos2) {
|
||||
|
||||
@Override public void clearAllEntities(Location pos1, Location pos2) {
|
||||
String worldName = pos1.getWorld();
|
||||
World world = SpongeUtil.getWorld(worldName);
|
||||
int bx = pos1.getX();
|
||||
@ -81,8 +78,7 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
int tx = pos2.getX();
|
||||
int tz = pos2.getZ();
|
||||
world.getEntities(new Predicate<Entity>() {
|
||||
@Override
|
||||
public boolean test(Entity entity) {
|
||||
@Override public boolean test(Entity entity) {
|
||||
org.spongepowered.api.world.Location loc = entity.getLocation();
|
||||
int x = loc.getBlockX();
|
||||
if ((x >= bx) && (x <= tx)) {
|
||||
@ -97,26 +93,25 @@ public class SpongeChunkManager extends ChunkManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void swap(Location bot1, Location top1, Location bot2, Location top2, Runnable whenDone) {
|
||||
|
||||
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
|
||||
Runnable whenDone) {
|
||||
// TODO swap region
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) {
|
||||
|
||||
@Override public void unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) {
|
||||
World worldObj = SpongeUtil.getWorld(world);
|
||||
Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||
if (chunk.isPresent()) {
|
||||
worldObj.unloadChunk(chunk.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerateRegion(Location pos1, Location pos2, boolean ignoreAugment, Runnable whenDone) {
|
||||
|
||||
@Override public boolean regenerateRegion(Location pos1, Location pos2, boolean ignoreAugment,
|
||||
Runnable whenDone) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -21,8 +20,8 @@ import java.util.*;
|
||||
|
||||
public class SpongeCommand implements CommandCallable {
|
||||
|
||||
@Override
|
||||
public CommandResult process(CommandSource source, String arguments) throws CommandException {
|
||||
@Override public CommandResult process(CommandSource source, String arguments)
|
||||
throws CommandException {
|
||||
TaskManager.runTask(() -> {
|
||||
String id = source.getIdentifier();
|
||||
PlotPlayer plotPlayer = null;
|
||||
@ -36,14 +35,14 @@ public class SpongeCommand implements CommandCallable {
|
||||
} catch (Exception ignored) {
|
||||
plotPlayer = ConsolePlayer.getConsole();
|
||||
}
|
||||
MainCommand.onCommand(plotPlayer, arguments.isEmpty() ? new String[]{} : arguments.split(" "));
|
||||
MainCommand.onCommand(plotPlayer,
|
||||
arguments.isEmpty() ? new String[] {} : arguments.split(" "));
|
||||
});
|
||||
return CommandResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSuggestions(CommandSource source, String arguments, Location<World> targetPosition)
|
||||
throws CommandException {
|
||||
@Override public List<String> getSuggestions(CommandSource source, String arguments,
|
||||
Location<World> targetPosition) throws CommandException {
|
||||
if (!(source instanceof Player)) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
@ -71,23 +70,19 @@ public class SpongeCommand implements CommandCallable {
|
||||
return names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission(CommandSource source) {
|
||||
@Override public boolean testPermission(CommandSource source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getShortDescription(CommandSource source) {
|
||||
@Override public Optional<Text> getShortDescription(CommandSource source) {
|
||||
return Optional.of(Text.of("Shows plot help"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Text> getHelp(CommandSource source) {
|
||||
@Override public Optional<Text> getHelp(CommandSource source) {
|
||||
return Optional.of(Text.of("/plot"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Text getUsage(CommandSource source) {
|
||||
@Override public Text getUsage(CommandSource source) {
|
||||
return Text.of("/plot <command>");
|
||||
}
|
||||
|
||||
|
@ -22,16 +22,14 @@ public class SpongeEconHandler extends EconHandler {
|
||||
econ = Sponge.getServiceManager().provide(EconomyService.class).get();
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onChangeServiceProvider(ChangeServiceProviderEvent event) {
|
||||
|
||||
@Listener public void onChangeServiceProvider(ChangeServiceProviderEvent event) {
|
||||
if (event.getService().equals(EconomyService.class)) {
|
||||
econ = (EconomyService) event.getNewProviderRegistration().getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withdrawMoney(PlotPlayer player, double amount) {
|
||||
@Override public void withdrawMoney(PlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
@ -41,9 +39,8 @@ public class SpongeEconHandler extends EconHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositMoney(PlotPlayer player, double amount) {
|
||||
|
||||
@Override public void depositMoney(PlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
@ -52,9 +49,8 @@ public class SpongeEconHandler extends EconHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositMoney(OfflinePlotPlayer player, double amount) {
|
||||
|
||||
@Override public void depositMoney(OfflinePlotPlayer player, double amount) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
@ -63,9 +59,8 @@ public class SpongeEconHandler extends EconHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String world, String player, String perm) {
|
||||
|
||||
@Override public boolean hasPermission(String world, String player, String perm) {
|
||||
SpongePlayer obj = (SpongePlayer) UUIDHandler.getPlayer(player);
|
||||
if (obj != null) {
|
||||
return obj.player.hasPermission(perm);
|
||||
@ -73,9 +68,8 @@ public class SpongeEconHandler extends EconHandler {
|
||||
// TODO offline
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(PlotPlayer player) {
|
||||
|
||||
@Override public double getBalance(PlotPlayer player) {
|
||||
if (econ != null) {
|
||||
Optional<UniqueAccount> accOpt = econ.getOrCreateAccount(player.getUUID());
|
||||
if (accOpt.isPresent()) {
|
||||
@ -86,5 +80,5 @@ public class SpongeEconHandler extends EconHandler {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,31 +1,10 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.Rating;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.events.ClusterFlagRemoveEvent;
|
||||
import com.plotsquared.sponge.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.sponge.events.PlayerEnterPlotEvent;
|
||||
import com.plotsquared.sponge.events.PlayerLeavePlotEvent;
|
||||
import com.plotsquared.sponge.events.PlayerPlotDeniedEvent;
|
||||
import com.plotsquared.sponge.events.PlayerPlotHelperEvent;
|
||||
import com.plotsquared.sponge.events.PlayerPlotTrustedEvent;
|
||||
import com.plotsquared.sponge.events.PlayerTeleportToPlotEvent;
|
||||
import com.plotsquared.sponge.events.PlotClearEvent;
|
||||
import com.plotsquared.sponge.events.PlotComponentSetEvent;
|
||||
import com.plotsquared.sponge.events.PlotDeleteEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagAddEvent;
|
||||
import com.plotsquared.sponge.events.PlotFlagRemoveEvent;
|
||||
import com.plotsquared.sponge.events.PlotMergeEvent;
|
||||
import com.plotsquared.sponge.events.PlotRateEvent;
|
||||
import com.plotsquared.sponge.events.PlotUnlinkEvent;
|
||||
import com.plotsquared.sponge.events.*;
|
||||
import org.spongepowered.api.event.Event;
|
||||
import org.spongepowered.api.event.EventManager;
|
||||
|
||||
@ -33,9 +12,9 @@ import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeEventUtil extends EventUtil {
|
||||
|
||||
|
||||
public EventManager events;
|
||||
|
||||
|
||||
public SpongeEventUtil() {
|
||||
this.events = SpongeMain.THIS.getGame().getEventManager();
|
||||
}
|
||||
@ -43,87 +22,71 @@ public class SpongeEventUtil extends EventUtil {
|
||||
public boolean callEvent(Event event) {
|
||||
return !this.events.post(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
||||
|
||||
@Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
|
||||
return callEvent(new PlayerClaimPlotEvent(SpongeUtil.getPlayer(player), plot, auto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
|
||||
@Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
|
||||
return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.getPlayer(player), from, plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callComponentSet(Plot plot, String component) {
|
||||
@Override public boolean callComponentSet(Plot plot, String component) {
|
||||
return callEvent(new PlotComponentSetEvent(plot, component));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callClear(Plot plot) {
|
||||
|
||||
@Override public boolean callClear(Plot plot) {
|
||||
return callEvent(new PlotClearEvent(plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callDelete(Plot plot) {
|
||||
|
||||
@Override public void callDelete(Plot plot) {
|
||||
callEvent(new PlotDeleteEvent(plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
|
||||
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
return callEvent(new PlotFlagAddEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
|
||||
@Override public boolean callFlagRemove(Flag<?> flag, Plot plot, Object value) {
|
||||
return callEvent(new PlotFlagRemoveEvent(flag, plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
|
||||
@Override public boolean callMerge(Plot plot, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getWorldName()), plot, plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
|
||||
|
||||
@Override public boolean callUnlink(PlotArea area, ArrayList<PlotId> plots) {
|
||||
return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEntry(PlotPlayer player, Plot plot) {
|
||||
|
||||
@Override public void callEntry(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerEnterPlotEvent(SpongeUtil.getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callLeave(PlotPlayer player, Plot plot) {
|
||||
|
||||
@Override public void callLeave(PlotPlayer player, Plot plot) {
|
||||
callEvent(new PlayerLeavePlotEvent(SpongeUtil.getPlayer(player), plot));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotDeniedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
|
||||
|
||||
@Override public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
|
||||
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
|
||||
@Override public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
|
||||
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
|
||||
this.events.post(event);
|
||||
return event.getRating();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||
|
||||
public class SpongeHybridUtils extends HybridUtils {
|
||||
|
||||
@Override
|
||||
public void analyzeRegion(String world, RegionWrapper region, RunnableVal<PlotAnalysis> whenDone) {
|
||||
@Override public void analyzeRegion(String world, RegionWrapper region,
|
||||
RunnableVal<PlotAnalysis> whenDone) {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,8 +24,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
builder = SpongeMain.THIS.getGame().getRegistry().createBuilder(ItemStack.Builder.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(final PlotInventory inv) {
|
||||
@Override public void open(final PlotInventory inv) {
|
||||
/*
|
||||
// TODO Auto-generated method stub
|
||||
final SpongePlayer sp = (SpongePlayer) inv.player;
|
||||
@ -54,8 +53,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
return builder.itemType(ItemTypes.SPONGE).quantity(item.amount).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(final PlotInventory inv) {
|
||||
@Override public void close(final PlotInventory inv) {
|
||||
if (!inv.isOpen()) {
|
||||
return;
|
||||
}
|
||||
@ -87,8 +85,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
return new PlotItemStack(id, amount, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotItemStack[] getItems(final PlotPlayer player) {
|
||||
@Override public PlotItemStack[] getItems(final PlotPlayer player) {
|
||||
final SpongePlayer sp = (SpongePlayer) player;
|
||||
sp.player.getInventory();
|
||||
new ArrayList<PlotItemStack>();
|
||||
@ -98,8 +95,7 @@ public class SpongeInventoryUtil extends InventoryUtil {
|
||||
// return list.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpen(final PlotInventory inv) {
|
||||
@Override public boolean isOpen(final PlotInventory inv) {
|
||||
if (!inv.isOpen()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -37,13 +37,7 @@ import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
import org.spongepowered.api.scheduler.Task;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.io.*;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
@ -112,8 +106,7 @@ public class SpongeMetrics {
|
||||
*/
|
||||
private volatile Task task = null;
|
||||
|
||||
@Inject
|
||||
public SpongeMetrics(final Game game, final PluginContainer plugin) {
|
||||
@Inject public SpongeMetrics(final Game game, final PluginContainer plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
@ -159,7 +152,8 @@ public class SpongeMetrics {
|
||||
* @param value
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
private static void appendJSONPair(final StringBuilder json, final String key, final String value) {
|
||||
private static void appendJSONPair(final StringBuilder json, final String key,
|
||||
final String value) {
|
||||
boolean isValueNumeric = false;
|
||||
|
||||
try {
|
||||
@ -295,8 +289,7 @@ public class SpongeMetrics {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
@ -396,14 +389,15 @@ public class SpongeMetrics {
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// Server software specific section
|
||||
final String pluginName = plugin.getName();
|
||||
final boolean onlineMode = game.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
final boolean onlineMode =
|
||||
game.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||
final String pluginVersion = plugin.getVersion().orElse("unknown");
|
||||
final String serverVersion = String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
|
||||
final String serverVersion =
|
||||
String.format("%s %s", "Sponge", game.getPlatform().getMinecraftVersion());
|
||||
final int playersOnline = game.getServer().getOnlinePlayers().size();
|
||||
|
||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||
@ -473,7 +467,8 @@ public class SpongeMetrics {
|
||||
connection.setDoOutput(true);
|
||||
|
||||
if (debug) {
|
||||
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed="
|
||||
+ uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
|
||||
// Write the data
|
||||
@ -482,7 +477,8 @@ public class SpongeMetrics {
|
||||
os.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
final BufferedReader reader =
|
||||
new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
@ -514,4 +510,4 @@ public class SpongeMetrics {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,7 @@
|
||||
package com.plotsquared.sponge.util;
|
||||
|
||||
import com.intellectualcrafters.jnbt.ByteArrayTag;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.jnbt.IntTag;
|
||||
import com.intellectualcrafters.jnbt.ListTag;
|
||||
import com.intellectualcrafters.jnbt.ShortTag;
|
||||
import com.intellectualcrafters.jnbt.StringTag;
|
||||
import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.jnbt.*;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
@ -21,13 +11,8 @@ import org.spongepowered.api.item.inventory.Carrier;
|
||||
import org.spongepowered.api.item.inventory.type.CarriedInventory;
|
||||
import org.spongepowered.api.world.World;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class SpongeSchematicHandler extends SchematicHandler {
|
||||
|
||||
@ -38,12 +23,11 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCompoundTag(String world, Set<RegionWrapper> regions, RunnableVal<CompoundTag> whenDone) {
|
||||
@Override public void getCompoundTag(String world, Set<RegionWrapper> regions,
|
||||
RunnableVal<CompoundTag> whenDone) {
|
||||
// async
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
// Main positions
|
||||
Location[] corners = MainUtil.getCorners(world, regions);
|
||||
Location bot = corners[0];
|
||||
@ -71,16 +55,18 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
// Queue
|
||||
ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions);
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
if (queue.isEmpty()) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override 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<>()));
|
||||
schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
|
||||
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);
|
||||
System.gc();
|
||||
@ -115,22 +101,23 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
World worldObj = SpongeUtil.getWorld(world);
|
||||
// Main thread
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
long start = System.currentTimeMillis();
|
||||
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 20) {
|
||||
while (!chunks.isEmpty()
|
||||
&& System.currentTimeMillis() - start < 20) {
|
||||
// save schematics
|
||||
ChunkLoc chunk = chunks.remove(0);
|
||||
int X = chunk.x;
|
||||
int Z = chunk.z;
|
||||
int xxb = X << 4;
|
||||
int zzb = Z << 4;
|
||||
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj.loadChunk(xxb, 1, zzb, false).isPresent()) {
|
||||
if (!worldObj.getChunk(xxb, 1, zzb).isPresent() && !worldObj
|
||||
.loadChunk(xxb, 1, zzb, false).isPresent()) {
|
||||
continue;
|
||||
}
|
||||
int xxt = xxb + 15;
|
||||
int zzt = zzb + 15;
|
||||
|
||||
|
||||
if (X == bcx) {
|
||||
xxb = p1x;
|
||||
}
|
||||
@ -264,22 +251,28 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
||||
CompoundTag rawTag;
|
||||
if (state instanceof Carrier) {
|
||||
Carrier chest = (Carrier) state;
|
||||
CarriedInventory<? extends Carrier> inv = chest.getInventory();
|
||||
CarriedInventory<? extends Carrier>
|
||||
inv = chest.getInventory();
|
||||
// TODO serialize inventory
|
||||
rawTag = null;
|
||||
} else {
|
||||
rawTag = null;
|
||||
}
|
||||
if (rawTag != null) {
|
||||
Map<String, Tag> values = new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag.getValue().entrySet()) {
|
||||
values.put(entry.getKey(), entry.getValue());
|
||||
Map<String, Tag> values =
|
||||
new HashMap<>();
|
||||
for (Entry<String, Tag> entry : rawTag
|
||||
.getValue().entrySet()) {
|
||||
values.put(entry.getKey(),
|
||||
entry.getValue());
|
||||
}
|
||||
values.put("id", new StringTag("id", "Chest"));
|
||||
values.put("id",
|
||||
new StringTag("id", "Chest"));
|
||||
values.put("x", new IntTag("x", x));
|
||||
values.put("y", new IntTag("y", y));
|
||||
values.put("z", new IntTag("z", z));
|
||||
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
CompoundTag tileEntityTag =
|
||||
new CompoundTag(values);
|
||||
tileEntities.add(tileEntityTag);
|
||||
}
|
||||
default:
|
||||
|
@ -9,13 +9,6 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.DimensionTypes;
|
||||
import org.spongepowered.api.world.GeneratorTypes;
|
||||
@ -25,17 +18,23 @@ import org.spongepowered.api.world.gen.WorldGenerator;
|
||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||
import org.spongepowered.api.world.storage.WorldProperties;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class SpongeSetupUtils extends SetupUtils {
|
||||
|
||||
@Override
|
||||
public void updateGenerators() {
|
||||
@Override public void updateGenerators() {
|
||||
if (!SetupUtils.generators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
SetupUtils.generators.put(PS.imp().getPluginName(), new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator()));
|
||||
SetupUtils.generators.put(PS.imp().getPluginName() + ":single", new SpongePlotGenerator(new SingleWorldGenerator()));
|
||||
SetupUtils.generators.put(PS.imp().getPluginName(),
|
||||
new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator()));
|
||||
SetupUtils.generators.put(PS.imp().getPluginName() + ":single",
|
||||
new SpongePlotGenerator(new SingleWorldGenerator()));
|
||||
// TODO get external world generators
|
||||
Collection<WorldGeneratorModifier> wgms = Sponge.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||
Collection<WorldGeneratorModifier> wgms =
|
||||
Sponge.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||
for (WorldGeneratorModifier wgm : wgms) {
|
||||
String id = wgm.getId();
|
||||
String name = wgm.getName();
|
||||
@ -50,16 +49,14 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(String worldName, boolean safe) {
|
||||
@Override public void unload(String worldName, boolean safe) {
|
||||
Optional<World> world = Sponge.getServer().getWorld(worldName);
|
||||
if (world.isPresent()) {
|
||||
Sponge.getServer().unloadWorld(world.get());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotArea plotArea) {
|
||||
@Override public String getGenerator(PlotArea plotArea) {
|
||||
if (SetupUtils.generators.isEmpty()) {
|
||||
updateGenerators();
|
||||
}
|
||||
@ -71,8 +68,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String setupWorld(SetupObject object) {
|
||||
@Override public String setupWorld(SetupObject object) {
|
||||
SetupUtils.manager.updateGenerators();
|
||||
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
||||
String world = object.world;
|
||||
@ -83,14 +79,16 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
ConfigurationSection worldSection =
|
||||
PS.get().worlds.getConfigurationSection(worldPath);
|
||||
if (object.id != null) {
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
if (!worldSection.contains(areaPath)) {
|
||||
worldSection.createSection(areaPath);
|
||||
}
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
|
||||
ConfigurationSection areaSection =
|
||||
worldSection.getConfigurationSection(areaPath);
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
for (ConfigurationNode step : steps) {
|
||||
options.put(step.getConstant(), step.getValue());
|
||||
@ -98,7 +96,8 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
options.put("generator.type", object.type);
|
||||
options.put("generator.terrain", object.terrain);
|
||||
options.put("generator.plugin", object.plotManager);
|
||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||
if (object.setupGenerator != null && !object.setupGenerator
|
||||
.equals(object.plotManager)) {
|
||||
options.put("generator.init", object.setupGenerator);
|
||||
}
|
||||
for (Entry<String, Object> entry : options.entrySet()) {
|
||||
@ -124,15 +123,18 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
ConfigurationSection worldSection =
|
||||
PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
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);
|
||||
if (object.setupGenerator != null && !object.setupGenerator
|
||||
.equals(object.plotManager)) {
|
||||
PS.get().worlds
|
||||
.set("worlds." + world + ".generator.init", object.setupGenerator);
|
||||
}
|
||||
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||
if (gen != null && gen.isFull()) {
|
||||
@ -145,7 +147,8 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
ConfigurationSection worldSection =
|
||||
PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
@ -162,15 +165,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
// create world with generator
|
||||
GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator);
|
||||
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.FLAT)
|
||||
.usesMapFeatures(false)
|
||||
.enabled(true)
|
||||
.generatorModifiers(wgm)
|
||||
.build("PS-" + UUID.randomUUID(),object.world);
|
||||
WorldArchetype settings =
|
||||
WorldArchetype.builder().loadsOnStartup(true).keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD).generator(GeneratorTypes.FLAT)
|
||||
.usesMapFeatures(false).enabled(true).generatorModifiers(wgm)
|
||||
.build("PS-" + UUID.randomUUID(), object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
@ -186,14 +185,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
} else {
|
||||
System.out.println("Create vanilla world");
|
||||
// create vanilla world
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
.keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD)
|
||||
.generator(GeneratorTypes.OVERWORLD)
|
||||
.usesMapFeatures(true)
|
||||
.enabled(true)
|
||||
.build("PS-" + UUID.randomUUID(),object.world);
|
||||
WorldArchetype settings =
|
||||
WorldArchetype.builder().loadsOnStartup(true).keepsSpawnLoaded(true)
|
||||
.dimension(DimensionTypes.OVERWORLD).generator(GeneratorTypes.OVERWORLD)
|
||||
.usesMapFeatures(true).enabled(true)
|
||||
.build("PS-" + UUID.randomUUID(), object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
|
@ -18,8 +18,7 @@ public class SpongeTaskManager extends TaskManager {
|
||||
this.spongeMain = spongeMain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int taskRepeat(Runnable runnable, int interval) {
|
||||
@Override public int taskRepeat(Runnable runnable, int interval) {
|
||||
int val = this.i.incrementAndGet();
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(runnable);
|
||||
@ -28,42 +27,37 @@ public class SpongeTaskManager extends TaskManager {
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int taskRepeatAsync(Runnable runnable, int interval) {
|
||||
@Override public int taskRepeatAsync(Runnable runnable, int interval) {
|
||||
int val = this.i.incrementAndGet();
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(runnable);
|
||||
Task.Builder built =
|
||||
builder.delayTicks(interval).async().intervalTicks(interval).execute(runnable);
|
||||
Task task = built.submit(this.spongeMain.getPlugin());
|
||||
this.tasks.put(val, task);
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskAsync(Runnable runnable) {
|
||||
@Override public void taskAsync(Runnable runnable) {
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().execute(runnable).submit(this.spongeMain.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(Runnable runnable) {
|
||||
@Override public void task(Runnable runnable) {
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
builder.execute(runnable).submit(this.spongeMain.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLater(Runnable runnable, int delay) {
|
||||
@Override public void taskLater(Runnable runnable, int delay) {
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
builder.delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLaterAsync(Runnable runnable, int delay) {
|
||||
@Override public void taskLaterAsync(Runnable runnable, int delay) {
|
||||
Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder();
|
||||
builder.async().delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(int i) {
|
||||
@Override public void cancelTask(int i) {
|
||||
Task task = this.tasks.remove(i);
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
|
@ -9,7 +9,9 @@ public class SpongeTitleManager extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
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();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -40,9 +37,15 @@ 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.util.*;
|
||||
|
||||
public class SpongeUtil extends WorldUtil {
|
||||
|
||||
public static Cause CAUSE = Cause.builder().append(Sponge.getPluginManager().fromInstance(SpongeMain.THIS).get()).build(EventContext.empty());
|
||||
public static Cause CAUSE =
|
||||
Cause.builder().append(Sponge.getPluginManager().fromInstance(SpongeMain.THIS).get())
|
||||
.build(EventContext.empty());
|
||||
private static BiomeType[] biomes;
|
||||
private static HashMap<String, Integer> biomeMap;
|
||||
private static Player lastPlayer = null;
|
||||
@ -110,18 +113,15 @@ public class SpongeUtil extends WorldUtil {
|
||||
public static Translation getTranslation(String m) {
|
||||
return new Translation() {
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
@Override public String getId() {
|
||||
return m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale l, Object... args) {
|
||||
@Override public String get(Locale l, Object... args) {
|
||||
return m;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(Locale l) {
|
||||
@Override public String get(Locale l) {
|
||||
return m;
|
||||
}
|
||||
};
|
||||
@ -149,7 +149,8 @@ public class SpongeUtil extends WorldUtil {
|
||||
public static Location getLocationFull(Entity player) {
|
||||
String world = player.getWorld().getName();
|
||||
Vector3d rot = player.getRotation();
|
||||
float[] pitchYaw = MathMan.getPitchAndYaw((float) rot.getX(), (float) rot.getY(), (float) rot.getZ());
|
||||
float[] pitchYaw =
|
||||
MathMan.getPitchAndYaw((float) rot.getX(), (float) rot.getY(), (float) rot.getZ());
|
||||
org.spongepowered.api.world.Location loc = player.getLocation();
|
||||
Vector3i pos = loc.getBlockPosition();
|
||||
return new Location(world, pos.getX(), pos.getY(), pos.getZ(), pitchYaw[1], pitchYaw[0]);
|
||||
@ -213,8 +214,10 @@ public class SpongeUtil extends WorldUtil {
|
||||
|
||||
public static org.spongepowered.api.world.Location<World> getLocation(Location location) {
|
||||
Collection<World> worlds = Sponge.getServer().getWorlds();
|
||||
World world = Sponge.getServer().getWorld(location.getWorld()).orElse(worlds.toArray(new World[worlds.size()])[0]);
|
||||
return new org.spongepowered.api.world.Location<>(world, location.getX(), location.getY(), location.getZ());
|
||||
World world = Sponge.getServer().getWorld(location.getWorld())
|
||||
.orElse(worlds.toArray(new World[worlds.size()])[0]);
|
||||
return new org.spongepowered.api.world.Location<>(world, location.getX(), location.getY(),
|
||||
location.getZ());
|
||||
}
|
||||
|
||||
public static Location getLocation(String world, Vector3i position) {
|
||||
@ -222,11 +225,11 @@ public class SpongeUtil extends WorldUtil {
|
||||
}
|
||||
|
||||
public static Location getLocation(String world, Vector3d position) {
|
||||
return new Location(world, MathMan.roundInt(position.getX()), MathMan.roundInt(position.getY()), MathMan.roundInt(position.getZ()));
|
||||
return new Location(world, MathMan.roundInt(position.getX()),
|
||||
MathMan.roundInt(position.getY()), MathMan.roundInt(position.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockSolid(PlotBlock block) {
|
||||
@Override public boolean isBlockSolid(PlotBlock block) {
|
||||
BlockState state = SpongeUtil.getBlockState(block.id, block.data);
|
||||
Optional<SolidCubeProperty> property = state.getType().getProperty(SolidCubeProperty.class);
|
||||
if (property.isPresent()) {
|
||||
@ -236,8 +239,7 @@ public class SpongeUtil extends WorldUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
|
||||
@Override public StringComparison<PlotBlock>.ComparisonResult getClosestBlock(String name) {
|
||||
try {
|
||||
|
||||
byte data;
|
||||
@ -256,12 +258,12 @@ public class SpongeUtil extends WorldUtil {
|
||||
} else {
|
||||
List<BlockType> types = ReflectionUtils.getStaticFields(BlockTypes.class);
|
||||
StringComparison<BlockType>.ComparisonResult comparison =
|
||||
new StringComparison<BlockType>(name, types.toArray(new BlockType[types.size()])) {
|
||||
@Override
|
||||
public String getString(BlockType type) {
|
||||
return type.getId();
|
||||
}
|
||||
}.getBestMatchAdvanced();
|
||||
new StringComparison<BlockType>(name,
|
||||
types.toArray(new BlockType[types.size()])) {
|
||||
@Override public String getString(BlockType type) {
|
||||
return type.getId();
|
||||
}
|
||||
}.getBestMatchAdvanced();
|
||||
match = comparison.match;
|
||||
id = SpongeUtil.getPlotBlock(comparison.best.getDefaultState()).id;
|
||||
}
|
||||
@ -274,68 +276,61 @@ public class SpongeUtil extends WorldUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClosestMatchingName(PlotBlock block) {
|
||||
@Override public String getClosestMatchingName(PlotBlock block) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBiomeList() {
|
||||
@Override public String[] getBiomeList() {
|
||||
if (biomes == null) {
|
||||
initBiomeCache();
|
||||
}
|
||||
return biomeMap.keySet().toArray(new String[biomeMap.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addItems(String world, PlotItem items) {
|
||||
@Override public boolean addItems(String world, PlotItem items) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeFromString(String biome) {
|
||||
@Override public int getBiomeFromString(String biome) {
|
||||
if (biomes == null) {
|
||||
initBiomeCache();
|
||||
}
|
||||
return biomeMap.get(biome.toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBiome(String world, int x, int z) {
|
||||
@Override public String getBiome(String world, int x, int z) {
|
||||
return SpongeUtil.getWorld(world).getBiome(x, 0, z).getName().toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock getBlock(Location location) {
|
||||
BlockState state = SpongeUtil.getWorld(location.getWorld()).getBlock(location.getX(), location.getY(), location.getZ());
|
||||
@Override public PlotBlock getBlock(Location location) {
|
||||
BlockState state = SpongeUtil.getWorld(location.getWorld())
|
||||
.getBlock(location.getX(), location.getY(), location.getZ());
|
||||
return SpongeUtil.getPlotBlock(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawn(PlotPlayer plotPlayer) {
|
||||
@Override public Location getSpawn(PlotPlayer plotPlayer) {
|
||||
World world = getWorld(plotPlayer.getLocation().getWorld());
|
||||
return SpongeUtil.getLocation(world.getSpawnLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getSpawn(String world) {
|
||||
Location result = SpongeUtil.getLocation(world, SpongeUtil.getWorld(world).getSpawnLocation());
|
||||
@Override public Location getSpawn(String world) {
|
||||
Location result =
|
||||
SpongeUtil.getLocation(world, SpongeUtil.getWorld(world).getSpawnLocation());
|
||||
result.setY(1 + getHighestBlock(world, result.getX(), result.getZ()));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawn(Location location) {
|
||||
@Override public void setSpawn(Location location) {
|
||||
World world = getWorld(location.getWorld());
|
||||
if (world != null) {
|
||||
world.getProperties().setSpawnPosition(new Vector3i(location.getX(), location.getY(), location.getZ()));
|
||||
world.getProperties()
|
||||
.setSpawnPosition(new Vector3i(location.getX(), location.getY(), location.getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveWorld(String worldName) {
|
||||
@Override public void saveWorld(String worldName) {
|
||||
try {
|
||||
SpongeUtil.getWorld(worldName).save();
|
||||
} catch (IOException e) {
|
||||
@ -344,10 +339,10 @@ public class SpongeUtil extends WorldUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSign(Location location) {
|
||||
@Override public String[] getSign(Location location) {
|
||||
World world = SpongeUtil.getWorld(location.getWorld());
|
||||
Optional<TileEntity> block = world.getTileEntity(location.getX(), location.getY(), location.getZ());
|
||||
Optional<TileEntity> block =
|
||||
world.getTileEntity(location.getX(), location.getY(), location.getZ());
|
||||
if (!block.isPresent()) {
|
||||
return null;
|
||||
}
|
||||
@ -368,18 +363,15 @@ public class SpongeUtil extends WorldUtil {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorld(String worldName) {
|
||||
@Override public boolean isWorld(String worldName) {
|
||||
return SpongeUtil.getWorld(worldName) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMainWorld() {
|
||||
@Override public String getMainWorld() {
|
||||
return Sponge.getServer().getWorlds().iterator().next().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestBlock(String worldName, int x, int z) {
|
||||
@Override public int getHighestBlock(String worldName, int x, int z) {
|
||||
World world = SpongeUtil.getWorld(worldName);
|
||||
if (world == null) {
|
||||
return 63;
|
||||
@ -393,8 +385,7 @@ public class SpongeUtil extends WorldUtil {
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSign(String worldName, int x, int y, int z, String[] lines) {
|
||||
@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());
|
||||
Optional<TileEntity> block = world.getTileEntity(x, y, z);
|
||||
@ -413,8 +404,7 @@ public class SpongeUtil extends WorldUtil {
|
||||
sign.offer(Keys.SIGN_LINES, text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiomes(String worldName, RegionWrapper region, String biomename) {
|
||||
@Override public void setBiomes(String worldName, RegionWrapper region, String biomename) {
|
||||
World world = SpongeUtil.getWorld(worldName);
|
||||
BiomeType biome = SpongeUtil.getBiome(biomename);
|
||||
for (int x = region.minX; x <= region.maxX; x++) {
|
||||
|
@ -28,51 +28,44 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
this.world = wrap.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillBiome(String biomeName) {
|
||||
@Override public void fillBiome(String biomeName) {
|
||||
if (this.biome == null) {
|
||||
return;
|
||||
}
|
||||
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, 0,this.bz + z, biome);
|
||||
this.biome.setBiome(this.bx + x, 0, this.bz + z, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(int x, int z, String biomeName) {
|
||||
@Override public boolean setBiome(int x, int z, String biomeName) {
|
||||
modified = true;
|
||||
BiomeType biome = SpongeUtil.getBiome(biomeName.toUpperCase());
|
||||
this.biome.setBiome(this.bx + x, 0, this.bz + z, biome);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int id, int data) {
|
||||
@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));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock getBlock(int x, int y, int z) {
|
||||
@Override public PlotBlock getBlock(int x, int y, int z) {
|
||||
return SpongeUtil.getPlotBlock(this.terrain.getBlock(this.bx + x, y, this.bz + z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorld() {
|
||||
@Override public String getWorld() {
|
||||
return this.world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getMax() {
|
||||
@Override public Location getMax() {
|
||||
return new Location(getWorld(), 15 + bx, 255, 15 + bz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getMin() {
|
||||
@Override public Location getMin() {
|
||||
return new Location(getWorld(), bx, 0, bz);
|
||||
}
|
||||
|
||||
|
@ -36,19 +36,19 @@ import java.util.HashSet;
|
||||
|
||||
public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
|
||||
private BlockState AIR = BlockTypes.AIR.getDefaultState();
|
||||
|
||||
public SpongeLocalQueue(String world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalChunk<char[]> getLocalChunk(int x, int z) {
|
||||
@Override public LocalChunk<char[]> getLocalChunk(int x, int z) {
|
||||
return new CharLocalChunk_Sponge(this, x, z) {
|
||||
// Custom stuff?
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void optimize() {
|
||||
@Override public void optimize() {
|
||||
|
||||
}
|
||||
|
||||
@ -56,15 +56,13 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
return SpongeUtil.getWorld(getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock getBlock(int x, int y, int z) {
|
||||
@Override public PlotBlock getBlock(int x, int y, int z) {
|
||||
World worldObj = getSpongeWorld();
|
||||
BlockState block = worldObj.getBlock(x, y, z);
|
||||
return SpongeUtil.getPlotBlock(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshChunk(int x, int z) {
|
||||
@Override public void refreshChunk(int x, int z) {
|
||||
World world = getSpongeWorld();
|
||||
Chunk nmsChunk = ((net.minecraft.world.World) world).getChunkProvider().provideChunk(x, z);
|
||||
if (nmsChunk == null || !nmsChunk.isLoaded()) {
|
||||
@ -103,7 +101,8 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
continue;
|
||||
}
|
||||
for (Entity ent : slice) {
|
||||
EntityTrackerEntry entry = entries != null ? entries.lookup(ent.getEntityId()) : null;
|
||||
EntityTrackerEntry entry =
|
||||
entries != null ? entries.lookup(ent.getEntityId()) : null;
|
||||
if (entry == null) {
|
||||
continue;
|
||||
}
|
||||
@ -123,8 +122,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
for (EntityTrackerEntry entry : entities) {
|
||||
try {
|
||||
TaskManager.IMP.taskLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
for (EntityPlayerMP player : players) {
|
||||
if (entry.isVisibleTo(player)) {
|
||||
entry.removeFromTrackedPlayers(player);
|
||||
@ -144,12 +142,201 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixChunkLighting(int x, int z) {
|
||||
@Override public void fixChunkLighting(int x, int z) {
|
||||
Chunk nmsChunk = getChunk(getSpongeWorld(), x, z);
|
||||
nmsChunk.generateSkylightMap();
|
||||
}
|
||||
|
||||
public boolean isSurrounded(char[][] sections, int x, int y, int z) {
|
||||
return isSolid(getId(sections, x, y + 1, z)) && isSolid(getId(sections, x + 1, y - 1, z))
|
||||
&& isSolid(getId(sections, x - 1, y, z)) && isSolid(getId(sections, x, y, z + 1))
|
||||
&& isSolid(getId(sections, x, y, z - 1));
|
||||
}
|
||||
|
||||
public boolean isSolid(int i) {
|
||||
return i != 0 && Block.getBlockById(i)
|
||||
.isOpaqueCube(Block.getBlockById(i).getDefaultState());
|
||||
}
|
||||
|
||||
public int getId(char[][] sections, int x, int y, int z) {
|
||||
if (x < 0 || x > 15 || z < 0 || z > 15) {
|
||||
return 1;
|
||||
}
|
||||
if (y < 0 || y > 255) {
|
||||
return 1;
|
||||
}
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
char[] section = sections[i];
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
int j = MainUtil.CACHE_I[y][x][z];
|
||||
int combined = section[j];
|
||||
return combined >> 4;
|
||||
}
|
||||
|
||||
public boolean fixLighting(CharLocalChunk_Sponge bc, Chunk nmsChunk) {
|
||||
try {
|
||||
if (!nmsChunk.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
||||
nmsChunk.generateSkylightMap();
|
||||
net.minecraft.world.World nmsWorld = nmsChunk.getWorld();
|
||||
|
||||
int X = bc.getX() << 4;
|
||||
int Z = bc.getZ() << 4;
|
||||
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
ExtendedBlockStorage section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if ((bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0))
|
||||
|| bc.getAir(j) == 4096) {
|
||||
continue;
|
||||
}
|
||||
char[] array = bc.getIdArray(j);
|
||||
if (array != null) {
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(bc.blocks, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
pos.setPos(X + x, y, Z + z);
|
||||
nmsWorld.checkLight(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public final void regenChunk(int x, int z) {
|
||||
World worldObj = getSpongeWorld();
|
||||
throw new UnsupportedOperationException("NOT SUPPORTED");
|
||||
}
|
||||
|
||||
@Override public final void setComponents(LocalChunk<char[]> lc) {
|
||||
setBlocks(lc);
|
||||
setBiomes(lc);
|
||||
}
|
||||
|
||||
public Chunk getChunk(World world, int x, int z) {
|
||||
net.minecraft.world.chunk.Chunk chunk =
|
||||
((net.minecraft.world.World) world).getChunkProvider().provideChunk(x, z);
|
||||
if (chunk != null && !chunk.isLoaded()) {
|
||||
chunk.onLoad();
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
public void setBlocks(LocalChunk<char[]> lc) {
|
||||
World worldObj = getSpongeWorld();
|
||||
org.spongepowered.api.world.Chunk spongeChunk =
|
||||
(org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ());
|
||||
Chunk nmsChunk = (Chunk) spongeChunk;
|
||||
char[][] ids = ((CharLocalChunk) lc).blocks;
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
char[] array = ids[layer];
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
ExtendedBlockStorage section = nmsChunk.getBlockStorageArray()[layer];
|
||||
short[] cacheX = MainUtil.x_loc[0];
|
||||
short[] cacheY = MainUtil.y_loc[0];
|
||||
short[] cacheZ = MainUtil.z_loc[0];
|
||||
for (int j = 0; j < array.length; j++) {
|
||||
int combinedId = array[j];
|
||||
switch (combinedId) {
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
int x = cacheX[j];
|
||||
int y = cacheY[j];
|
||||
int z = cacheZ[j];
|
||||
section.set(x, y, z, Blocks.AIR.getDefaultState());
|
||||
continue;
|
||||
default:
|
||||
int id = combinedId >> 4;
|
||||
Block block = Block.getBlockById(id);
|
||||
int data = combinedId & 0xf;
|
||||
IBlockState ibd;
|
||||
if (data != 0) {
|
||||
ibd = block.getStateFromMeta(data);
|
||||
} else {
|
||||
ibd = block.getDefaultState();
|
||||
}
|
||||
x = cacheX[j];
|
||||
y = cacheY[j];
|
||||
z = cacheZ[j];
|
||||
section.set(x, y, z, ibd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshChunk(nmsChunk.x, nmsChunk.z);
|
||||
}
|
||||
|
||||
public void setBiomes(LocalChunk<char[]> lc) {
|
||||
if (lc.biomes != null) {
|
||||
World worldObj = getSpongeWorld();
|
||||
int bx = lc.getX() << 4;
|
||||
int bz = lc.getX() << 4;
|
||||
String last = null;
|
||||
BiomeType biome = null;
|
||||
for (int x = 0; x < lc.biomes.length; x++) {
|
||||
String[] biomes2 = lc.biomes[x];
|
||||
if (biomes2 != null) {
|
||||
for (int y = 0; y < biomes2.length; y++) {
|
||||
String biomeStr = biomes2[y];
|
||||
if (biomeStr != null) {
|
||||
if (last == null || !StringMan.isEqual(last, biomeStr)) {
|
||||
biome = SpongeUtil.getBiome(biomeStr.toUpperCase());
|
||||
}
|
||||
worldObj.setBiome(bx, 0, bz, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class CharLocalChunk_Sponge extends CharLocalChunk {
|
||||
public short[] count;
|
||||
public short[] air;
|
||||
@ -162,8 +349,7 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
this.relight = new short[16];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, int id, int data) {
|
||||
@Override public void setBlock(int x, int y, int z, int id, int data) {
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
int j = MainUtil.CACHE_J[y][x][z];
|
||||
char[] vs = this.blocks[i];
|
||||
@ -310,195 +496,4 @@ public class SpongeLocalQueue extends BasicLocalBlockQueue<char[]> {
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSurrounded(char[][] sections, int x, int y, int z) {
|
||||
return isSolid(getId(sections, x, y + 1, z))
|
||||
&& isSolid(getId(sections, x + 1, y - 1, z))
|
||||
&& isSolid(getId(sections, x - 1, y, z))
|
||||
&& isSolid(getId(sections, x, y, z + 1))
|
||||
&& isSolid(getId(sections, x, y, z - 1));
|
||||
}
|
||||
|
||||
public boolean isSolid(int i) {
|
||||
return i != 0 && Block.getBlockById(i).isOpaqueCube(Block.getBlockById(i).getDefaultState());
|
||||
}
|
||||
|
||||
public int getId(char[][] sections, int x, int y, int z) {
|
||||
if (x < 0 || x > 15 || z < 0 || z > 15) {
|
||||
return 1;
|
||||
}
|
||||
if (y < 0 || y > 255) {
|
||||
return 1;
|
||||
}
|
||||
int i = MainUtil.CACHE_I[y][x][z];
|
||||
char[] section = sections[i];
|
||||
if (section == null) {
|
||||
return 0;
|
||||
}
|
||||
int j = MainUtil.CACHE_I[y][x][z];
|
||||
int combined = section[j];
|
||||
return combined >> 4;
|
||||
}
|
||||
|
||||
public boolean fixLighting(CharLocalChunk_Sponge bc, Chunk nmsChunk) {
|
||||
try {
|
||||
if (!nmsChunk.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
ExtendedBlockStorage[] sections = nmsChunk.getBlockStorageArray();
|
||||
nmsChunk.generateSkylightMap();
|
||||
net.minecraft.world.World nmsWorld = nmsChunk.getWorld();
|
||||
|
||||
int X = bc.getX() << 4;
|
||||
int Z = bc.getZ() << 4;
|
||||
|
||||
BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(0, 0, 0);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
ExtendedBlockStorage section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if ((bc.getCount(j) == 0) || ((bc.getCount(j) >= 4096) && (bc.getAir(j) == 0)) || bc.getAir(j) == 4096) {
|
||||
continue;
|
||||
}
|
||||
char[] array = bc.getIdArray(j);
|
||||
if (array != null) {
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(bc.blocks, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
pos.setPos(X + x, y, Z + z);
|
||||
nmsWorld.checkLight(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void regenChunk(int x, int z) {
|
||||
World worldObj = getSpongeWorld();
|
||||
throw new UnsupportedOperationException("NOT SUPPORTED");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setComponents(LocalChunk<char[]> lc) {
|
||||
setBlocks(lc);
|
||||
setBiomes(lc);
|
||||
}
|
||||
|
||||
public Chunk getChunk(World world, int x, int z) {
|
||||
net.minecraft.world.chunk.Chunk chunk = ((net.minecraft.world.World) world).getChunkProvider().provideChunk(x, z);
|
||||
if (chunk != null && !chunk.isLoaded()) {
|
||||
chunk.onLoad();
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private BlockState AIR = BlockTypes.AIR.getDefaultState();
|
||||
|
||||
public void setBlocks(LocalChunk<char[]> lc) {
|
||||
World worldObj = getSpongeWorld();
|
||||
org.spongepowered.api.world.Chunk spongeChunk = (org.spongepowered.api.world.Chunk) getChunk(worldObj, lc.getX(), lc.getZ());
|
||||
Chunk nmsChunk = (Chunk) spongeChunk;
|
||||
char[][] ids = ((CharLocalChunk) lc).blocks;
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
char[] array = ids[layer];
|
||||
if (array == null) {
|
||||
continue;
|
||||
}
|
||||
ExtendedBlockStorage section = nmsChunk.getBlockStorageArray()[layer];
|
||||
short[] cacheX = MainUtil.x_loc[0];
|
||||
short[] cacheY = MainUtil.y_loc[0];
|
||||
short[] cacheZ = MainUtil.z_loc[0];
|
||||
for (int j = 0; j < array.length; j++) {
|
||||
int combinedId = array[j];
|
||||
switch (combinedId) {
|
||||
case 0:
|
||||
continue;
|
||||
case 1:
|
||||
int x = cacheX[j];
|
||||
int y = cacheY[j];
|
||||
int z = cacheZ[j];
|
||||
section.set(x, y, z, Blocks.AIR.getDefaultState());
|
||||
continue;
|
||||
default:
|
||||
int id = combinedId >> 4;
|
||||
Block block = Block.getBlockById(id);
|
||||
int data = combinedId & 0xf;
|
||||
IBlockState ibd;
|
||||
if (data != 0) {
|
||||
ibd = block.getStateFromMeta(data);
|
||||
} else {
|
||||
ibd = block.getDefaultState();
|
||||
}
|
||||
x = cacheX[j];
|
||||
y = cacheY[j];
|
||||
z = cacheZ[j];
|
||||
section.set(x, y, z, ibd);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshChunk(nmsChunk.x, nmsChunk.z);
|
||||
}
|
||||
|
||||
public void setBiomes(LocalChunk<char[]> lc) {
|
||||
if (lc.biomes != null) {
|
||||
World worldObj = getSpongeWorld();
|
||||
int bx = lc.getX() << 4;
|
||||
int bz = lc.getX() << 4;
|
||||
String last = null;
|
||||
BiomeType biome = null;
|
||||
for (int x = 0; x < lc.biomes.length; x++) {
|
||||
String[] biomes2 = lc.biomes[x];
|
||||
if (biomes2 != null) {
|
||||
for (int y = 0; y < biomes2.length; y++) {
|
||||
String biomeStr = biomes2[y];
|
||||
if (biomeStr != null) {
|
||||
if (last == null || !StringMan.isEqual(last, biomeStr)) {
|
||||
biome = SpongeUtil.getBiome(biomeStr.toUpperCase());
|
||||
}
|
||||
worldObj.setBiome(bx, 0, bz, biome);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,20 @@ import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
|
||||
public SpongeLowerOfflineUUIDWrapper() {
|
||||
// Anything?
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
|
||||
@Override public UUID getUUID(PlotPlayer player) {
|
||||
return getUUID(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
|
||||
@Override public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return getUUID(player.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
String name = UUIDHandler.getName(uuid);
|
||||
if (name == null) {
|
||||
try {
|
||||
@ -54,47 +51,41 @@ public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||
}
|
||||
String username = name;
|
||||
return new OfflinePlotPlayer() {
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
@Override public boolean isOnline() {
|
||||
return UUIDHandler.getPlayer(uuid) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
|
||||
@Override public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
||||
@Override public String getName() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
|
||||
@Override public long getLastPlayed() {
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public Player[] getOnlinePlayers() {
|
||||
Collection<Player> onlinePlayers = SpongeMain.THIS.getServer().getOnlinePlayers();
|
||||
return onlinePlayers.toArray(new Player[onlinePlayers.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
|
||||
@Override public UUID getUUID(String name) {
|
||||
return UUID
|
||||
.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
|
||||
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
// TODO FIXME
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
}
|
||||
|
@ -17,24 +17,23 @@ import java.util.UUID;
|
||||
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
|
||||
private UserStorageService userStorageService;
|
||||
|
||||
public SpongeOnlineUUIDWrapper() {
|
||||
Optional<UserStorageService> userStorage = Sponge.getServiceManager().provide(UserStorageService.class);
|
||||
Optional<UserStorageService> userStorage =
|
||||
Sponge.getServiceManager().provide(UserStorageService.class);
|
||||
userStorage.ifPresent(userStorageService -> this.userStorageService = userStorageService);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(PlotPlayer player) {
|
||||
@Override public UUID getUUID(PlotPlayer player) {
|
||||
return ((SpongePlayer) player).player.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(OfflinePlotPlayer player) {
|
||||
|
||||
@Override public UUID getUUID(OfflinePlotPlayer player) {
|
||||
return player.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID(String name) {
|
||||
|
||||
@Override public UUID getUUID(String name) {
|
||||
Optional<Player> player = Sponge.getServer().getPlayer(name);
|
||||
if (player.isPresent()) {
|
||||
return player.get().getUniqueId();
|
||||
@ -42,9 +41,8 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
Optional<User> user = userStorageService.get(name);
|
||||
return user.map(Identifiable::getUniqueId).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(UUID uuid) {
|
||||
Optional<Player> player = Sponge.getServer().getPlayer(uuid);
|
||||
if (player.isPresent()) {
|
||||
return new SpongeOfflinePlayer(player.get());
|
||||
@ -52,14 +50,12 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
Optional<User> user = userStorageService.get(uuid);
|
||||
return user.map(SpongeOfflinePlayer::new).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
|
||||
@Override public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
@Override public OfflinePlotPlayer getOfflinePlayer(String name) {
|
||||
Optional<Player> player = Sponge.getServer().getPlayer(name);
|
||||
if (player.isPresent()) {
|
||||
return new SpongeOfflinePlayer(player.get());
|
||||
@ -67,5 +63,5 @@ public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||
Optional<User> user = userStorageService.get(name);
|
||||
return user.map(SpongeOfflinePlayer::new).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,17 +6,17 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import java.util.UUID;
|
||||
import org.spongepowered.api.profile.GameProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
|
||||
public SpongeUUIDHandler(UUIDWrapper wrapper) {
|
||||
super(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCaching(Runnable whenDone) {
|
||||
|
||||
@Override public boolean startCaching(Runnable whenDone) {
|
||||
if (!super.startCaching(whenDone)) {
|
||||
return false;
|
||||
}
|
||||
@ -24,7 +24,8 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
public boolean cache(Runnable whenDone) {
|
||||
for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache().getProfiles()) {
|
||||
for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache()
|
||||
.getProfiles()) {
|
||||
String name = profile.getName().orElse(null);
|
||||
if (name != null) {
|
||||
add(new StringWrapper(name), profile.getUniqueId());
|
||||
@ -32,16 +33,14 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
|
||||
@Override public void fetchUUID(String name, RunnableVal<UUID> ifFetch) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@Override public void run() {
|
||||
ifFetch.value = SpongeUUIDHandler.this.uuidWrapper.getUUID(name);
|
||||
TaskManager.runTask(ifFetch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user