Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 02:50:06 +01:00
Renamed hey0's plugin to SMWorldEdit. Made WorldEdit somewhat a singleton to hold the ServerInterface instance.
Dieser Commit ist enthalten in:
Ursprung
5f1a014bfb
Commit
92dc88562c
@ -41,7 +41,7 @@ public class EditSession {
|
|||||||
/**
|
/**
|
||||||
* Server interface.
|
* Server interface.
|
||||||
*/
|
*/
|
||||||
public static ServerInterface server;
|
protected ServerInterface server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the original blocks before modification.
|
* Stores the original blocks before modification.
|
||||||
@ -88,6 +88,7 @@ public class EditSession {
|
|||||||
* Default constructor. There is no maximum blocks limit.
|
* Default constructor. There is no maximum blocks limit.
|
||||||
*/
|
*/
|
||||||
public EditSession() {
|
public EditSession() {
|
||||||
|
server = WorldEdit.getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,6 +99,8 @@ public class EditSession {
|
|||||||
throw new IllegalArgumentException("Max blocks must be >= -1");
|
throw new IllegalArgumentException("Max blocks must be >= -1");
|
||||||
}
|
}
|
||||||
this.maxBlocks = maxBlocks;
|
this.maxBlocks = maxBlocks;
|
||||||
|
|
||||||
|
server = WorldEdit.getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,11 +26,21 @@ import com.sk89q.worldedit.ServerInterface;
|
|||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class WorldEditSM extends Plugin {
|
public class SMWorldEdit extends Plugin {
|
||||||
|
/**
|
||||||
|
* WorldEdit's properties file.
|
||||||
|
*/
|
||||||
private PropertiesFile properties;
|
private PropertiesFile properties;
|
||||||
private static final WorldEdit worldEdit = new WorldEdit();
|
/**
|
||||||
private static final WorldEditSMListener listener =
|
* WorldEdit instance.
|
||||||
new WorldEditSMListener(worldEdit);
|
*/
|
||||||
|
private static final WorldEdit worldEdit =
|
||||||
|
WorldEdit.setup(new SMServerInterface());
|
||||||
|
/**
|
||||||
|
* Listener for the plugin system.
|
||||||
|
*/
|
||||||
|
private static final SMWorldEditListener listener =
|
||||||
|
new SMWorldEditListener();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the plugin.
|
* Initializes the plugin.
|
||||||
@ -49,10 +59,6 @@ public class WorldEditSM extends Plugin {
|
|||||||
PluginListener.Priority.MEDIUM);
|
PluginListener.Priority.MEDIUM);
|
||||||
loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
|
loader.addListener(PluginLoader.Hook.LOGIN, listener, this,
|
||||||
PluginListener.Priority.MEDIUM);
|
PluginListener.Priority.MEDIUM);
|
||||||
|
|
||||||
ServerInterface server = new SMServerInterface();
|
|
||||||
WorldEditPlayer.server = server;
|
|
||||||
EditSession.server = server;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -24,27 +24,14 @@ import com.sk89q.worldedit.*;
|
|||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class WorldEditSMListener extends PluginListener {
|
public class SMWorldEditListener extends PluginListener {
|
||||||
/**
|
|
||||||
* Stores a reference to the WorldEdit object.
|
|
||||||
*/
|
|
||||||
private WorldEdit worldEdit;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the listener with a reference to the WorldEdit object.
|
|
||||||
*
|
|
||||||
* @param worldEdit
|
|
||||||
*/
|
|
||||||
public WorldEditSMListener(WorldEdit worldEdit) {
|
|
||||||
this.worldEdit = worldEdit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onDisconnect(Player player) {
|
public void onDisconnect(Player player) {
|
||||||
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
worldEdit.removeSession(new SMWorldEditPlayer(player));
|
worldEdit.removeSession(new SMWorldEditPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +47,7 @@ public class WorldEditSMListener extends PluginListener {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onBlockCreate(Player modPlayer, Block blockPlaced,
|
public boolean onBlockCreate(Player modPlayer, Block blockPlaced,
|
||||||
Block blockClicked, int itemInHand) {
|
Block blockClicked, int itemInHand) {
|
||||||
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
|
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
|
||||||
|
|
||||||
if (itemInHand != 271) { return false; }
|
if (itemInHand != 271) { return false; }
|
||||||
@ -94,6 +82,7 @@ public class WorldEditSMListener extends PluginListener {
|
|||||||
if (!modPlayer.canUseCommand("/editpos1")
|
if (!modPlayer.canUseCommand("/editpos1")
|
||||||
&& !modPlayer.canUseCommand("/.")) { return false; }
|
&& !modPlayer.canUseCommand("/.")) { return false; }
|
||||||
|
|
||||||
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
|
WorldEditPlayer player = new SMWorldEditPlayer(modPlayer);
|
||||||
WorldEditSession session = worldEdit.getSession(player);
|
WorldEditSession session = worldEdit.getSession(player);
|
||||||
|
|
||||||
@ -133,6 +122,8 @@ public class WorldEditSMListener extends PluginListener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(Player modPlayer, String[] split) {
|
public boolean onCommand(Player modPlayer, String[] split) {
|
||||||
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (worldEdit.getCommands().containsKey(split[0])) {
|
if (worldEdit.getCommands().containsKey(split[0])) {
|
||||||
if (modPlayer.canUseCommand(split[0])) {
|
if (modPlayer.canUseCommand(split[0])) {
|
@ -33,6 +33,15 @@ import com.sk89q.worldedit.*;
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class WorldEdit {
|
public class WorldEdit {
|
||||||
|
/**
|
||||||
|
* WorldEdit instance.
|
||||||
|
*/
|
||||||
|
private static WorldEdit instance;
|
||||||
|
/**
|
||||||
|
* Server interface.
|
||||||
|
*/
|
||||||
|
private ServerInterface server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of default allowed blocks.
|
* List of default allowed blocks.
|
||||||
*/
|
*/
|
||||||
@ -65,10 +74,41 @@ public class WorldEdit {
|
|||||||
*/
|
*/
|
||||||
private int defaultChangeLimit = -1;
|
private int defaultChangeLimit = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up an instance.
|
||||||
|
*
|
||||||
|
* @param server
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static WorldEdit setup(ServerInterface server) {
|
||||||
|
WorldEdit worldEdit = new WorldEdit();
|
||||||
|
worldEdit.server = server;
|
||||||
|
instance = worldEdit;
|
||||||
|
return worldEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get WorldEdit instance.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static WorldEdit getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get server interface.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static ServerInterface getServer() {
|
||||||
|
return instance.server;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance of the plugin.
|
* Construct an instance of the plugin.
|
||||||
*/
|
*/
|
||||||
public WorldEdit() {
|
private WorldEdit() {
|
||||||
commands.put("/editpos1", "Set editing position #1");
|
commands.put("/editpos1", "Set editing position #1");
|
||||||
commands.put("/editpos2", "Set editing position #2");
|
commands.put("/editpos2", "Set editing position #2");
|
||||||
commands.put("/toggleplace", "Toggle placing at pos #1");
|
commands.put("/toggleplace", "Toggle placing at pos #1");
|
||||||
|
@ -28,7 +28,14 @@ public abstract class WorldEditPlayer {
|
|||||||
/**
|
/**
|
||||||
* Server interface.
|
* Server interface.
|
||||||
*/
|
*/
|
||||||
public static ServerInterface server;
|
protected ServerInterface server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the player.
|
||||||
|
*/
|
||||||
|
public WorldEditPlayer() {
|
||||||
|
server = WorldEdit.getServer();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of the player.
|
* Get the name of the player.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren