geforkt von Mirrors/FastAsyncWorldEdit
Merge remote-tracking branch 'refs/remotes/sk89q/master'
Dieser Commit ist enthalten in:
Commit
d4bcc1914a
16
README.md
16
README.md
@ -1,17 +1,15 @@
|
|||||||
![WorldEdit](http://static.sk89q.com/readme/worldedit.png)
|
![WorldEdit](http://static.sk89q.com/readme/worldedit.png)
|
||||||
=========
|
=========
|
||||||
|
|
||||||
WorldEdit is an easy-to-use in-game world editor for Minecraft, supporting both
|
WorldEdit is Minecraft mod that turns Minecraft into an in-game map editor (sorta, kinda).
|
||||||
single player and multiplayer, that lets you:
|
|
||||||
|
|
||||||
* Change thousands of blocks in an area at once by selecting regions.
|
* Make awesome stuff with half the time OR make ***quadriply** awesome* creations with the same time :sparkles:
|
||||||
* Use over 100 functions to modify the world or remove problems.
|
* Get lost in hundreds of options and functions that even we've forgotten existed
|
||||||
* Remove large chunks of land as you wish.
|
* Utilize Photoshop-like tools like "selection areas" and "brushes"
|
||||||
* Sculpt the world and build mountains with brushes.
|
* Making fjords and other natural wonders with weird names
|
||||||
* Fix annoyances such as broken water, missing snow, raging fires, and more.
|
* Also: fix grief, broken water, missing snow, raging fires, and other :poop:
|
||||||
|
|
||||||
WorldEdit is open source and is available under the GNU Lesser General Public
|
WorldEdit is open source!, so if you've just learned how to make a button blink, I probably recommend picking up a book on CS algorithms. The project is licensed using the GNU Lesser General Public License license, v3.
|
||||||
License v3.
|
|
||||||
|
|
||||||
Compiling
|
Compiling
|
||||||
---------
|
---------
|
||||||
|
10
build.gradle
10
build.gradle
@ -21,7 +21,8 @@ buildscript {
|
|||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
force 'com.google.guava:guava:17.0'
|
force 'com.google.guava:guava:21.0'
|
||||||
|
force 'org.ow2.asm:asm:6.0_BETA'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = 'com.sk89q.worldedit'
|
group = 'com.sk89q.worldedit'
|
||||||
version = '6.1.7-SNAPSHOT'
|
version = '7.0.0-SNAPSHOT'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!project.hasProperty("artifactory_contextUrl")) ext.artifactory_contextUrl = "http://localhost"
|
if (!project.hasProperty("artifactory_contextUrl")) ext.artifactory_contextUrl = "http://localhost"
|
||||||
@ -86,10 +87,11 @@ subprojects {
|
|||||||
|
|
||||||
ext.internalVersion = version + ";" + gitCommitHash
|
ext.internalVersion = version + ";" + gitCommitHash
|
||||||
|
|
||||||
sourceCompatibility = 1.7
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
targetCompatibility = 1.7
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml")
|
checkstyle.configFile = new File(rootProject.projectDir, "config/checkstyle/checkstyle.xml")
|
||||||
|
checkstyle.toolVersion = '7.6.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
<property name="max" value="2"/>
|
<property name="max" value="2"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="SuperFinalize"/> <!-- We don't actually use this -->
|
<module name="SuperFinalize"/> <!-- We don't actually use this -->
|
||||||
<module name="JUnitTestCase"/> <!-- Checks tearDown(), setUp() etc. -->
|
|
||||||
|
|
||||||
<!-- Style -->
|
<!-- Style -->
|
||||||
<module name="LeftCurly"> <!-- Left brace never goes on another line -->
|
<module name="LeftCurly"> <!-- Left brace never goes on another line -->
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binäre Datei nicht angezeigt.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,5 @@
|
|||||||
#Wed Nov 23 21:39:25 PST 2016
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
|
|
||||||
|
11
gradlew
vendored
11
gradlew
vendored
@ -155,13 +155,14 @@ if $cygwin ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Escape application args
|
||||||
for s in "${@}" ; do
|
save () {
|
||||||
s=\"$s\"
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
APP_ARGS=$APP_ARGS" "$s
|
echo " "
|
||||||
done
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- "$DEFAULT_JVM_OPTS" "$JAVA_OPTS" "$GRADLE_OPTS" "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
|
apply plugin: 'maven'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
|
maven { url "https://hub.spigotmc.org/nexus/content/groups/public" }
|
||||||
@ -8,7 +9,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile project(':worldedit-core')
|
compile project(':worldedit-core')
|
||||||
compile 'com.sk89q:dummypermscompat:1.8'
|
compile 'com.sk89q:dummypermscompat:1.8'
|
||||||
compile 'org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT' // zzz
|
compile 'org.bukkit:bukkit:1.13-R0.1-SNAPSHOT' // zzz
|
||||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,10 +34,7 @@ jar {
|
|||||||
shadowJar {
|
shadowJar {
|
||||||
dependencies {
|
dependencies {
|
||||||
include(dependency(':worldedit-core'))
|
include(dependency(':worldedit-core'))
|
||||||
include(dependency('com.google.code.gson:gson:2.2.4'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
relocate('com.google.gson', 'com.sk89q.worldedit.internal.gson')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build.dependsOn(shadowJar)
|
build.dependsOn(shadowJar)
|
||||||
|
@ -82,7 +82,7 @@ public class CommandRegistration {
|
|||||||
|
|
||||||
public boolean unregisterCommands() {
|
public boolean unregisterCommands() {
|
||||||
CommandMap commandMap = getCommandMap();
|
CommandMap commandMap = getCommandMap();
|
||||||
List<String> toRemove = new ArrayList<String>();
|
List<String> toRemove = new ArrayList<>();
|
||||||
Map<String, org.bukkit.command.Command> knownCommands = ReflectionUtil.getField(commandMap, "knownCommands");
|
Map<String, org.bukkit.command.Command> knownCommands = ReflectionUtil.getField(commandMap, "knownCommands");
|
||||||
Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
|
Set<String> aliases = ReflectionUtil.getField(commandMap, "aliases");
|
||||||
if (knownCommands == null || aliases == null) {
|
if (knownCommands == null || aliases == null) {
|
||||||
|
@ -50,7 +50,7 @@ public class CommandsManagerRegistration extends CommandRegistration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean registerAll(List<Command> registered) {
|
public boolean registerAll(List<Command> registered) {
|
||||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
List<CommandInfo> toRegister = new ArrayList<>();
|
||||||
for (Command command : registered) {
|
for (Command command : registered) {
|
||||||
List<String> permissions = null;
|
List<String> permissions = null;
|
||||||
Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]);
|
Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]);
|
||||||
@ -59,7 +59,7 @@ public class CommandsManagerRegistration extends CommandRegistration {
|
|||||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||||
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
|
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||||
} else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) {
|
} else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) {
|
||||||
permissions = new ArrayList<String>();
|
permissions = new ArrayList<>();
|
||||||
for (Method m : childMethods.values()) {
|
for (Method m : childMethods.values()) {
|
||||||
if (m.isAnnotationPresent(CommandPermissions.class)) {
|
if (m.isAnnotationPresent(CommandPermissions.class)) {
|
||||||
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
|
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.wepif;
|
package com.sk89q.wepif;
|
||||||
|
|
||||||
|
import com.sk89q.util.yaml.YAMLNode;
|
||||||
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.sk89q.util.yaml.YAMLNode;
|
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
|
|
||||||
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
||||||
private YAMLProcessor config;
|
private YAMLProcessor config;
|
||||||
private Map<String, Set<String>> userPermissionsCache;
|
private Map<String, Set<String>> userPermissionsCache;
|
||||||
@ -52,11 +52,11 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
userGroups = new HashMap<String, Set<String>>();
|
userGroups = new HashMap<>();
|
||||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
userPermissionsCache = new HashMap<>();
|
||||||
defaultPermissionsCache = new HashSet<String>();
|
defaultPermissionsCache = new HashSet<>();
|
||||||
|
|
||||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||||
|
|
||||||
List<String> groupKeys = config.getStringList("permissions.groups", null);
|
List<String> groupKeys = config.getStringList("permissions.groups", null);
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
config.getStringList("permissions.groups." + key + ".permissions", null);
|
config.getStringList("permissions.groups." + key + ".permissions", null);
|
||||||
|
|
||||||
if (!permissions.isEmpty()) {
|
if (!permissions.isEmpty()) {
|
||||||
Set<String> groupPerms = new HashSet<String>(permissions);
|
Set<String> groupPerms = new HashSet<>(permissions);
|
||||||
userGroupPermissions.put(key, groupPerms);
|
userGroupPermissions.put(key, groupPerms);
|
||||||
|
|
||||||
if (key.equals("default")) {
|
if (key.equals("default")) {
|
||||||
@ -80,7 +80,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
if (userKeys != null) {
|
if (userKeys != null) {
|
||||||
for (String key : userKeys) {
|
for (String key : userKeys) {
|
||||||
Set<String> permsCache = new HashSet<String>();
|
Set<String> permsCache = new HashSet<>();
|
||||||
|
|
||||||
List<String> permissions =
|
List<String> permissions =
|
||||||
config.getStringList("permissions.users." + key + ".permissions", null);
|
config.getStringList("permissions.users." + key + ".permissions", null);
|
||||||
@ -103,7 +103,7 @@ public class ConfigurationPermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||||
userGroups.put(key.toLowerCase(), new HashSet<String>(groups));
|
userGroups.put(key.toLowerCase(), new HashSet<>(groups));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,13 @@ public class DinnerPermsResolver implements PermissionsResolver {
|
|||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
List<String> groupNames = new ArrayList<String>();
|
List<String> groupNames = new ArrayList<>();
|
||||||
for (PermissionAttachmentInfo permAttach : perms.getEffectivePermissions()) {
|
for (PermissionAttachmentInfo permAttach : perms.getEffectivePermissions()) {
|
||||||
String perm = permAttach.getPermission();
|
String perm = permAttach.getPermission();
|
||||||
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
if (!(perm.startsWith(GROUP_PREFIX) && permAttach.getValue())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
groupNames.add(perm.substring(GROUP_PREFIX.length(), perm.length()));
|
groupNames.add(perm.substring(GROUP_PREFIX.length()));
|
||||||
}
|
}
|
||||||
return groupNames.toArray(new String[groupNames.size()]);
|
return groupNames.toArray(new String[groupNames.size()]);
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,8 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
this.userFile = userFile;
|
this.userFile = userFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static boolean filesExists() {
|
|
||||||
return (new File("perms_groups.txt")).exists() && (new File("perms_users.txt")).exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Set<String>> loadGroupPermissions() {
|
public Map<String, Set<String>> loadGroupPermissions() {
|
||||||
Map<String, Set<String>> userGroupPermissions = new HashMap<String, Set<String>>();
|
Map<String, Set<String>> userGroupPermissions = new HashMap<>();
|
||||||
|
|
||||||
BufferedReader buff = null;
|
BufferedReader buff = null;
|
||||||
|
|
||||||
@ -98,7 +93,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
if (parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
String[] perms = parts[1].split(",");
|
String[] perms = parts[1].split(",");
|
||||||
|
|
||||||
Set<String> groupPerms = new HashSet<String>(Arrays.asList(perms));
|
Set<String> groupPerms = new HashSet<>(Arrays.asList(perms));
|
||||||
userGroupPermissions.put(key, groupPerms);
|
userGroupPermissions.put(key, groupPerms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,9 +113,9 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load() {
|
public void load() {
|
||||||
userGroups = new HashMap<String, Set<String>>();
|
userGroups = new HashMap<>();
|
||||||
userPermissionsCache = new HashMap<String, Set<String>>();
|
userPermissionsCache = new HashMap<>();
|
||||||
defaultPermissionsCache = new HashSet<String>();
|
defaultPermissionsCache = new HashSet<>();
|
||||||
|
|
||||||
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
|
Map<String, Set<String>> userGroupPermissions = loadGroupPermissions();
|
||||||
|
|
||||||
@ -136,7 +131,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = buff.readLine()) != null) {
|
while ((line = buff.readLine()) != null) {
|
||||||
Set<String> permsCache = new HashSet<String>();
|
Set<String> permsCache = new HashSet<>();
|
||||||
|
|
||||||
line = line.trim();
|
line = line.trim();
|
||||||
|
|
||||||
@ -165,7 +160,7 @@ public class FlatFilePermissionsResolver implements PermissionsResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
userPermissionsCache.put(key.toLowerCase(), permsCache);
|
||||||
userGroups.put(key.toLowerCase(), new HashSet<String>(Arrays.asList(groups)));
|
userGroups.put(key.toLowerCase(), new HashSet<>(Arrays.asList(groups)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.wepif;
|
package com.sk89q.wepif;
|
||||||
|
|
||||||
|
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
@ -27,7 +28,6 @@ import org.bukkit.command.PluginCommand;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -50,7 +50,7 @@ public class NijiPermissionsResolver implements PermissionsResolver {
|
|||||||
Plugin plugin = pluginManager.getPlugin("Permissions");
|
Plugin plugin = pluginManager.getPlugin("Permissions");
|
||||||
|
|
||||||
// Check if plugin is loaded and has Permissions interface
|
// Check if plugin is loaded and has Permissions interface
|
||||||
if (plugin == null || !(plugin instanceof Permissions)) {
|
if (!(plugin instanceof Permissions)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,19 +22,19 @@ package com.sk89q.wepif;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
||||||
public interface PermissionsProvider {
|
public interface PermissionsProvider {
|
||||||
public boolean hasPermission(String name, String permission);
|
boolean hasPermission(String name, String permission);
|
||||||
|
|
||||||
public boolean hasPermission(String worldName, String name, String permission);
|
boolean hasPermission(String worldName, String name, String permission);
|
||||||
|
|
||||||
public boolean inGroup(String player, String group);
|
boolean inGroup(String player, String group);
|
||||||
|
|
||||||
public String[] getGroups(String player);
|
String[] getGroups(String player);
|
||||||
|
|
||||||
public boolean hasPermission(OfflinePlayer player, String permission);
|
boolean hasPermission(OfflinePlayer player, String permission);
|
||||||
|
|
||||||
public boolean hasPermission(String worldName, OfflinePlayer player, String permission);
|
boolean hasPermission(String worldName, OfflinePlayer player, String permission);
|
||||||
|
|
||||||
public boolean inGroup(OfflinePlayer player, String group);
|
boolean inGroup(OfflinePlayer player, String group);
|
||||||
|
|
||||||
public String[] getGroups(OfflinePlayer player);
|
String[] getGroups(OfflinePlayer player);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package com.sk89q.wepif;
|
package com.sk89q.wepif;
|
||||||
|
|
||||||
public interface PermissionsResolver extends PermissionsProvider {
|
public interface PermissionsResolver extends PermissionsProvider {
|
||||||
public void load();
|
void load();
|
||||||
|
|
||||||
public String getDetectionMessage();
|
String getDetectionMessage();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
private PermissionsResolver permissionResolver;
|
private PermissionsResolver permissionResolver;
|
||||||
private YAMLProcessor config;
|
private YAMLProcessor config;
|
||||||
private Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
private Logger logger = Logger.getLogger(getClass().getCanonicalName());
|
||||||
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<Class<? extends PermissionsResolver>>();
|
private List<Class<? extends PermissionsResolver>> enabledResolvers = new ArrayList<>();
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
protected Class<? extends PermissionsResolver>[] availableResolvers = new Class[] {
|
||||||
@ -213,7 +213,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
|
|
||||||
if (!keys.contains("resolvers")) {
|
if (!keys.contains("resolvers")) {
|
||||||
//List<String> resolverKeys = config.getKeys("resolvers");
|
//List<String> resolverKeys = config.getKeys("resolvers");
|
||||||
List<String> resolvers = new ArrayList<String>();
|
List<String> resolvers = new ArrayList<>();
|
||||||
for (Class<?> clazz : availableResolvers) {
|
for (Class<?> clazz : availableResolvers) {
|
||||||
resolvers.add(clazz.getSimpleName());
|
resolvers.add(clazz.getSimpleName());
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ public class PermissionsResolverManager implements PermissionsResolver {
|
|||||||
config.setProperty("resolvers.enabled", resolvers);
|
config.setProperty("resolvers.enabled", resolvers);
|
||||||
isUpdated = true;
|
isUpdated = true;
|
||||||
} else {
|
} else {
|
||||||
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<String>());
|
List<String> disabledResolvers = config.getStringList("resolvers.disabled", new ArrayList<>());
|
||||||
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
List<String> stagedEnabled = config.getStringList("resolvers.enabled", null);
|
||||||
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
for (Iterator<String> i = stagedEnabled.iterator(); i.hasNext();) {
|
||||||
String nextName = i.next();
|
String nextName = i.next();
|
||||||
|
@ -19,22 +19,62 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||||
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapts between Bukkit and WorldEdit equivalent objects.
|
* Adapts between Bukkit and WorldEdit equivalent objects.
|
||||||
*/
|
*/
|
||||||
final class BukkitAdapter {
|
public class BukkitAdapter {
|
||||||
|
|
||||||
private BukkitAdapter() {
|
private BukkitAdapter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final ParserContext TO_BLOCK_CONTEXT = new ParserContext();
|
||||||
|
|
||||||
|
static {
|
||||||
|
TO_BLOCK_CONTEXT.setRestricted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks equality between a WorldEdit BlockType and a Bukkit Material
|
||||||
|
*
|
||||||
|
* @param blockType The WorldEdit BlockType
|
||||||
|
* @param type The Bukkit Material
|
||||||
|
* @return If they are equal
|
||||||
|
*/
|
||||||
|
public static boolean equals(BlockType blockType, Material type) {
|
||||||
|
return Objects.equals(blockType.getId(), type.getKey().toString());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
* Convert any WorldEdit world into an equivalent wrapped Bukkit world.
|
||||||
*
|
*
|
||||||
@ -67,6 +107,26 @@ final class BukkitAdapter {
|
|||||||
return new BukkitWorld(world);
|
return new BukkitWorld(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit Player from a Bukkit Player.
|
||||||
|
*
|
||||||
|
* @param player The Bukkit player
|
||||||
|
* @return The WorldEdit player
|
||||||
|
*/
|
||||||
|
public static BukkitPlayer adapt(Player player) {
|
||||||
|
return WorldEditPlugin.getInstance().wrapPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit Player from a WorldEdit Player.
|
||||||
|
*
|
||||||
|
* @param player The WorldEdit player
|
||||||
|
* @return The Bukkit player
|
||||||
|
*/
|
||||||
|
public static Player adapt(com.sk89q.worldedit.entity.Player player) {
|
||||||
|
return ((BukkitPlayer) player).getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a Bukkit world from a WorldEdit world.
|
* Create a Bukkit world from a WorldEdit world.
|
||||||
*
|
*
|
||||||
@ -95,7 +155,7 @@ final class BukkitAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Location adapt(org.bukkit.Location location) {
|
public static Location adapt(org.bukkit.Location location) {
|
||||||
checkNotNull(location);
|
checkNotNull(location);
|
||||||
Vector position = BukkitUtil.toVector(location);
|
Vector position = asVector(location);
|
||||||
return new com.sk89q.worldedit.util.Location(
|
return new com.sk89q.worldedit.util.Location(
|
||||||
adapt(location.getWorld()),
|
adapt(location.getWorld()),
|
||||||
position,
|
position,
|
||||||
@ -151,6 +211,17 @@ final class BukkitAdapter {
|
|||||||
location.getPitch());
|
location.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit Vector from a Bukkit location.
|
||||||
|
*
|
||||||
|
* @param location The Bukkit location
|
||||||
|
* @return a WorldEdit vector
|
||||||
|
*/
|
||||||
|
public static Vector asVector(org.bukkit.Location location) {
|
||||||
|
checkNotNull(location);
|
||||||
|
return new Vector(location.getX(), location.getY(), location.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a WorldEdit entity from a Bukkit entity.
|
* Create a WorldEdit entity from a Bukkit entity.
|
||||||
*
|
*
|
||||||
@ -162,4 +233,142 @@ final class BukkitAdapter {
|
|||||||
return new BukkitEntity(entity);
|
return new BukkitEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit Material form a WorldEdit ItemType
|
||||||
|
*
|
||||||
|
* @param itemType The WorldEdit ItemType
|
||||||
|
* @return The Bukkit Material
|
||||||
|
*/
|
||||||
|
public static Material adapt(ItemType itemType) {
|
||||||
|
checkNotNull(itemType);
|
||||||
|
if (!itemType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports Minecraft items");
|
||||||
|
}
|
||||||
|
return Material.getMaterial(itemType.getId().replace("minecraft:", "").toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit Material form a WorldEdit BlockType
|
||||||
|
*
|
||||||
|
* @param blockType The WorldEdit BlockType
|
||||||
|
* @return The Bukkit Material
|
||||||
|
*/
|
||||||
|
public static Material adapt(BlockType blockType) {
|
||||||
|
checkNotNull(blockType);
|
||||||
|
if (!blockType.getId().startsWith("minecraft:")) {
|
||||||
|
throw new IllegalArgumentException("Bukkit only supports Minecraft blocks");
|
||||||
|
}
|
||||||
|
return Material.getMaterial(blockType.getId().replace("minecraft:", "").toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit GameMode from a Bukkit one.
|
||||||
|
*
|
||||||
|
* @param gameMode Bukkit GameMode
|
||||||
|
* @return WorldEdit GameMode
|
||||||
|
*/
|
||||||
|
public static GameMode adapt(org.bukkit.GameMode gameMode) {
|
||||||
|
checkNotNull(gameMode);
|
||||||
|
return GameModes.get(gameMode.name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Material to a BlockType
|
||||||
|
*
|
||||||
|
* @param material The material
|
||||||
|
* @return The blocktype
|
||||||
|
*/
|
||||||
|
public static BlockType asBlockType(Material material) {
|
||||||
|
checkNotNull(material);
|
||||||
|
if (!material.isBlock()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not a block!");
|
||||||
|
}
|
||||||
|
return BlockTypes.get(material.getKey().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Material to a ItemType
|
||||||
|
*
|
||||||
|
* @param material The material
|
||||||
|
* @return The itemtype
|
||||||
|
*/
|
||||||
|
public static ItemType asItemType(Material material) {
|
||||||
|
checkNotNull(material);
|
||||||
|
if (!material.isItem()) {
|
||||||
|
throw new IllegalArgumentException(material.getKey().toString() + " is not an item!");
|
||||||
|
}
|
||||||
|
return ItemTypes.get(material.getKey().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, BlockState> blockStateCache = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit BlockState from a Bukkit BlockData
|
||||||
|
*
|
||||||
|
* @param blockData The Bukkit BlockData
|
||||||
|
* @return The WorldEdit BlockState
|
||||||
|
*/
|
||||||
|
public static BlockState adapt(BlockData blockData) {
|
||||||
|
checkNotNull(blockData);
|
||||||
|
return blockStateCache.computeIfAbsent(blockData.getAsString(), new Function<String, BlockState>() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockState apply(@Nullable String input) {
|
||||||
|
try {
|
||||||
|
return WorldEdit.getInstance().getBlockFactory().parseFromInput(input, TO_BLOCK_CONTEXT).toImmutableState();
|
||||||
|
} catch (InputParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit BlockData from a WorldEdit BlockStateHolder
|
||||||
|
*
|
||||||
|
* @param block The WorldEdit BlockStateHolder
|
||||||
|
* @return The Bukkit BlockData
|
||||||
|
*/
|
||||||
|
public static BlockData adapt(BlockStateHolder block) {
|
||||||
|
checkNotNull(block);
|
||||||
|
return Bukkit.createBlockData(block.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit BlockState from a Bukkit ItemStack
|
||||||
|
*
|
||||||
|
* @param itemStack The Bukkit ItemStack
|
||||||
|
* @return The WorldEdit BlockState
|
||||||
|
*/
|
||||||
|
public static BlockState asBlockState(ItemStack itemStack) {
|
||||||
|
checkNotNull(itemStack);
|
||||||
|
if (itemStack.getType().isBlock()) {
|
||||||
|
return adapt(itemStack.getType().createBlockData());
|
||||||
|
} else {
|
||||||
|
return BlockTypes.AIR.getDefaultState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a WorldEdit BaseItemStack from a Bukkit ItemStack
|
||||||
|
*
|
||||||
|
* @param itemStack The Bukkit ItemStack
|
||||||
|
* @return The WorldEdit BaseItemStack
|
||||||
|
*/
|
||||||
|
public static BaseItemStack adapt(ItemStack itemStack) {
|
||||||
|
checkNotNull(itemStack);
|
||||||
|
return new BaseItemStack(ItemTypes.get(itemStack.getType().getKey().toString()), itemStack.getAmount());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a Bukkit ItemStack from a WorldEdit BaseItemStack
|
||||||
|
*
|
||||||
|
* @param item The WorldEdit BaseItemStack
|
||||||
|
* @return The Bukkit ItemStack
|
||||||
|
*/
|
||||||
|
public static ItemStack adapt(BaseItemStack item) {
|
||||||
|
checkNotNull(item);
|
||||||
|
return new ItemStack(adapt(item.getType()), item.getAmount());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,12 @@ import com.sk89q.worldedit.world.biome.BiomeData;
|
|||||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A biome registry for Bukkit.
|
* A biome registry for Bukkit.
|
||||||
*/
|
*/
|
||||||
@ -48,7 +49,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
|||||||
public List<BaseBiome> getBiomes() {
|
public List<BaseBiome> getBiomes() {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
List<BaseBiome> biomes = new ArrayList<BaseBiome>();
|
List<BaseBiome> biomes = new ArrayList<>();
|
||||||
for (Biome biome : Biome.values()) {
|
for (Biome biome : Biome.values()) {
|
||||||
int biomeId = adapter.getBiomeId(biome);
|
int biomeId = adapter.getBiomeId(biome);
|
||||||
biomes.add(new BaseBiome(biomeId));
|
biomes.add(new BaseBiome(biomeId));
|
||||||
@ -65,12 +66,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
|||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
final Biome bukkitBiome = adapter.getBiome(biome.getId());
|
final Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||||
return new BiomeData() {
|
return bukkitBiome::name;
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return bukkitBiome.name();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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.bukkit;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.registry.BundledBlockRegistry;
|
||||||
|
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class BukkitBlockRegistry extends BundledBlockRegistry {
|
||||||
|
|
||||||
|
private Map<Material, BukkitBlockMaterial> materialMap = new EnumMap<>(Material.class);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public BlockMaterial getMaterial(BlockType blockType) {
|
||||||
|
return materialMap.computeIfAbsent(BukkitAdapter.adapt(blockType),
|
||||||
|
material -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), material));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Map<String, ? extends Property> getProperties(BlockType blockType) {
|
||||||
|
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
|
||||||
|
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getProperties(blockType);
|
||||||
|
}
|
||||||
|
return super.getProperties(blockType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BukkitBlockMaterial extends PassthroughBlockMaterial {
|
||||||
|
|
||||||
|
private final Material material;
|
||||||
|
|
||||||
|
public BukkitBlockMaterial(@Nullable BlockMaterial material, Material bukkitMaterial) {
|
||||||
|
super(material);
|
||||||
|
this.material = bukkitMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSolid() {
|
||||||
|
return material.isSolid();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isBurnable() {
|
||||||
|
return material.isBurnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTranslucent() {
|
||||||
|
return material.isTransparent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.bukkit.util.CommandInspector;
|
import com.sk89q.bukkit.util.CommandInspector;
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
@ -30,8 +32,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
class BukkitCommandInspector implements CommandInspector {
|
class BukkitCommandInspector implements CommandInspector {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(BukkitCommandInspector.class.getCanonicalName());
|
private static final Logger logger = Logger.getLogger(BukkitCommandInspector.class.getCanonicalName());
|
||||||
|
@ -19,19 +19,20 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
|
import com.sk89q.worldedit.util.auth.AuthorizationException;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import javax.annotation.Nullable;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
public class BukkitCommandSender implements Actor {
|
public class BukkitCommandSender implements Actor {
|
||||||
|
|
||||||
|
@ -19,19 +19,20 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.entity.metadata.EntityType;
|
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.NullWorld;
|
import com.sk89q.worldedit.world.NullWorld;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An adapter to adapt a Bukkit entity into a WorldEdit one.
|
* An adapter to adapt a Bukkit entity into a WorldEdit one.
|
||||||
@ -47,7 +48,7 @@ class BukkitEntity implements Entity {
|
|||||||
*/
|
*/
|
||||||
BukkitEntity(org.bukkit.entity.Entity entity) {
|
BukkitEntity(org.bukkit.entity.Entity entity) {
|
||||||
checkNotNull(entity);
|
checkNotNull(entity);
|
||||||
this.entityRef = new WeakReference<org.bukkit.entity.Entity>(entity);
|
this.entityRef = new WeakReference<>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -105,8 +106,8 @@ class BukkitEntity implements Entity {
|
|||||||
@Override
|
@Override
|
||||||
public <T> T getFacet(Class<? extends T> cls) {
|
public <T> T getFacet(Class<? extends T> cls) {
|
||||||
org.bukkit.entity.Entity entity = entityRef.get();
|
org.bukkit.entity.Entity entity = entityRef.get();
|
||||||
if (entity != null && EntityType.class.isAssignableFrom(cls)) {
|
if (entity != null && EntityProperties.class.isAssignableFrom(cls)) {
|
||||||
return (T) new BukkitEntityType(entity);
|
return (T) new BukkitEntityProperties(entity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,14 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.entity.metadata.EntityType;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.entity.metadata.EntityProperties;
|
||||||
import com.sk89q.worldedit.util.Enums;
|
import com.sk89q.worldedit.util.Enums;
|
||||||
import org.bukkit.entity.Ambient;
|
import org.bukkit.entity.Ambient;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
import org.bukkit.entity.Boat;
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.ComplexEntityPart;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.FallingBlock;
|
||||||
@ -34,22 +37,21 @@ import org.bukkit.entity.ItemFrame;
|
|||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Painting;
|
import org.bukkit.entity.Painting;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
class BukkitEntityProperties implements EntityProperties {
|
||||||
|
|
||||||
class BukkitEntityType implements EntityType {
|
|
||||||
|
|
||||||
private static final org.bukkit.entity.EntityType armorStandType =
|
private static final org.bukkit.entity.EntityType armorStandType =
|
||||||
Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND");
|
Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND");
|
||||||
|
|
||||||
private final Entity entity;
|
private final Entity entity;
|
||||||
|
|
||||||
BukkitEntityType(Entity entity) {
|
BukkitEntityProperties(Entity entity) {
|
||||||
checkNotNull(entity);
|
checkNotNull(entity);
|
||||||
this.entity = entity;
|
this.entity = entity;
|
||||||
}
|
}
|
||||||
@ -136,11 +138,16 @@ class BukkitEntityType implements EntityType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTagged() {
|
public boolean isTagged() {
|
||||||
return entity instanceof LivingEntity && ((LivingEntity) entity).getCustomName() != null;
|
return entity instanceof LivingEntity && entity.getCustomName() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isArmorStand() {
|
public boolean isArmorStand() {
|
||||||
return entity.getType() == armorStandType;
|
return entity.getType() == armorStandType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPasteable() {
|
||||||
|
return !(entity instanceof Player || entity instanceof ComplexEntityPart);
|
||||||
|
}
|
||||||
}
|
}
|
@ -20,32 +20,34 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.extension.platform.AbstractPlayerActor;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BukkitPlayer extends LocalPlayer {
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class BukkitPlayer extends AbstractPlayerActor {
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private WorldEditPlugin plugin;
|
private WorldEditPlugin plugin;
|
||||||
|
|
||||||
public BukkitPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
public BukkitPlayer(WorldEditPlugin plugin, Player player) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
@ -56,15 +58,19 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemInHand() {
|
public BaseItemStack getItemInHand(HandSide handSide) {
|
||||||
ItemStack itemStack = player.getItemInHand();
|
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
||||||
return itemStack != null ? itemStack.getTypeId() : 0;
|
? player.getInventory().getItemInMainHand()
|
||||||
|
: player.getInventory().getItemInOffHand();
|
||||||
|
return BukkitAdapter.adapt(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlockInHand() throws WorldEditException {
|
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
||||||
ItemStack itemStack = player.getItemInHand();
|
ItemStack itemStack = handSide == HandSide.MAIN_HAND
|
||||||
return BukkitUtil.toBlock(getWorld(), itemStack);
|
? player.getInventory().getItemInMainHand()
|
||||||
|
: player.getInventory().getItemInOffHand();
|
||||||
|
return BukkitAdapter.asBlockState(itemStack).toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -73,25 +79,8 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorldVector getPosition() {
|
public void giveItem(BaseItemStack itemStack) {
|
||||||
Location loc = player.getLocation();
|
player.getInventory().addItem(BukkitAdapter.adapt(itemStack));
|
||||||
return new WorldVector(BukkitUtil.getLocalWorld(loc.getWorld()),
|
|
||||||
loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getPitch() {
|
|
||||||
return player.getLocation().getPitch();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getYaw() {
|
|
||||||
return player.getLocation().getYaw();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void giveItem(int type, int amt) {
|
|
||||||
player.getInventory().addItem(new ItemStack(type, amt));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -138,6 +127,16 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
return new BukkitPlayerBlockBag(player);
|
return new BukkitPlayerBlockBag(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameMode getGameMode() {
|
||||||
|
return GameModes.get(player.getGameMode().name().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGameMode(GameMode gameMode) {
|
||||||
|
player.setGameMode(org.bukkit.GameMode.valueOf(gameMode.getId().toUpperCase()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String perm) {
|
public boolean hasPermission(String perm) {
|
||||||
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|
return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp())
|
||||||
@ -146,8 +145,8 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalWorld getWorld() {
|
public World getWorld() {
|
||||||
return BukkitUtil.getLocalWorld(player.getWorld());
|
return BukkitAdapter.adapt(player.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -164,11 +163,6 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasCreativeMode() {
|
|
||||||
return player.getGameMode() == GameMode.CREATIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
public void floatAt(int x, int y, int z, boolean alwaysGlass) {
|
||||||
if (alwaysGlass || !player.getAllowFlight()) {
|
if (alwaysGlass || !player.getAllowFlight()) {
|
||||||
@ -188,7 +182,7 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public com.sk89q.worldedit.util.Location getLocation() {
|
public com.sk89q.worldedit.util.Location getLocation() {
|
||||||
Location nativeLocation = player.getLocation();
|
Location nativeLocation = player.getLocation();
|
||||||
Vector position = BukkitUtil.toVector(nativeLocation);
|
Vector position = BukkitAdapter.asVector(nativeLocation);
|
||||||
return new com.sk89q.worldedit.util.Location(
|
return new com.sk89q.worldedit.util.Location(
|
||||||
getWorld(),
|
getWorld(),
|
||||||
position,
|
position,
|
||||||
@ -235,7 +229,7 @@ public class BukkitPlayer extends LocalPlayer {
|
|||||||
// CopyOnWrite list for the list of players, but the Bukkit
|
// CopyOnWrite list for the list of players, but the Bukkit
|
||||||
// specification doesn't require thread safety (though the
|
// specification doesn't require thread safety (though the
|
||||||
// spec is extremely incomplete)
|
// spec is extremely incomplete)
|
||||||
return Bukkit.getServer().getPlayerExact(name) != null;
|
return Bukkit.getServer().getPlayer(uuid) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,14 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
|
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.util.Location;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.sk89q.worldedit.extent.inventory.*;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
|
||||||
|
|
||||||
public class BukkitPlayerBlockBag extends BlockBag {
|
public class BukkitPlayerBlockBag extends BlockBag {
|
||||||
|
|
||||||
@ -61,14 +63,8 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
public void fetchBlock(BlockState blockState) throws BlockBagException {
|
||||||
final int id = item.getType();
|
if (blockState.getBlockType() == BlockTypes.AIR) {
|
||||||
final int damage = item.getData();
|
|
||||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
|
||||||
assert(amount == 1);
|
|
||||||
boolean usesDamageValue = ItemType.usesDamageValue(id);
|
|
||||||
|
|
||||||
if (id == BlockID.AIR) {
|
|
||||||
throw new IllegalArgumentException("Can't fetch air block");
|
throw new IllegalArgumentException("Can't fetch air block");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,16 +79,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bukkitItem.getTypeId() != id) {
|
if (!BukkitAdapter.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||||
// Type id doesn't fit
|
// Type id doesn't fit
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
|
||||||
// Damage value doesn't fit.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentAmount = bukkitItem.getAmount();
|
int currentAmount = bukkitItem.getAmount();
|
||||||
if (currentAmount < 0) {
|
if (currentAmount < 0) {
|
||||||
// Unlimited
|
// Unlimited
|
||||||
@ -116,16 +107,13 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeItem(BaseItem item) throws BlockBagException {
|
public void storeBlock(BlockState blockState, int amount) throws BlockBagException {
|
||||||
final int id = item.getType();
|
if (blockState.getBlockType() == BlockTypes.AIR) {
|
||||||
final int damage = item.getData();
|
|
||||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
|
||||||
assert(amount <= 64);
|
|
||||||
boolean usesDamageValue = ItemType.usesDamageValue(id);
|
|
||||||
|
|
||||||
if (id == BlockID.AIR) {
|
|
||||||
throw new IllegalArgumentException("Can't store air block");
|
throw new IllegalArgumentException("Can't store air block");
|
||||||
}
|
}
|
||||||
|
if (!blockState.getBlockType().hasItemType()) {
|
||||||
|
throw new IllegalArgumentException("This block cannot be stored");
|
||||||
|
}
|
||||||
|
|
||||||
loadInventory();
|
loadInventory();
|
||||||
|
|
||||||
@ -144,16 +132,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bukkitItem.getTypeId() != id) {
|
if (!BukkitAdapter.equals(blockState.getBlockType(), bukkitItem.getType())) {
|
||||||
// Type id doesn't fit
|
// Type id doesn't fit
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
|
||||||
// Damage value doesn't fit.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentAmount = bukkitItem.getAmount();
|
int currentAmount = bukkitItem.getAmount();
|
||||||
if (currentAmount < 0) {
|
if (currentAmount < 0) {
|
||||||
// Unlimited
|
// Unlimited
|
||||||
@ -175,11 +158,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (freeSlot > -1) {
|
if (freeSlot > -1) {
|
||||||
items[freeSlot] = new ItemStack(id, amount);
|
items[freeSlot] = BukkitAdapter.adapt(new BaseItemStack(blockState.getBlockType().getItemType(), amount));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new OutOfSpaceException(id);
|
throw new OutOfSpaceException(blockState.getBlockType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -191,11 +174,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSourcePosition(WorldVector pos) {
|
public void addSourcePosition(Location pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSingleSourcePosition(WorldVector pos) {
|
public void addSingleSourcePosition(Location pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,20 +20,27 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||||
import com.sk89q.worldedit.world.registry.LegacyWorldData;
|
import com.sk89q.worldedit.world.registry.BlockRegistry;
|
||||||
|
import com.sk89q.worldedit.world.registry.BundledRegistries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* World data for the Bukkit platform.
|
* World data for the Bukkit platform.
|
||||||
*/
|
*/
|
||||||
class BukkitWorldData extends LegacyWorldData {
|
class BukkitRegistries extends BundledRegistries {
|
||||||
|
|
||||||
private static final BukkitWorldData INSTANCE = new BukkitWorldData();
|
private static final BukkitRegistries INSTANCE = new BukkitRegistries();
|
||||||
|
private final BlockRegistry blockRegistry = new BukkitBlockRegistry();
|
||||||
private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry();
|
private final BiomeRegistry biomeRegistry = new BukkitBiomeRegistry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
BukkitWorldData() {
|
BukkitRegistries() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockRegistry getBlockRegistry() {
|
||||||
|
return blockRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -46,7 +53,7 @@ class BukkitWorldData extends LegacyWorldData {
|
|||||||
*
|
*
|
||||||
* @return an instance
|
* @return an instance
|
||||||
*/
|
*/
|
||||||
public static BukkitWorldData getInstance() {
|
public static BukkitRegistries getInstance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
@ -22,8 +22,6 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
import com.sk89q.bukkit.util.CommandInfo;
|
import com.sk89q.bukkit.util.CommandInfo;
|
||||||
import com.sk89q.bukkit.util.CommandRegistration;
|
import com.sk89q.bukkit.util.CommandRegistration;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
@ -32,30 +30,29 @@ import com.sk89q.worldedit.extension.platform.Preference;
|
|||||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||||
import com.sk89q.worldedit.util.command.Description;
|
import com.sk89q.worldedit.util.command.Description;
|
||||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||||
|
import com.sk89q.worldedit.world.registry.Registries;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BukkitServerInterface extends ServerInterface implements MultiUserPlatform {
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class BukkitServerInterface implements MultiUserPlatform {
|
||||||
public Server server;
|
public Server server;
|
||||||
public WorldEditPlugin plugin;
|
public WorldEditPlugin plugin;
|
||||||
private CommandRegistration dynamicCommands;
|
private CommandRegistration dynamicCommands;
|
||||||
private BukkitBiomeRegistry biomes;
|
|
||||||
private boolean hookingEvents;
|
private boolean hookingEvents;
|
||||||
|
|
||||||
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
public BukkitServerInterface(WorldEditPlugin plugin, Server server) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.biomes = new BukkitBiomeRegistry();
|
|
||||||
dynamicCommands = new CommandRegistration(plugin);
|
dynamicCommands = new CommandRegistration(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +61,8 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int resolveItem(String name) {
|
public Registries getRegistries() {
|
||||||
Material mat = Material.matchMaterial(name);
|
return BukkitRegistries.getInstance();
|
||||||
return mat == null ? 0 : mat.getId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,12 +82,12 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LocalWorld> getWorlds() {
|
public List<com.sk89q.worldedit.world.World> getWorlds() {
|
||||||
List<World> worlds = server.getWorlds();
|
List<World> worlds = server.getWorlds();
|
||||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
List<com.sk89q.worldedit.world.World> ret = new ArrayList<>(worlds.size());
|
||||||
|
|
||||||
for (World world : worlds) {
|
for (World world : worlds) {
|
||||||
ret.add(BukkitUtil.getLocalWorld(world));
|
ret.add(BukkitAdapter.adapt(world));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -104,7 +100,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
return player;
|
return player;
|
||||||
} else {
|
} else {
|
||||||
org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName());
|
org.bukkit.entity.Player bukkitPlayer = server.getPlayerExact(player.getName());
|
||||||
return bukkitPlayer != null ? new BukkitPlayer(plugin, this, bukkitPlayer) : null;
|
return bukkitPlayer != null ? new BukkitPlayer(plugin, bukkitPlayer) : null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +117,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands(Dispatcher dispatcher) {
|
public void registerCommands(Dispatcher dispatcher) {
|
||||||
List<CommandInfo> toRegister = new ArrayList<CommandInfo>();
|
List<CommandInfo> toRegister = new ArrayList<>();
|
||||||
BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher);
|
BukkitCommandInspector inspector = new BukkitCommandInspector(plugin, dispatcher);
|
||||||
|
|
||||||
for (CommandMapping command : dispatcher.getCommands()) {
|
for (CommandMapping command : dispatcher.getCommands()) {
|
||||||
@ -163,7 +159,7 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Capability, Preference> getCapabilities() {
|
public Map<Capability, Preference> getCapabilities() {
|
||||||
Map<Capability, Preference> capabilities = new EnumMap<Capability, Preference>(Capability.class);
|
Map<Capability, Preference> capabilities = new EnumMap<>(Capability.class);
|
||||||
capabilities.put(Capability.CONFIGURATION, Preference.NORMAL);
|
capabilities.put(Capability.CONFIGURATION, Preference.NORMAL);
|
||||||
capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL);
|
capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL);
|
||||||
capabilities.put(Capability.GAME_HOOKS, Preference.PREFERRED);
|
capabilities.put(Capability.GAME_HOOKS, Preference.PREFERRED);
|
||||||
@ -179,9 +175,9 @@ public class BukkitServerInterface extends ServerInterface implements MultiUserP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Actor> getConnectedUsers() {
|
public Collection<Actor> getConnectedUsers() {
|
||||||
List<Actor> users = new ArrayList<Actor>();
|
List<Actor> users = new ArrayList<>();
|
||||||
for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) {
|
for (org.bukkit.entity.Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
users.add(new BukkitPlayer(plugin, this, player));
|
users.add(new BukkitPlayer(plugin, player));
|
||||||
}
|
}
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
@ -1,196 +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.bukkit;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
|
||||||
import com.sk89q.worldedit.blocks.ItemID;
|
|
||||||
import com.sk89q.worldedit.blocks.SkullBlock;
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Painting;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
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 com.sk89q.worldedit.bukkit.entity.BukkitEntity;
|
|
||||||
import com.sk89q.worldedit.bukkit.entity.BukkitExpOrb;
|
|
||||||
import com.sk89q.worldedit.bukkit.entity.BukkitItem;
|
|
||||||
import com.sk89q.worldedit.bukkit.entity.BukkitPainting;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.material.Dye;
|
|
||||||
|
|
||||||
public final class BukkitUtil {
|
|
||||||
|
|
||||||
private BukkitUtil() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LocalWorld getLocalWorld(World w) {
|
|
||||||
return new BukkitWorld(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockVector toVector(Block block) {
|
|
||||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockVector toVector(BlockFace face) {
|
|
||||||
return new BlockVector(face.getModX(), face.getModY(), face.getModZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BlockWorldVector toWorldVector(Block block) {
|
|
||||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector toVector(org.bukkit.Location loc) {
|
|
||||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Location toLocation(org.bukkit.Location loc) {
|
|
||||||
return new Location(
|
|
||||||
getLocalWorld(loc.getWorld()),
|
|
||||||
new Vector(loc.getX(), loc.getY(), loc.getZ()),
|
|
||||||
loc.getYaw(), loc.getPitch()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector toVector(org.bukkit.util.Vector vector) {
|
|
||||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static org.bukkit.Location toLocation(WorldVector pt) {
|
|
||||||
return new org.bukkit.Location(toWorld(pt), pt.getX(), pt.getY(), pt.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static org.bukkit.Location toLocation(World world, Vector pt) {
|
|
||||||
return new org.bukkit.Location(world, pt.getX(), pt.getY(), pt.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static org.bukkit.Location center(org.bukkit.Location loc) {
|
|
||||||
return new org.bukkit.Location(
|
|
||||||
loc.getWorld(),
|
|
||||||
loc.getBlockX() + 0.5,
|
|
||||||
loc.getBlockY() + 0.5,
|
|
||||||
loc.getBlockZ() + 0.5,
|
|
||||||
loc.getPitch(),
|
|
||||||
loc.getYaw()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Player matchSinglePlayer(Server server, String name) {
|
|
||||||
List<Player> players = server.matchPlayer(name);
|
|
||||||
if (players.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return players.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Block toBlock(BlockWorldVector pt) {
|
|
||||||
return toWorld(pt).getBlockAt(toLocation(pt));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World toWorld(WorldVector pt) {
|
|
||||||
return ((BukkitWorld) pt.getWorld()).getWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bukkit's Location class has serious problems with floating point
|
|
||||||
* precision.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("RedundantIfStatement")
|
|
||||||
public static boolean equals(org.bukkit.Location a, org.bukkit.Location b) {
|
|
||||||
if (Math.abs(a.getX() - b.getX()) > EQUALS_PRECISION) return false;
|
|
||||||
if (Math.abs(a.getY() - b.getY()) > EQUALS_PRECISION) return false;
|
|
||||||
if (Math.abs(a.getZ() - b.getZ()) > EQUALS_PRECISION) return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final double EQUALS_PRECISION = 0.0001;
|
|
||||||
|
|
||||||
public static org.bukkit.Location toLocation(Location location) {
|
|
||||||
Vector pt = location.getPosition();
|
|
||||||
return new org.bukkit.Location(
|
|
||||||
toWorld(location.getWorld()),
|
|
||||||
pt.getX(), pt.getY(), pt.getZ(),
|
|
||||||
location.getYaw(), location.getPitch()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static World toWorld(final LocalWorld world) {
|
|
||||||
return ((BukkitWorld) world).getWorld();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BukkitEntity toLocalEntity(Entity e) {
|
|
||||||
switch (e.getType()) {
|
|
||||||
case EXPERIENCE_ORB:
|
|
||||||
return new BukkitExpOrb(toLocation(e.getLocation()), e.getUniqueId(), ((ExperienceOrb)e).getExperience());
|
|
||||||
case PAINTING:
|
|
||||||
Painting paint = (Painting) e;
|
|
||||||
return new BukkitPainting(toLocation(e.getLocation()), paint.getArt(), paint.getFacing(), e.getUniqueId());
|
|
||||||
case DROPPED_ITEM:
|
|
||||||
return new BukkitItem(toLocation(e.getLocation()), ((Item)e).getItemStack(), e.getUniqueId());
|
|
||||||
default:
|
|
||||||
return new BukkitEntity(toLocation(e.getLocation()), e.getType(), e.getUniqueId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BaseBlock toBlock(LocalWorld world, ItemStack itemStack) throws WorldEditException {
|
|
||||||
final int typeId = itemStack.getTypeId();
|
|
||||||
|
|
||||||
switch (typeId) {
|
|
||||||
case ItemID.INK_SACK:
|
|
||||||
final Dye materialData = (Dye) itemStack.getData();
|
|
||||||
if (materialData.getColor() == DyeColor.BROWN) {
|
|
||||||
return new BaseBlock(BlockID.COCOA_PLANT, -1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ItemID.HEAD:
|
|
||||||
return new SkullBlock(0, (byte) itemStack.getDurability());
|
|
||||||
|
|
||||||
default:
|
|
||||||
final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
|
|
||||||
if (baseBlock != null) {
|
|
||||||
return baseBlock;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.isValidBlockType(typeId)) {
|
|
||||||
return new BaseBlock(typeId, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotABlockException(typeId);
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,24 +19,27 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.history.change.BlockChange;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
|
import com.sk89q.worldedit.world.AbstractWorld;
|
||||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||||
|
import com.sk89q.worldedit.world.weather.WeatherTypes;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -46,9 +49,7 @@ import org.bukkit.block.Chest;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.inventory.DoubleChestInventory;
|
import org.bukkit.inventory.DoubleChestInventory;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
@ -58,13 +59,13 @@ import java.util.Map;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class BukkitWorld extends LocalWorld {
|
public class BukkitWorld extends AbstractWorld {
|
||||||
|
|
||||||
private static final Logger logger = WorldEdit.logger;
|
private static final Logger logger = WorldEdit.logger;
|
||||||
|
|
||||||
private static final Map<Integer, Effect> effects = new HashMap<Integer, Effect>();
|
private static final Map<Integer, Effect> effects = new HashMap<>();
|
||||||
static {
|
static {
|
||||||
for (Effect effect : Effect.values()) {
|
for (Effect effect : Effect.values()) {
|
||||||
effects.put(effect.getId(), effect);
|
effects.put(effect.getId(), effect);
|
||||||
@ -78,9 +79,8 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
*
|
*
|
||||||
* @param world the world
|
* @param world the world
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public BukkitWorld(World world) {
|
public BukkitWorld(World world) {
|
||||||
this.worldRef = new WeakReference<World>(world);
|
this.worldRef = new WeakReference<>(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,9 +88,9 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
|
||||||
List<Entity> ents = world.getEntities();
|
List<Entity> ents = world.getEntities();
|
||||||
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<com.sk89q.worldedit.entity.Entity>();
|
List<com.sk89q.worldedit.entity.Entity> entities = new ArrayList<>();
|
||||||
for (Entity ent : ents) {
|
for (Entity ent : ents) {
|
||||||
if (region.contains(BukkitUtil.toVector(ent.getLocation()))) {
|
if (region.contains(BukkitAdapter.asVector(ent.getLocation()))) {
|
||||||
entities.add(BukkitAdapter.adapt(ent));
|
entities.add(BukkitAdapter.adapt(ent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
public List<com.sk89q.worldedit.entity.Entity> getEntities() {
|
||||||
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<com.sk89q.worldedit.entity.Entity>();
|
List<com.sk89q.worldedit.entity.Entity> list = new ArrayList<>();
|
||||||
for (Entity entity : getWorld().getEntities()) {
|
for (Entity entity : getWorld().getEntities()) {
|
||||||
list.add(BukkitAdapter.adapt(entity));
|
list.add(BukkitAdapter.adapt(entity));
|
||||||
}
|
}
|
||||||
@ -111,12 +111,21 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
|
try {
|
||||||
Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity);
|
Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity);
|
||||||
if (createdEntity != null) {
|
if (createdEntity != null) {
|
||||||
return new BukkitEntity(createdEntity);
|
return new BukkitEntity(createdEntity);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warning("Corrupt entity found when creating: " + entity.getType().getId());
|
||||||
|
if (entity.getNbtData() != null) {
|
||||||
|
logger.warning(entity.getNbtData().toString());
|
||||||
|
}
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -156,7 +165,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean regenerate(Region region, EditSession editSession) {
|
public boolean regenerate(Region region, EditSession editSession) {
|
||||||
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];
|
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
|
||||||
|
|
||||||
for (Vector2D chunk : region.getChunks()) {
|
for (Vector2D chunk : region.getChunks()) {
|
||||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
||||||
@ -167,7 +176,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
for (int z = 0; z < 16; ++z) {
|
for (int z = 0; z < 16; ++z) {
|
||||||
Vector pt = min.add(x, y, z);
|
Vector pt = min.add(x, y, z);
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
int index = y * 16 * 16 + z * 16 + x;
|
||||||
history[index] = editSession.getBlock(pt);
|
history[index] = editSession.getFullBlock(pt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,8 +198,7 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
if (!region.contains(pt)) {
|
if (!region.contains(pt)) {
|
||||||
editSession.smartSetBlock(pt, history[index]);
|
editSession.smartSetBlock(pt, history[index]);
|
||||||
} else { // Otherwise fool with history
|
} else { // Otherwise fool with history
|
||||||
editSession.rememberChange(pt, history[index],
|
editSession.getChangeSet().add(new BlockChange(pt.toBlockVector(), history[index], editSession.getFullBlock(pt)));
|
||||||
editSession.rawGetBlock(pt));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,41 +256,11 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateBigTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.BIG_TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateBirchTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.BIRCH, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.TALL_REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
||||||
*/
|
*/
|
||||||
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
|
private static final EnumMap<TreeGenerator.TreeType, TreeType> treeTypeMapping =
|
||||||
new EnumMap<TreeGenerator.TreeType, TreeType>(TreeGenerator.TreeType.class);
|
new EnumMap<>(TreeGenerator.TreeType.class);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||||
@ -316,22 +294,14 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
TreeType bukkitType = toBukkitTreeType(type);
|
TreeType bukkitType = toBukkitTreeType(type);
|
||||||
return type != null && world.generateTree(BukkitUtil.toLocation(world, pt), bukkitType,
|
return type != null && world.generateTree(BukkitAdapter.adapt(world, pt), bukkitType,
|
||||||
new EditSessionBlockChangeDelegate(editSession));
|
new EditSessionBlockChangeDelegate(editSession));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, BaseItemStack item) {
|
public void dropItem(Vector pt, BaseItemStack item) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
ItemStack bukkitItem = new ItemStack(item.getType(), item.getAmount(),
|
world.dropItemNaturally(BukkitAdapter.adapt(world, pt), BukkitAdapter.adapt(item));
|
||||||
item.getData());
|
|
||||||
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), bukkitItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public boolean isValidBlockType(int type) {
|
|
||||||
return Material.getMaterial(type) != null && Material.getMaterial(type).isBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -383,14 +353,54 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
world.playEffect(BukkitUtil.toLocation(world, position), effect, data);
|
world.playEffect(BukkitAdapter.adapt(world, position), effect, data);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WorldData getWorldData() {
|
public WeatherType getWeather() {
|
||||||
return BukkitWorldData.getInstance();
|
if (getWorld().isThundering()) {
|
||||||
|
return WeatherTypes.THUNDER_STORM;
|
||||||
|
} else if (getWorld().hasStorm()) {
|
||||||
|
return WeatherTypes.RAIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WeatherTypes.CLEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getRemainingWeatherDuration() {
|
||||||
|
return getWorld().getWeatherDuration();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWeather(WeatherType weatherType) {
|
||||||
|
if (weatherType == WeatherTypes.THUNDER_STORM) {
|
||||||
|
getWorld().setThundering(true);
|
||||||
|
} else if (weatherType == WeatherTypes.RAIN) {
|
||||||
|
getWorld().setStorm(true);
|
||||||
|
} else {
|
||||||
|
getWorld().setStorm(false);
|
||||||
|
getWorld().setThundering(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setWeather(WeatherType weatherType, long duration) {
|
||||||
|
// Who named these methods...
|
||||||
|
if (weatherType == WeatherTypes.THUNDER_STORM) {
|
||||||
|
getWorld().setThundering(true);
|
||||||
|
getWorld().setThunderDuration((int) duration);
|
||||||
|
getWorld().setWeatherDuration((int) duration);
|
||||||
|
} else if (weatherType == WeatherTypes.RAIN) {
|
||||||
|
getWorld().setStorm(true);
|
||||||
|
getWorld().setWeatherDuration((int) duration);
|
||||||
|
} else {
|
||||||
|
getWorld().setStorm(false);
|
||||||
|
getWorld().setThundering(false);
|
||||||
|
getWorld().setWeatherDuration((int) duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -399,35 +409,44 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Vector position) {
|
public com.sk89q.worldedit.world.block.BlockState getBlock(Vector position) {
|
||||||
|
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
||||||
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
if (adapter != null) {
|
||||||
|
try {
|
||||||
|
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (block instanceof BaseBlock && ((BaseBlock) block).getNbtData() != null) {
|
||||||
|
logger.warning("Tried to set a corrupt tile entity at " + position.toString());
|
||||||
|
logger.warning(((BaseBlock) block).getNbtData().toString());
|
||||||
|
}
|
||||||
|
e.printStackTrace();
|
||||||
|
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
bukkitBlock.setBlockData(BukkitAdapter.adapt(block), notifyAndLight);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
|
bukkitBlock.setBlockData(BukkitAdapter.adapt(block), notifyAndLight);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(Vector position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position));
|
||||||
} else {
|
} else {
|
||||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
return getBlock(position).toBaseBlock();
|
||||||
return new BaseBlock(bukkitBlock.getTypeId(), bukkitBlock.getData());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
|
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
|
||||||
if (adapter != null) {
|
|
||||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
|
||||||
} else {
|
|
||||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
|
||||||
return bukkitBlock.setTypeIdAndData(block.getType(), (byte) block.getData(), notifyAndLight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
|
||||||
public BaseBlock getLazyBlock(Vector position) {
|
|
||||||
World world = getWorld();
|
|
||||||
Block bukkitBlock = world.getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
|
||||||
return new LazyBlock(bukkitBlock.getTypeId(), bukkitBlock.getData(), this, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBiome getBiome(Vector2D position) {
|
public BaseBiome getBiome(Vector2D position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
@ -450,12 +469,4 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setBlock(Vector, BaseBlock, boolean)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public boolean setBlock(Vector pt, com.sk89q.worldedit.foundation.Block block, boolean notifyAdjacent) throws WorldEditException {
|
|
||||||
return setBlock(pt, (BaseBlock) block, notifyAdjacent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
import org.bukkit.BlockChangeDelegate;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
import org.bukkit.BlockChangeDelegate;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proxy class to catch calls to set blocks.
|
* Proxy class to catch calls to set blocks.
|
||||||
@ -38,36 +38,18 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setRawTypeId(int x, int y, int z, int typeId) {
|
public boolean setBlockData(int x, int y, int z, BlockData blockData) {
|
||||||
try {
|
try {
|
||||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId));
|
editSession.setBlock(new Vector(x, y, z), BukkitAdapter.adapt(blockData));
|
||||||
} catch (MaxChangedBlocksException ex) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setRawTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
public BlockData getBlockData(int x, int y, int z) {
|
||||||
try {
|
return BukkitAdapter.adapt(editSession.getBlock(new Vector(x, y, z)));
|
||||||
return editSession.setBlock(new Vector(x, y, z), new BaseBlock(typeId, data));
|
|
||||||
} catch (MaxChangedBlocksException ex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setTypeId(int x, int y, int z, int typeId) {
|
|
||||||
return setRawTypeId(x, y, z, typeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setTypeIdAndData(int x, int y, int z, int typeId, int data) {
|
|
||||||
return setRawTypeIdAndData(x, y, z, typeId, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTypeId(int x, int y, int z) {
|
|
||||||
return editSession.getBlockType(new Vector(x, y, z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,7 +59,7 @@ public class EditSessionBlockChangeDelegate implements BlockChangeDelegate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty(int x, int y, int z) {
|
public boolean isEmpty(int x, int y, int z) {
|
||||||
return editSession.getBlockType(new Vector(x, y, z)) == BlockID.AIR;
|
return editSession.getBlock(new Vector(x, y, z)).getBlockType() == BlockTypes.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,9 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.internal.LocalWorldAdapter;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Event.Result;
|
import org.bukkit.event.Event.Result;
|
||||||
@ -67,7 +66,7 @@ public class WorldEditListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this will automatically refresh their session, we don't have to do anything
|
// this will automatically refresh their session, we don't have to do anything
|
||||||
WorldEdit.getInstance().getSession(plugin.wrapPlayer(event.getPlayer()));
|
WorldEdit.getInstance().getSessionManager().get(plugin.wrapPlayer(event.getPlayer()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,18 +119,17 @@ public class WorldEditListener implements Listener {
|
|||||||
return; // TODO api needs to be able to get either hand depending on event
|
return; // TODO api needs to be able to get either hand depending on event
|
||||||
// for now just ignore all off hand interacts
|
// for now just ignore all off hand interacts
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodError ignored) {
|
} catch (NoSuchMethodError | NoSuchFieldError ignored) {
|
||||||
} catch (NoSuchFieldError ignored) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
final Player player = plugin.wrapPlayer(event.getPlayer());
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
final WorldEdit we = plugin.getWorldEdit();
|
final WorldEdit we = plugin.getWorldEdit();
|
||||||
|
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
if (action == Action.LEFT_CLICK_BLOCK) {
|
if (action == Action.LEFT_CLICK_BLOCK) {
|
||||||
final Block clickedBlock = event.getClickedBlock();
|
final Block clickedBlock = event.getClickedBlock();
|
||||||
final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
|
final Location pos = new Location(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
|
||||||
|
|
||||||
if (we.handleBlockLeftClick(player, pos)) {
|
if (we.handleBlockLeftClick(player, pos)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -150,8 +148,7 @@ public class WorldEditListener implements Listener {
|
|||||||
|
|
||||||
} else if (action == Action.RIGHT_CLICK_BLOCK) {
|
} else if (action == Action.RIGHT_CLICK_BLOCK) {
|
||||||
final Block clickedBlock = event.getClickedBlock();
|
final Block clickedBlock = event.getClickedBlock();
|
||||||
final WorldVector pos = new WorldVector(LocalWorldAdapter.adapt(world), clickedBlock.getX(),
|
final Location pos = new Location(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ());
|
||||||
clickedBlock.getY(), clickedBlock.getZ());
|
|
||||||
|
|
||||||
if (we.handleBlockRightClick(player, pos)) {
|
if (we.handleBlockRightClick(player, pos)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -19,23 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
import com.sk89q.wepif.PermissionsResolverManager;
|
import com.sk89q.wepif.PermissionsResolverManager;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.IncompleteRegionException;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditOperation;
|
|
||||||
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
|
import com.sk89q.worldedit.bukkit.adapter.AdapterLoadException;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
|
||||||
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
import com.sk89q.worldedit.bukkit.adapter.BukkitImplLoader;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CylinderSelection;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
|
||||||
import com.sk89q.worldedit.event.platform.CommandEvent;
|
import com.sk89q.worldedit.event.platform.CommandEvent;
|
||||||
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
import com.sk89q.worldedit.event.platform.CommandSuggestionEvent;
|
||||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||||
@ -43,21 +37,12 @@ import com.sk89q.worldedit.extension.platform.Actor;
|
|||||||
import com.sk89q.worldedit.extension.platform.Capability;
|
import com.sk89q.worldedit.extension.platform.Capability;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
|
||||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
import com.sk89q.worldedit.util.Java8Detector;
|
|
||||||
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -69,21 +54,19 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for Bukkit.
|
* Plugin for Bukkit.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName());
|
private static final Logger log = Logger.getLogger(WorldEditPlugin.class.getCanonicalName());
|
||||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
public static final String CUI_PLUGIN_CHANNEL = "worldedit:cui";
|
||||||
private static WorldEditPlugin INSTANCE;
|
private static WorldEditPlugin INSTANCE;
|
||||||
|
|
||||||
private BukkitImplAdapter bukkitAdapter;
|
private BukkitImplAdapter bukkitAdapter;
|
||||||
private BukkitServerInterface server;
|
private BukkitServerInterface server;
|
||||||
private final WorldEditAPI api = new WorldEditAPI(this);
|
|
||||||
private BukkitConfiguration config;
|
private BukkitConfiguration config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,12 +82,15 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
|
|
||||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
|
|
||||||
loadConfig(); // Load configuration
|
loadAdapter(); // Need an adapter to work with special blocks with NBT data
|
||||||
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
|
||||||
|
|
||||||
// Setup platform
|
// Setup platform
|
||||||
server = new BukkitServerInterface(this, getServer());
|
server = new BukkitServerInterface(this, getServer());
|
||||||
worldEdit.getPlatformManager().register(server);
|
worldEdit.getPlatformManager().register(server);
|
||||||
|
worldEdit.loadMappings();
|
||||||
|
|
||||||
|
loadConfig(); // Load configuration
|
||||||
|
PermissionsResolverManager.initialize(this); // Setup permission resolver
|
||||||
|
|
||||||
// Register CUI
|
// Register CUI
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this));
|
||||||
@ -117,11 +103,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
// Forge WorldEdit and there's (probably) not going to be any other
|
// Forge WorldEdit and there's (probably) not going to be any other
|
||||||
// platforms to be worried about... at the current time of writing
|
// platforms to be worried about... at the current time of writing
|
||||||
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent());
|
||||||
|
|
||||||
loadAdapter(); // Need an adapter to work with special blocks with NBT data
|
|
||||||
|
|
||||||
// Check Java version
|
|
||||||
Java8Detector.notifyIfNot8();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadConfig() {
|
private void loadConfig() {
|
||||||
@ -169,7 +150,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
WorldEdit worldEdit = WorldEdit.getInstance();
|
WorldEdit worldEdit = WorldEdit.getInstance();
|
||||||
worldEdit.clearSessions();
|
worldEdit.getSessionManager().clear();
|
||||||
worldEdit.getPlatformManager().unregister(server);
|
worldEdit.getPlatformManager().unregister(server);
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
config.unload();
|
config.unload();
|
||||||
@ -269,7 +250,7 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
* @return a session
|
* @return a session
|
||||||
*/
|
*/
|
||||||
public LocalSession getSession(Player player) {
|
public LocalSession getSession(Player player) {
|
||||||
return WorldEdit.getInstance().getSession(wrapPlayer(player));
|
return WorldEdit.getInstance().getSessionManager().get(wrapPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,8 +260,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
* @return a session
|
* @return a session
|
||||||
*/
|
*/
|
||||||
public EditSession createEditSession(Player player) {
|
public EditSession createEditSession(Player player) {
|
||||||
LocalPlayer wePlayer = wrapPlayer(player);
|
com.sk89q.worldedit.entity.Player wePlayer = wrapPlayer(player);
|
||||||
LocalSession session = WorldEdit.getInstance().getSession(wePlayer);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
|
||||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||||
|
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory()
|
||||||
@ -297,8 +278,8 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
* @param editSession an edit session
|
* @param editSession an edit session
|
||||||
*/
|
*/
|
||||||
public void remember(Player player, EditSession editSession) {
|
public void remember(Player player, EditSession editSession) {
|
||||||
LocalPlayer wePlayer = wrapPlayer(player);
|
com.sk89q.worldedit.entity.Player wePlayer = wrapPlayer(player);
|
||||||
LocalSession session = WorldEdit.getInstance().getSession(wePlayer);
|
LocalSession session = WorldEdit.getInstance().getSessionManager().get(wePlayer);
|
||||||
|
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
editSession.flushQueue();
|
editSession.flushQueue();
|
||||||
@ -306,38 +287,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
WorldEdit.getInstance().flushBlockBag(wePlayer, editSession);
|
WorldEdit.getInstance().flushBlockBag(wePlayer, editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrap an operation into an EditSession.
|
|
||||||
*
|
|
||||||
* @param player a player
|
|
||||||
* @param op the operation
|
|
||||||
* @throws Throwable on any error
|
|
||||||
* @deprecated use the regular API
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void perform(Player player, WorldEditOperation op) throws Throwable {
|
|
||||||
LocalPlayer wePlayer = wrapPlayer(player);
|
|
||||||
LocalSession session = WorldEdit.getInstance().getSession(wePlayer);
|
|
||||||
|
|
||||||
EditSession editSession = createEditSession(player);
|
|
||||||
try {
|
|
||||||
op.run(session, wePlayer, editSession);
|
|
||||||
} finally {
|
|
||||||
remember(player, editSession);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the API.
|
|
||||||
*
|
|
||||||
* @return the API
|
|
||||||
* @deprecated use the regular API
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public WorldEditAPI getAPI() {
|
|
||||||
return api;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the configuration used by WorldEdit.
|
* Returns the configuration used by WorldEdit.
|
||||||
*
|
*
|
||||||
@ -357,13 +306,13 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
* Used to wrap a Bukkit Player as a WorldEdit Player.
|
||||||
*
|
*
|
||||||
* @param player a player
|
* @param player a player
|
||||||
* @return a wrapped player
|
* @return a wrapped player
|
||||||
*/
|
*/
|
||||||
public BukkitPlayer wrapPlayer(Player player) {
|
public BukkitPlayer wrapPlayer(Player player) {
|
||||||
return new BukkitPlayer(this, this.server, player);
|
return new BukkitPlayer(this, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Actor wrapCommandSender(CommandSender sender) {
|
public Actor wrapCommandSender(CommandSender sender) {
|
||||||
@ -374,15 +323,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
return new BukkitCommandSender(this, sender);
|
return new BukkitCommandSender(this, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the server interface.
|
|
||||||
*
|
|
||||||
* @return the server interface
|
|
||||||
*/
|
|
||||||
public ServerInterface getServerInterface() {
|
|
||||||
return server;
|
|
||||||
}
|
|
||||||
|
|
||||||
BukkitServerInterface getInternalPlatform() {
|
BukkitServerInterface getInternalPlatform() {
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
@ -396,64 +336,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter {
|
|||||||
return WorldEdit.getInstance();
|
return WorldEdit.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the region selection for the player.
|
|
||||||
*
|
|
||||||
* @param player aplayer
|
|
||||||
* @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 = WorldEdit.getInstance().getSession(wrapPlayer(player));
|
|
||||||
RegionSelector selector = session.getRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()));
|
|
||||||
|
|
||||||
try {
|
|
||||||
Region region = selector.getRegion();
|
|
||||||
World world = BukkitAdapter.asBukkitWorld(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 if (region instanceof CylinderRegion) {
|
|
||||||
return new CylinderSelection(world, selector, (CylinderRegion) region);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} catch (IncompleteRegionException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the region selection for a player.
|
|
||||||
*
|
|
||||||
* @param player the player
|
|
||||||
* @param selection a 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 = WorldEdit.getInstance().getSession(wrapPlayer(player));
|
|
||||||
RegionSelector sel = selection.getRegionSelector();
|
|
||||||
session.setRegionSelector(BukkitUtil.getLocalWorld(player.getWorld()), sel);
|
|
||||||
session.dispatchCUISelection(wrapPlayer(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the instance of this plugin.
|
* Gets the instance of this plugin.
|
||||||
*
|
*
|
||||||
|
@ -19,13 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.bukkit.adapter;
|
package com.sk89q.worldedit.bukkit.adapter;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.registry.state.Property;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,26 +37,6 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public interface BukkitImplAdapter {
|
public interface BukkitImplAdapter {
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block ID for the given material.
|
|
||||||
*
|
|
||||||
* <p>Returns 0 if it is not known or it doesn't exist.</p>
|
|
||||||
*
|
|
||||||
* @param material the material
|
|
||||||
* @return the block ID
|
|
||||||
*/
|
|
||||||
int getBlockId(Material material);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the material for the given block ID.
|
|
||||||
*
|
|
||||||
* <p>Returns {@link Material#AIR} if it is not known or it doesn't exist.</p>
|
|
||||||
*
|
|
||||||
* @param id the block ID
|
|
||||||
* @return the material
|
|
||||||
*/
|
|
||||||
Material getMaterial(int id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the biome ID for the given biome.
|
* Get the biome ID for the given biome.
|
||||||
*
|
*
|
||||||
@ -89,7 +73,7 @@ public interface BukkitImplAdapter {
|
|||||||
* @param notifyAndLight notify and light if set
|
* @param notifyAndLight notify and light if set
|
||||||
* @return true if a block was likely changed
|
* @return true if a block was likely changed
|
||||||
*/
|
*/
|
||||||
boolean setBlock(Location location, BaseBlock state, boolean notifyAndLight);
|
boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the state for the given entity.
|
* Get the state for the given entity.
|
||||||
@ -110,5 +94,11 @@ public interface BukkitImplAdapter {
|
|||||||
@Nullable
|
@Nullable
|
||||||
Entity createEntity(Location location, BaseEntity state);
|
Entity createEntity(Location location, BaseEntity state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a map of string -> properties
|
||||||
|
*
|
||||||
|
* @param blockType The block type
|
||||||
|
* @return The properties map
|
||||||
|
*/
|
||||||
|
Map<String, ? extends Property> getProperties(BlockType blockType);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ import java.util.logging.Logger;
|
|||||||
public class BukkitImplLoader {
|
public class BukkitImplLoader {
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(BukkitImplLoader.class.getCanonicalName());
|
private static final Logger log = Logger.getLogger(BukkitImplLoader.class.getCanonicalName());
|
||||||
private final List<String> adapterCandidates = new ArrayList<String>();
|
private final List<String> adapterCandidates = new ArrayList<>();
|
||||||
private String customCandidate;
|
private String customCandidate;
|
||||||
|
|
||||||
private static final String SEARCH_PACKAGE = "com.sk89q.worldedit.bukkit.adapter.impl";
|
private static final String SEARCH_PACKAGE = "com.sk89q.worldedit.bukkit.adapter.impl";
|
||||||
|
@ -1,49 +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.bukkit.entity;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Location;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class BukkitExpOrb extends BukkitEntity {
|
|
||||||
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
public BukkitExpOrb(Location loc, UUID entityId, int amount) {
|
|
||||||
super(loc, EntityType.EXPERIENCE_ORB, entityId);
|
|
||||||
this.amount = amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean spawn(Location weLoc) {
|
|
||||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
|
||||||
ExperienceOrb orb = loc.getWorld().spawn(loc, ExperienceOrb.class);
|
|
||||||
if (orb != null) {
|
|
||||||
orb.setExperience(amount);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,110 +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.bukkit.entity;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Location;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|
||||||
import org.bukkit.Art;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Painting;
|
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class BukkitPainting extends BukkitEntity {
|
|
||||||
|
|
||||||
private static final Logger log = Logger.getLogger(BukkitPainting.class.getCanonicalName());
|
|
||||||
|
|
||||||
private static int spawnTask = -1;
|
|
||||||
private static final Deque<QueuedPaintingSpawn> spawnQueue = new ArrayDeque<QueuedPaintingSpawn>();
|
|
||||||
|
|
||||||
private class QueuedPaintingSpawn {
|
|
||||||
private final Location weLoc;
|
|
||||||
|
|
||||||
private QueuedPaintingSpawn(Location weLoc) {
|
|
||||||
this.weLoc = weLoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void spawn() {
|
|
||||||
spawnRaw(weLoc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class PaintingSpawnRunnable implements Runnable {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
synchronized (spawnQueue) {
|
|
||||||
QueuedPaintingSpawn spawn;
|
|
||||||
while ((spawn = spawnQueue.poll()) != null) {
|
|
||||||
try {
|
|
||||||
spawn.spawn();
|
|
||||||
} catch (Throwable t) {
|
|
||||||
log.log(Level.WARNING, "Failed to spawn painting", t);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
spawnTask = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Art art;
|
|
||||||
private final BlockFace facingDirection;
|
|
||||||
public BukkitPainting(Location loc, Art art, BlockFace facingDirection, UUID entityId) {
|
|
||||||
super(loc, EntityType.PAINTING, entityId);
|
|
||||||
this.art = art;
|
|
||||||
this.facingDirection = facingDirection;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queue the painting to be spawned at the specified location.
|
|
||||||
* This operation is delayed so that the block changes that may be applied can be applied before the painting spawn is attempted.
|
|
||||||
*
|
|
||||||
* @param weLoc The WorldEdit location
|
|
||||||
* @return Whether the spawn as successful
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean spawn(Location weLoc) {
|
|
||||||
synchronized (spawnQueue) {
|
|
||||||
spawnQueue.add(new QueuedPaintingSpawn(weLoc));
|
|
||||||
if (spawnTask == -1) {
|
|
||||||
spawnTask = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("WorldEdit"), new PaintingSpawnRunnable(), 1L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean spawnRaw(Location weLoc) {
|
|
||||||
org.bukkit.Location loc = BukkitUtil.toLocation(weLoc);
|
|
||||||
Painting paint = loc.getWorld().spawn(loc, Painting.class);
|
|
||||||
if (paint != null) {
|
|
||||||
paint.setFacingDirection(facingDirection, true);
|
|
||||||
paint.setArt(art, true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,70 +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.bukkit.selections;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.limit.PermissiveSelectorLimits;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
public class CuboidSelection extends RegionSelection {
|
|
||||||
|
|
||||||
protected CuboidRegion cuboid;
|
|
||||||
|
|
||||||
public CuboidSelection(World world, Location pt1, Location pt2) {
|
|
||||||
this(world, BukkitUtil.toVector(pt1), BukkitUtil.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(BukkitUtil.getLocalWorld(world));
|
|
||||||
|
|
||||||
// set up selector
|
|
||||||
sel.selectPrimary(pt1, PermissiveSelectorLimits.getInstance());
|
|
||||||
sel.selectSecondary(pt2, PermissiveSelectorLimits.getInstance());
|
|
||||||
|
|
||||||
// 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,80 +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.bukkit.selections;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|
||||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A selection representing a {@link CylinderRegion}
|
|
||||||
*/
|
|
||||||
public class CylinderSelection extends RegionSelection {
|
|
||||||
|
|
||||||
private CylinderRegion cylRegion;
|
|
||||||
|
|
||||||
public CylinderSelection(World world, RegionSelector selector, CylinderRegion region) {
|
|
||||||
super(world, selector, region);
|
|
||||||
this.cylRegion = region;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CylinderSelection(World world, BlockVector2D center, BlockVector2D radius, int minY, int maxY) {
|
|
||||||
super(world);
|
|
||||||
LocalWorld lWorld = BukkitUtil.getLocalWorld(world);
|
|
||||||
|
|
||||||
// Validate input
|
|
||||||
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
|
|
||||||
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
|
|
||||||
|
|
||||||
// Create and set up new selector
|
|
||||||
CylinderRegionSelector sel = new CylinderRegionSelector(lWorld, center, radius, minY, maxY);
|
|
||||||
|
|
||||||
// set up selection
|
|
||||||
cylRegion = sel.getIncompleteRegion();
|
|
||||||
|
|
||||||
// set up RegionSelection
|
|
||||||
setRegionSelector(sel);
|
|
||||||
setRegion(cylRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the center vector of the cylinder
|
|
||||||
*
|
|
||||||
* @return the center
|
|
||||||
*/
|
|
||||||
public BlockVector2D getCenter() {
|
|
||||||
return cylRegion.getCenter().toVector2D().toBlockVector2D();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the radius vector of the cylinder
|
|
||||||
*
|
|
||||||
* @return the radius
|
|
||||||
*/
|
|
||||||
public BlockVector2D getRadius() {
|
|
||||||
return cylRegion.getRadius().toBlockVector2D();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +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.bukkit.selections;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
|
||||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitUtil;
|
|
||||||
import com.sk89q.worldedit.regions.*;
|
|
||||||
|
|
||||||
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 = BukkitUtil.getLocalWorld(world);
|
|
||||||
|
|
||||||
// Validate input
|
|
||||||
minY = Math.min(Math.max(0, minY), world.getMaxHeight());
|
|
||||||
maxY = Math.min(Math.max(0, maxY), world.getMaxHeight());
|
|
||||||
|
|
||||||
// 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,118 +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.bukkit.selections;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
|
|
||||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toLocation;
|
|
||||||
import static com.sk89q.worldedit.bukkit.BukkitUtil.toVector;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RegionSelector getRegionSelector() {
|
|
||||||
return selector;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setRegionSelector(RegionSelector selector) {
|
|
||||||
this.selector = selector;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getMinimumPoint() {
|
|
||||||
return toLocation(world, region.getMinimumPoint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector getNativeMinimumPoint() {
|
|
||||||
return region.getMinimumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getMaximumPoint() {
|
|
||||||
return toLocation(world, region.getMaximumPoint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector getNativeMaximumPoint() {
|
|
||||||
return region.getMaximumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public World getWorld() {
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getArea() {
|
|
||||||
return region.getArea();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getWidth() {
|
|
||||||
return region.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getHeight() {
|
|
||||||
return region.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLength() {
|
|
||||||
return region.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Location position) {
|
|
||||||
if (!position.getWorld().equals(world)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return region.contains(toVector(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,113 +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.bukkit.selections;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An abstraction of WorldEdit regions, which do not use Bukkit objects.
|
|
||||||
*/
|
|
||||||
public interface Selection {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the lower point of a region.
|
|
||||||
*
|
|
||||||
* @return min. point
|
|
||||||
*/
|
|
||||||
public Location 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 Location getMaximumPoint();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the upper point of a region.
|
|
||||||
*
|
|
||||||
* @return max. point
|
|
||||||
*/
|
|
||||||
public Vector getNativeMaximumPoint();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the region selector. This is for internal use.
|
|
||||||
*
|
|
||||||
* @return the region selector
|
|
||||||
*/
|
|
||||||
public RegionSelector getRegionSelector();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the world.
|
|
||||||
*
|
|
||||||
* @return the world, which may be null
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
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 position a vector
|
|
||||||
* @return true if it is contained
|
|
||||||
*/
|
|
||||||
public boolean contains(Location position);
|
|
||||||
|
|
||||||
}
|
|
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
@ -1,18 +1,19 @@
|
|||||||
#
|
#
|
||||||
# WorldEdit's configuration file
|
# WorldEdit's Configuration File
|
||||||
#
|
#
|
||||||
# About editing this file:
|
# About editing this file:
|
||||||
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If
|
# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain and post
|
||||||
# you use an editor like Notepad++ (recommended for Windows users), you
|
# errors. If you use an editor, like Notepad++ (recommended for Windows
|
||||||
# must configure it to "replace tabs with spaces." In Notepad++, this can
|
# users), you must configure it to "replace tabs with spaces."
|
||||||
# be changed in Settings > Preferences > Language Menu.
|
# This can be changed in Settings > Preferences > Language Menu.
|
||||||
# - Don't get rid of the indents. They are indented so some entries are
|
# - Don't get rid of indentations. They are indented so some entries that are
|
||||||
# in categories (like "max-blocks-changed" is in the "limits"
|
# in categories, like "max-blocks-changed", are placed in the "limits"
|
||||||
# category.
|
# category.
|
||||||
# - If you want to check the format of this file before putting it
|
# - If you want to check the format of this file before putting it
|
||||||
# into WorldEdit, paste it into http://yaml-online-parser.appspot.com/
|
# into WorldEdit, paste it into http://yaml-online-parser.appspot.com/
|
||||||
# and see if it gives "ERROR:".
|
# and see if it gives you "ERROR:".
|
||||||
# - Lines starting with # are commentsand so they are ignored.
|
# - Lines starting with # are comments, so they are ignored.
|
||||||
|
# - If you want to allow blocks, make sure to change "disallowed-blocks" to []
|
||||||
#
|
#
|
||||||
|
|
||||||
limits:
|
limits:
|
||||||
@ -29,7 +30,67 @@ limits:
|
|||||||
butcher-radius:
|
butcher-radius:
|
||||||
default: -1
|
default: -1
|
||||||
maximum: -1
|
maximum: -1
|
||||||
disallowed-blocks: [6, 7, 14, 15, 16, 26, 27, 28, 29, 39, 31, 32, 33, 34, 36, 37, 38, 39, 40, 46, 50, 51, 56, 59, 69, 73, 74, 75, 76, 77, 81, 83]
|
disallowed-blocks:
|
||||||
|
- "minecraft:oak_sapling"
|
||||||
|
- "minecraft:jungle_sapling"
|
||||||
|
- "minecraft:dark_oak_sapling:"
|
||||||
|
- "minecraft:spruce_sapling"
|
||||||
|
- "minecraft:birch_sapling"
|
||||||
|
- "minecraft:acacia_sapling"
|
||||||
|
- "minecraft:black_bed"
|
||||||
|
- "minecraft:blue_bed"
|
||||||
|
- "minecraft:brown_bed"
|
||||||
|
- "minecraft:cyan_bed"
|
||||||
|
- "minecraft:gray_bed"
|
||||||
|
- "minecraft:green_bed"
|
||||||
|
- "minecraft:light_blue_bed"
|
||||||
|
- "minecraft:light_gray_bed"
|
||||||
|
- "minecraft:lime_bed"
|
||||||
|
- "minecraft:magenta_bed"
|
||||||
|
- "minecraft:orange_bed"
|
||||||
|
- "minecraft:pink_bed"
|
||||||
|
- "minecraft:purple_bed"
|
||||||
|
- "minecraft:red_bed"
|
||||||
|
- "minecraft:white_bed"
|
||||||
|
- "minecraft:yellow_bed"
|
||||||
|
- "minecraft:powered_rail"
|
||||||
|
- "minecraft:detector_rail"
|
||||||
|
- "minecraft:grass"
|
||||||
|
- "minecraft:dead_bush"
|
||||||
|
- "minecraft:moving_piston"
|
||||||
|
- "minecraft:piston_head"
|
||||||
|
- "minecraft:sunflower"
|
||||||
|
- "minecraft:rose_bush"
|
||||||
|
- "minecraft:dandelion"
|
||||||
|
- "minecraft:poppy"
|
||||||
|
- "minecraft:brown_mushroom"
|
||||||
|
- "minecraft:red_mushroom"
|
||||||
|
- "minecraft:tnt"
|
||||||
|
- "minecraft:torch"
|
||||||
|
- "minecraft:fire"
|
||||||
|
- "minecraft:redstone_wire"
|
||||||
|
- "minecraft:wheat"
|
||||||
|
- "minecraft:potatoes"
|
||||||
|
- "minecraft:carrots"
|
||||||
|
- "minecraft:melon_stem"
|
||||||
|
- "minecraft:pumpkin_stem"
|
||||||
|
- "minecraft:beetroots"
|
||||||
|
- "minecraft:rail"
|
||||||
|
- "minecraft:lever"
|
||||||
|
- "minecraft:redstone_torch"
|
||||||
|
- "minecraft:redstone_wall_torch"
|
||||||
|
- "minecraft:repeater"
|
||||||
|
- "minecraft:comparator"
|
||||||
|
- "minecraft:stone_button"
|
||||||
|
- "minecraft:birch_button"
|
||||||
|
- "minecraft:acacia_button"
|
||||||
|
- "minecraft:dark_oak_button"
|
||||||
|
- "minecraft:jungle_button"
|
||||||
|
- "minecraft:oak_button"
|
||||||
|
- "minecraft:spruce_button"
|
||||||
|
- "minecraft:cactus"
|
||||||
|
- "minecraft:sugar_cane"
|
||||||
|
- "minecraft:bedrock"
|
||||||
|
|
||||||
use-inventory:
|
use-inventory:
|
||||||
enable: false
|
enable: false
|
||||||
@ -39,6 +100,17 @@ use-inventory:
|
|||||||
logging:
|
logging:
|
||||||
log-commands: false
|
log-commands: false
|
||||||
file: worldedit.log
|
file: worldedit.log
|
||||||
|
# The format of custom log message. This is java general format string (java.util.Formatter). Arguments are:
|
||||||
|
# 1$ : date - a Date object representing event time of the log record.
|
||||||
|
# 2$ : source - a string representing the caller, if available; otherwise, the logger's name.
|
||||||
|
# 3$ : logger - the logger's name.
|
||||||
|
# 4$ : level - the log level.
|
||||||
|
# 5$ : message - the formatted log message returned from the Formatter.formatMessage(LogRecord) method. It uses java.text formatting and does not use the java.util.Formatter format argument.
|
||||||
|
# 6$ : thrown - a string representing the throwable associated with the log record and its backtrace beginning with a newline character, if any; otherwise, an empty string.
|
||||||
|
# For details see:
|
||||||
|
# https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
|
||||||
|
# https://docs.oracle.com/javase/8/docs/api/java/util/logging/SimpleFormatter.html#format-java.util.logging.LogRecord-
|
||||||
|
format: "[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s]: %5$s%6$s%n"
|
||||||
|
|
||||||
super-pickaxe:
|
super-pickaxe:
|
||||||
drop-items: true
|
drop-items: true
|
||||||
@ -48,7 +120,7 @@ snapshots:
|
|||||||
directory:
|
directory:
|
||||||
|
|
||||||
navigation-wand:
|
navigation-wand:
|
||||||
item: 345
|
item: minecraft:compass
|
||||||
max-distance: 100
|
max-distance: 100
|
||||||
|
|
||||||
scripting:
|
scripting:
|
||||||
@ -65,7 +137,7 @@ history:
|
|||||||
size: 15
|
size: 15
|
||||||
expiration: 10
|
expiration: 10
|
||||||
|
|
||||||
wand-item: 271
|
wand-item: minecraft:wooden_axe
|
||||||
shell-save-type:
|
shell-save-type:
|
||||||
no-double-slash: false
|
no-double-slash: false
|
||||||
no-op-permissions: false
|
no-op-permissions: false
|
||||||
|
@ -2,6 +2,7 @@ name: WorldEdit
|
|||||||
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
|
||||||
version: "${internalVersion}"
|
version: "${internalVersion}"
|
||||||
softdepend: [Spout] #hack to fix trove errors
|
softdepend: [Spout] #hack to fix trove errors
|
||||||
|
api-version: 1.13
|
||||||
|
|
||||||
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms
|
||||||
# for how WorldEdit permissions actually work.
|
# for how WorldEdit permissions actually work.
|
||||||
|
@ -19,13 +19,15 @@
|
|||||||
|
|
||||||
package com.sk89q.wepif;
|
package com.sk89q.wepif;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
public class DinnerPermsResolverTest {
|
public class DinnerPermsResolverTest {
|
||||||
private DinnerPermsResolver resolver;
|
private DinnerPermsResolver resolver;
|
||||||
|
@ -28,13 +28,17 @@ import org.bukkit.permissions.PermissionAttachment;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
||||||
private boolean op;
|
private boolean op;
|
||||||
private UUID randomUuid = UUID.randomUUID();
|
private UUID randomUuid = UUID.randomUUID();
|
||||||
|
|
||||||
private final Map<String, Boolean> assignedPermissions = new HashMap<String, Boolean>();
|
private final Map<String, Boolean> assignedPermissions = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOp() {
|
public boolean isOp() {
|
||||||
@ -101,7 +105,7 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||||
Set<PermissionAttachmentInfo> ret = new HashSet<PermissionAttachmentInfo>();
|
Set<PermissionAttachmentInfo> ret = new HashSet<>();
|
||||||
for (Map.Entry<String, Boolean> entry : assignedPermissions.entrySet()) {
|
for (Map.Entry<String, Boolean> entry : assignedPermissions.entrySet()) {
|
||||||
ret.add(new PermissionAttachmentInfo(this, entry.getKey(), null, entry.getValue()));
|
ret.add(new PermissionAttachmentInfo(this, entry.getKey(), null, entry.getValue()));
|
||||||
}
|
}
|
||||||
@ -141,11 +145,6 @@ public class TestOfflinePermissible implements OfflinePlayer, Permissible {
|
|||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setBanned(boolean b) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isWhitelisted() {
|
public boolean isWhitelisted() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
@ -28,7 +28,7 @@ public class BukkitWorldTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testTreeTypeMapping() {
|
public void testTreeTypeMapping() {
|
||||||
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
for (TreeGenerator.TreeType type : TreeGenerator.TreeType.values()) {
|
||||||
Assert.assertFalse("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type) == null);
|
Assert.assertNotNull("No mapping for: " + type, BukkitWorld.toBukkitTreeType(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@ dependencies {
|
|||||||
compile 'de.schlichtherle:truezip:6.8.3'
|
compile 'de.schlichtherle:truezip:6.8.3'
|
||||||
compile 'rhino:js:1.7R2'
|
compile 'rhino:js:1.7R2'
|
||||||
compile 'org.yaml:snakeyaml:1.9'
|
compile 'org.yaml:snakeyaml:1.9'
|
||||||
compile 'com.google.guava:guava:17.0'
|
compile 'com.google.guava:guava:21.0'
|
||||||
compile 'com.sk89q:jchronic:0.2.4a'
|
compile 'com.sk89q:jchronic:0.2.4a'
|
||||||
compile 'com.google.code.findbugs:jsr305:1.3.9'
|
compile 'com.google.code.findbugs:jsr305:1.3.9'
|
||||||
compile 'com.thoughtworks.paranamer:paranamer:2.6'
|
compile 'com.thoughtworks.paranamer:paranamer:2.6'
|
||||||
compile 'com.google.code.gson:gson:2.2.4'
|
compile 'com.google.code.gson:gson:2.8.0'
|
||||||
compile 'com.sk89q.lib:jlibnoise:1.0.0'
|
compile 'com.sk89q.lib:jlibnoise:1.0.0'
|
||||||
//compile 'net.sf.trove4j:trove4j:3.0.3'
|
//compile 'net.sf.trove4j:trove4j:3.0.3'
|
||||||
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
testCompile 'org.mockito:mockito-core:1.9.0-rc1'
|
||||||
|
@ -1,202 +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.bags;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldVector;
|
|
||||||
import com.sk89q.worldedit.blocks.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Block bags are currently not a supported feature of WorldEdit
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Deprecated
|
|
||||||
|
|
||||||
public abstract class BlockBag {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores a block as if it was mined.
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @throws BlockBagException thrown on a error
|
|
||||||
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void storeDroppedBlock(int id) throws BlockBagException {
|
|
||||||
storeDroppedBlock(id, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores a block as if it was mined.
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @param data the data value of the block
|
|
||||||
* @throws BlockBagException thrown on a error
|
|
||||||
*/
|
|
||||||
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
|
||||||
BaseItem dropped = BlockType.getBlockBagItem(id, data);
|
|
||||||
if (dropped == null) return;
|
|
||||||
if (dropped.getType() == BlockID.AIR) return;
|
|
||||||
|
|
||||||
storeItem(dropped);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a block as if it was placed by hand.
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @throws BlockBagException
|
|
||||||
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void fetchPlacedBlock(int id) throws BlockBagException {
|
|
||||||
fetchPlacedBlock(id, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a block as if it was placed by hand.
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @param data the data value of the block
|
|
||||||
* @throws BlockBagException
|
|
||||||
*/
|
|
||||||
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
|
||||||
try {
|
|
||||||
// Blocks that can't be fetched...
|
|
||||||
switch (id) {
|
|
||||||
case BlockID.BEDROCK:
|
|
||||||
case BlockID.GOLD_ORE:
|
|
||||||
case BlockID.IRON_ORE:
|
|
||||||
case BlockID.COAL_ORE:
|
|
||||||
case BlockID.DIAMOND_ORE:
|
|
||||||
case BlockID.TNT:
|
|
||||||
case BlockID.MOB_SPAWNER:
|
|
||||||
case BlockID.CROPS:
|
|
||||||
case BlockID.REDSTONE_ORE:
|
|
||||||
case BlockID.GLOWING_REDSTONE_ORE:
|
|
||||||
case BlockID.SNOW:
|
|
||||||
case BlockID.LIGHTSTONE:
|
|
||||||
case BlockID.PORTAL:
|
|
||||||
throw new UnplaceableBlockException();
|
|
||||||
|
|
||||||
case BlockID.WATER:
|
|
||||||
case BlockID.STATIONARY_WATER:
|
|
||||||
case BlockID.LAVA:
|
|
||||||
case BlockID.STATIONARY_LAVA:
|
|
||||||
// Override liquids
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
fetchBlock(id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (OutOfBlocksException e) {
|
|
||||||
BaseItem placed = BlockType.getBlockBagItem(id, data);
|
|
||||||
if (placed == null) throw e; // TODO: check
|
|
||||||
if (placed.getType() == BlockID.AIR) throw e; // TODO: check
|
|
||||||
|
|
||||||
fetchItem(placed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block.
|
|
||||||
*
|
|
||||||
* Either this method or fetchItem needs to be overridden
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @throws BlockBagException
|
|
||||||
*/
|
|
||||||
public void fetchBlock(int id) throws BlockBagException {
|
|
||||||
fetchItem(new BaseItem(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block.
|
|
||||||
*
|
|
||||||
* Either this method or fetchBlock needs to be overridden
|
|
||||||
*
|
|
||||||
* @param item the item
|
|
||||||
* @throws BlockBagException
|
|
||||||
*/
|
|
||||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
|
||||||
fetchBlock(item.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a block.
|
|
||||||
*
|
|
||||||
* Either this method or storeItem needs to be overridden
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @throws BlockBagException
|
|
||||||
*/
|
|
||||||
public void storeBlock(int id) throws BlockBagException {
|
|
||||||
storeItem(new BaseItem(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Store a block.
|
|
||||||
*
|
|
||||||
* Either this method or storeBlock needs to be overridden
|
|
||||||
*
|
|
||||||
* @param item the item
|
|
||||||
* @throws BlockBagException
|
|
||||||
*/
|
|
||||||
public void storeItem(BaseItem item) throws BlockBagException {
|
|
||||||
storeBlock(item.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks to see if a block exists without removing it.
|
|
||||||
*
|
|
||||||
* @param id the ID of the block
|
|
||||||
* @return whether the block exists
|
|
||||||
*/
|
|
||||||
public boolean peekBlock(int id) {
|
|
||||||
try {
|
|
||||||
fetchBlock(id);
|
|
||||||
storeBlock(id);
|
|
||||||
return true;
|
|
||||||
} catch (BlockBagException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flush any changes. This is called at the end.
|
|
||||||
*/
|
|
||||||
public abstract void flushChanges();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a position to be used a source.
|
|
||||||
*
|
|
||||||
* @param position the position of the source
|
|
||||||
*/
|
|
||||||
public abstract void addSourcePosition(WorldVector position);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a position to be used a source.
|
|
||||||
*
|
|
||||||
* @param position the position of the source
|
|
||||||
*/
|
|
||||||
public abstract void addSingleSourcePosition(WorldVector position);
|
|
||||||
|
|
||||||
}
|
|
@ -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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.world.DataException;
|
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a chest block.
|
|
||||||
*/
|
|
||||||
public class ChestBlock extends ContainerBlock {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty chest block with the default orientation (data value).
|
|
||||||
*/
|
|
||||||
public ChestBlock() {
|
|
||||||
super(BlockID.CHEST, 27);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty chest block with a custom data value.
|
|
||||||
*
|
|
||||||
* @param data data indicating the position of the chest
|
|
||||||
*/
|
|
||||||
public ChestBlock(int data) {
|
|
||||||
super(BlockID.CHEST, data, 27);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the chest block with a custom data value and a list of items.
|
|
||||||
*
|
|
||||||
* @param data data indicating the position of the chest
|
|
||||||
* @param items array of items
|
|
||||||
*/
|
|
||||||
public ChestBlock(int data, BaseItemStack[] items) {
|
|
||||||
super(BlockID.CHEST, data, 27);
|
|
||||||
setItems(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNbtId() {
|
|
||||||
return "Chest";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getNbtData() {
|
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
|
||||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
|
||||||
return new CompoundTag(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
|
||||||
if (rootTag == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
|
||||||
|
|
||||||
Tag t = values.get("id");
|
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Chest")) {
|
|
||||||
throw new RuntimeException("'Chest' tile entity expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
|
||||||
if (!(tag instanceof CompoundTag)) {
|
|
||||||
throw new RuntimeException("CompoundTag expected as child tag of Chest's Items");
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add((CompoundTag) tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
setItems(deserializeInventory(items));
|
|
||||||
} catch (InvalidFormatException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (DataException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,141 +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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
|
||||||
import com.sk89q.jnbt.ShortTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.world.DataException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a block that stores items.
|
|
||||||
*/
|
|
||||||
public abstract class ContainerBlock extends BaseBlock implements TileEntityBlock {
|
|
||||||
|
|
||||||
private BaseItemStack[] items;
|
|
||||||
|
|
||||||
public ContainerBlock(int type, int inventorySize) {
|
|
||||||
super(type);
|
|
||||||
this.items = new BaseItemStack[inventorySize];
|
|
||||||
}
|
|
||||||
|
|
||||||
public ContainerBlock(int type, int data, int inventorySize) {
|
|
||||||
super(type, data);
|
|
||||||
this.items = new BaseItemStack[inventorySize];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the list of items.
|
|
||||||
*
|
|
||||||
* @return an array of stored items
|
|
||||||
*/
|
|
||||||
public BaseItemStack[] getItems() {
|
|
||||||
return this.items;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the list of items.
|
|
||||||
*
|
|
||||||
* @param items an array of stored items
|
|
||||||
*/
|
|
||||||
public void setItems(BaseItemStack[] items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNbtData() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Tag> serializeItem(BaseItemStack item) {
|
|
||||||
Map<String, Tag> data = new HashMap<String, Tag>();
|
|
||||||
data.put("id", new ShortTag((short) item.getType()));
|
|
||||||
data.put("Damage", new ShortTag(item.getData()));
|
|
||||||
data.put("Count", new ByteTag((byte) item.getAmount()));
|
|
||||||
if (!item.getEnchantments().isEmpty()) {
|
|
||||||
List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
|
|
||||||
for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
|
||||||
Map<String, Tag> enchantment = new HashMap<String, Tag>();
|
|
||||||
enchantment.put("id", new ShortTag(entry.getKey().shortValue()));
|
|
||||||
enchantment.put("lvl", new ShortTag(entry.getValue().shortValue()));
|
|
||||||
enchantmentList.add(new CompoundTag(enchantment));
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Tag> auxData = new HashMap<String, Tag>();
|
|
||||||
auxData.put("ench", new ListTag(CompoundTag.class, enchantmentList));
|
|
||||||
data.put("tag", new CompoundTag(auxData));
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseItemStack deserializeItem(Map<String, Tag> data) throws DataException {
|
|
||||||
short id = NBTUtils.getChildTag(data, "id", ShortTag.class).getValue();
|
|
||||||
short damage = NBTUtils.getChildTag(data, "Damage", ShortTag.class).getValue();
|
|
||||||
byte count = NBTUtils.getChildTag(data, "Count", ByteTag.class).getValue();
|
|
||||||
|
|
||||||
BaseItemStack stack = new BaseItemStack(id, count, damage);
|
|
||||||
|
|
||||||
if (data.containsKey("tag")) {
|
|
||||||
Map<String, Tag> auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue();
|
|
||||||
ListTag ench = (ListTag)auxData.get("ench");
|
|
||||||
for(Tag e : ench.getValue()) {
|
|
||||||
Map<String, Tag> vars = ((CompoundTag) e).getValue();
|
|
||||||
short enchId = NBTUtils.getChildTag(vars, "id", ShortTag.class).getValue();
|
|
||||||
short enchLevel = NBTUtils.getChildTag(vars, "lvl", ShortTag.class).getValue();
|
|
||||||
stack.getEnchantments().put((int) enchId, (int) enchLevel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseItemStack[] deserializeInventory(List<CompoundTag> items) throws DataException {
|
|
||||||
BaseItemStack[] stacks = new BaseItemStack[items.size()];
|
|
||||||
for (CompoundTag tag : items) {
|
|
||||||
Map<String, Tag> item = tag.getValue();
|
|
||||||
BaseItemStack stack = deserializeItem(item);
|
|
||||||
byte slot = NBTUtils.getChildTag(item, "Slot", ByteTag.class).getValue();
|
|
||||||
if (slot >= 0 && slot < stacks.length) {
|
|
||||||
stacks[slot] = stack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stacks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CompoundTag> serializeInventory(BaseItemStack[] items) {
|
|
||||||
List<CompoundTag> tags = new ArrayList<CompoundTag>();
|
|
||||||
for (int i = 0; i < items.length; ++i) {
|
|
||||||
if (items[i] != null) {
|
|
||||||
Map<String, Tag> tagData = serializeItem(items[i]);
|
|
||||||
tagData.put("Slot", new ByteTag((byte) i));
|
|
||||||
tags.add(new CompoundTag(tagData));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,107 +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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.world.DataException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents dispensers.
|
|
||||||
*/
|
|
||||||
public class DispenserBlock extends ContainerBlock {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty dispenser block.
|
|
||||||
*/
|
|
||||||
public DispenserBlock() {
|
|
||||||
super(BlockID.DISPENSER, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty dispenser block.
|
|
||||||
*
|
|
||||||
* @param data data value (orientation)
|
|
||||||
*/
|
|
||||||
public DispenserBlock(int data) {
|
|
||||||
super(BlockID.DISPENSER, data, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a dispenser block with the given orientation and inventory.
|
|
||||||
*
|
|
||||||
* @param data data value (orientation)
|
|
||||||
* @param items array of items in the inventory
|
|
||||||
*/
|
|
||||||
public DispenserBlock(int data, BaseItemStack[] items) {
|
|
||||||
super(BlockID.DISPENSER, data, 9);
|
|
||||||
this.setItems(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNbtId() {
|
|
||||||
return "Trap";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getNbtData() {
|
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
|
||||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
|
||||||
return new CompoundTag(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
|
||||||
try {
|
|
||||||
if (rootTag == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
|
||||||
|
|
||||||
Tag t = values.get("id");
|
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Trap")) {
|
|
||||||
throw new DataException("'Trap' tile entity expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CompoundTag> items = new ArrayList<CompoundTag>();
|
|
||||||
for (Tag tag : NBTUtils.getChildTag(values, "Items", ListTag.class).getValue()) {
|
|
||||||
if (!(tag instanceof CompoundTag)) {
|
|
||||||
throw new DataException("CompoundTag expected as child tag of Trap Items");
|
|
||||||
}
|
|
||||||
|
|
||||||
items.add((CompoundTag) tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
setItems(deserializeInventory(items));
|
|
||||||
} catch (DataException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,165 +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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.NBTUtils;
|
|
||||||
import com.sk89q.jnbt.ShortTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.world.DataException;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a furnace block.
|
|
||||||
*/
|
|
||||||
public class FurnaceBlock extends ContainerBlock {
|
|
||||||
|
|
||||||
private short burnTime;
|
|
||||||
private short cookTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty furnace block with the default orientation.
|
|
||||||
*
|
|
||||||
* @param type type ID
|
|
||||||
*/
|
|
||||||
public FurnaceBlock(int type) {
|
|
||||||
super(type, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an empty furnace block with a given orientation.
|
|
||||||
*
|
|
||||||
* @param type type ID
|
|
||||||
* @param data orientation
|
|
||||||
*/
|
|
||||||
public FurnaceBlock(int type, int data) {
|
|
||||||
super(type, data, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an furnace block with a given orientation and inventory.
|
|
||||||
*
|
|
||||||
* @param type type ID
|
|
||||||
* @param data orientation
|
|
||||||
* @param items inventory items
|
|
||||||
*/
|
|
||||||
public FurnaceBlock(int type, int data, BaseItemStack[] items) {
|
|
||||||
super(type, data, 2);
|
|
||||||
setItems(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the burn time.
|
|
||||||
*
|
|
||||||
* @return the burn time
|
|
||||||
*/
|
|
||||||
public short getBurnTime() {
|
|
||||||
return burnTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the burn time.
|
|
||||||
*
|
|
||||||
* @param burnTime the burn time
|
|
||||||
*/
|
|
||||||
public void setBurnTime(short burnTime) {
|
|
||||||
this.burnTime = burnTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the cook time.
|
|
||||||
*
|
|
||||||
* @return the cook time
|
|
||||||
*/
|
|
||||||
public short getCookTime() {
|
|
||||||
return cookTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the cook time.
|
|
||||||
*
|
|
||||||
* @param cookTime the cook time to set
|
|
||||||
*/
|
|
||||||
public void setCookTime(short cookTime) {
|
|
||||||
this.cookTime = cookTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNbtId() {
|
|
||||||
return "Furnace";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getNbtData() {
|
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
|
||||||
values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
|
|
||||||
values.put("BurnTime", new ShortTag(burnTime));
|
|
||||||
values.put("CookTime", new ShortTag(cookTime));
|
|
||||||
return new CompoundTag(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
|
||||||
if (rootTag == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
|
||||||
|
|
||||||
Tag t = values.get("id");
|
|
||||||
if (!(t instanceof StringTag)
|
|
||||||
|| !((StringTag) t).getValue().equals("Furnace")) {
|
|
||||||
throw new RuntimeException("'Furnace' tile entity expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
ListTag items = NBTUtils.getChildTag(values, "Items", ListTag.class);
|
|
||||||
|
|
||||||
List<CompoundTag> compound = new ArrayList<CompoundTag>();
|
|
||||||
|
|
||||||
for (Tag tag : items.getValue()) {
|
|
||||||
if (!(tag instanceof CompoundTag)) {
|
|
||||||
throw new RuntimeException("CompoundTag expected as child tag of Furnace Items");
|
|
||||||
}
|
|
||||||
compound.add((CompoundTag) tag);
|
|
||||||
}
|
|
||||||
setItems(deserializeInventory(compound));
|
|
||||||
|
|
||||||
t = values.get("BurnTime");
|
|
||||||
if (t instanceof ShortTag) {
|
|
||||||
burnTime = ((ShortTag) t).getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
t = values.get("CookTime");
|
|
||||||
if (t instanceof ShortTag) {
|
|
||||||
cookTime = ((ShortTag) t).getValue();
|
|
||||||
}
|
|
||||||
} catch (DataException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,100 +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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A implementation of a lazy block for {@link Extent#getLazyBlock(Vector)}
|
|
||||||
* that takes the block's ID and metadata, but will defer loading of NBT
|
|
||||||
* data until time of access.
|
|
||||||
*
|
|
||||||
* <p>NBT data is later loaded using a call to {@link Extent#getBlock(Vector)}
|
|
||||||
* with a stored {@link Extent} and location.</p>
|
|
||||||
*
|
|
||||||
* <p>All mutators on this object will throw an
|
|
||||||
* {@link UnsupportedOperationException}.</p>
|
|
||||||
*/
|
|
||||||
public class LazyBlock extends BaseBlock {
|
|
||||||
|
|
||||||
private final Extent extent;
|
|
||||||
private final Vector position;
|
|
||||||
private boolean loaded = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new lazy block.
|
|
||||||
*
|
|
||||||
* @param type the block type
|
|
||||||
* @param extent the extent to later load the full block data from
|
|
||||||
* @param position the position to later load the full block data from
|
|
||||||
*/
|
|
||||||
public LazyBlock(int type, Extent extent, Vector position) {
|
|
||||||
super(type);
|
|
||||||
checkNotNull(extent);
|
|
||||||
checkNotNull(position);
|
|
||||||
this.extent = extent;
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new lazy block.
|
|
||||||
*
|
|
||||||
* @param type the block type
|
|
||||||
* @param data the data value
|
|
||||||
* @param extent the extent to later load the full block data from
|
|
||||||
* @param position the position to later load the full block data from
|
|
||||||
*/
|
|
||||||
public LazyBlock(int type, int data, Extent extent, Vector position) {
|
|
||||||
super(type, data);
|
|
||||||
checkNotNull(extent);
|
|
||||||
checkNotNull(position);
|
|
||||||
this.extent = extent;
|
|
||||||
this.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setId(int id) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setData(int data) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getNbtData() {
|
|
||||||
if (!loaded) {
|
|
||||||
BaseBlock loadedBlock = extent.getBlock(position);
|
|
||||||
super.setNbtData(loadedBlock.getNbtData());
|
|
||||||
}
|
|
||||||
return super.getNbtData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(CompoundTag nbtData) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -25,7 +25,8 @@ import com.sk89q.jnbt.NBTUtils;
|
|||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.blocks.metadata.MobType;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -49,41 +50,23 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
private short maxNearbyEntities;
|
private short maxNearbyEntities;
|
||||||
private short requiredPlayerRange;
|
private short requiredPlayerRange;
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the mob spawner block with a pig as the mob type.
|
|
||||||
*/
|
|
||||||
public MobSpawnerBlock() {
|
|
||||||
super(BlockID.MOB_SPAWNER);
|
|
||||||
this.mobType = MobType.PIG.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the mob spawner block with a given mob type.
|
|
||||||
*
|
|
||||||
* @param mobType mob type
|
|
||||||
*/
|
|
||||||
public MobSpawnerBlock(String mobType) {
|
|
||||||
super(BlockID.MOB_SPAWNER);
|
|
||||||
this.mobType = mobType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the mob spawner block with a specified data value.
|
* Construct the mob spawner block with a specified data value.
|
||||||
*
|
*
|
||||||
* @param data data value
|
* @param blockState The block state
|
||||||
*/
|
*/
|
||||||
public MobSpawnerBlock(int data) {
|
public MobSpawnerBlock(BlockState blockState) {
|
||||||
super(BlockID.MOB_SPAWNER, data);
|
super(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the mob spawner block.
|
* Construct the mob spawner block.
|
||||||
*
|
*
|
||||||
* @param data data value
|
* @param blockState The block state
|
||||||
* @param mobType mob type
|
* @param mobType mob type
|
||||||
*/
|
*/
|
||||||
public MobSpawnerBlock(int data, String mobType) {
|
public MobSpawnerBlock(BlockState blockState, String mobType) {
|
||||||
super(BlockID.MOB_SPAWNER, data);
|
super(blockState);
|
||||||
this.mobType = mobType;
|
this.mobType = mobType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +118,7 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
values.put("EntityId", new StringTag(mobType));
|
values.put("EntityId", new StringTag(mobType));
|
||||||
values.put("Delay", new ShortTag(delay));
|
values.put("Delay", new ShortTag(delay));
|
||||||
values.put("SpawnCount", new ShortTag(spawnCount));
|
values.put("SpawnCount", new ShortTag(spawnCount));
|
||||||
|
@ -1,122 +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.blocks;
|
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A note block.
|
|
||||||
*/
|
|
||||||
public class NoteBlock extends BaseBlock implements TileEntityBlock {
|
|
||||||
|
|
||||||
private byte note;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the note block with a data value of 0.
|
|
||||||
*/
|
|
||||||
public NoteBlock() {
|
|
||||||
super(BlockID.NOTE_BLOCK);
|
|
||||||
this.note = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the note block with a given data value.
|
|
||||||
*
|
|
||||||
* @param data data value
|
|
||||||
*/
|
|
||||||
public NoteBlock(int data) {
|
|
||||||
super(BlockID.NOTE_BLOCK, data);
|
|
||||||
this.note = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the note block with a given data value and note.
|
|
||||||
*
|
|
||||||
* @param data data value
|
|
||||||
* @param note note
|
|
||||||
*/
|
|
||||||
public NoteBlock(int data, byte note) {
|
|
||||||
super(BlockID.NOTE_BLOCK, data);
|
|
||||||
this.note = note;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the note.
|
|
||||||
*
|
|
||||||
* @return the note
|
|
||||||
*/
|
|
||||||
public byte getNote() {
|
|
||||||
return note;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the note.
|
|
||||||
*
|
|
||||||
* @param note the note to set
|
|
||||||
*/
|
|
||||||
public void setNote(byte note) {
|
|
||||||
this.note = note;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNbtData() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getNbtId() {
|
|
||||||
return "Music";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getNbtData() {
|
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
|
||||||
values.put("note", new ByteTag(note));
|
|
||||||
return new CompoundTag(values);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNbtData(CompoundTag rootTag) {
|
|
||||||
if (rootTag == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, Tag> values = rootTag.getValue();
|
|
||||||
|
|
||||||
Tag t;
|
|
||||||
|
|
||||||
t = values.get("id");
|
|
||||||
if (!(t instanceof StringTag) || !((StringTag) t).getValue().equals("Music")) {
|
|
||||||
throw new RuntimeException("'Music' tile entity expected");
|
|
||||||
}
|
|
||||||
|
|
||||||
t = values.get("note");
|
|
||||||
if (t instanceof ByteTag) {
|
|
||||||
note = ((ByteTag) t).getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -23,6 +23,8 @@ import com.sk89q.jnbt.CompoundTag;
|
|||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.util.gson.GsonUtil;
|
import com.sk89q.worldedit.util.gson.GsonUtil;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -36,26 +38,14 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
private static String EMPTY = "{\"text\":\"\"}";
|
private static String EMPTY = "{\"text\":\"\"}";
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the sign without text.
|
|
||||||
*
|
|
||||||
* @param type type ID
|
|
||||||
* @param data data value (orientation)
|
|
||||||
*/
|
|
||||||
public SignBlock(int type, int data) {
|
|
||||||
super(type, data);
|
|
||||||
this.text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the sign with text.
|
* Construct the sign with text.
|
||||||
*
|
*
|
||||||
* @param type type ID
|
* @param blockState The block state
|
||||||
* @param data data value (orientation)
|
|
||||||
* @param text lines of text
|
* @param text lines of text
|
||||||
*/
|
*/
|
||||||
public SignBlock(int type, int data, String[] text) {
|
public SignBlock(BlockState blockState, String[] text) {
|
||||||
super(type, data);
|
super(blockState);
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
this.text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
|
this.text = new String[] { EMPTY, EMPTY, EMPTY, EMPTY };
|
||||||
return;
|
return;
|
||||||
@ -103,7 +93,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
values.put("Text1", new StringTag(text[0]));
|
values.put("Text1", new StringTag(text[0]));
|
||||||
values.put("Text2", new StringTag(text[1]));
|
values.put("Text2", new StringTag(text[1]));
|
||||||
values.put("Text3", new StringTag(text[2]));
|
values.put("Text3", new StringTag(text[2]));
|
||||||
|
@ -19,10 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteTag;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -33,60 +34,25 @@ import java.util.Map;
|
|||||||
public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
||||||
|
|
||||||
private String owner = ""; // notchian
|
private String owner = ""; // notchian
|
||||||
private byte skullType; // stored here for block, in damage value for item
|
|
||||||
private byte rot; // only matters if block data == 0x1 (on floor)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a default type of skelton.
|
* Construct the skull block with a default type of skelton.
|
||||||
* @param data data value to set, controls placement
|
* @param state BlockState to set
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data) {
|
public SkullBlock(BlockState state) {
|
||||||
this(data, (byte) 0);
|
super(state);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the skull block with a given type.
|
|
||||||
* 0 - skeleton
|
|
||||||
* 1 - wither skelly
|
|
||||||
* 2 - zombie
|
|
||||||
* 3 - human
|
|
||||||
* 4 - creeper
|
|
||||||
* @param data data value to set, controls placement
|
|
||||||
* @param type type of skull
|
|
||||||
*/
|
|
||||||
public SkullBlock(int data, byte type) {
|
|
||||||
this(data, type, (byte) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the skull block with a given type and rotation.
|
|
||||||
* @param data data value to set, controls placement
|
|
||||||
* @param type type of skull
|
|
||||||
* @param rot rotation (if on floor)
|
|
||||||
*/
|
|
||||||
public SkullBlock(int data, byte type, byte rot) {
|
|
||||||
super(BlockID.HEAD, data);
|
|
||||||
if (type < (byte) 0 || type > (byte) 4) {
|
|
||||||
this.skullType = (byte) 0;
|
|
||||||
} else {
|
|
||||||
this.skullType = type;
|
|
||||||
}
|
|
||||||
this.rot = rot;
|
|
||||||
this.owner = "";
|
this.owner = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the skull block with a given rotation and owner.
|
* Construct the skull block with a given rotation and owner.
|
||||||
* The type is assumed to be player unless owner is null or empty.
|
* The type is assumed to be player unless owner is null or empty.
|
||||||
* @param data data value to set, controls placement
|
* @param blockState BlockState to set
|
||||||
* @param rot rotation of skull
|
|
||||||
* @param owner name of player
|
* @param owner name of player
|
||||||
*/
|
*/
|
||||||
public SkullBlock(int data, byte rot, String owner) {
|
public SkullBlock(BlockState blockState, String owner) {
|
||||||
super(BlockID.HEAD, data);
|
super(blockState);
|
||||||
this.rot = rot;
|
|
||||||
this.setOwner(owner);
|
this.setOwner(owner);
|
||||||
if (owner == null || owner.isEmpty()) this.skullType = (byte) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,7 +66,6 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
if (owner.length() > 16 || owner.isEmpty()) this.owner = "";
|
if (owner.length() > 16 || owner.isEmpty()) this.owner = "";
|
||||||
else this.owner = owner;
|
else this.owner = owner;
|
||||||
}
|
}
|
||||||
if (this.owner != null && !this.owner.isEmpty()) this.skullType = (byte) 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,38 +76,6 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the type of skull.
|
|
||||||
* @return the skullType
|
|
||||||
*/
|
|
||||||
public byte getSkullType() {
|
|
||||||
return skullType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the type of skull;
|
|
||||||
* @param skullType the skullType to set
|
|
||||||
*/
|
|
||||||
public void setSkullType(byte skullType) {
|
|
||||||
this.skullType = skullType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get rotation of skull. This only means anything if the block data is 1.
|
|
||||||
* @return the rotation
|
|
||||||
*/
|
|
||||||
public byte getRot() {
|
|
||||||
return rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the rotation of skull.
|
|
||||||
* @param rot the rotation to set
|
|
||||||
*/
|
|
||||||
public void setRot(byte rot) {
|
|
||||||
this.rot = rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNbtData() {
|
public boolean hasNbtData() {
|
||||||
return true;
|
return true;
|
||||||
@ -155,11 +88,9 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
Map<String, Tag> values = new HashMap<String, Tag>();
|
Map<String, Tag> values = new HashMap<>();
|
||||||
values.put("SkullType", new ByteTag(skullType));
|
|
||||||
if (owner == null) owner = "";
|
if (owner == null) owner = "";
|
||||||
values.put("ExtraType", new StringTag(owner));
|
values.put("ExtraType", new StringTag(owner));
|
||||||
values.put("Rot", new ByteTag(rot));
|
|
||||||
return new CompoundTag(values);
|
return new CompoundTag(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,17 +109,9 @@ public class SkullBlock extends BaseBlock implements TileEntityBlock {
|
|||||||
throw new RuntimeException("'Skull' tile entity expected");
|
throw new RuntimeException("'Skull' tile entity expected");
|
||||||
}
|
}
|
||||||
|
|
||||||
t = values.get("SkullType");
|
|
||||||
if (t instanceof ByteTag) {
|
|
||||||
skullType = ((ByteTag) t).getValue();
|
|
||||||
}
|
|
||||||
t = values.get("ExtraType");
|
t = values.get("ExtraType");
|
||||||
if (t != null && t instanceof StringTag) {
|
if (t instanceof StringTag) {
|
||||||
owner = ((StringTag) t).getValue();
|
owner = ((StringTag) t).getValue();
|
||||||
}
|
}
|
||||||
t = values.get("Rot");
|
|
||||||
if (t instanceof ByteTag) {
|
|
||||||
rot = ((ByteTag) t).getValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,42 +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.foundation;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link BaseBlock}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class Block {
|
|
||||||
|
|
||||||
public abstract int getId();
|
|
||||||
|
|
||||||
public abstract void setId(int id);
|
|
||||||
|
|
||||||
public abstract int getData();
|
|
||||||
|
|
||||||
public abstract void setData(int data);
|
|
||||||
|
|
||||||
public abstract void setIdAndData(int id, int data);
|
|
||||||
|
|
||||||
public abstract boolean hasWildcardData();
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Switch to {@link com.sk89q.worldedit.function.mask.AbstractMask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class AbstractMask implements Mask {
|
|
||||||
@Override
|
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,73 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.BlockMask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class BlockMask extends AbstractMask {
|
|
||||||
|
|
||||||
private final Set<BaseBlock> blocks;
|
|
||||||
|
|
||||||
public BlockMask() {
|
|
||||||
blocks = new HashSet<BaseBlock>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMask(Set<BaseBlock> types) {
|
|
||||||
this.blocks = types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMask(BaseBlock... block) {
|
|
||||||
blocks = new HashSet<BaseBlock>();
|
|
||||||
for (BaseBlock b : block) {
|
|
||||||
add(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMask(BaseBlock block) {
|
|
||||||
this();
|
|
||||||
add(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(BaseBlock block) {
|
|
||||||
blocks.add(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addAll(Collection<BaseBlock> blocks) {
|
|
||||||
blocks.addAll(blocks);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
BaseBlock block = editSession.getBlock(position);
|
|
||||||
return blocks.contains(block)
|
|
||||||
|| blocks.contains(new BaseBlock(block.getType(), -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link MaskIntersection}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class CombinedMask extends AbstractMask {
|
|
||||||
private final List<Mask> masks = new ArrayList<Mask>();
|
|
||||||
|
|
||||||
public CombinedMask() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public CombinedMask(Mask mask) {
|
|
||||||
add(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CombinedMask(Mask ...mask) {
|
|
||||||
for (Mask m : mask) {
|
|
||||||
add(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CombinedMask(List<Mask> masks) {
|
|
||||||
this.masks.addAll(masks);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Mask mask) {
|
|
||||||
masks.add(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean remove(Mask mask) {
|
|
||||||
return masks.remove(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean has(Mask mask) {
|
|
||||||
return masks.contains(mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
|
||||||
for (Mask mask : masks) {
|
|
||||||
mask.prepare(session, player, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
for (Mask mask : masks) {
|
|
||||||
if (!mask.matches(editSession, position)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class ExistingBlockMask extends AbstractMask {
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
return editSession.getBlockType(position) != BlockID.AIR;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.blocks.Blocks;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.FuzzyBlockMask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class FuzzyBlockMask extends AbstractMask {
|
|
||||||
|
|
||||||
private final Set<BaseBlock> filter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new fuzzy block mask.
|
|
||||||
*
|
|
||||||
* @param filter a list of block types to match
|
|
||||||
*/
|
|
||||||
public FuzzyBlockMask(Set<BaseBlock> filter) {
|
|
||||||
this.filter = filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new fuzzy block mask.
|
|
||||||
*
|
|
||||||
* @param block a list of block types to match
|
|
||||||
*/
|
|
||||||
public FuzzyBlockMask(BaseBlock... block) {
|
|
||||||
Set<BaseBlock> filter = new HashSet<BaseBlock>();
|
|
||||||
Collections.addAll(filter, block);
|
|
||||||
this.filter = filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
BaseBlock compare = new BaseBlock(editSession.getBlockType(position), editSession.getBlockData(position));
|
|
||||||
return Blocks.containsFuzzy(filter, compare);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link com.sk89q.worldedit.function.mask.Mask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface Mask {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called one time before each edit session.
|
|
||||||
*
|
|
||||||
* @param session a session
|
|
||||||
* @param player a player
|
|
||||||
* @param target target of the brush, null if not a brush mask
|
|
||||||
*/
|
|
||||||
void prepare(LocalSession session, LocalPlayer player, Vector target);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a block position, this method returns true if the block at
|
|
||||||
* that position matches the filter. Block information is not provided
|
|
||||||
* as getting a BaseBlock has unneeded overhead in most block querying
|
|
||||||
* situations (enumerating a chest's contents is a waste, for example).
|
|
||||||
*
|
|
||||||
* @param editSession an instance
|
|
||||||
* @param position the position to check
|
|
||||||
* @return true if it matches
|
|
||||||
*/
|
|
||||||
boolean matches(EditSession editSession, Vector position);
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link com.sk89q.worldedit.function.mask.SolidBlockMask}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class SolidBlockMask extends AbstractMask {
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
return !BlockType.canPassThrough(editSession.getBlockType(position), editSession.getBlockData(position));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +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.masks;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.function.mask.MaskIntersection;
|
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
|
||||||
import com.sk89q.worldedit.function.mask.OffsetMask;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link OffsetMask} with {@link MaskIntersection} and {@link Masks#negate(com.sk89q.worldedit.function.mask.Mask)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class UnderOverlayMask extends AbstractMask {
|
|
||||||
private final int yMod;
|
|
||||||
private Mask mask;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public UnderOverlayMask(Set<Integer> ids, boolean overlay) {
|
|
||||||
this(new BlockTypeMask(ids), overlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnderOverlayMask(Mask mask, boolean overlay) {
|
|
||||||
this.yMod = overlay ? -1 : 1;
|
|
||||||
this.mask = mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void addAll(Set<Integer> ids) {
|
|
||||||
if (mask instanceof BlockMask) {
|
|
||||||
final BlockMask blockTypeMask = (BlockMask) mask;
|
|
||||||
for (Integer id : ids) {
|
|
||||||
blockTypeMask.add(new BaseBlock(id));
|
|
||||||
}
|
|
||||||
} else if (mask instanceof ExistingBlockMask) {
|
|
||||||
final BlockMask blockMask = new BlockMask();
|
|
||||||
for (int type : ids) {
|
|
||||||
blockMask.add(new BaseBlock(type));
|
|
||||||
}
|
|
||||||
mask = blockMask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void prepare(LocalSession session, LocalPlayer player, Vector target) {
|
|
||||||
mask.prepare(session, player, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean matches(EditSession editSession, Vector position) {
|
|
||||||
return !mask.matches(editSession, position) && mask.matches(editSession, position.add(0, yMod, 0));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +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.patterns;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link com.sk89q.worldedit.function.pattern.Pattern}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public interface Pattern {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block for a position. This return value of this method does
|
|
||||||
* not have to be consistent for the same position.
|
|
||||||
*
|
|
||||||
* @param position the position where a block is needed
|
|
||||||
* @return a block
|
|
||||||
*/
|
|
||||||
public BaseBlock next(Vector position);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a block for a position. This return value of this method does
|
|
||||||
* not have to be consistent for the same position.
|
|
||||||
*
|
|
||||||
* @param x the X coordinate
|
|
||||||
* @param y the Y coordinate
|
|
||||||
* @param z the Z coordinate
|
|
||||||
* @return a block
|
|
||||||
*/
|
|
||||||
public BaseBlock next(int x, int y, int z);
|
|
||||||
|
|
||||||
}
|
|
@ -1,82 +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.patterns;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.function.pattern.RandomPattern;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated See {@link RandomPattern}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class RandomFillPattern implements Pattern {
|
|
||||||
|
|
||||||
private static final Random random = new Random();
|
|
||||||
private List<BlockChance> blocks;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object.
|
|
||||||
*
|
|
||||||
* @param blocks a list of blocks
|
|
||||||
*/
|
|
||||||
public RandomFillPattern(List<BlockChance> blocks) {
|
|
||||||
double max = 0;
|
|
||||||
|
|
||||||
for (BlockChance block : blocks) {
|
|
||||||
max += block.getChance();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<BlockChance> finalBlocks = new ArrayList<BlockChance>();
|
|
||||||
|
|
||||||
double i = 0;
|
|
||||||
|
|
||||||
for (BlockChance block : blocks) {
|
|
||||||
double v = block.getChance() / max;
|
|
||||||
i += v;
|
|
||||||
finalBlocks.add(new BlockChance(block.getBlock(), i));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.blocks = finalBlocks;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock next(Vector position) {
|
|
||||||
double r = random.nextDouble();
|
|
||||||
|
|
||||||
for (BlockChance block : blocks) {
|
|
||||||
if (r <= block.getChance()) {
|
|
||||||
return block.getBlock();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException("ProportionalFillPattern");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock next(int x, int y, int z) {
|
|
||||||
return next(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,44 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
|
|
||||||
abstract class AbstractLegacyRegionSelector implements RegionSelector {
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public final void explainPrimarySelection(LocalPlayer player, LocalSession session, Vector position) {
|
|
||||||
explainPrimarySelection((Actor) player, session, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public final void explainSecondarySelection(LocalPlayer player, LocalSession session, Vector position) {
|
|
||||||
explainSecondarySelection((Actor) player, session, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public final void explainRegionAdjust(LocalPlayer player, LocalSession session) {
|
|
||||||
explainRegionAdjust((Actor) player, session);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class ConvexPolyhedralRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class CuboidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class CylinderRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class EllipsoidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class ExtendingCuboidRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -1,37 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class Polygonal2DRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of points.
|
|
||||||
*
|
|
||||||
* @return the number of points
|
|
||||||
*/
|
|
||||||
public abstract int getPointCount();
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +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.regions;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This class only exists as to not break binary compatibility
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public abstract class SphereRegionSelector extends AbstractLegacyRegionSelector implements CUIRegion {
|
|
||||||
}
|
|
@ -72,7 +72,7 @@ public final class CompoundTag extends Tag {
|
|||||||
* @return the builder
|
* @return the builder
|
||||||
*/
|
*/
|
||||||
public CompoundTagBuilder createBuilder() {
|
public CompoundTagBuilder createBuilder() {
|
||||||
return new CompoundTagBuilder(new HashMap<String, Tag>(value));
|
return new CompoundTagBuilder(new HashMap<>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -317,6 +317,24 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a {@code long[]} named with the given key.
|
||||||
|
*
|
||||||
|
* <p>If the key does not exist or its value is not an long array tag,
|
||||||
|
* then an empty array will be returned.</p>
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @return an int array
|
||||||
|
*/
|
||||||
|
public long[] getLongArray(String key) {
|
||||||
|
Tag tag = value.get(key);
|
||||||
|
if (tag instanceof LongArrayTag) {
|
||||||
|
return ((LongArrayTag) tag).getValue();
|
||||||
|
} else {
|
||||||
|
return new long[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a long named with the given key.
|
* Get a long named with the given key.
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps create compound tags.
|
* Helps create compound tags.
|
||||||
*/
|
*/
|
||||||
@ -35,7 +35,7 @@ public class CompoundTagBuilder {
|
|||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*/
|
*/
|
||||||
CompoundTagBuilder() {
|
CompoundTagBuilder() {
|
||||||
this.entries = new HashMap<String, Tag>();
|
this.entries = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,6 +133,18 @@ public class CompoundTagBuilder {
|
|||||||
return put(key, new IntTag(value));
|
return put(key, new IntTag(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put the given key and value into the compound tag as a
|
||||||
|
* {@code LongArrayTag}.
|
||||||
|
*
|
||||||
|
* @param key they key
|
||||||
|
* @param value the value
|
||||||
|
* @return this object
|
||||||
|
*/
|
||||||
|
public CompoundTagBuilder putLongArray(String key, long[] value) {
|
||||||
|
return put(key, new LongArrayTag(value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the given key and value into the compound tag as a
|
* Put the given key and value into the compound tag as a
|
||||||
* {@code LongTag}.
|
* {@code LongTag}.
|
||||||
@ -189,7 +201,7 @@ public class CompoundTagBuilder {
|
|||||||
* @return the new compound tag
|
* @return the new compound tag
|
||||||
*/
|
*/
|
||||||
public CompoundTag build() {
|
public CompoundTag build() {
|
||||||
return new CompoundTag(new HashMap<String, Tag>(entries));
|
return new CompoundTag(new HashMap<>(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
@ -79,11 +79,10 @@ public final class ListTag extends Tag {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Tag getIfExists(int index) {
|
public Tag getIfExists(int index) {
|
||||||
try {
|
if (index >= value.size()) {
|
||||||
return value.get(index);
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
return value.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helps create list tags.
|
* Helps create list tags.
|
||||||
*/
|
*/
|
||||||
@ -42,7 +42,7 @@ public class ListTagBuilder {
|
|||||||
ListTagBuilder(Class<? extends Tag> type) {
|
ListTagBuilder(Class<? extends Tag> type) {
|
||||||
checkNotNull(type);
|
checkNotNull(type);
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.entries = new ArrayList<Tag>();
|
this.entries = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,7 +80,7 @@ public class ListTagBuilder {
|
|||||||
* @return the new list tag
|
* @return the new list tag
|
||||||
*/
|
*/
|
||||||
public ListTag build() {
|
public ListTag build() {
|
||||||
return new ListTag(type, new ArrayList<Tag>(entries));
|
return new ListTag(type, new ArrayList<>(entries));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,41 +17,44 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.patterns;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pattern that repeats the clipboard.
|
* The {@code TAG_Long_Array} tag.
|
||||||
*/
|
*/
|
||||||
public class ClipboardPattern implements Pattern {
|
public class LongArrayTag extends Tag {
|
||||||
|
|
||||||
private CuboidClipboard clipboard;
|
private final long[] value;
|
||||||
private Vector size;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Creates the tag with an empty name.
|
||||||
*
|
*
|
||||||
* @param clipboard the clipboard
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public ClipboardPattern(CuboidClipboard clipboard) {
|
public LongArrayTag(long[] value) {
|
||||||
this.clipboard = clipboard;
|
super();
|
||||||
this.size = clipboard.getSize();
|
checkNotNull(value);
|
||||||
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock next(Vector position) {
|
public long[] getValue() {
|
||||||
return next(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock next(int x, int y, int z) {
|
public String toString() {
|
||||||
int xp = Math.abs(x) % size.getBlockX();
|
StringBuilder hex = new StringBuilder();
|
||||||
int yp = Math.abs(y) % size.getBlockY();
|
for (long b : value) {
|
||||||
int zp = Math.abs(z) % size.getBlockZ();
|
String hexDigits = Long.toHexString(b).toUpperCase();
|
||||||
|
if (hexDigits.length() == 1) {
|
||||||
return clipboard.getPoint(new Vector(xp, yp, zp));
|
hex.append("0");
|
||||||
|
}
|
||||||
|
hex.append(hexDigits).append(" ");
|
||||||
|
}
|
||||||
|
return "TAG_Long_Array(" + hex + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -31,7 +31,7 @@ public final class NBTConstants {
|
|||||||
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
|
public static final int TYPE_END = 0, TYPE_BYTE = 1, TYPE_SHORT = 2,
|
||||||
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
|
TYPE_INT = 3, TYPE_LONG = 4, TYPE_FLOAT = 5, TYPE_DOUBLE = 6,
|
||||||
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
TYPE_BYTE_ARRAY = 7, TYPE_STRING = 8, TYPE_LIST = 9,
|
||||||
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11;
|
TYPE_COMPOUND = 10, TYPE_INT_ARRAY = 11, TYPE_LONG_ARRAY = 12;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default private constructor.
|
* Default private constructor.
|
||||||
@ -73,6 +73,8 @@ public final class NBTConstants {
|
|||||||
return CompoundTag.class;
|
return CompoundTag.class;
|
||||||
case TYPE_INT_ARRAY:
|
case TYPE_INT_ARRAY:
|
||||||
return IntArrayTag.class;
|
return IntArrayTag.class;
|
||||||
|
case TYPE_LONG_ARRAY:
|
||||||
|
return LongArrayTag.class;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown tag type ID of " + id);
|
throw new IllegalArgumentException("Unknown tag type ID of " + id);
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
int childType = is.readByte();
|
int childType = is.readByte();
|
||||||
length = is.readInt();
|
length = is.readInt();
|
||||||
|
|
||||||
List<Tag> tagList = new ArrayList<Tag>();
|
List<Tag> tagList = new ArrayList<>();
|
||||||
for (int i = 0; i < length; ++i) {
|
for (int i = 0; i < length; ++i) {
|
||||||
Tag tag = readTagPayload(childType, depth + 1);
|
Tag tag = readTagPayload(childType, depth + 1);
|
||||||
if (tag instanceof EndTag) {
|
if (tag instanceof EndTag) {
|
||||||
@ -139,7 +139,7 @@ public final class NBTInputStream implements Closeable {
|
|||||||
|
|
||||||
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
|
return new ListTag(NBTUtils.getTypeClass(childType), tagList);
|
||||||
case NBTConstants.TYPE_COMPOUND:
|
case NBTConstants.TYPE_COMPOUND:
|
||||||
Map<String, Tag> tagMap = new HashMap<String, Tag>();
|
Map<String, Tag> tagMap = new HashMap<>();
|
||||||
while (true) {
|
while (true) {
|
||||||
NamedTag namedTag = readNamedTag(depth + 1);
|
NamedTag namedTag = readNamedTag(depth + 1);
|
||||||
Tag tag = namedTag.getTag();
|
Tag tag = namedTag.getTag();
|
||||||
@ -158,6 +158,13 @@ public final class NBTInputStream implements Closeable {
|
|||||||
data[i] = is.readInt();
|
data[i] = is.readInt();
|
||||||
}
|
}
|
||||||
return new IntArrayTag(data);
|
return new IntArrayTag(data);
|
||||||
|
case NBTConstants.TYPE_LONG_ARRAY:
|
||||||
|
length = is.readInt();
|
||||||
|
long[] longData = new long[length];
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
longData[i] = is.readLong();
|
||||||
|
}
|
||||||
|
return new LongArrayTag(longData);
|
||||||
default:
|
default:
|
||||||
throw new IOException("Invalid tag type: " + type + ".");
|
throw new IOException("Invalid tag type: " + type + ".");
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -26,8 +28,6 @@ import java.io.OutputStream;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||||
* {@code Tag} objects to an underlying {@code OutputStream}.
|
* {@code Tag} objects to an underlying {@code OutputStream}.
|
||||||
@ -129,6 +129,9 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
case NBTConstants.TYPE_INT_ARRAY:
|
case NBTConstants.TYPE_INT_ARRAY:
|
||||||
writeIntArrayTagPayload((IntArrayTag) tag);
|
writeIntArrayTagPayload((IntArrayTag) tag);
|
||||||
break;
|
break;
|
||||||
|
case NBTConstants.TYPE_LONG_ARRAY:
|
||||||
|
writeLongArrayTagPayload((LongArrayTag) tag);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IOException("Invalid tag type: " + type + ".");
|
throw new IOException("Invalid tag type: " + type + ".");
|
||||||
}
|
}
|
||||||
@ -286,6 +289,14 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeLongArrayTagPayload(LongArrayTag tag) throws IOException {
|
||||||
|
long[] data = tag.getValue();
|
||||||
|
os.writeInt(data.length);
|
||||||
|
for (long aData : data) {
|
||||||
|
os.writeLong(aData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
os.close();
|
os.close();
|
||||||
|
@ -19,13 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.jnbt;
|
package com.sk89q.jnbt;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class which contains NBT-related utility methods.
|
* A class which contains NBT-related utility methods.
|
||||||
*
|
*
|
||||||
@ -69,6 +69,8 @@ public final class NBTUtils {
|
|||||||
return "TAG_String";
|
return "TAG_String";
|
||||||
} else if (clazz.equals(IntArrayTag.class)) {
|
} else if (clazz.equals(IntArrayTag.class)) {
|
||||||
return "TAG_Int_Array";
|
return "TAG_Int_Array";
|
||||||
|
} else if (clazz.equals(LongArrayTag.class)) {
|
||||||
|
return "TAG_Long_Array";
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid tag classs ("
|
throw new IllegalArgumentException("Invalid tag classs ("
|
||||||
+ clazz.getName() + ").");
|
+ clazz.getName() + ").");
|
||||||
@ -107,6 +109,8 @@ public final class NBTUtils {
|
|||||||
return NBTConstants.TYPE_STRING;
|
return NBTConstants.TYPE_STRING;
|
||||||
} else if (clazz.equals(IntArrayTag.class)) {
|
} else if (clazz.equals(IntArrayTag.class)) {
|
||||||
return NBTConstants.TYPE_INT_ARRAY;
|
return NBTConstants.TYPE_INT_ARRAY;
|
||||||
|
} else if (clazz.equals(LongArrayTag.class)) {
|
||||||
|
return NBTConstants.TYPE_LONG_ARRAY;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Invalid tag classs ("
|
throw new IllegalArgumentException("Invalid tag classs ("
|
||||||
+ clazz.getName() + ").");
|
+ clazz.getName() + ").");
|
||||||
@ -146,6 +150,8 @@ public final class NBTUtils {
|
|||||||
return CompoundTag.class;
|
return CompoundTag.class;
|
||||||
case NBTConstants.TYPE_INT_ARRAY:
|
case NBTConstants.TYPE_INT_ARRAY:
|
||||||
return IntArrayTag.class;
|
return IntArrayTag.class;
|
||||||
|
case NBTConstants.TYPE_LONG_ARRAY:
|
||||||
|
return LongArrayTag.class;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid tag type : " + type
|
throw new IllegalArgumentException("Invalid tag type : " + type
|
||||||
+ ".");
|
+ ".");
|
||||||
|
@ -34,8 +34,8 @@ public class CommandContext {
|
|||||||
|
|
||||||
protected final List<Integer> originalArgIndices;
|
protected final List<Integer> originalArgIndices;
|
||||||
protected final String[] originalArgs;
|
protected final String[] originalArgs;
|
||||||
protected final Set<Character> booleanFlags = new HashSet<Character>();
|
protected final Set<Character> booleanFlags = new HashSet<>();
|
||||||
protected final Map<Character, String> valueFlags = new HashMap<Character, String>();
|
protected final Map<Character, String> valueFlags = new HashMap<>();
|
||||||
protected final SuggestionContext suggestionContext;
|
protected final SuggestionContext suggestionContext;
|
||||||
protected final CommandLocals locals;
|
protected final CommandLocals locals;
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ public class CommandContext {
|
|||||||
SuggestionContext suggestionContext = SuggestionContext.hangingValue();
|
SuggestionContext suggestionContext = SuggestionContext.hangingValue();
|
||||||
|
|
||||||
// Eliminate empty args and combine multiword args first
|
// Eliminate empty args and combine multiword args first
|
||||||
List<Integer> argIndexList = new ArrayList<Integer>(args.length);
|
List<Integer> argIndexList = new ArrayList<>(args.length);
|
||||||
List<String> argList = new ArrayList<String>(args.length);
|
List<String> argList = new ArrayList<>(args.length);
|
||||||
for (int i = 1; i < args.length; ++i) {
|
for (int i = 1; i < args.length; ++i) {
|
||||||
isHanging = false;
|
isHanging = false;
|
||||||
|
|
||||||
@ -152,8 +152,8 @@ public class CommandContext {
|
|||||||
|
|
||||||
// Then flags
|
// Then flags
|
||||||
|
|
||||||
this.originalArgIndices = new ArrayList<Integer>(argIndexList.size());
|
this.originalArgIndices = new ArrayList<>(argIndexList.size());
|
||||||
this.parsedArgs = new ArrayList<String>(argList.size());
|
this.parsedArgs = new ArrayList<>(argList.size());
|
||||||
|
|
||||||
if (parseFlags) {
|
if (parseFlags) {
|
||||||
for (int nextArg = 0; nextArg < argList.size(); ) {
|
for (int nextArg = 0; nextArg < argList.size(); ) {
|
||||||
|
@ -19,16 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.minecraft.util.commands;
|
package com.sk89q.minecraft.util.commands;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class CommandException extends Exception {
|
public class CommandException extends Exception {
|
||||||
|
|
||||||
private List<String> commandStack = new ArrayList<String>();
|
private List<String> commandStack = new ArrayList<>();
|
||||||
|
|
||||||
public CommandException() {
|
public CommandException() {
|
||||||
super();
|
super();
|
||||||
|
@ -24,7 +24,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class CommandLocals {
|
public class CommandLocals {
|
||||||
|
|
||||||
private final Map<Object, Object> locals = new HashMap<Object, Object>();
|
private final Map<Object, Object> locals = new HashMap<>();
|
||||||
|
|
||||||
public boolean containsKey(Object key) {
|
public boolean containsKey(Object key) {
|
||||||
return locals.containsKey(key);
|
return locals.containsKey(key);
|
||||||
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren