Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 11:00:05 +01:00
[Forge] Cleaned up the code somewhat.
Dieser Commit ist enthalten in:
Ursprung
cb7508f481
Commit
b6ee2c570a
@ -25,7 +25,7 @@ import com.sk89q.worldedit.util.PropertiesConfiguration;
|
||||
|
||||
public class ForgeConfiguration extends PropertiesConfiguration {
|
||||
|
||||
public ForgeConfiguration(WorldEditMod mod) {
|
||||
public ForgeConfiguration(ForgeWorldEdit mod) {
|
||||
super(new File(mod.getWorkingDir() + File.separator + "worldedit.properties"));
|
||||
}
|
||||
|
||||
@ -35,6 +35,6 @@ public class ForgeConfiguration extends PropertiesConfiguration {
|
||||
}
|
||||
|
||||
public File getWorkingDirectory() {
|
||||
return WorldEditMod.inst.getWorkingDir();
|
||||
return ForgeWorldEdit.inst.getWorkingDir();
|
||||
}
|
||||
}
|
@ -1,148 +1,148 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
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.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;
|
||||
|
||||
public class ForgeServerInterface extends ServerInterface {
|
||||
private final WorldEditMod mod;
|
||||
private final MinecraftServer server;
|
||||
private final ForgeBiomeTypes biomes;
|
||||
|
||||
public ForgeServerInterface(WorldEditMod mod) {
|
||||
this.mod = mod;
|
||||
this.server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
this.biomes = new ForgeBiomeTypes();
|
||||
}
|
||||
|
||||
public int resolveItem(String name) {
|
||||
if (name == null) return 0;
|
||||
for (Item item : Item.itemsList) {
|
||||
if (item == null) continue;
|
||||
if (item.getUnlocalizedName() == null) continue;
|
||||
if (item.getUnlocalizedName().startsWith("item.")) {
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase("item." + name)) return item.itemID;
|
||||
}
|
||||
if (item.getUnlocalizedName().startsWith("tile.")) {
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase("tile." + name)) return item.itemID;
|
||||
}
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase(name)) return item.itemID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isValidMobType(String type) {
|
||||
return EntityList.stringToClassMapping.containsKey(type);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
}
|
||||
|
||||
public BiomeTypes getBiomes() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public List<LocalWorld> getWorlds() {
|
||||
List<WorldServer> worlds = Arrays.asList(DimensionManager.getWorlds());
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
for (WorldServer world : worlds) {
|
||||
ret.add(new ForgeWorld(world));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands) {
|
||||
if (server == null) return;
|
||||
ServerCommandManager mcMan = (ServerCommandManager) server.getCommandManager();
|
||||
for (final Command cmd : commands) {
|
||||
mcMan.registerCommand(new CommandBase() {
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return cmd.aliases()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandAliases() {
|
||||
return Arrays.asList(cmd.aliases());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2) {}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/" + cmd.aliases()[0] + " " + cmd.usage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o instanceof ICommand) {
|
||||
return super.compareTo((ICommand) o);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalConfiguration getConfiguration() {
|
||||
return mod.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return mod.getInternalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Forge-Official";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return mod.getInternalVersion();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
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.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;
|
||||
|
||||
class ForgePlatform extends ServerInterface {
|
||||
private final ForgeWorldEdit mod;
|
||||
private final MinecraftServer server;
|
||||
private final ForgeBiomeTypes biomes;
|
||||
|
||||
public ForgePlatform(ForgeWorldEdit mod) {
|
||||
this.mod = mod;
|
||||
this.server = FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
this.biomes = new ForgeBiomeTypes();
|
||||
}
|
||||
|
||||
public int resolveItem(String name) {
|
||||
if (name == null) return 0;
|
||||
for (Item item : Item.itemsList) {
|
||||
if (item == null) continue;
|
||||
if (item.getUnlocalizedName() == null) continue;
|
||||
if (item.getUnlocalizedName().startsWith("item.")) {
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase("item." + name)) return item.itemID;
|
||||
}
|
||||
if (item.getUnlocalizedName().startsWith("tile.")) {
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase("tile." + name)) return item.itemID;
|
||||
}
|
||||
if (item.getUnlocalizedName().equalsIgnoreCase(name)) return item.itemID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isValidMobType(String type) {
|
||||
return EntityList.stringToClassMapping.containsKey(type);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
}
|
||||
|
||||
public BiomeTypes getBiomes() {
|
||||
return this.biomes;
|
||||
}
|
||||
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public List<LocalWorld> getWorlds() {
|
||||
List<WorldServer> worlds = Arrays.asList(DimensionManager.getWorlds());
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
for (WorldServer world : worlds) {
|
||||
ret.add(new ForgeWorld(world));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands) {
|
||||
if (server == null) return;
|
||||
ServerCommandManager mcMan = (ServerCommandManager) server.getCommandManager();
|
||||
for (final Command cmd : commands) {
|
||||
mcMan.registerCommand(new CommandBase() {
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return cmd.aliases()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getCommandAliases() {
|
||||
return Arrays.asList(cmd.aliases());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender var1, String[] var2) {}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender) {
|
||||
return "/" + cmd.aliases()[0] + " " + cmd.usage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o instanceof ICommand) {
|
||||
return super.compareTo((ICommand) o);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalConfiguration getConfiguration() {
|
||||
return mod.getConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return mod.getInternalVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Forge-Official";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformVersion() {
|
||||
return mod.getInternalVersion();
|
||||
}
|
||||
}
|
@ -19,24 +19,20 @@
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
|
||||
public class ForgePlayer extends LocalPlayer {
|
||||
private EntityPlayerMP player;
|
||||
|
||||
protected ForgePlayer(EntityPlayerMP player) {
|
||||
super(WorldEditMod.inst.getServerInterface());
|
||||
super((ServerInterface) ForgeWorldEdit.inst.getPlatform());
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@ -50,11 +46,11 @@ public class ForgePlayer extends LocalPlayer {
|
||||
}
|
||||
|
||||
public WorldVector getPosition() {
|
||||
return new WorldVector(WorldEditMod.inst.getWorld(this.player.worldObj), this.player.posX, this.player.posY, this.player.posZ);
|
||||
return new WorldVector(ForgeWorldEdit.inst.getWorld(this.player.worldObj), this.player.posX, this.player.posY, this.player.posZ);
|
||||
}
|
||||
|
||||
public LocalWorld getWorld() {
|
||||
return WorldEditMod.inst.getWorld(this.player.worldObj);
|
||||
return ForgeWorldEdit.inst.getWorld(this.player.worldObj);
|
||||
}
|
||||
|
||||
public double getPitch() {
|
||||
@ -75,7 +71,7 @@ public class ForgePlayer extends LocalPlayer {
|
||||
if (params.length > 0) {
|
||||
send = send + "|" + StringUtil.joinString(params, "|");
|
||||
}
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload(WorldEditMod.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET));
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, send.getBytes(WECUIPacketHandler.UTF_8_CHARSET));
|
||||
this.player.playerNetServerHandler.sendPacketToPlayer(packet);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ import java.util.Set;
|
||||
public class ForgeWorld extends LocalWorld {
|
||||
private WeakReference<World> world;
|
||||
|
||||
public ForgeWorld(World world) {
|
||||
ForgeWorld(World world) {
|
||||
this.world = new WeakReference<World>(world);
|
||||
}
|
||||
|
||||
|
270
src/forge/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java
Normale Datei
270
src/forge/java/com/sk89q/worldedit/forge/ForgeWorldEdit.java
Normale Datei
@ -0,0 +1,270 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
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.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformRejectionException;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.CommandEvent;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static net.minecraftforge.event.entity.player.PlayerInteractEvent.Action;
|
||||
|
||||
/**
|
||||
* The Forge implementation of WorldEdit.
|
||||
*/
|
||||
@Mod(modid = "WorldEdit", name = "WorldEdit", version = "%VERSION%")
|
||||
@NetworkMod(channels="WECUI", packetHandler=WECUIPacketHandler.class)
|
||||
public class ForgeWorldEdit {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ForgeWorldEdit.class.getCanonicalName());
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
|
||||
@Instance("WorldEdit")
|
||||
public static ForgeWorldEdit inst;
|
||||
|
||||
private ForgePlatform platform;
|
||||
private ForgeConfiguration config;
|
||||
private File workingDir;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// Redirect all loggers under com.sk89q to FML's logger
|
||||
Logger.getLogger("com.sk89q").setParent(FMLLog.getLogger());
|
||||
|
||||
// Setup working directory
|
||||
workingDir = new File(event.getModConfigurationDirectory() + File.separator + "worldedit");
|
||||
workingDir.mkdir();
|
||||
|
||||
// Create default configuration
|
||||
createDefaultConfiguration(event.getSourceFile(), "worldedit.properties");
|
||||
|
||||
config = new ForgeConfiguration(this);
|
||||
config.load();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
logger.info("WorldEdit for Forge (version " + getInternalVersion() + ") is loaded");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
if (this.platform != null) {
|
||||
logger.warning("FMLServerStartingEvent occurred when FMLServerStoppingEvent hasn't");
|
||||
WorldEdit.getInstance().getPlatformManager().unregister(platform);
|
||||
}
|
||||
|
||||
this.platform = new ForgePlatform(this);
|
||||
try {
|
||||
WorldEdit.getInstance().getPlatformManager().register(platform);
|
||||
} catch (PlatformRejectionException e) {
|
||||
throw new RuntimeException("Failed to register with WorldEdit", e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStopping(FMLServerStoppingEvent event) {
|
||||
WorldEdit.getInstance().getPlatformManager().unregister(platform);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.useItem == Result.DENY || event.entity.worldObj.isRemote) return;
|
||||
|
||||
WorldEdit we = WorldEdit.getInstance();
|
||||
ForgePlayer player = wrap((EntityPlayerMP) event.entityPlayer);
|
||||
ForgeWorld world = getWorld(event.entityPlayer.worldObj);
|
||||
|
||||
Action action = event.action;
|
||||
switch (action) {
|
||||
case LEFT_CLICK_BLOCK: {
|
||||
WorldVector pos = new WorldVector(world, event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
case RIGHT_CLICK_BLOCK: {
|
||||
WorldVector pos = new WorldVector(world, event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
case RIGHT_CLICK_AIR: {
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the configuration.
|
||||
*
|
||||
* @return the Forge configuration
|
||||
*/
|
||||
ForgeConfiguration getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldEdit proxy for the given player.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the WorldEdit player
|
||||
*/
|
||||
public ForgePlayer wrap(EntityPlayerMP player) {
|
||||
checkNotNull(player);
|
||||
return new ForgePlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session for a player.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the session
|
||||
*/
|
||||
public LocalSession getSession(EntityPlayerMP player) {
|
||||
checkNotNull(player);
|
||||
return WorldEdit.getInstance().getSessionManager().get(wrap(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldEdit proxy for the given world.
|
||||
*
|
||||
* @param world the world
|
||||
* @return the WorldEdit world
|
||||
*/
|
||||
public ForgeWorld getWorld(World world) {
|
||||
checkNotNull(world);
|
||||
return new ForgeWorld(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the WorldEdit proxy for the platform.
|
||||
*
|
||||
* @return the WorldEdit platform
|
||||
*/
|
||||
public Platform getPlatform() {
|
||||
return this.platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the working directory where WorldEdit's files are stored.
|
||||
*
|
||||
* @return the working directory
|
||||
*/
|
||||
public File getWorkingDir() {
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the default configuration.
|
||||
*
|
||||
* @param jar the jar
|
||||
* @param name the name
|
||||
*/
|
||||
private void createDefaultConfiguration(File jar, String name) {
|
||||
checkNotNull(jar);
|
||||
checkNotNull(name);
|
||||
|
||||
String path = "defaults/" + name;
|
||||
File targetFile = new File(getWorkingDir(), name);
|
||||
Closer closer = Closer.create();
|
||||
|
||||
try {
|
||||
@Nullable InputStream inputStream = getClass().getResourceAsStream(path);
|
||||
if (inputStream == null) {
|
||||
throw new IOException("Failed to get resource '" + path + "' from .class");
|
||||
}
|
||||
closer.register(inputStream);
|
||||
FileOutputStream outputStream = new FileOutputStream(targetFile);
|
||||
ByteStreams.copy(inputStream, outputStream);
|
||||
logger.info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "Failed to extract defaults", e);
|
||||
} finally {
|
||||
try {
|
||||
closer.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version of the WorldEdit-for-Forge implementation.
|
||||
*
|
||||
* @return a version string
|
||||
*/
|
||||
String getInternalVersion() {
|
||||
return ForgeWorldEdit.class.getAnnotation(Mod.class).version();
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,7 @@ public class WECUIPacketHandler implements IPacketHandler {
|
||||
|
||||
public void onPacketData(INetworkManager manager, Packet250CustomPayload packet, Player player) {
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
LocalSession session = WorldEditMod.inst.getSession((EntityPlayerMP) player);
|
||||
LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player);
|
||||
|
||||
if (session.hasCUISupport()) {
|
||||
return;
|
||||
|
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraftforge.event.CommandEvent;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
|
||||
public class WorldEditForgeListener {
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onCommandEvent(CommandEvent event) {
|
||||
if (WorldEditMod.inst.getWorldEdit() == null) return;
|
||||
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());
|
||||
|
||||
WorldEditMod.inst.getWorldEdit().handleCommand(WorldEditMod.inst.wrapPlayer((EntityPlayerMP) event.sender), split);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (WorldEditMod.inst.getWorldEdit() == null) return;
|
||||
if (event.useItem == Result.DENY || event.entity.worldObj.isRemote) return;
|
||||
|
||||
LocalPlayer player = WorldEditMod.inst.wrapPlayer((EntityPlayerMP) event.entityPlayer);
|
||||
LocalWorld world = WorldEditMod.inst.getWorld(event.entityPlayer.worldObj);
|
||||
WorldEdit we = WorldEditMod.inst.getWorldEdit();
|
||||
|
||||
PlayerInteractEvent.Action action = event.action;
|
||||
if (action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
|
||||
WorldVector pos = new WorldVector(world, event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
} else if (action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
|
||||
WorldVector pos = new WorldVector(world, event.x, event.y, event.z);
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player))
|
||||
event.setCanceled(true);
|
||||
} else if ((action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR) && (we.handleRightClick(player))) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,184 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformRejectionException;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
@Mod(modid = "WorldEdit", name = "WorldEdit", version = "%VERSION%")
|
||||
@NetworkMod(channels="WECUI", packetHandler=WECUIPacketHandler.class)
|
||||
public class WorldEditMod {
|
||||
|
||||
@Instance("WorldEdit")
|
||||
public static WorldEditMod inst;
|
||||
|
||||
protected static Logger logger;
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
private ForgeServerInterface server;
|
||||
private WorldEdit controller;
|
||||
private ForgeConfiguration config;
|
||||
private File workingDir;
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
logger = Logger.getLogger(getClass().getAnnotation(Mod.class).modid());
|
||||
logger.setParent(FMLLog.getLogger());
|
||||
Logger.getLogger("com.sk89q").setParent(FMLLog.getLogger());
|
||||
|
||||
String modVersion = getInternalVersion();
|
||||
String manifestVersion = WorldEdit.getVersion();
|
||||
if (!manifestVersion.equalsIgnoreCase(modVersion) && !modVersion.equals("%VERSION%")) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + modVersion + ")");
|
||||
}
|
||||
|
||||
this.workingDir = new File(event.getModConfigurationDirectory() + File.separator + "WorldEdit");
|
||||
this.workingDir.mkdir();
|
||||
|
||||
createDefaultConfiguration(event.getSourceFile(), "worldedit.properties");
|
||||
config = new ForgeConfiguration(this);
|
||||
config.load();
|
||||
// PermissionsResolverManager.initialize(this, this.workingDir);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
MinecraftForge.EVENT_BUS.register(new WorldEditForgeListener());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
logger.info("WorldEdit " + WorldEdit.getVersion() + " Loaded");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
this.server = new ForgeServerInterface(this);
|
||||
this.controller = WorldEdit.getInstance();
|
||||
try {
|
||||
controller.getPlatformManager().register(server);
|
||||
} catch (PlatformRejectionException e) {
|
||||
throw new RuntimeException("Failed to register with WorldEdit", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ForgeConfiguration getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
||||
/*public PermissionsResolverManager getPermissionsResolver() {
|
||||
return PermissionsResolverManager.getInstance();
|
||||
}*/
|
||||
|
||||
public LocalSession getSession(EntityPlayerMP player) {
|
||||
return this.controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
public LocalWorld getWorld(World world) {
|
||||
return new ForgeWorld(world);
|
||||
}
|
||||
|
||||
public ForgePlayer wrapPlayer(EntityPlayerMP player) {
|
||||
return new ForgePlayer(player);
|
||||
}
|
||||
|
||||
public WorldEdit getWorldEdit() {
|
||||
return this.controller;
|
||||
}
|
||||
|
||||
public ServerInterface getServerInterface() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
public File getWorkingDir() {
|
||||
return this.workingDir;
|
||||
}
|
||||
|
||||
private void createDefaultConfiguration(File jar, String name) {
|
||||
File actual = new File(getWorkingDir(), name);
|
||||
if (!actual.exists()) {
|
||||
InputStream input = null;
|
||||
JarFile file = null;
|
||||
try {
|
||||
file = new JarFile(jar);
|
||||
ZipEntry copy = file.getEntry("defaults/" + name);
|
||||
if (copy == null)
|
||||
throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} catch (IOException e) {
|
||||
logger.severe("Unable to read default configuration: " + name);
|
||||
} finally {
|
||||
try {
|
||||
file.close();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
try {
|
||||
output = new FileOutputStream(actual);
|
||||
byte[] buf = new byte[8192];
|
||||
int length = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
logger.info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (input != null)
|
||||
input.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
try {
|
||||
if (output != null)
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getInternalVersion() {
|
||||
return WorldEditMod.class.getAnnotation(Mod.class).version();
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge.selections;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.forge.WorldEditMod;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Location pt1, Location pt2) {
|
||||
this(world, pt1 == null ? null : pt1.getPosition(), pt2 == null ? null : pt2.getPosition());
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(WorldEditMod.inst.getWorld(world));
|
||||
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
this.cuboid = sel.getIncompleteRegion();
|
||||
|
||||
setRegionSelector(sel);
|
||||
setRegion(this.cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge.selections;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.forge.WorldEditMod;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, region);
|
||||
this.poly2d = region;
|
||||
}
|
||||
|
||||
public Polygonal2DSelection(World world, List points, int minY, int maxY) {
|
||||
super(world);
|
||||
LocalWorld lWorld = WorldEditMod.inst.getWorld(world);
|
||||
|
||||
minY = Math.min(Math.max(0, minY), world.getActualHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getActualHeight());
|
||||
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
this.poly2d = sel.getIncompleteRegion();
|
||||
|
||||
setRegionSelector(sel);
|
||||
setRegion(this.poly2d);
|
||||
}
|
||||
|
||||
public List getNativePoints() {
|
||||
return Collections.unmodifiableList(this.poly2d.getPoints());
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge.selections;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.forge.WorldEditMod;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
private WeakReference<World> world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = new WeakReference<World>(world);
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this(world);
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return this.region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return this.selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public Location getMinimumPoint() {
|
||||
return new Location(WorldEditMod.inst.getWorld(this.world.get()), this.region.getMinimumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return this.region.getMinimumPoint();
|
||||
}
|
||||
|
||||
public Location getMaximumPoint() {
|
||||
return new Location(WorldEditMod.inst.getWorld(this.world.get()), this.region.getMaximumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return this.region.getMaximumPoint();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return this.world.get();
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return this.region.getArea();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.region.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.region.getHeight();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.region.getLength();
|
||||
}
|
||||
|
||||
public boolean contains(Location pt) {
|
||||
if (!pt.getWorld().equals(this.world.get())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.region.contains(new Vector(pt.getPosition()));
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.forge.selections;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
|
||||
public abstract interface Selection {
|
||||
public abstract Location getMinimumPoint();
|
||||
|
||||
public abstract Vector getNativeMinimumPoint();
|
||||
|
||||
public abstract Location getMaximumPoint();
|
||||
|
||||
public abstract Vector getNativeMaximumPoint();
|
||||
|
||||
public abstract RegionSelector getRegionSelector();
|
||||
|
||||
public abstract World getWorld();
|
||||
|
||||
public abstract int getArea();
|
||||
|
||||
public abstract int getWidth();
|
||||
|
||||
public abstract int getHeight();
|
||||
|
||||
public abstract int getLength();
|
||||
|
||||
public abstract boolean contains(Location paramLocation);
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren