mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-05 04:16:06 +00:00
Merge branch 'master' into feature/mapping
This commit is contained in:
commit
a9de9f619b
@ -24,16 +24,12 @@ Contributing
|
||||
We happily accept contributions, especially through pull requests on GitHub.
|
||||
Submissions must be licensed under the GNU Lesser General Public License v3.
|
||||
|
||||
Please read CONTRIBUTING.md for important guidelines to follow.
|
||||
|
||||
We recommend following our
|
||||
[mailing list](https://groups.google.com/d/forum/sk-dev-discuss), especially if
|
||||
you have some big ideas that you want to implement.
|
||||
Please read [CONTRIBUTING.md](CONTRIBUTING.md) for important guidelines to follow.
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Mailing list](https://groups.google.com/d/forum/sk-dev-discuss)
|
||||
* [Visit our website](http://www.enginehub.org/)
|
||||
* [IRC channel](http://skq.me/irc/irc.esper.net/sk89q/) (#sk89q on irc.esper.net)
|
||||
* [Issue tracker](http://youtrack.sk89q.com/issues/WORLDEDIT)
|
||||
* [Continuous integration](http://builds.enginehub.org) [![Build Status](https://secure.travis-ci.org/sk89q/worldedit.png)](http://travis-ci.org/sk89q/worldedit)
|
||||
|
65
pom.xml
65
pom.xml
@ -666,70 +666,5 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!--
|
||||
=====================================
|
||||
Spout (BROKEN)
|
||||
=====================================
|
||||
-->
|
||||
<profile>
|
||||
<id>spout</id>
|
||||
|
||||
<repositories>
|
||||
<repository> <!-- WARNING: This breaks all the time -->
|
||||
<id>spout-repo</id>
|
||||
<url>http://nexus.spout.org/content/groups/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>spoutapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version> <!-- WARNING: This breaks all the time -->
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>vanilla</artifactId>
|
||||
<version>1.4.7-SNAPSHOT</version> <!-- WARNING: This breaks all the time -->
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>.</targetPath>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/spout/resources/</directory>
|
||||
<includes>
|
||||
<include>properties.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-spout-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${basedir}/src/spout/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -1,52 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.SessionCheck;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
/**
|
||||
* Used to remove expired sessions in Bukkit.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SessionTimer implements Runnable {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
private SessionCheck checker;
|
||||
|
||||
public SessionTimer(WorldEdit worldEdit, final Server game) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.checker = new SessionCheck() {
|
||||
public boolean isOnlinePlayer(String name) {
|
||||
Player player = game.getPlayer(name, true);
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void run() {
|
||||
worldEdit.flushExpiredSessions(checker);
|
||||
}
|
||||
|
||||
}
|
@ -1,52 +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.spout;
|
||||
|
||||
import org.spout.api.generator.biome.Biome;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class SpoutBiomeType implements com.sk89q.worldedit.BiomeType {
|
||||
private final Biome type;
|
||||
|
||||
public SpoutBiomeType(Biome type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return type.getName().toLowerCase().replace(" ", "");
|
||||
}
|
||||
|
||||
public Biome getSpoutBiome() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other instanceof SpoutBiomeType && ((SpoutBiomeType)other).type.equals(this.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 + type.hashCode();
|
||||
}
|
||||
}
|
@ -1,62 +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.spout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sk89q.worldedit.BiomeTypes;
|
||||
import com.sk89q.worldedit.UnknownBiomeTypeException;
|
||||
import org.spout.api.generator.biome.BiomeGenerator;
|
||||
import org.spout.api.generator.biome.Biome;
|
||||
|
||||
public class SpoutBiomeTypes implements BiomeTypes {
|
||||
private final Map<String, SpoutBiomeType> types = new HashMap<String, SpoutBiomeType>();
|
||||
|
||||
@Override
|
||||
public boolean has(String name) {
|
||||
return types.containsKey(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpoutBiomeType get(String name) throws UnknownBiomeTypeException {
|
||||
if (!has(name)) {
|
||||
throw new UnknownBiomeTypeException(name);
|
||||
} else {
|
||||
return types.get(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
public void registerBiomeTypes(BiomeGenerator generator) {
|
||||
for (Biome type : generator.getBiomes()) {
|
||||
final SpoutBiomeType weType = new SpoutBiomeType(type);
|
||||
if (!types.containsKey(weType.getName())) {
|
||||
types.put(weType.getName(), weType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.sk89q.worldedit.BiomeType> all() {
|
||||
return new ArrayList<com.sk89q.worldedit.BiomeType>(types.values());
|
||||
}
|
||||
}
|
@ -1,124 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.PlayerNeededException;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
public class SpoutCommandSender extends LocalPlayer {
|
||||
private CommandSource sender;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutCommandSender(WorldEditPlugin plugin, ServerInterface server, CommandSource sender) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
sender.sendRawMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
sender.sendMessage(ChatStyle.GRAY, msg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
sender.sendMessage(ChatStyle.PURPLE, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
sender.sendMessage(ChatStyle.RED, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return sender.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return sender.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
}
|
@ -1,41 +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.spout;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Subclass of {@link YAMLConfiguration} with spout-specific data folder
|
||||
*/
|
||||
public class SpoutConfiguration extends YAMLConfiguration {
|
||||
private final WorldEditPlugin plugin;
|
||||
public SpoutConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||
super(config, plugin.getLogger());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDirectory() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
}
|
@ -1,84 +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.spout;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import org.spout.api.component.Component;
|
||||
import org.spout.api.datatable.ManagedHashMap;
|
||||
import org.spout.api.entity.Entity;
|
||||
import org.spout.api.geo.LoadOption;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.math.QuaternionMath;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class SpoutEntity extends LocalEntity {
|
||||
private final byte[] datatableBytes;
|
||||
private final List<Class<? extends Component>> components;
|
||||
private final int entityId;
|
||||
|
||||
public SpoutEntity(Location position, int id, Collection<Class<? extends Component>> components, ManagedHashMap datatable) {
|
||||
super(position);
|
||||
this.components = Lists.newArrayList(components);
|
||||
this.datatableBytes = datatable.serialize();
|
||||
this.entityId = id;
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawn(Location loc) {
|
||||
World world = ((SpoutWorld) loc.getWorld()).getWorld();
|
||||
Point pos = SpoutUtil.toPoint(world, loc.getPosition());
|
||||
Class<? extends Component> mainComponent = null;
|
||||
if (components.size() > 0) {
|
||||
mainComponent = components.get(0);
|
||||
}
|
||||
if (mainComponent == null) {
|
||||
return false;
|
||||
}
|
||||
Entity e = world.createAndSpawnEntity(pos, mainComponent, LoadOption.LOAD_ONLY); // Blocks should already be pasted by time entitieos are brought in
|
||||
|
||||
if (e != null) {
|
||||
e.getScene().setRotation(QuaternionMath.rotation(loc.getPitch(), loc.getYaw(), 0));
|
||||
for (Class<? extends Component> clazz : Iterables.skip(components, 1)) {
|
||||
e.add(clazz);
|
||||
}
|
||||
try {
|
||||
e.getData().deserialize(datatableBytes, true);
|
||||
} catch (IOException e1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,160 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
|
||||
import org.spout.api.Client;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.component.impl.SceneComponent;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.api.math.QuaternionMath;
|
||||
import org.spout.api.math.Vector3;
|
||||
import org.spout.vanilla.api.inventory.Slot;
|
||||
import org.spout.vanilla.plugin.component.inventory.PlayerInventory;
|
||||
import org.spout.vanilla.plugin.component.living.neutral.Human;
|
||||
import org.spout.vanilla.api.material.VanillaMaterial;
|
||||
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||
|
||||
public class SpoutPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
if (player.has(Human.class)) {
|
||||
Slot slot = player.get(PlayerInventory.class).getQuickbar().getSelectedSlot();
|
||||
if (slot.get() == null) {
|
||||
return 0;
|
||||
}
|
||||
return ((VanillaMaterial) slot.get().getMaterial()).getMinecraftId();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
Point loc = player.getScene().getPosition();
|
||||
return new WorldVector(SpoutUtil.getLocalWorld(loc.getWorld()),
|
||||
loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
return player.getScene().getRotation().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
return player.getScene().getRotation().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
if (player.has(Human.class)) {
|
||||
player.get(PlayerInventory.class).add(new ItemStack(VanillaMaterials.getMaterial((short) type), amt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.PINK, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.GRAY, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.RED, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
SceneComponent component = player.getScene();
|
||||
player.teleport(SpoutUtil.toPoint(player.getWorld(), pos));
|
||||
component.setRotation(QuaternionMath.rotation(pitch, yaw, component.getRotation().getRoll()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return player.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
return new SpoutPlayerBlockBag(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
return SpoutUtil.getLocalWorld(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
player.getSession().send(player.getSession().getEngine() instanceof Client, new WorldEditCUIMessage(event));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
@ -1,265 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||
import com.sk89q.worldedit.extent.inventory.OutOfSpaceException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.vanilla.plugin.component.inventory.PlayerInventory;
|
||||
import org.spout.vanilla.plugin.component.living.neutral.Human;
|
||||
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||
|
||||
public class SpoutPlayerBlockBag extends BlockBag {
|
||||
/**
|
||||
* Player instance.
|
||||
*/
|
||||
private Player player;
|
||||
/**
|
||||
* The player's inventory;
|
||||
*/
|
||||
private ItemInfo items;
|
||||
|
||||
private static class ItemInfo {
|
||||
ItemStack[] inventory;
|
||||
boolean includesFullInventory;
|
||||
|
||||
public ItemInfo(ItemStack[] inventory, boolean full) {
|
||||
this.inventory = inventory;
|
||||
this.includesFullInventory = full;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public SpoutPlayerBlockBag(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads inventory on first use.
|
||||
*/
|
||||
private void loadInventory() {
|
||||
if (items == null) {
|
||||
items = getViewableItems(player);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemInfo getViewableItems(Player player) {
|
||||
boolean includesFullInventory = true;
|
||||
ItemStack[] items;
|
||||
Human human = player.get(Human.class);
|
||||
PlayerInventory inv = player.get(PlayerInventory.class);
|
||||
if (human.isCreative()) {
|
||||
includesFullInventory = false;
|
||||
items = new ItemStack[inv.getQuickbar().size()];
|
||||
} else {
|
||||
items = new ItemStack[inv.getQuickbar().size() + inv.getMain().size()];
|
||||
}
|
||||
int index = 0;
|
||||
for (; index < inv.getQuickbar().size(); ++index) {
|
||||
items[index] = inv.getQuickbar().get(index);
|
||||
}
|
||||
|
||||
if (!human.isCreative()) {
|
||||
for (int i = 0; i < inv.getMain().size() && index < items.length; ++i) {
|
||||
items[index++] = inv.getMain().get(i);
|
||||
}
|
||||
}
|
||||
return new ItemInfo(items, includesFullInventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short)item.getType();
|
||||
final short damage = item.getData();
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount == 1);
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't fetch air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAmount > 1) {
|
||||
spoutItem.setAmount(currentAmount - 1);
|
||||
found = true;
|
||||
} else {
|
||||
items.inventory[slot] = null;
|
||||
found = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new OutOfBlocksException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short) item.getType();
|
||||
final short damage = item.getData();
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount <= mat.getMaxStackSize());
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't store air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
int freeSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
// Delay using up a free slot until we know there are no stacks
|
||||
// of this item to merge into
|
||||
|
||||
if (freeSlot == -1) {
|
||||
freeSlot = slot;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
if (currentAmount >= mat.getMaxStackSize()) {
|
||||
// Full stack
|
||||
continue;
|
||||
}
|
||||
|
||||
int spaceLeft = mat.getMaxStackSize() - currentAmount;
|
||||
if (spaceLeft >= amount) {
|
||||
spoutItem.setAmount(currentAmount + amount);
|
||||
return;
|
||||
}
|
||||
|
||||
spoutItem.setAmount(mat.getMaxStackSize());
|
||||
amount -= spaceLeft;
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items.inventory[freeSlot] = new ItemStack(mat, amount);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new OutOfSpaceException(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@Override
|
||||
public void flushChanges() {
|
||||
if (items != null) {
|
||||
PlayerInventory inv = player.get(PlayerInventory.class);
|
||||
for (int i = 0; i < inv.getQuickbar().size(); i++) {
|
||||
inv.getQuickbar().set(i, items.inventory[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < inv.getMain().size(); ++i) {
|
||||
inv.getMain().set(i, items.inventory[inv.getQuickbar().size() + i]);
|
||||
}
|
||||
items = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSourcePosition(WorldVector pos) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSingleSourcePosition(WorldVector pos) {
|
||||
}
|
||||
}
|
@ -1,53 +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.spout;
|
||||
|
||||
import org.spout.api.chat.ChatSection;
|
||||
import org.spout.api.command.Command;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.command.RawCommandExecutor;
|
||||
import org.spout.api.exception.CommandException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class SpoutRawCommandExecutor implements RawCommandExecutor {
|
||||
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public SpoutRawCommandExecutor(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Command cmd, CommandSource source, String name, List<ChatSection> args, int baseIndex, boolean fuzzyLookup) throws CommandException {
|
||||
String[] argArray = new String[args.size() - baseIndex + 1];
|
||||
argArray[0] = "/" + cmd.getPreferredName();
|
||||
for (int i = baseIndex; i < args.size(); ++i) {
|
||||
argArray[i - baseIndex + 1] = args.get(i).getPlainString();
|
||||
}
|
||||
|
||||
if (!plugin.getWorldEdit().handleCommand(plugin.wrapCommandSender(source), argArray)) {
|
||||
throw new CommandException("Unknown command: '/" + name + "'!");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,111 +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.spout;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.material.MaterialRegistry;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
import org.spout.vanilla.api.material.VanillaMaterial;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutServerInterface extends ServerInterface {
|
||||
public Engine game;
|
||||
public WorldEditPlugin plugin;
|
||||
private final SpoutRawCommandExecutor executor;
|
||||
private SpoutBiomeTypes biomes;
|
||||
|
||||
public SpoutServerInterface(WorldEditPlugin plugin, Engine game) {
|
||||
this.plugin = plugin;
|
||||
this.game = game;
|
||||
this.biomes = new SpoutBiomeTypes();
|
||||
this.executor = new SpoutRawCommandExecutor(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolveItem(String name) {
|
||||
Material mat = MaterialRegistry.get(name);
|
||||
return mat == null || !(mat instanceof VanillaMaterial) ? 0 : ((VanillaMaterial) mat).getMinecraftId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return false;
|
||||
//return CreatureType.fromName(type) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
plugin.loadConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpoutBiomeTypes getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return game.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay * 50, period * 50, TaskPriority.NORMAL).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalWorld> getWorlds() {
|
||||
Collection<World> worlds = game.getWorlds();
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
ret.add(SpoutUtil.getLocalWorld(world));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||
for (Command command : commands) {
|
||||
org.spout.api.command.Command spoutCommand = game.getRootCommand().addSubCommand(plugin, command.aliases()[0])
|
||||
.addAlias(command.aliases()).setRawExecutor(executor)
|
||||
.setHelp("/" + command.aliases()[0] + " " + command.usage() + " - " + command.desc());
|
||||
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
}
|
||||
spoutCommand.closeSubCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalConfiguration getConfiguration() {
|
||||
return plugin.getLocalConfiguration();
|
||||
}
|
||||
}
|
@ -1,114 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Entity;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.cuboid.Block;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.material.block.BlockFace;
|
||||
import org.spout.api.math.GenericMath;
|
||||
import org.spout.api.math.Vector3;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpoutUtil {
|
||||
private SpoutUtil() {
|
||||
}
|
||||
|
||||
private static final Map<World, LocalWorld> wlw = new HashMap<World, LocalWorld>();
|
||||
|
||||
public static LocalWorld getLocalWorld(World w) {
|
||||
LocalWorld lw = wlw.get(w);
|
||||
if (lw == null) {
|
||||
lw = new SpoutWorld(w);
|
||||
wlw.put(w, lw);
|
||||
}
|
||||
return lw;
|
||||
}
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return toBlockVector(face.getOffset());
|
||||
}
|
||||
|
||||
public static BlockVector toBlockVector(Vector3 vector) {
|
||||
return new BlockVector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static BlockWorldVector toWorldVector(Block block) {
|
||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(Point loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(org.spout.api.math.Vector3 vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(WorldVector pt) {
|
||||
return new Point(toWorld(pt), (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(World world, Vector pt) {
|
||||
return new Point(world, (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point center(Point loc) {
|
||||
return new Point(
|
||||
loc.getWorld(),
|
||||
GenericMath.floor(loc.getX()) + 0.5F,
|
||||
GenericMath.floor(loc.getY()) + 0.5F,
|
||||
GenericMath.floor(loc.getZ()) + 0.5F
|
||||
);
|
||||
}
|
||||
|
||||
public static Player matchSinglePlayer(Engine game, String name) {
|
||||
return game instanceof Server ? ((Server) game).getPlayer(name, false) : null;
|
||||
}
|
||||
|
||||
public static Block toBlock(BlockWorldVector pt) {
|
||||
return toWorld(pt).getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
}
|
||||
|
||||
public static World toWorld(WorldVector pt) {
|
||||
return ((SpoutWorld) pt.getWorld()).getWorld();
|
||||
}
|
||||
|
||||
public static Location toLocation(Entity ent) {
|
||||
return new Location(getLocalWorld(ent.getWorld()), toVector(ent.getScene().getPosition()),
|
||||
ent.getScene().getRotation().getYaw(), ent.getScene().getRotation().getPitch());
|
||||
}
|
||||
}
|
@ -1,828 +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.spout;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EntityType;
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
import org.spout.api.component.Component;
|
||||
import org.spout.api.entity.Entity;
|
||||
import org.spout.api.generator.biome.BiomeGenerator;
|
||||
import org.spout.api.geo.LoadOption;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.cuboid.Chunk;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.BlockMaterial;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.vanilla.plugin.component.substance.Painting;
|
||||
import org.spout.vanilla.plugin.component.substance.XPOrb;
|
||||
import org.spout.vanilla.plugin.component.substance.object.Item;
|
||||
import org.spout.vanilla.plugin.component.substance.object.Tnt;
|
||||
import org.spout.vanilla.plugin.component.substance.object.projectile.Arrow;
|
||||
import org.spout.vanilla.plugin.component.substance.object.vehicle.Boat;
|
||||
import org.spout.vanilla.api.material.VanillaMaterial;
|
||||
import org.spout.vanilla.plugin.component.substance.object.vehicle.minecart.Minecart;
|
||||
import org.spout.vanilla.plugin.material.VanillaMaterials;
|
||||
import org.spout.vanilla.plugin.world.generator.normal.object.tree.TreeObject;
|
||||
import org.spout.vanilla.plugin.world.generator.normal.object.tree.SmallTreeObject;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutWorld extends LocalWorld {
|
||||
private World world;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
* @param world
|
||||
*/
|
||||
public SpoutWorld(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the world handle.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the world
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return world.getName();
|
||||
}
|
||||
|
||||
public Material getSpoutMaterial(int id) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return BlockMaterial.AIR;
|
||||
default:
|
||||
return VanillaMaterials.getMaterial((short) id);
|
||||
}
|
||||
}
|
||||
|
||||
public Material getSpoutMaterial(int id, int data) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return BlockMaterial.AIR;
|
||||
default:
|
||||
return VanillaMaterials.getMaterial((short) id, (short) data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block type.
|
||||
*
|
||||
* @param pt
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean setBlockType(Vector pt, int type) {
|
||||
Material mat = getSpoutMaterial(type);
|
||||
if (mat != null && mat instanceof BlockMaterial) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) 0, WorldEditPlugin.asCause());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block type.
|
||||
*
|
||||
* @param pt
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean setBlockTypeFast(Vector pt, int type) {
|
||||
return setBlockType(pt, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* set block type & data
|
||||
* @param pt
|
||||
* @param type
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean setTypeIdAndData(Vector pt, int type, int data) {
|
||||
Material mat = getSpoutMaterial(type, data);
|
||||
if (mat != null && mat instanceof BlockMaterial) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockMaterial(x, y, z, (BlockMaterial) mat, (short) data, WorldEditPlugin.asCause());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* set block type & data
|
||||
* Everything is threaded, so no need for fastmode here.
|
||||
* @param pt
|
||||
* @param type
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean setTypeIdAndDataFast(Vector pt, int type, int data) {
|
||||
return setTypeIdAndData(pt, type, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block type.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getBlockType(Vector pt) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
Material mat = world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).getBlockMaterial(x, y, z);
|
||||
return mat instanceof VanillaMaterial ? ((VanillaMaterial) mat).getMinecraftId() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block data.
|
||||
*
|
||||
* @param pt
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setBlockData(Vector pt, int data) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).setBlockData(x, y, z, (short) data, WorldEditPlugin.asCause());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set block data.
|
||||
*
|
||||
* @param pt
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setBlockDataFast(Vector pt, int data) {
|
||||
setBlockData(pt, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block data.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getBlockData(Vector pt) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).getBlockData(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block light level.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int getBlockLightLevel(Vector pt) {
|
||||
final int x = pt.getBlockX();
|
||||
final int y = pt.getBlockY();
|
||||
final int z = pt.getBlockZ();
|
||||
return world.getChunkFromBlock(x, y, z, LoadOption.LOAD_GEN).getBlockLight(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get biome type
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public BiomeType getBiome(Vector2D pt) {
|
||||
if (world.getGenerator() instanceof BiomeGenerator) {
|
||||
BiomeGenerator gen = (BiomeGenerator) world.getGenerator();
|
||||
return new SpoutBiomeType(gen.getBiome(pt.getBlockX(), pt.getBlockZ(), world.getSeed()));
|
||||
}
|
||||
return BiomeType.UNKNOWN;
|
||||
}
|
||||
|
||||
public void setBiome(Vector2D pt, BiomeType biome) {
|
||||
if (biome instanceof SpoutBiomeType &&
|
||||
world.getGenerator() instanceof BiomeGenerator) {
|
||||
throw new UnsupportedOperationException("Biome changing is not yet supported in Spout");
|
||||
//BiomeGenerator gen = (BiomeGenerator) world.getGenerator();
|
||||
//gen.setBiome(new Vector3(pt.getBlockX(), 0, pt.getBlockZ()), ((SpoutBiomeType) biome).getSpoutBiome());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate an area.
|
||||
*
|
||||
* @param region
|
||||
* @param editSession
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
/*BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
||||
|
||||
for (Vector2D chunk : region.getChunks()) {
|
||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||
|
||||
// First save all the blocks inside
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
Vector pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
history[index] = editSession.getBlock(pt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
world.regenerateChunk(chunk.getBlockX(), chunk.getBlockZ());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
// Then restore
|
||||
for (int x = 0; x < 16; ++x) {
|
||||
for (int y = 0; y < (getMaxY() + 1); ++y) {
|
||||
for (int z = 0; z < 16; ++z) {
|
||||
Vector pt = min.add(x, y, z);
|
||||
int index = y * 16 * 16 + z * 16 + x;
|
||||
|
||||
// We have to restore the block if it was outside
|
||||
if (!region.contains(pt)) {
|
||||
editSession.smartSetBlock(pt, history[index]);
|
||||
} else { // Otherwise fool with history
|
||||
editSession.rememberChange(pt, history[index],
|
||||
editSession.rawGetBlock(pt));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;*/
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to accurately copy a BaseBlock's extra data to the world.
|
||||
*
|
||||
* @param pt
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean copyToWorld(Vector pt, BaseBlock block) {
|
||||
/*if (block instanceof SignBlock) {
|
||||
// Signs
|
||||
setSignText(pt, ((SignBlock) block).getText());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof FurnaceBlock) {
|
||||
// Furnaces
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof Furnace)) return false;
|
||||
Furnace bukkit = (Furnace) state;
|
||||
FurnaceBlock we = (FurnaceBlock) block;
|
||||
bukkit.setBurnTime(we.getBurnTime());
|
||||
bukkit.setCookTime(we.getCookTime());
|
||||
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
|
||||
}
|
||||
|
||||
if (block instanceof ContainerBlock) {
|
||||
// Chests/dispenser
|
||||
return setContainerBlockContents(pt, ((ContainerBlock) block).getItems());
|
||||
}
|
||||
|
||||
if (block instanceof MobSpawnerBlock) {
|
||||
// Mob spawners
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof CreatureSpawner)) return false;
|
||||
CreatureSpawner bukkit = (CreatureSpawner) state;
|
||||
MobSpawnerBlock we = (MobSpawnerBlock) block;
|
||||
bukkit.setCreatureTypeId(we.getMobType());
|
||||
bukkit.setDelay(we.getDelay());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof NoteBlock) {
|
||||
// Note block
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
|
||||
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
|
||||
NoteBlock we = (NoteBlock) block;
|
||||
bukkit.setRawNote(we.getNote());
|
||||
return true;
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to read a BaseBlock's extra data from the world.
|
||||
*
|
||||
* @param pt
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean copyFromWorld(Vector pt, BaseBlock block) {
|
||||
/*if (block instanceof SignBlock) {
|
||||
// Signs
|
||||
((SignBlock) block).setText(getSignText(pt));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof FurnaceBlock) {
|
||||
// Furnaces
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof Furnace)) return false;
|
||||
Furnace bukkit = (Furnace) state;
|
||||
FurnaceBlock we = (FurnaceBlock) block;
|
||||
we.setBurnTime(bukkit.getBurnTime());
|
||||
we.setCookTime(bukkit.getCookTime());
|
||||
((ContainerBlock) block).setItems(getContainerBlockContents(pt));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof ContainerBlock) {
|
||||
// Chests/dispenser
|
||||
((ContainerBlock) block).setItems(getContainerBlockContents(pt));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof MobSpawnerBlock) {
|
||||
// Mob spawners
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof CreatureSpawner)) return false;
|
||||
CreatureSpawner bukkit = (CreatureSpawner) state;
|
||||
MobSpawnerBlock we = (MobSpawnerBlock) block;
|
||||
we.setMobType(bukkit.getCreatureTypeId());
|
||||
we.setDelay((short) bukkit.getDelay());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (block instanceof NoteBlock) {
|
||||
// Note block
|
||||
Block bukkitBlock = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (bukkitBlock == null) return false;
|
||||
BlockState state = bukkitBlock.getState();
|
||||
if (!(state instanceof org.bukkit.block.NoteBlock)) return false;
|
||||
org.bukkit.block.NoteBlock bukkit = (org.bukkit.block.NoteBlock) state;
|
||||
NoteBlock we = (NoteBlock) block;
|
||||
we.setNote(bukkit.getRawNote());
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear a chest's contents.
|
||||
*
|
||||
* @param pt
|
||||
*/
|
||||
@Override
|
||||
public boolean clearContainerBlockContents(Vector pt) {
|
||||
/* Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof org.bukkit.block.ContainerBlock)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
inven.clear();
|
||||
return true;*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
||||
throws MaxChangedBlocksException {
|
||||
//VanillaObjects.byName()
|
||||
TreeObject tree = new SmallTreeObject(); //TODO: properly check for tree type
|
||||
if (!tree.canPlaceObject(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ())) {
|
||||
return false;
|
||||
}
|
||||
tree.placeObject(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop an item.
|
||||
*
|
||||
* @param pt
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void dropItem(Vector pt, BaseItemStack item) {
|
||||
Material mat = VanillaMaterials.getMaterial((short) item.getType());
|
||||
if (mat.hasSubMaterials()) {
|
||||
mat = mat.getSubMaterial(item.getData());
|
||||
}
|
||||
ItemStack spoutItem = new ItemStack(mat, item.getData(), item.getAmount());
|
||||
world.createEntity(SpoutUtil.toPoint(world, pt), Item.class).get(Item.class).setItemStack(spoutItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kill mobs in an area.
|
||||
*
|
||||
* @param origin The center of the area to kill mobs in.
|
||||
* @param radius Maximum distance to kill mobs at; radius < 0 means kill all mobs
|
||||
* @param flags various flags that determine what to kill
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int killMobs(Vector origin, double radius, int flags) {
|
||||
/*boolean killPets = (flags & KillFlags.PETS) != 0;
|
||||
boolean killNPCs = (flags & KillFlags.NPCS) != 0;
|
||||
boolean killAnimals = (flags & KillFlags.ANIMALS) != 0;*/
|
||||
|
||||
int num = 0;
|
||||
/*double radiusSq = radius * radius;
|
||||
|
||||
Point bukkitOrigin = SpoutUtil.toPoint(world, origin);
|
||||
|
||||
|
||||
for (LivingEntity ent : world.getLivingEntities()) {
|
||||
if (ent instanceof HumanEntity) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!killAnimals && ent instanceof Animals) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!killPets && ent instanceof Tameable && ((Tameable) ent).isTamed()) {
|
||||
continue; // tamed wolf
|
||||
}
|
||||
|
||||
try {
|
||||
// Temporary solution until org.bukkit.entity.NPC is widely deployed.
|
||||
if (!killNPCs && Class.forName("org.bukkit.entity.NPC").isAssignableFrom(ent.getClass())) {
|
||||
continue;
|
||||
}
|
||||
} catch (ClassNotFoundException e) {}
|
||||
|
||||
if (radius < 0 || bukkitOrigin.distanceSquared(ent.getLocation()) <= radiusSq) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
}*/
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove entities in an area.
|
||||
*
|
||||
* @param origin
|
||||
* @param radius
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int removeEntities(EntityType type, Vector origin, int radius) {
|
||||
int num = 0;
|
||||
double radiusSq = radius * radius;
|
||||
|
||||
for (Entity ent : world.getAll()) {
|
||||
if (radius != -1
|
||||
&& origin.distanceSq(SpoutUtil.toVector(ent.getScene().getPosition())) > radiusSq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == EntityType.ARROWS) {
|
||||
if (ent.has(Arrow.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.BOATS) {
|
||||
if (ent.has(Boat.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.ITEMS) {
|
||||
if (ent.has(Item.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.MINECARTS) {
|
||||
if (ent.has(Minecart.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.PAINTINGS) {
|
||||
if (ent.has(Painting.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.TNT) {
|
||||
if (ent.has(Tnt.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
} else if (type == EntityType.XP_ORBS) {
|
||||
if (ent.has(XPOrb.class)) {
|
||||
ent.remove();
|
||||
++num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a sign's text.
|
||||
*
|
||||
* @param pt
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
/*private boolean setSignText(Vector pt, String[] text) {
|
||||
Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) return false;
|
||||
BlockState state = block.getState();
|
||||
if (state == null || !(state instanceof Sign)) return false;
|
||||
Sign sign = (Sign) state;
|
||||
sign.setLine(0, text[0]);
|
||||
sign.setLine(1, text[1]);
|
||||
sign.setLine(2, text[2]);
|
||||
sign.setLine(3, text[3]);
|
||||
sign.update();
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get a sign's text.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
/*private String[] getSignText(Vector pt) {
|
||||
Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) return new String[] { "", "", "", "" };
|
||||
BlockState state = block.getState();
|
||||
if (state == null || !(state instanceof Sign)) return new String[] { "", "", "", "" };
|
||||
Sign sign = (Sign) state;
|
||||
String line0 = sign.getLine(0);
|
||||
String line1 = sign.getLine(1);
|
||||
String line2 = sign.getLine(2);
|
||||
String line3 = sign.getLine(3);
|
||||
return new String[] {
|
||||
line0 != null ? line0 : "",
|
||||
line1 != null ? line1 : "",
|
||||
line2 != null ? line2 : "",
|
||||
line3 != null ? line3 : "",
|
||||
};
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get a container block's contents.
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
/*private BaseItemStack[] getContainerBlockContents(Vector pt) {
|
||||
Block block = world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) {
|
||||
return new BaseItemStack[0];
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof org.bukkit.block.ContainerBlock)) {
|
||||
return new BaseItemStack[0];
|
||||
}
|
||||
|
||||
org.bukkit.block.ContainerBlock container = (org.bukkit.block.ContainerBlock) state;
|
||||
Inventory inven = container.getInventory();
|
||||
int size = inven.getContents().length
|
||||
BaseItemStack[] contents = new BaseItemStack[size];
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
ItemStack bukkitStack = inven.getItem(i);
|
||||
if (bukkitStack.getMaterial() != MaterialData.air) {
|
||||
contents[i] = new BaseItemStack(
|
||||
bukkitStack.getMaterial().getRawId(),
|
||||
bukkitStack.getAmount(),
|
||||
bukkitStack.getDamage());
|
||||
try {
|
||||
for (Map.Entry<Enchantment, Integer> entry : bukkitStack.getEnchantments().entrySet()) {
|
||||
contents[i].getEnchantments().put(entry.getKey().getId(), entry.getValue());
|
||||
}
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
}
|
||||
|
||||
return contents;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Set a container block's contents.
|
||||
*
|
||||
* @param pt
|
||||
* @param contents
|
||||
* @return
|
||||
*/
|
||||
/*private boolean setContainerBlockContents(Vector pt, BaseItemStack[] contents) {
|
||||
Block block = world.getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
BlockState state = block.getState();
|
||||
if (!(state instanceof org.bukkit.block.ContainerBlock)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
org.bukkit.block.ContainerBlock chest = (org.bukkit.block.ContainerBlock) state;
|
||||
Inventory inven = chest.getInventory();
|
||||
int size = inven.getSize();
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
if (i >= contents.length) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (contents[i] != null) {
|
||||
ItemStack toAdd = new ItemStack(contents[i].getType(),
|
||||
contents[i].getAmount(),
|
||||
(byte) contents[i].getDamage());
|
||||
try {
|
||||
for (Map.Entry<Integer, Integer> entry : contents[i].getEnchantments().entrySet()) {
|
||||
toAdd.addEnchantment(Enchantment.getById(entry.getKey()), entry.getValue());
|
||||
}
|
||||
} catch (Throwable ignore) {}
|
||||
inven.setItem(i, toAdd);
|
||||
} else {
|
||||
inven.setItem(i, null);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns whether a block has a valid ID.
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isValidBlockType(int type) {
|
||||
return getSpoutMaterial(type) instanceof BlockMaterial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkLoadedChunk(Vector pt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof SpoutWorld)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((SpoutWorld) other).world.equals(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return world.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return world.getHeight() - 1; //TODO: We have infinite-height worlds now
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
|
||||
/*for (BlockVector2D chunkPos : chunks) {
|
||||
world.refreshChunk(chunkPos.getBlockX(), chunkPos.getBlockZ());
|
||||
}*/
|
||||
}
|
||||
|
||||
/*private static final Map<Integer, Effect> effects = new HashMap<Integer, Effect>();
|
||||
static {
|
||||
for (Effect effect : Effect.values()) {
|
||||
effects.put(effect.getId(), effect);
|
||||
}
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean playEffect(Vector position, int type, int data) {
|
||||
/*final Effect effect = effects.get(type);
|
||||
if (effect == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
world.playEffect(SpoutUtil.toLocation(world, position), effect, data);
|
||||
|
||||
return true;
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpoutEntity[] getEntities(Region region) {
|
||||
List<SpoutEntity> entities = new ArrayList<SpoutEntity>();
|
||||
for (Vector pt : region.getChunkCubes()) {
|
||||
Chunk chunk = world.getChunkFromBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), LoadOption.LOAD_GEN);
|
||||
if (chunk == null) {
|
||||
continue;
|
||||
}
|
||||
for (Entity ent : chunk.getEntities()) {
|
||||
if (region.contains(SpoutUtil.toVector(ent.getScene().getPosition()))) {
|
||||
Collection<Class<? extends Component>> revisedComponents = Collections2.transform(ent.values(), new Function<Component, Class<? extends Component>>() {
|
||||
@Override
|
||||
public Class<? extends Component> apply(@Nullable Component component) {
|
||||
return component == null ? null : component.getClass();
|
||||
}
|
||||
});
|
||||
entities.add(new SpoutEntity(SpoutUtil.toLocation(ent), ent.getId(), revisedComponents, ent.getData().getBaseMap())); // TODO:; Fix entity adding
|
||||
}
|
||||
}
|
||||
}
|
||||
return entities.toArray(new SpoutEntity[entities.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int killEntities(LocalEntity... entities) {
|
||||
int amount = 0;
|
||||
for (LocalEntity weEnt : entities) {
|
||||
SpoutEntity entity = (SpoutEntity) weEnt;
|
||||
Entity spoutEntity = world.getEntity(entity.getEntityId());
|
||||
if (spoutEntity != null) {
|
||||
spoutEntity.remove();
|
||||
++amount;
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
}
|
@ -1,60 +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.spout;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
import org.spout.api.protocol.MessageCodec;
|
||||
import org.spout.api.util.Named;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class WorldEditCUICodec extends MessageCodec<WorldEditCUIMessage> implements Named {
|
||||
public static final Charset UTF_8_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
public WorldEditCUICodec(int opcode) {
|
||||
super(WorldEditCUIMessage.class, opcode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChannelBuffer encode(WorldEditCUIMessage message) {
|
||||
byte[] data = message.getMessage().getBytes(UTF_8_CHARSET);
|
||||
|
||||
ChannelBuffer buffer = ChannelBuffers.buffer(data.length);
|
||||
buffer.writeBytes(data);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldEditCUIMessage decode(ChannelBuffer buffer) {
|
||||
byte[] data = new byte[buffer.readableBytes()];
|
||||
buffer.readBytes(data);
|
||||
String message = new String(data, UTF_8_CHARSET);
|
||||
return new WorldEditCUIMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "WECUI";
|
||||
}
|
||||
}
|
@ -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.spout;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.spout.api.protocol.Message;
|
||||
import org.spout.api.util.SpoutToStringStyle;
|
||||
|
||||
public class WorldEditCUIMessage implements Message {
|
||||
private final String message;
|
||||
|
||||
public WorldEditCUIMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public WorldEditCUIMessage(CUIEvent event) {
|
||||
String[] params = event.getParameters();
|
||||
if (params.length > 0) {
|
||||
this.message = event.getTypeId() + '|' + StringUtil.joinString(event.getParameters(), "|");
|
||||
} else {
|
||||
this.message = event.getTypeId();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, SpoutToStringStyle.INSTANCE)
|
||||
.append("message", message)
|
||||
.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsync() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChannelId() {
|
||||
return DEFAULT_CHANNEL;
|
||||
}
|
||||
}
|
@ -1,45 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import org.spout.api.protocol.MessageHandler;
|
||||
import org.spout.api.protocol.Session;
|
||||
|
||||
/**
|
||||
* MessageHandler for WorldEditCUIMessage
|
||||
*/
|
||||
public class WorldEditCUIMessageHandler extends MessageHandler<WorldEditCUIMessage> {
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public WorldEditCUIMessageHandler(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServer(Session session, WorldEditCUIMessage message) {
|
||||
LocalSession localSession = plugin.getSession(session.getPlayer());
|
||||
if (localSession.hasCUISupport()) { // Already initialized
|
||||
return;
|
||||
}
|
||||
|
||||
localSession.handleCUIInitializationMessage(message.getMessage());
|
||||
}
|
||||
}
|
@ -1,174 +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.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Spout;
|
||||
import org.spout.api.chat.ChatArguments;
|
||||
import org.spout.api.chat.ChatSection;
|
||||
import org.spout.api.event.EventHandler;
|
||||
import org.spout.api.event.Listener;
|
||||
import org.spout.api.event.Order;
|
||||
import org.spout.api.event.player.PlayerInteractEvent;
|
||||
import org.spout.api.event.player.PlayerInteractEvent.Action;
|
||||
import org.spout.api.event.player.PlayerLeaveEvent;
|
||||
import org.spout.api.event.server.PreCommandEvent;
|
||||
import org.spout.api.event.world.WorldLoadEvent;
|
||||
import org.spout.api.generator.biome.BiomeGenerator;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player leaves a server
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerLeaveEvent event) {
|
||||
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player attempts to use a command
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(order = Order.EARLY)
|
||||
public void onPlayerCommandPreprocess(PreCommandEvent event) {
|
||||
|
||||
if (event.getCommand().startsWith("nowe:")) {
|
||||
event.setCommand(event.getCommand().substring(5));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ChatSection> args = event.getArguments().toSections(ChatSection.SplitType.WORD);
|
||||
if (args.size() > 0) {
|
||||
String[] split = new String[args.size() + 1];
|
||||
split[0] = "/" + event.getCommand();
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
split[i + 1] = args.get(i).getPlainString();
|
||||
}
|
||||
|
||||
String[] newSplit = plugin.getWorldEdit().commandDetection(split);
|
||||
if (!Arrays.equals(split, newSplit)) {
|
||||
event.setCommand(newSplit[0]);
|
||||
ChatArguments newArgs = new ChatArguments();
|
||||
for (int i = 1; i < newSplit.length; ++i) {
|
||||
newArgs.append(newSplit[i]);
|
||||
}
|
||||
event.setArguments(newArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
|
||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
final LocalWorld world = player.getWorld();
|
||||
final WorldEdit we = plugin.getWorldEdit();
|
||||
|
||||
PlayerInteractEvent.Action action = event.getAction();
|
||||
if (action == Action.LEFT_CLICK) {
|
||||
if (event.isAir() && ignoreLeftClickAir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.isAir() && !ignoreLeftClickAir) {
|
||||
final int taskId = Spout.getEngine().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}
|
||||
}, 100, TaskPriority.NORMAL).getTaskId();
|
||||
|
||||
if (taskId != -1) {
|
||||
ignoreLeftClickAir = true;
|
||||
}
|
||||
}
|
||||
} else if (action == Action.RIGHT_CLICK) {
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
if (event.getWorld().getGenerator() instanceof BiomeGenerator) {
|
||||
plugin.getServerInterface().getBiomes().registerBiomeTypes((BiomeGenerator) event.getWorld().getGenerator());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,372 +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.spout;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.extension.platform.PlatformRejectionException;
|
||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Selection;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.event.Cause;
|
||||
import org.spout.api.event.cause.PluginCause;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.api.plugin.CommonPlugin;
|
||||
import org.spout.api.plugin.Plugin;
|
||||
import org.spout.api.protocol.Protocol;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* Plugin for Spout.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldEditPlugin extends CommonPlugin {
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
private SpoutServerInterface server;
|
||||
/**
|
||||
* Main WorldEdit instance.
|
||||
*/
|
||||
private WorldEdit controller;
|
||||
|
||||
/**
|
||||
* Holds the configuration for WorldEdit.
|
||||
*/
|
||||
private YAMLConfiguration config;
|
||||
|
||||
private static WorldEditPlugin instance;
|
||||
private static PluginCause instanceCause;
|
||||
{
|
||||
instance = this;
|
||||
instanceCause = new PluginCause(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
public void onEnable() {
|
||||
final String pluginYmlVersion = getDescription().getVersion();
|
||||
final String manifestVersion = WorldEdit.getVersion();
|
||||
|
||||
getLogger().info("WorldEdit " + pluginYmlVersion + " enabled.");
|
||||
if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
|
||||
}
|
||||
|
||||
// Make the data folders that WorldEdit uses
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
// Create the default configuration file
|
||||
createDefaultConfiguration("config.yml");
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new SpoutConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
|
||||
// Load the configuration
|
||||
loadConfiguration();
|
||||
|
||||
// Setup interfaces
|
||||
server = new SpoutServerInterface(this, getEngine());
|
||||
controller = WorldEdit.getInstance();
|
||||
try {
|
||||
controller.getPlatformManager().register(server);
|
||||
} catch (PlatformRejectionException e) {
|
||||
throw new RuntimeException("Failed to register with WorldEdit", e);
|
||||
}
|
||||
|
||||
// Now we can register events!
|
||||
registerEvents();
|
||||
|
||||
for (Protocol proto : Protocol.getProtocols()) {
|
||||
proto.registerPacket(WorldEditCUICodec.class, new WorldEditCUIMessageHandler(this));
|
||||
}
|
||||
|
||||
getEngine().getScheduler().scheduleSyncRepeatingTask(this,
|
||||
new SessionTimer(controller, getServer()), 6 * 1000, 6 * 1000, TaskPriority.LOWEST);
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
if (!(getEngine() instanceof Server)) {
|
||||
throw new IllegalStateException("WorldEdit must be running on a server for this operation!");
|
||||
}
|
||||
|
||||
return (Server) getEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
public void onDisable() {
|
||||
controller.clearSessions();
|
||||
config.unload();
|
||||
getEngine().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
protected void loadConfiguration() {
|
||||
config.unload();
|
||||
config.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the events used by WorldEdit.
|
||||
*/
|
||||
protected void registerEvents() {
|
||||
getEngine().getEventManager().registerEvents(new WorldEditListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected void createDefaultConfiguration(String name) {
|
||||
File actual = new File(getDataFolder(), name);
|
||||
if (!actual.exists()) {
|
||||
InputStream input =
|
||||
null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + name);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} catch (IOException e) {
|
||||
getLogger().severe("Unable to read default configuration: " + name);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException ignore) {}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public EditSession createEditSession(Player player) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||
.getEditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag, wePlayer);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
* @param player
|
||||
* @param editSession
|
||||
*/
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
|
||||
controller.flushBlockBag(wePlayer, editSession);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an operation into an EditSession.
|
||||
*
|
||||
* @param player
|
||||
* @param op
|
||||
* @throws Throwable
|
||||
*/
|
||||
public void perform(Player player, WorldEditOperation op)
|
||||
throws Throwable {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
EditSession editSession = createEditSession(player);
|
||||
try {
|
||||
op.run(session, wePlayer, editSession);
|
||||
} finally {
|
||||
remember(player, editSession);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration used by WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public YAMLConfiguration getLocalConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public SpoutPlayer wrapPlayer(Player player) {
|
||||
return new SpoutPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
public LocalPlayer wrapCommandSender(CommandSource sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
||||
return new SpoutCommandSender(this, this.server, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SpoutServerInterface getServerInterface() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WorldEdit getWorldEdit() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return the selection or null if there was none
|
||||
*/
|
||||
public Selection getSelection(Player player) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()));
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = ((SpoutWorld) session.getSelectionWorld()).getWorld();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
* @param player
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelection(Player player, Selection selection) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
}
|
||||
|
||||
static WorldEditPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
static Cause<Plugin> asCause() {
|
||||
return instanceCause;
|
||||
}
|
||||
}
|
@ -1,69 +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.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Point pt1, Point pt2) {
|
||||
this(world, SpoutUtil.toVector(pt1), SpoutUtil.toVector(pt2));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
// Validate input
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
// Create new selector
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(SpoutUtil.getLocalWorld(world));
|
||||
|
||||
// set up selector
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
// set up CuboidSelection
|
||||
cuboid = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
@ -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.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
LocalWorld lWorld = SpoutUtil.getLocalWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
// set up CuboidSelection
|
||||
poly2d = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
}
|
@ -1,105 +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.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public Point getMinimumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMinimumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
public Point getMaximumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMaximumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return region.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return region.getHeight();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return region.getLength();
|
||||
}
|
||||
|
||||
public boolean contains(Point pt) {
|
||||
if (!pt.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return region.contains(SpoutUtil.toVector(pt));
|
||||
}
|
||||
|
||||
}
|
@ -1,105 +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.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public interface Selection {
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Point getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Point getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(Point pt);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
name: WorldEdit
|
||||
main: com.sk89q.worldedit.spout.WorldEditPlugin
|
||||
version: ${project.version}
|
||||
platform: BOTH
|
||||
|
||||
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
||||
# for how WorldEdit permissions actually work.
|
Loading…
Reference in New Issue
Block a user