mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Merge branch 'master' into feature/mapping
Conflicts: src/bukkit/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java src/main/java/com/sk89q/worldedit/internal/LocalWorldAdapter.java src/main/java/com/sk89q/worldedit/util/TargetBlock.java
This commit is contained in:
@ -19,36 +19,49 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Preference;
|
||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||
import com.sk89q.worldedit.util.command.Description;
|
||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommand;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.ServerCommandManager;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
|
||||
class ForgePlatform extends ServerInterface {
|
||||
|
||||
private final ForgeWorldEdit mod;
|
||||
private final MinecraftServer server;
|
||||
private final ForgeBiomeTypes biomes;
|
||||
private boolean hookingEvents = false;
|
||||
|
||||
public ForgePlatform(ForgeWorldEdit mod) {
|
||||
ForgePlatform(ForgeWorldEdit mod) {
|
||||
this.mod = mod;
|
||||
this.server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
this.biomes = new ForgeBiomeTypes();
|
||||
}
|
||||
|
||||
boolean isHookingEvents() {
|
||||
return hookingEvents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolveItem(String name) {
|
||||
if (name == null) return 0;
|
||||
for (Item item : Item.itemsList) {
|
||||
@ -65,21 +78,26 @@ class ForgePlatform extends ServerInterface {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return EntityList.stringToClassMapping.containsKey(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeTypes getBiomes() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends com.sk89q.worldedit.world.World> getWorlds() {
|
||||
List<WorldServer> worlds = Arrays.asList(DimensionManager.getWorlds());
|
||||
List<com.sk89q.worldedit.world.World> ret = new ArrayList<com.sk89q.worldedit.world.World>(worlds.size());
|
||||
@ -89,20 +107,50 @@ class ForgePlatform extends ServerInterface {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands) {
|
||||
public Player matchPlayer(Player player) {
|
||||
if (player instanceof ForgePlayer) {
|
||||
return player;
|
||||
} else {
|
||||
EntityPlayerMP entity = server.getConfigurationManager().getPlayerForUsername(player.getName());
|
||||
return entity != null ? new ForgePlayer(entity) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public World matchWorld(World world) {
|
||||
if (world instanceof ForgeWorld) {
|
||||
return world;
|
||||
} else {
|
||||
for (WorldServer ws : DimensionManager.getWorlds()) {
|
||||
if (ws.getWorldInfo().getWorldName().equals(world.getName())) {
|
||||
return new ForgeWorld(ws);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands(Dispatcher dispatcher) {
|
||||
if (server == null) return;
|
||||
ServerCommandManager mcMan = (ServerCommandManager) server.getCommandManager();
|
||||
for (final Command cmd : commands) {
|
||||
|
||||
for (final CommandMapping command : dispatcher.getCommands()) {
|
||||
final Description description = command.getDescription();
|
||||
|
||||
mcMan.registerCommand(new CommandBase() {
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return cmd.aliases()[0];
|
||||
return command.getPrimaryAlias();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandAliases() {
|
||||
return Arrays.asList(cmd.aliases());
|
||||
return Arrays.asList(command.getAllAliases());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,12 +158,14 @@ class ForgePlatform extends ServerInterface {
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/" + cmd.aliases()[0] + " " + cmd.usage();
|
||||
return "/" + command.getPrimaryAlias() + " " + description.getUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o instanceof ICommand) {
|
||||
public int compareTo(@Nullable Object o) {
|
||||
if (o == null) {
|
||||
return -1;
|
||||
} else if (o instanceof ICommand) {
|
||||
return super.compareTo((ICommand) o);
|
||||
} else {
|
||||
return -1;
|
||||
@ -125,6 +175,12 @@ class ForgePlatform extends ServerInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerGameHooks() {
|
||||
// We registered the events already anyway, so we just 'turn them on'
|
||||
hookingEvents = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalConfiguration getConfiguration() {
|
||||
return mod.getConfig();
|
||||
@ -144,4 +200,16 @@ class ForgePlatform extends ServerInterface {
|
||||
public String getPlatformVersion() {
|
||||
return mod.getInternalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Capability, Preference> getCapabilities() {
|
||||
Map<Capability, Preference> capabilities = new EnumMap<Capability, Preference>(Capability.class);
|
||||
capabilities.put(Capability.CONFIGURATION, Preference.PREFER_OTHERS);
|
||||
capabilities.put(Capability.GAME_HOOKS, Preference.NORMAL);
|
||||
capabilities.put(Capability.PERMISSIONS, Preference.PREFER_OTHERS);
|
||||
capabilities.put(Capability.USER_COMMANDS, Preference.NORMAL);
|
||||
capabilities.put(Capability.WORLD_EDITING, Preference.PREFERRED);
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ public class ForgePlayer extends LocalPlayer {
|
||||
private EntityPlayerMP player;
|
||||
|
||||
protected ForgePlayer(EntityPlayerMP player) {
|
||||
super((ServerInterface) ForgeWorldEdit.inst.getPlatform());
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@ -65,7 +64,7 @@ public class ForgePlayer extends LocalPlayer {
|
||||
}
|
||||
|
||||
public WorldVector getPosition() {
|
||||
return new WorldVector(LocalWorldAdapter.wrap(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
|
||||
return new WorldVector(LocalWorldAdapter.adapt(ForgeWorldEdit.inst.getWorld(this.player.worldObj)), this.player.posX, this.player.posY, this.player.posZ);
|
||||
}
|
||||
|
||||
public com.sk89q.worldedit.world.World getWorld() {
|
||||
|
@ -113,7 +113,7 @@ public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getWorld().provider.getDimensionName();
|
||||
return getWorld().getWorldInfo().getWorldName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -465,11 +465,15 @@ public class ForgeWorld extends AbstractWorld {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ((o instanceof ForgeWorld)) {
|
||||
ForgeWorld other = ((ForgeWorld) o);
|
||||
World otherWorld = other.worldRef.get();
|
||||
World thisWorld = other.worldRef.get();
|
||||
return otherWorld != null && thisWorld != null && otherWorld.equals(thisWorld);
|
||||
if (o == null) {
|
||||
return false;
|
||||
} else if ((o instanceof ForgeWorld)) {
|
||||
ForgeWorld other = ((ForgeWorld) o);
|
||||
World otherWorld = other.worldRef.get();
|
||||
World thisWorld = other.worldRef.get();
|
||||
return otherWorld != null && thisWorld != null && otherWorld.equals(thisWorld);
|
||||
} else if (o instanceof com.sk89q.worldedit.world.World) {
|
||||
return ((com.sk89q.worldedit.world.World) o).getName().equals(getName());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
@ -19,13 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closer;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformRejectionException;
|
||||
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
@ -103,11 +104,8 @@ public class ForgeWorldEdit {
|
||||
}
|
||||
|
||||
this.platform = new ForgePlatform(this);
|
||||
try {
|
||||
WorldEdit.getInstance().getPlatformManager().register(platform);
|
||||
} catch (PlatformRejectionException e) {
|
||||
throw new RuntimeException("Failed to register with WorldEdit", e);
|
||||
}
|
||||
|
||||
WorldEdit.getInstance().getPlatformManager().register(platform);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -115,19 +113,28 @@ public class ForgeWorldEdit {
|
||||
WorldEdit.getInstance().getPlatformManager().unregister(platform);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarted(FMLServerStartedEvent event) {
|
||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onCommandEvent(CommandEvent event) {
|
||||
if ((event.sender instanceof EntityPlayerMP)) {
|
||||
if (((EntityPlayerMP) event.sender).worldObj.isRemote) return;
|
||||
String[] split = new String[event.parameters.length + 1];
|
||||
System.arraycopy(event.parameters, 0, split, 1, event.parameters.length);
|
||||
split[0] = ("/" + event.command.getCommandName());
|
||||
WorldEdit.getInstance().handleCommand(wrap((EntityPlayerMP) event.sender), split);
|
||||
split[0] = event.command.getCommandName();
|
||||
com.sk89q.worldedit.event.platform.CommandEvent weEvent =
|
||||
new com.sk89q.worldedit.event.platform.CommandEvent(wrap((EntityPlayerMP) event.sender), Joiner.on(" ").join(split));
|
||||
WorldEdit.getInstance().getEventBus().post(weEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!platform.isHookingEvents()) return; // We have to be told to catch these events
|
||||
|
||||
if (event.useItem == Result.DENY || event.entity.worldObj.isRemote) return;
|
||||
|
||||
WorldEdit we = WorldEdit.getInstance();
|
||||
@ -137,7 +144,7 @@ public class ForgeWorldEdit {
|
||||
Action action = event.action;
|
||||
switch (action) {
|
||||
case LEFT_CLICK_BLOCK: {
|
||||
WorldVector pos = new WorldVector(LocalWorldAdapter.wrap(world), event.x, event.y, event.z);
|
||||
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
@ -146,9 +153,11 @@ public class ForgeWorldEdit {
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case RIGHT_CLICK_BLOCK: {
|
||||
WorldVector pos = new WorldVector(LocalWorldAdapter.wrap(world), event.x, event.y, event.z);
|
||||
WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
@ -157,11 +166,15 @@ public class ForgeWorldEdit {
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case RIGHT_CLICK_AIR: {
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -236,7 +249,7 @@ public class ForgeWorldEdit {
|
||||
checkNotNull(jar);
|
||||
checkNotNull(name);
|
||||
|
||||
String path = "defaults/" + name;
|
||||
String path = "/defaults/" + name;
|
||||
File targetFile = new File(getWorkingDir(), name);
|
||||
Closer closer = Closer.create();
|
||||
|
||||
|
@ -1,32 +1,32 @@
|
||||
#Don't put comments; they get removed
|
||||
default-max-polygon-points=-1
|
||||
schematic-save-dir=schematics
|
||||
allow-extra-data-values=false
|
||||
super-pickaxe-many-drop-items=true
|
||||
register-help=true
|
||||
nav-wand-item=345
|
||||
profile=false
|
||||
super-pickaxe-drop-items=true
|
||||
disallowed-blocks=6,26,27,28,31,32,34,36,37,38,39,40,46,50,51,55,59,66,69,75,76,93,94,77,81,83,7,14,15,16,56
|
||||
max-super-pickaxe-size=5
|
||||
max-brush-radius=10
|
||||
craftscript-dir=craftscripts
|
||||
no-double-slash=false
|
||||
wand-item=271
|
||||
shell-save-type=
|
||||
scripting-timeout=3000
|
||||
snapshots-dir=
|
||||
use-inventory-creative-override=false
|
||||
log-file=worldedit.log
|
||||
max-changed-blocks=-1
|
||||
nav-wand-distance=50
|
||||
butcher-default-radius=-1
|
||||
default-max-changed-blocks=-1
|
||||
history-size=15
|
||||
use-inventory=false
|
||||
allow-symbolic-links=false
|
||||
use-inventory-override=false
|
||||
log-commands=false
|
||||
butcher-max-radius=-1
|
||||
max-polygon-points=20
|
||||
max-radius=-1
|
||||
#Don't put comments; they get removed
|
||||
default-max-polygon-points=-1
|
||||
schematic-save-dir=schematics
|
||||
allow-extra-data-values=false
|
||||
super-pickaxe-many-drop-items=true
|
||||
register-help=true
|
||||
nav-wand-item=345
|
||||
profile=false
|
||||
super-pickaxe-drop-items=true
|
||||
disallowed-blocks=6,26,27,28,31,32,34,36,37,38,39,40,46,50,51,55,59,66,69,75,76,93,94,77,81,83,7,14,15,16,56
|
||||
max-super-pickaxe-size=5
|
||||
max-brush-radius=10
|
||||
craftscript-dir=craftscripts
|
||||
no-double-slash=false
|
||||
wand-item=271
|
||||
shell-save-type=
|
||||
scripting-timeout=3000
|
||||
snapshots-dir=
|
||||
use-inventory-creative-override=false
|
||||
log-file=worldedit.log
|
||||
max-changed-blocks=-1
|
||||
nav-wand-distance=50
|
||||
butcher-default-radius=-1
|
||||
default-max-changed-blocks=-1
|
||||
history-size=15
|
||||
use-inventory=false
|
||||
allow-symbolic-links=false
|
||||
use-inventory-override=false
|
||||
log-commands=false
|
||||
butcher-max-radius=-1
|
||||
max-polygon-points=20
|
||||
max-radius=-1
|
Reference in New Issue
Block a user