Fixes for sponge + minor tweaks for spigot

- Updated to sponge 591
- Added optional WorldEdit restriction
- several fixes (including greeting/farewell flag)
This commit is contained in:
boy0001 2015-09-07 22:17:48 +10:00
parent 2b3b947143
commit 66730794d6
21 changed files with 68 additions and 67 deletions

View file

@ -39,6 +39,7 @@
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>bukkit</id>
@ -146,13 +147,11 @@
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
</dependency>
<!--
<dependency>
<groupId>org.spongepowered</groupId>
<artifactId>spongeapi</artifactId>
<version>2.1-SNAPSHOT</version>
<version>2.1-20150828.013112-189</version>
</dependency>
-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>

View file

@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
import com.sk89q.worldedit.WorldEdit;
public interface IPlotMain {
@ -114,7 +115,7 @@ public interface IPlotMain {
/**
* Register the WorldEdit hook
*/
void registerWorldEditEvents();
boolean initWorldEdit();
/**
* Register TNT related events (if TNT protection is enabled)

View file

@ -31,6 +31,8 @@ import java.util.zip.ZipInputStream;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.commands.WE_Anywhere;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
import com.intellectualcrafters.plot.config.Settings;
@ -78,6 +80,8 @@ 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.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit;
/**
* An implementation of the core,
@ -103,6 +107,7 @@ public class PS {
public YamlConfiguration storage;
public IPlotMain IMP = null;
public TaskManager TASK;
public WorldEdit worldedit;
public URL update;
// private:
@ -167,8 +172,13 @@ public class PS {
if (Settings.KILL_ROAD_MOBS || Settings.KILL_ROAD_VEHICLES) {
IMP.runEntityTask();
}
if (IMP.initWorldEdit()) {
worldedit = WorldEdit.getInstance();
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
MainCommand.getInstance().createCommand(new WE_Anywhere());
}
// Events
IMP.registerWorldEditEvents();
IMP.registerCommands();
IMP.registerPlayerEvents();
IMP.registerInventoryEvents();

View file

@ -25,6 +25,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
@ -105,7 +106,7 @@ public class Toggle extends SubCommand {
return true;
}
});
if (BukkitMain.worldEdit != null) {
if (PS.get().worldedit != null) {
toggles.put("worldedit",
new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {

View file

@ -25,8 +25,8 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
import com.plotsquared.general.commands.CommandDeclaration;
import com.plotsquared.listener.WEManager;
@CommandDeclaration(
command = "weanywhere",

View file

@ -64,7 +64,6 @@ import com.plotsquared.bukkit.listeners.PlotPlusListener;
import com.plotsquared.bukkit.listeners.TNTListener;
import com.plotsquared.bukkit.listeners.WorldEvents;
import com.plotsquared.bukkit.listeners.worldedit.WEListener;
import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
import com.plotsquared.bukkit.titles.DefaultTitle;
import com.plotsquared.bukkit.util.BukkitChatManager;
import com.plotsquared.bukkit.util.BukkitChunkManager;
@ -90,6 +89,7 @@ import com.plotsquared.bukkit.uuid.FileUUIDHandler;
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
@ -368,7 +368,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}
@Override
public void registerWorldEditEvents() {
public boolean initWorldEdit() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
final String version = BukkitMain.worldEdit.getDescription().getVersion();
@ -378,10 +378,10 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
log("&c - http://builds.enginehub.org/job/worldedit");
} else {
getServer().getPluginManager().registerEvents(new WEListener(), this);
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
MainCommand.getInstance().createCommand(new WE_Anywhere());
return true;
}
}
return false;
}
@Override

View file

@ -117,10 +117,10 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
import com.plotsquared.bukkit.object.BukkitLazyBlock;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.WEManager;
/**
* Player Events involving plots

View file

@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.util.SetBlockQueue;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.SetBlockFast;
import com.plotsquared.listener.WEManager;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import java.lang.reflect.Field;
import java.util.HashSet;
@ -7,9 +7,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.SetBlockQueue;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.Vector2D;
import com.sk89q.worldedit.WorldEditException;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import java.util.HashSet;

View file

@ -1,4 +1,4 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import java.util.HashSet;
import java.util.UUID;

View file

@ -1,11 +1,8 @@
package com.plotsquared.bukkit.listeners.worldedit;
package com.plotsquared.listener;
import java.lang.reflect.Field;
import java.util.HashSet;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
@ -14,31 +11,18 @@ import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.bukkit.BukkitMain;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.EditSession.Stage;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.ChangeSetExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.MaskingExtent;
import com.sk89q.worldedit.extent.cache.LastAccessExtentCache;
import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
import com.sk89q.worldedit.extent.validation.DataValidatorExtent;
import com.sk89q.worldedit.extent.world.BlockQuirkExtent;
import com.sk89q.worldedit.extent.world.ChunkLoadingExtent;
import com.sk89q.worldedit.extent.world.FastModeExtent;
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World;
@ -47,9 +31,9 @@ public class WESubscriber {
@Subscribe(priority=Priority.VERY_EARLY)
public void onEditSession(EditSessionEvent event) {
WorldEditPlugin worldedit = BukkitMain.worldEdit;
WorldEdit worldedit = PS.get().worldedit;
if (worldedit == null) {
WorldEdit.getInstance().getEventBus().unregister(this);
worldedit.getEventBus().unregister(this);
return;
}
World worldObj = event.getWorld();
@ -61,12 +45,11 @@ public class WESubscriber {
if (pp != null && pp.getAttribute("worldedit")) {
return;
}
PlotPlayer player = UUIDHandler.getPlayer(actor.getName());
HashSet<RegionWrapper> mask = WEManager.getMask(player);
HashSet<RegionWrapper> mask = WEManager.getMask(pp);
PlotWorld plotworld = PS.get().getPlotWorld(world);
if (mask.size() == 0) {
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASS);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
}
if (plotworld != null) {
event.setExtent(new NullExtent());
@ -76,13 +59,13 @@ public class WESubscriber {
if (Settings.CHUNK_PROCESSOR) {
if (Settings.EXPERIMENTAL_FAST_ASYNC_WORLDEDIT) {
try {
LocalSession session = worldedit.getWorldEdit().getSession(name);
LocalSession session = worldedit.getSession(name);
boolean hasMask = session.getMask() != null;
Player objPlayer = ((BukkitPlayer) player).player;
ItemStack item = objPlayer.getItemInHand();
if (item != null && !hasMask) {
Player objPlayer = (Player) actor;
int item = objPlayer.getItemInHand();
if (!hasMask) {
try {
Tool tool = session.getTool(item.getTypeId());
Tool tool = session.getTool(item);
if (tool != null && tool instanceof BrushTool) {
hasMask = ((BrushTool) tool).getMask() != null;
}
@ -149,7 +132,7 @@ public class WESubscriber {
event.setExtent(new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(), event.getExtent()));
}
}
else if (PS.get().isPlotWorld(world)) {
else if (plotworld != null) {
event.setExtent(new WEExtent(mask, event.getExtent()));
}
}

View file

@ -21,7 +21,9 @@ import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.block.BlockType;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.entity.player.PlayerChatEvent;
import org.spongepowered.api.event.state.InitializationEvent;
import org.spongepowered.api.event.state.PreInitializationEvent;
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
import org.spongepowered.api.plugin.Plugin;
@ -36,7 +38,6 @@ import org.spongepowered.api.world.GeneratorTypes;
import org.spongepowered.api.world.World;
import com.google.common.base.Optional;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
@ -79,12 +80,13 @@ import com.plotsquared.sponge.util.SpongeUtil;
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
import com.sk89q.worldedit.WorldEdit;
/**
* Created by robin on 01/11/2014
*/
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0")
@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies="before:WorldEdit")
public class SpongeMain implements IPlotMain, PluginContainer {
public static SpongeMain THIS;
@ -210,7 +212,12 @@ public class SpongeMain implements IPlotMain, PluginContainer {
}
///////////////////////////////////////////////////////////////////////
///////////////////// ON ENABLE /////////////////////
///////////////////// ON ENABLE /////////////////////
@Subscribe
public void init(InitializationEvent event) {
log("INIT");
}
@Subscribe
public void onInit(PreInitializationEvent event) {
log("PRE INIT");
@ -218,13 +225,11 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Subscribe
public void onServerAboutToStart(ServerAboutToStartEvent event) {
log("INIT");
log("ABOUT START");
THIS = this;
//
resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
plugin = game.getPluginManager().getPlugin("PlotSquared").get().getInstance();
log("PLUGIN IS THIS: " + (plugin == this));
plugin = this;
server = game.getServer();
//
@ -514,7 +519,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
@Override
public void registerCommands() {
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2");
getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), new String[] {"plots", "p", "plot", "ps", "plotsquared", "p2", "2"});
}
@Override
@ -541,9 +546,15 @@ public class SpongeMain implements IPlotMain, PluginContainer {
}
@Override
public void registerWorldEditEvents() {
// TODO Auto-generated method stub
log("registerWorldEditEvents is not implemented!");
public boolean initWorldEdit() {
try {
log("CHECKING FOR WORLDEDIT!?");
Class.forName("com.sk89q.worldedit.WorldEdit");
return true;
}
catch (Throwable e) {
return false;
}
}
@Override

View file

@ -43,11 +43,11 @@ public class WorldModify implements WorldGeneratorModifier {
@Override
public String getName() {
return "PlotSquared";
return "plotsquared";
}
@Override
public String getId() {
return "PlotSquared";
return "plotsquared";
}
}

View file

@ -15,6 +15,7 @@ import org.spongepowered.api.entity.living.monster.Monster;
import org.spongepowered.api.entity.player.Player;
import org.spongepowered.api.entity.vehicle.Boat;
import org.spongepowered.api.entity.vehicle.minecart.Minecart;
import org.spongepowered.api.event.Subscribe;
import org.spongepowered.api.event.block.BlockMoveEvent;
import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent;
import org.spongepowered.api.event.block.FloraGrowEvent;
@ -45,7 +46,6 @@ import org.spongepowered.api.world.extent.Extent;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import com.google.common.base.Predicate;
import com.google.common.eventbus.Subscribe;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;

View file

@ -98,9 +98,6 @@ public class SpongePlayer extends PlotPlayer {
return true;
}
boolean value = this.player.hasPermission(perm);
// TODO check children
return value;
}

Binary file not shown.

Binary file not shown.