Complete Rework (completly untested)
Dieser Commit ist enthalten in:
Ursprung
02a16bbb22
Commit
7cf2de33b7
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1 @@
|
|||||||
.idea
|
.idea
|
||||||
pom.xml
|
|
||||||
WarShipFactory.iml
|
|
||||||
|
87
pom.xml
Normale Datei
87
pom.xml
Normale Datei
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>de.warking</groupId>
|
||||||
|
<artifactId>bausystem</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven</id>
|
||||||
|
<url>https://warking.de:81/maven/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src</directory>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*.java</exclude>
|
||||||
|
<exclude>**/*.kt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.6.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>warking</groupId>
|
||||||
|
<artifactId>SpigotCore</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>warking</groupId>
|
||||||
|
<artifactId>WorldEdit</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>warking</groupId>
|
||||||
|
<artifactId>WorldGuard</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>warking</groupId>
|
||||||
|
<artifactId>FAWE</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
@ -1,7 +1,5 @@
|
|||||||
package de.pro_crafting.commandframework;
|
package de.pro_crafting.commandframework;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.command.CommandException;
|
import org.bukkit.command.CommandException;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -9,6 +7,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command Framework - BukkitCommand <br>
|
* Command Framework - BukkitCommand <br>
|
||||||
* An implementation of Bukkit's Command class allowing for registering of
|
* An implementation of Bukkit's Command class allowing for registering of
|
||||||
@ -17,19 +17,13 @@ import org.bukkit.plugin.Plugin;
|
|||||||
* @author minnymin3
|
* @author minnymin3
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class BukkitCommand extends org.bukkit.command.Command {
|
class BukkitCommand extends org.bukkit.command.Command {
|
||||||
|
|
||||||
private final Plugin owningPlugin;
|
private final Plugin owningPlugin;
|
||||||
private CommandExecutor executor;
|
private final CommandExecutor executor;
|
||||||
protected BukkitCompleter completer;
|
BukkitCompleter completer;
|
||||||
|
|
||||||
/**
|
BukkitCommand(String label, CommandExecutor executor, Plugin owner) {
|
||||||
* A slimmed down PluginCommand
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param owner
|
|
||||||
*/
|
|
||||||
protected BukkitCommand(String label, CommandExecutor executor, Plugin owner) {
|
|
||||||
super(label);
|
super(label);
|
||||||
this.executor = executor;
|
this.executor = executor;
|
||||||
this.owningPlugin = owner;
|
this.owningPlugin = owner;
|
||||||
@ -38,7 +32,7 @@ public class BukkitCommand extends org.bukkit.command.Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
boolean success = false;
|
boolean success;
|
||||||
|
|
||||||
if (!owningPlugin.isEnabled()) {
|
if (!owningPlugin.isEnabled()) {
|
||||||
return false;
|
return false;
|
@ -1,5 +1,9 @@
|
|||||||
package de.pro_crafting.commandframework;
|
package de.pro_crafting.commandframework;
|
||||||
|
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.AbstractMap;
|
import java.util.AbstractMap;
|
||||||
@ -8,10 +12,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.TabCompleter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command Framework - BukkitCompleter <br>
|
* Command Framework - BukkitCompleter <br>
|
||||||
* An implementation of the TabCompleter class allowing for multiple tab
|
* An implementation of the TabCompleter class allowing for multiple tab
|
||||||
@ -22,20 +22,20 @@ import org.bukkit.command.TabCompleter;
|
|||||||
*/
|
*/
|
||||||
public class BukkitCompleter implements TabCompleter {
|
public class BukkitCompleter implements TabCompleter {
|
||||||
|
|
||||||
private Map<String, Entry<Method, Object>> completers = new HashMap<String, Entry<Method, Object>>();
|
private final Map<String, Entry<Method, Object>> completers = new HashMap<>();
|
||||||
|
|
||||||
public void addCompleter(String label, Method m, Object obj) {
|
public void addCompleter(String label, Method m, Object obj) {
|
||||||
completers.put(label, new AbstractMap.SimpleEntry<Method, Object>(m, obj));
|
completers.put(label, new AbstractMap.SimpleEntry<>(m, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||||
for (int i = args.length; i >= 0; i--) {
|
for (int i = args.length; i >= 0; i--) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append(label.toLowerCase());
|
buffer.append(label.toLowerCase());
|
||||||
for (int x = 0; x < i; x++) {
|
for (int x = 0; x < i; x++) {
|
||||||
if (!args[x].equals("") && !args[x].equals(" ")) {
|
if (!args[x].equals("") && !args[x].equals(" ")) {
|
||||||
buffer.append("." + args[x].toLowerCase());
|
buffer.append(".").append(args[x].toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String cmdLabel = buffer.toString();
|
String cmdLabel = buffer.toString();
|
||||||
@ -49,11 +49,7 @@ public class BukkitCompleter implements TabCompleter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return labelParts;
|
return labelParts;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package de.pro_crafting.commandframework;
|
package de.pro_crafting.commandframework;
|
||||||
|
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -24,14 +26,14 @@ public @interface Command {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String name();
|
String name();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the required permission of the command
|
* Gets the required permission of the command
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String permission() default "";
|
String permission() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The message sent to the player when they do not have permission to
|
* The message sent to the player when they do not have permission to
|
||||||
@ -39,7 +41,7 @@ public @interface Command {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String noPerm() default "You do not have permission to perform that action";
|
String noPerm() default BauSystem.PREFIX + "§cFür diesen Befehl hast du keine Rechte";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of alternate names that the command is executed under. See
|
* A list of alternate names that the command is executed under. See
|
||||||
@ -47,26 +49,26 @@ public @interface Command {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String[] aliases() default {};
|
String[] aliases() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The description that will appear in /help of the command
|
* The description that will appear in /help of the command
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String description() default "";
|
String description() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The usage that will appear in /help (commandname)
|
* The usage that will appear in /help (commandname)
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String usage() default "";
|
String usage() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not the command is available to players only
|
* Whether or not the command is available to players only
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean inGameOnly() default false;
|
boolean inGameOnly() default false;
|
||||||
}
|
}
|
@ -13,22 +13,20 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public class CommandArgs {
|
public class CommandArgs {
|
||||||
|
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
private org.bukkit.command.Command command;
|
private final org.bukkit.command.Command command;
|
||||||
private String label;
|
private final String label;
|
||||||
private String[] args;
|
private final String[] args;
|
||||||
|
|
||||||
protected CommandArgs(CommandSender sender, org.bukkit.command.Command command, String label, String[] args,
|
CommandArgs(CommandSender sender, org.bukkit.command.Command command, String label, String[] args,
|
||||||
int subCommand) {
|
int subCommand) {
|
||||||
String[] modArgs = new String[args.length - subCommand];
|
String[] modArgs = new String[args.length - subCommand];
|
||||||
for (int i = 0; i < args.length - subCommand; i++) {
|
if (args.length - subCommand >= 0) System.arraycopy(args, 0 + subCommand, modArgs, 0, args.length - subCommand);
|
||||||
modArgs[i] = args[i + subCommand];
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append(label);
|
buffer.append(label);
|
||||||
for (int x = 0; x < subCommand; x++) {
|
for (int x = 0; x < subCommand; x++) {
|
||||||
buffer.append("." + args[x]);
|
buffer.append(".").append(args[x]);
|
||||||
}
|
}
|
||||||
String cmdLabel = buffer.toString();
|
String cmdLabel = buffer.toString();
|
||||||
this.sender = sender;
|
this.sender = sender;
|
@ -1,16 +1,5 @@
|
|||||||
package de.pro_crafting.commandframework;
|
package de.pro_crafting.commandframework;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
@ -24,6 +13,12 @@ import org.bukkit.help.IndexHelpTopic;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.SimplePluginManager;
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command Framework - CommandFramework <br>
|
* Command Framework - CommandFramework <br>
|
||||||
* The main command framework class used for controlling the framework.
|
* The main command framework class used for controlling the framework.
|
||||||
@ -33,9 +28,9 @@ import org.bukkit.plugin.SimplePluginManager;
|
|||||||
*/
|
*/
|
||||||
public class CommandFramework implements CommandExecutor {
|
public class CommandFramework implements CommandExecutor {
|
||||||
|
|
||||||
private Map<String, Entry<Method, Object>> commandMap = new HashMap<String, Entry<Method, Object>>();
|
private final Map<String, Entry<Method, Object>> commandMap = new HashMap<>();
|
||||||
private CommandMap map;
|
private CommandMap map;
|
||||||
private Plugin plugin;
|
private final Plugin plugin;
|
||||||
private String noPermMessage = null;
|
private String noPermMessage = null;
|
||||||
|
|
||||||
private String inGameOnlyMessage;
|
private String inGameOnlyMessage;
|
||||||
@ -51,13 +46,7 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
|
Field field = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
map = (CommandMap) field.get(manager);
|
map = (CommandMap) field.get(manager);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | NoSuchFieldException | IllegalAccessException | SecurityException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,9 +73,9 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
* @param args The arguments parsed from onCommand
|
* @param args The arguments parsed from onCommand
|
||||||
* @return Always returns true for simplicity's sake in onCommand
|
* @return Always returns true for simplicity's sake in onCommand
|
||||||
*/
|
*/
|
||||||
public boolean handleCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
|
private boolean handleCommand(CommandSender sender, org.bukkit.command.Command cmd, String label, String[] args) {
|
||||||
for (int i = args.length; i >= 0; i--) {
|
for (int i = args.length; i >= 0; i--) {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append(label.toLowerCase());
|
buffer.append(label.toLowerCase());
|
||||||
for (int x = 0; x < i; x++) {
|
for (int x = 0; x < i; x++) {
|
||||||
buffer.append(".").append(args[x].toLowerCase());
|
buffer.append(".").append(args[x].toLowerCase());
|
||||||
@ -96,7 +85,8 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
Method method = commandMap.get(cmdLabel).getKey();
|
Method method = commandMap.get(cmdLabel).getKey();
|
||||||
Object methodObject = commandMap.get(cmdLabel).getValue();
|
Object methodObject = commandMap.get(cmdLabel).getValue();
|
||||||
Command command = method.getAnnotation(Command.class);
|
Command command = method.getAnnotation(Command.class);
|
||||||
if (command.permission() != null && !command.permission().isEmpty() && !sender.hasPermission(command.permission())) {
|
command.permission();
|
||||||
|
if (!command.permission().isEmpty() && !sender.hasPermission(command.permission())) {
|
||||||
if(!command.noPerm().equals("You do not have permission to perform that action") || this.noPermMessage == null){
|
if(!command.noPerm().equals("You do not have permission to perform that action") || this.noPermMessage == null){
|
||||||
sender.sendMessage(command.noPerm());
|
sender.sendMessage(command.noPerm());
|
||||||
return true;
|
return true;
|
||||||
@ -114,11 +104,7 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
try {
|
try {
|
||||||
method.invoke(methodObject, new CommandArgs(sender, cmd, label, args,
|
method.invoke(methodObject, new CommandArgs(sender, cmd, label, args,
|
||||||
cmdLabel.split("\\.").length - 1));
|
cmdLabel.split("\\.").length - 1));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException | InvocationTargetException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -179,7 +165,7 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
* Registers all the commands under the plugin's help
|
* Registers all the commands under the plugin's help
|
||||||
*/
|
*/
|
||||||
public void registerHelp() {
|
public void registerHelp() {
|
||||||
Set<HelpTopic> help = new TreeSet<HelpTopic>(HelpTopicComparator.helpTopicComparatorInstance());
|
Set<HelpTopic> help = new TreeSet<>(HelpTopicComparator.helpTopicComparatorInstance());
|
||||||
for (String s : commandMap.keySet()) {
|
for (String s : commandMap.keySet()) {
|
||||||
if (!s.contains(".")) {
|
if (!s.contains(".")) {
|
||||||
org.bukkit.command.Command cmd = map.getCommand(s);
|
org.bukkit.command.Command cmd = map.getCommand(s);
|
||||||
@ -192,9 +178,9 @@ public class CommandFramework implements CommandExecutor {
|
|||||||
Bukkit.getServer().getHelpMap().addTopic(topic);
|
Bukkit.getServer().getHelpMap().addTopic(topic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand(Command command, String label, Method m, Object obj) {
|
private void registerCommand(Command command, String label, Method m, Object obj) {
|
||||||
commandMap.put(label.toLowerCase(), new AbstractMap.SimpleEntry<Method, Object>(m, obj));
|
commandMap.put(label.toLowerCase(), new AbstractMap.SimpleEntry<>(m, obj));
|
||||||
commandMap.put(this.plugin.getName() + ':' + label.toLowerCase(), new AbstractMap.SimpleEntry<Method, Object>(m, obj));
|
commandMap.put(this.plugin.getName() + ':' + label.toLowerCase(), new AbstractMap.SimpleEntry<>(m, obj));
|
||||||
String cmdLabel = label.replace(".", ",").split(",")[0].toLowerCase();
|
String cmdLabel = label.replace(".", ",").split(",")[0].toLowerCase();
|
||||||
if (map.getCommand(cmdLabel) == null) {
|
if (map.getCommand(cmdLabel) == null) {
|
||||||
org.bukkit.command.Command cmd = new BukkitCommand(cmdLabel, this, plugin);
|
org.bukkit.command.Command cmd = new BukkitCommand(cmdLabel, this, plugin);
|
@ -1,29 +1,21 @@
|
|||||||
package de.quantumnanox.warshipfactory.main;
|
package de.warking.bausystem;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import de.pro_crafting.commandframework.CommandArgs;
|
import de.pro_crafting.commandframework.CommandArgs;
|
||||||
import de.pro_crafting.commandframework.CommandFramework;
|
import de.pro_crafting.commandframework.CommandFramework;
|
||||||
import de.pro_crafting.commandframework.Completer;
|
import de.pro_crafting.commandframework.Completer;
|
||||||
import de.pro_crafting.sawe.RegionListener;
|
import de.warking.bausystem.commands.CommandBau;
|
||||||
import de.quantumnanox.warshipfactory.commands.*;
|
import de.warking.bausystem.commands.CommandGamemode;
|
||||||
import de.quantumnanox.warshipfactory.config.Config;
|
import de.warking.bausystem.commands.CommandGui;
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
import de.warking.bausystem.commands.CommandTeleport;
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
import de.warking.bausystem.config.Config;
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
import de.warking.bausystem.world.RegionListener;
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.thecobix.tag.Tag;
|
|
||||||
import net.thecobix.tag.TagCompound;
|
|
||||||
import net.thecobix.tag.TagInputStream;
|
|
||||||
import net.thecobix.tag.TagOutputStream;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -32,43 +24,34 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class WarShipFactory extends JavaPlugin implements Listener {
|
public class BauSystem extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
public static final String S_PREFIX = "§8[§3BauFactory§8] §7";
|
public static final String PREFIX = "§6BauSystem§8» §7";
|
||||||
|
|
||||||
public Config config;
|
public Config config;
|
||||||
@Getter
|
|
||||||
private World wrapped;
|
|
||||||
private CommandFramework cmdFramework;
|
private CommandFramework cmdFramework;
|
||||||
private BungeeUtil bungeeUtil;
|
private final File regions = new File("plugins/BauSystem", "regions.data");
|
||||||
public File regions = new File("plugins/WarShipFactory", "regions.data");
|
public final FileConfiguration getRegionData = YamlConfiguration.loadConfiguration(regions);
|
||||||
public FileConfiguration getRegionData = YamlConfiguration.loadConfiguration(regions);
|
|
||||||
|
|
||||||
private static WarShipFactory plugin;
|
private static BauSystem plugin;
|
||||||
|
|
||||||
public void saveRegionData() {
|
private void saveRegionData() {
|
||||||
try { getRegionData.save(regions); } catch (Exception ex) { }
|
try { getRegionData.save(regions); } catch (Exception ignored) { }
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getServer().getPluginManager().registerEvents(new CommandGui(), this);
|
getServer().getPluginManager().registerEvents(new CommandGui(), this);
|
||||||
File checkFile = new File("plugins/WarShipFactory", "regions.data");
|
File checkFile = new File("plugins/BauSystem", "regions.data");
|
||||||
if(!checkFile.exists()) {
|
if(!checkFile.exists()) {
|
||||||
|
|
||||||
getRegionData.options().header("Config auf dieser Basis unendlich erweiterbar");
|
getRegionData.options().header("Config auf dieser Basis unendlich erweiterbar");
|
||||||
@ -100,9 +83,7 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
saveRegionData();
|
saveRegionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Bootstrap", "BauFactory v" + getDescription().getVersion() + " by Exceptionflug | updatet by. RedstoneTechnik.");
|
// Time to replace the vanillacommands with BauSystem's own versions
|
||||||
|
|
||||||
// Time to replace the vanillacommands with WarShipFactory's own versions
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeCommand("tp");
|
CommandRemover.removeCommand("tp");
|
||||||
CommandInjector.injectCommand(new CommandTeleport());
|
CommandInjector.injectCommand(new CommandTeleport());
|
||||||
@ -110,16 +91,15 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
CommandInjector.injectCommand(new CommandGamemode());
|
CommandInjector.injectCommand(new CommandGamemode());
|
||||||
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
log("Bootstrap", "§cError while replacing some bukkit internals with seagiants code:");
|
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
new File("plugins/WarShipFactory/worlds/").mkdirs();
|
new File("plugins/BauSystem/worlds/").mkdirs();
|
||||||
config = new Config();
|
config = new Config();
|
||||||
config.initConfig();
|
config.initConfig();
|
||||||
log("Bootstrap", "§aConfig loaded.");
|
|
||||||
cmdFramework = new CommandFramework(this);
|
cmdFramework = new CommandFramework(this);
|
||||||
cmdFramework.setInGameOnlyMessage(S_PREFIX + "Dieser Befehl darf nur Ingame verwendet werden!");
|
cmdFramework.setInGameOnlyMessage(PREFIX + "Dieser Befehl darf nur Ingame verwendet werden!");
|
||||||
cmdFramework.setNoPermMessage("Unknown command. Type \"/help\" for help.");
|
cmdFramework.setNoPermMessage(PREFIX + "§cUnbekannter Befehl");
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
Bukkit.getPluginManager().registerEvents(this, this);
|
||||||
Method[] methods = this.getClass().getMethods();
|
Method[] methods = this.getClass().getMethods();
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
@ -129,56 +109,46 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmdFramework.registerCommands(new CommandBau());
|
cmdFramework.registerCommands(new CommandBau());
|
||||||
log("Bootstrap", "§aCommand framework initiated.");
|
|
||||||
Bukkit.getPluginManager().registerEvents(new RegionListener(this), this);
|
Bukkit.getPluginManager().registerEvents(new RegionListener(this), this);
|
||||||
log("Bootstrap", "§aSaWe initiated.");
|
|
||||||
|
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||||
public void run() {
|
|
||||||
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");
|
||||||
Date d = new Date();
|
Date d = new Date();
|
||||||
if (df.format(d).equalsIgnoreCase("23:55:00")) {
|
if (df.format(d).equalsIgnoreCase("23:55:00")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 5 Minuten neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 5 Minuten neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:00")) {
|
if (df.format(d).equalsIgnoreCase("23:59:00")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 1 Minute neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 1 Minute neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:30")) {
|
if (df.format(d).equalsIgnoreCase("23:59:30")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 30 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 30 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:50")) {
|
if (df.format(d).equalsIgnoreCase("23:59:50")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 10 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 10 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:55")) {
|
if (df.format(d).equalsIgnoreCase("23:59:55")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 5 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 5 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:56")) {
|
if (df.format(d).equalsIgnoreCase("23:59:56")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 4 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 4 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:57")) {
|
if (df.format(d).equalsIgnoreCase("23:59:57")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 3 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 3 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:58")) {
|
if (df.format(d).equalsIgnoreCase("23:59:58")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 2 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 2 Sekunden neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("23:59:59")) {
|
if (df.format(d).equalsIgnoreCase("23:59:59")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet in 1 Sekunden neu.");
|
Bukkit.broadcastMessage(PREFIX + "Der Server startet in 1 Sekunde neu");
|
||||||
}
|
}
|
||||||
if (df.format(d).equalsIgnoreCase("00:00:00")) {
|
if (df.format(d).equalsIgnoreCase("00:00:00")) {
|
||||||
Bukkit.broadcastMessage(S_PREFIX + "Der Server startet neu.");
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
bungeeUtil.sendToServer(p, config.cfg.getString("Lobby.name"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (df.format(d).equalsIgnoreCase("00:00:05")) {
|
|
||||||
Bukkit.spigot().restart();
|
Bukkit.spigot().restart();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}, 20L, 20L);
|
}, 20L, 20L);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
|
|
||||||
}
|
}
|
||||||
public static WarShipFactory getPlugin() {
|
public static BauSystem getPlugin() {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
public static WorldEditPlugin getWorldEdit() {
|
public static WorldEditPlugin getWorldEdit() {
|
||||||
@ -190,66 +160,25 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
{
|
|
||||||
log("Shutdown", "Unloading world ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String section, String msg) {
|
public static BauSystem getInstance() {
|
||||||
Bukkit.getConsoleSender().sendMessage("[WSF | " + section + "] " + msg);
|
return JavaPlugin.getPlugin(BauSystem.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WarShipFactory getInstance() {
|
|
||||||
return JavaPlugin.getPlugin(WarShipFactory.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public FactoryWorld getWorldFromOwner(UUID ownaz) {
|
|
||||||
{
|
|
||||||
if (Bauwelt.getBauwelt(ownaz).getUUID().equals(ownaz));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public FactoryWorld getWorldByAddress(String address, UUID ownaz) {
|
|
||||||
if (Bauwelt.getBauwelt(ownaz).getUUID().equals(ownaz));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Completer(name = "bau")
|
@Completer(name = "bau")
|
||||||
public List<String> completeCommands(CommandArgs args) {
|
public List<String> completeCommands(CommandArgs args) {
|
||||||
List<String> ret = new ArrayList<String>();
|
List<String> ret = new ArrayList<>();
|
||||||
String label = args.getCommand().getLabel();
|
StringBuilder label = new StringBuilder(args.getCommand().getLabel());
|
||||||
for (String arg : args.getArgs()) {
|
for (String arg : args.getArgs()) {
|
||||||
label += " " + arg;
|
label.append(" ").append(arg);
|
||||||
}
|
}
|
||||||
for (String currentLabel : this.cmdFramework.getCommandLabels()) {
|
for (String currentLabel : this.cmdFramework.getCommandLabels()) {
|
||||||
String current = currentLabel.replace('.', ' ');
|
String current = currentLabel.replace('.', ' ');
|
||||||
if (currentLabel.contains("BauFactory"))
|
if (currentLabel.contains("BauFactory"))
|
||||||
continue;
|
continue;
|
||||||
if (current.contains(label)) {
|
if (current.contains(label.toString())) {
|
||||||
current = current.substring(label.lastIndexOf(' ')).trim();
|
current = current.substring(label.toString().lastIndexOf(' ')).trim();
|
||||||
current = current.substring(0, current.indexOf(' ') != -1 ? current.indexOf(' ') : current.length())
|
|
||||||
.trim();
|
|
||||||
if (!ret.contains(current)) {
|
|
||||||
ret.add(current);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@Completer(name = "gs")
|
|
||||||
public List<String> completeCommands1(CommandArgs args) {
|
|
||||||
List<String> ret = new ArrayList<String>();
|
|
||||||
String label = args.getCommand().getLabel();
|
|
||||||
for (String arg : args.getArgs()) {
|
|
||||||
label += " " + arg;
|
|
||||||
}
|
|
||||||
for (String currentLabel : this.cmdFramework.getCommandLabels()) {
|
|
||||||
String current = currentLabel.replace('.', ' ');
|
|
||||||
if (currentLabel.contains("BauFactory"))
|
|
||||||
continue;
|
|
||||||
if (current.contains(label)) {
|
|
||||||
current = current.substring(label.lastIndexOf(' ')).trim();
|
|
||||||
current = current.substring(0, current.indexOf(' ') != -1 ? current.indexOf(' ') : current.length())
|
current = current.substring(0, current.indexOf(' ') != -1 ? current.indexOf(' ') : current.length())
|
||||||
.trim();
|
.trim();
|
||||||
if (!ret.contains(current)) {
|
if (!ret.contains(current)) {
|
||||||
@ -260,15 +189,38 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CommandInjector {
|
@Completer(name = "gs")
|
||||||
private static String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
public List<String> completeCommands1(CommandArgs args) {
|
||||||
private static String version;
|
List<String> ret = new ArrayList<>();
|
||||||
|
StringBuilder label = new StringBuilder(args.getCommand().getLabel());
|
||||||
|
for (String arg : args.getArgs()) {
|
||||||
|
label.append(" ").append(arg);
|
||||||
|
}
|
||||||
|
for (String currentLabel : this.cmdFramework.getCommandLabels()) {
|
||||||
|
String current = currentLabel.replace('.', ' ');
|
||||||
|
if (currentLabel.contains("BauFactory"))
|
||||||
|
continue;
|
||||||
|
if (current.contains(label.toString())) {
|
||||||
|
current = current.substring(label.toString().lastIndexOf(' ')).trim();
|
||||||
|
current = current.substring(0, current.indexOf(' ') != -1 ? current.indexOf(' ') : current.length())
|
||||||
|
.trim();
|
||||||
|
if (!ret.contains(current)) {
|
||||||
|
ret.add(current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class CommandInjector {
|
||||||
|
private static final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
private static final String version;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
version = packageName.substring(packageName.lastIndexOf(".") + 1);
|
version = packageName.substring(packageName.lastIndexOf(".") + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void injectCommand(Command cmd) throws Exception {
|
static void injectCommand(Command cmd) throws Exception {
|
||||||
Class serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
|
Class serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
|
||||||
Field f1 = serverClass.getDeclaredField("commandMap");
|
Field f1 = serverClass.getDeclaredField("commandMap");
|
||||||
f1.setAccessible(true);
|
f1.setAccessible(true);
|
||||||
@ -291,10 +243,9 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e) throws SQLException {
|
public void onJoin(PlayerJoinEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
p.teleport(config.spawn);
|
p.teleport(config.spawn);
|
||||||
p.getInventory().clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -304,7 +255,7 @@ public class WarShipFactory extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
if (e.getCause() == TeleportCause.SPECTATE) {
|
if (e.getCause() == TeleportCause.SPECTATE) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
e.getPlayer().sendMessage(WarShipFactory.S_PREFIX + "§cDu darfst die GM3 Teleportfunktion nicht benutzen!");
|
e.getPlayer().sendMessage(BauSystem.PREFIX + "§cDu darfst die GM3 Teleportfunktion nicht benutzen!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,20 +1,19 @@
|
|||||||
package de.quantumnanox.warshipfactory.main;
|
package de.warking.bausystem;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
|
||||||
public class CommandRemover {
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
private static String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
class CommandRemover {
|
||||||
private static String version = packageName.substring(packageName.lastIndexOf(".") + 1);
|
|
||||||
|
private static final String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
private static final String version = packageName.substring(packageName.lastIndexOf(".") + 1);
|
||||||
|
|
||||||
public static void removeAll(String... cmds) throws Exception {
|
public static void removeAll(String... cmds) throws Exception {
|
||||||
for (int i = 0; i < cmds.length; i++)
|
for (String cmd : cmds) removeCommand(cmd);
|
||||||
removeCommand(cmds[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,7 +23,7 @@ public class CommandRemover {
|
|||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static boolean removeCommand(String command) throws Exception {
|
public static void removeCommand(String command) throws Exception {
|
||||||
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
|
Class<?> serverClass = Class.forName("org.bukkit.craftbukkit." + version + ".CraftServer");
|
||||||
|
|
||||||
Field f1 = serverClass.getDeclaredField("commandMap");
|
Field f1 = serverClass.getDeclaredField("commandMap");
|
||||||
@ -35,7 +34,7 @@ public class CommandRemover {
|
|||||||
f2.setAccessible(true);
|
f2.setAccessible(true);
|
||||||
Map<String, Command> knownCommands = (Map<String, Command>) f2.get(commandMap);
|
Map<String, Command> knownCommands = (Map<String, Command>) f2.get(commandMap);
|
||||||
|
|
||||||
return knownCommands.remove(command.toLowerCase()) != null;
|
knownCommands.remove(command.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
611
src/de/warking/bausystem/commands/CommandBau.java
Normale Datei
611
src/de/warking/bausystem/commands/CommandBau.java
Normale Datei
@ -0,0 +1,611 @@
|
|||||||
|
package de.warking.bausystem.commands;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.CuboidClipboard;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
|
import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import de.pro_crafting.commandframework.Command;
|
||||||
|
import de.pro_crafting.commandframework.CommandArgs;
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.bausystem.world.BauWorld;
|
||||||
|
import de.warking.hunjy.MySQL.Bauwelt;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandBau {
|
||||||
|
|
||||||
|
@Command(name = "bau", aliases = "gs")
|
||||||
|
public void onBau(CommandArgs args) {
|
||||||
|
onHelp(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.help", aliases = "gs.help", inGameOnly = true)
|
||||||
|
public void onHelp(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Hilfeseite 1 von 2:");
|
||||||
|
p.sendMessage("§6/bau help §7- Zeigt dir diese Hilfe");
|
||||||
|
p.sendMessage("§6/bau help 2 §7- Zeigt dir Seite 2 der Hilfe");
|
||||||
|
p.sendMessage("§6/bau home §7- Teleportiert dich auf deine Welt");
|
||||||
|
p.sendMessage("§6/bau addmember §7- Fügt zu deiner Welt einen Spieler hinzu");
|
||||||
|
p.sendMessage("§6/bau delmember §7- Entfernt einen Spieler von deiner Welt");
|
||||||
|
p.sendMessage("§6/bau tntdmg §7- Erlaubt / verbietet Explosionen");
|
||||||
|
p.sendMessage("§6/bau firedmg §7- Erlaubt / verbietet Feuerschaden");
|
||||||
|
p.sendMessage("§6/bau testblock §7- Erneuert den nächsten Testblock");
|
||||||
|
p.sendMessage("§6/bau reset §7- Setzt die derzeitige Region zurück");
|
||||||
|
p.sendMessage("§6/bau resetall §7- Setzt deine Welt zurück");
|
||||||
|
p.sendMessage("§6/bau replace §7- Ersetzt in einer Region Obsidian zu TNT und Grundgestein zu Schleim");
|
||||||
|
p.sendMessage("§6/bau speed §7- Ändert deine Fluggeschwindigkeit");
|
||||||
|
p.sendMessage("§6/bau tp §7- Teleportiert dich auf eine Welt");
|
||||||
|
p.sendMessage("§6/bau info §7- Informationen über die aktuelle Welt");
|
||||||
|
p.sendMessage("§6/bau gui §7- Öffnet eine GUI");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.help.2", aliases = "gs.help.2", inGameOnly = true)
|
||||||
|
public void onHelp2(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Hilfeseite 2 von 2:");
|
||||||
|
p.sendMessage("§6/bau togglewe §7- Darf ein Spieler WorldEdit verwenden");
|
||||||
|
p.sendMessage("§6/bau togglebuild §7- Darf ein Spieler bauen");
|
||||||
|
p.sendMessage("§6/bau toggletp §7- Darf ein Spieler sich teleportieren");
|
||||||
|
p.sendMessage("§6/bau toggletestblock §7- Darf ein Spieler einen TestBlock erneuern");
|
||||||
|
p.sendMessage("§6/bau togglereset §7- Darf ein Spieler eine Region erneuern");
|
||||||
|
p.sendMessage("§6/bau togglereplace §7- Darf ein Spieler in einer Region replacen");
|
||||||
|
p.sendMessage("§6/bau togglechgm §7- Darf ein Spieler seinen Spielmodus ändern");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.home", aliases = "gs.home", inGameOnly = true)
|
||||||
|
public void onHome(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()) == null) {
|
||||||
|
new Bauwelt(p.getUniqueId(), false, false);
|
||||||
|
}
|
||||||
|
if (Bukkit.getWorld(p.getUniqueId()) == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet");
|
||||||
|
try {
|
||||||
|
BauWorld.loadWorld(p.getUniqueId());
|
||||||
|
} catch (IOException e) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p.teleport(Bukkit.getWorld(p.getUniqueId().toString()).getSpawnLocation());
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> p.setGameMode(GameMode.CREATIVE),20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.addmember", aliases = "gs.addmember", inGameOnly = true)
|
||||||
|
public void onAdd(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast noch keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau addmember <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}else if (BauweltMember.getBauMember(p.getUniqueId(), id) != null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BauweltMember(p.getUniqueId(), id, true, false, false, false, false);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler wurde zu deiner Welt hinzugefügt");
|
||||||
|
Player z = Bukkit.getPlayer(id);
|
||||||
|
if(z != null)
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.delmember", aliases = "gs.delmember", inGameOnly = true)
|
||||||
|
public void onDel(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast noch keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau delmember <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
BauWorld.removePlayer(p, id);
|
||||||
|
}
|
||||||
|
@Command(name = "bau.tp", aliases = "gs.tp", inGameOnly = true)
|
||||||
|
public void onTp(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau tp <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}else if (Bauwelt.getBauwelt(id) == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist kein Mitglied dieser Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!p.hasPermission("bau.team")) {
|
||||||
|
if(BauweltMember.getBauMember(id, p.getUniqueId()) == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist kein Mitglied dieser Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.getWorld(p.getUniqueId()) == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet");
|
||||||
|
try {
|
||||||
|
BauWorld.loadWorld(id);
|
||||||
|
} catch (IOException e) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p.teleport(Bukkit.getWorld(id.toString()).getSpawnLocation());
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(BauSystem.getInstance(), () -> p.setGameMode(GameMode.CREATIVE), 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.speed", aliases = "gs.speed", inGameOnly = true)
|
||||||
|
public void onSpeed(CommandArgs args){
|
||||||
|
final Player player = args.getPlayer();
|
||||||
|
if (args.length() == 0){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "/bau speed [Geschwindigkeit]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float speed;
|
||||||
|
try{
|
||||||
|
speed = Float.valueOf(args.getArgs(0));
|
||||||
|
}catch(NumberFormatException e){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (speed < 0 || speed > 10) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFlySpeed(speed);
|
||||||
|
player.setWalkSpeed(speed);
|
||||||
|
player.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.gui", aliases = "gs.gui", inGameOnly = true)
|
||||||
|
public boolean ongui(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 9, "§aBauoptionen");
|
||||||
|
ItemStack bau = new ItemStack(Material.COMPASS);
|
||||||
|
ItemMeta meta = bau.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§7Grundstücksregionen");
|
||||||
|
bau.setItemMeta(meta);
|
||||||
|
inv.addItem(bau);
|
||||||
|
ItemStack optionen = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
|
meta = optionen.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§7Weltoptionen");
|
||||||
|
optionen.setItemMeta(meta);
|
||||||
|
inv.setItem(8, optionen);
|
||||||
|
ItemStack spieler = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = spieler.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§7Spieleroptionen");
|
||||||
|
spieler.setItemMeta(meta);
|
||||||
|
inv.setItem(4, spieler);
|
||||||
|
p.openInventory(inv);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.togglewe", aliases = "gs.togglewe", inGameOnly = true)
|
||||||
|
public void onToggleWE(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau togglewe <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleWE(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.toggletp", aliases = "gs.toggletp", inGameOnly = true)
|
||||||
|
public void onToggleTP(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau toggletp <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleTP(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.togglebuild", aliases = "gs.togglebuild", inGameOnly = true)
|
||||||
|
public void onToggleBD(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau togglebuild <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleBuild(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.togglechgm", aliases = "gs.togglechgm", inGameOnly = true)
|
||||||
|
public void onToggleCHG(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau togglechgm <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleGM(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.toggletestblock", aliases = "gs.toggletestblock", inGameOnly = true)
|
||||||
|
public void onToggleTestblock(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau toggletestblock <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleTestblock(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.togglereset", aliases = "gs.togglereset", inGameOnly = true)
|
||||||
|
public void onTogglereset(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau togglereset <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleTestblock(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.togglereplace", aliases = "gs.togglereplace", inGameOnly = true)
|
||||||
|
public void onToggleReplace(CommandArgs args) {
|
||||||
|
Player p = args.getPlayer();
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
return;
|
||||||
|
}else if (args.length() == 0) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "/bau togglereplace <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(args.getArgs(0)).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauWorld.toggleTestblock(p, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.testblock", aliases = "gs.testblock", inGameOnly = true)
|
||||||
|
public void onTestblock(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(p.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist auf keiner Bauwelt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!p.getUniqueId().equals(worldOwner)){
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
if(member == null || !member.isTestblock()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst den Testblock nicht erneuern");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location playerLocation = p.getLocation();
|
||||||
|
World playerWorld = p.getWorld();
|
||||||
|
|
||||||
|
for (ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
|
||||||
|
|
||||||
|
String rgID = rg.getId();
|
||||||
|
|
||||||
|
if(rgID.equalsIgnoreCase("resetall"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector position = new Vector(Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
|
||||||
|
File file = new File(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.testblock"));
|
||||||
|
|
||||||
|
pasteSchematic(p, file, position);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aTestblock erneuert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.reset", aliases = "gs.reset", inGameOnly = true)
|
||||||
|
public void onReset(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(p.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist auf keiner Bauwelt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!p.getUniqueId().equals(worldOwner)){
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
if(member == null || !member.isTestblock()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst keine Regionen erneuern");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Location playerLocation = p.getLocation();
|
||||||
|
World playerWorld = p.getWorld();
|
||||||
|
|
||||||
|
for (ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
|
||||||
|
String rgID = rg.getId();
|
||||||
|
|
||||||
|
if(rgID.equalsIgnoreCase("resetall"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Vector position = new Vector(Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
|
||||||
|
File file = new File(BauSystem.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.reset"));
|
||||||
|
|
||||||
|
pasteSchematic(p, file, position);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aRegion " + rgID + " wurde erneuert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.resetall", aliases = "gs.resetall", inGameOnly = true)
|
||||||
|
public void onResetAll(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDeine Welt wird zurückgesetzt. Einen Moment bitte");
|
||||||
|
BauWorld.unloadWorld(p.getUniqueId());
|
||||||
|
File directory = new File(p.getUniqueId().toString());
|
||||||
|
del(directory);
|
||||||
|
File directory1 = new File("plugins/WorldGuard/worlds/" + p.getUniqueId().toString());
|
||||||
|
del(directory1);
|
||||||
|
onHome(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.replace", aliases = "gs.replace", inGameOnly = true)
|
||||||
|
public void onReplace(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(p.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist auf keiner Bauwelt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!p.getUniqueId().equals(worldOwner)){
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
if(member == null || !member.isTestblock()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst nicht Obsidian & Grundgestein ersetzen");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
World world = p.getWorld();
|
||||||
|
for(ProtectedRegion rg : BauSystem.getWorldGuard().getRegionManager(world).getApplicableRegions(p.getLocation())) {
|
||||||
|
String rgID = rg.getId();
|
||||||
|
|
||||||
|
if(rgID.equalsIgnoreCase("resetall"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
EditSession editSession = BauSystem.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(p.getWorld()), Integer.MAX_VALUE);
|
||||||
|
CuboidSelection selection = new CuboidSelection(p.getWorld(), new Location(p.getWorld(), rg.getMinimumPoint().getBlockX(), rg.getMinimumPoint().getBlockY(), rg.getMinimumPoint().getBlockZ()), new Location(p.getWorld(), rg.getMaximumPoint().getBlockX(), rg.getMaximumPoint().getBlockY(), rg.getMaximumPoint().getBlockZ()));
|
||||||
|
|
||||||
|
Set<BaseBlock> targetObsidian = new HashSet<>();
|
||||||
|
targetObsidian.add(new BaseBlock(49));
|
||||||
|
Set<BaseBlock> targetBedrock = new HashSet<>();
|
||||||
|
targetBedrock.add(new BaseBlock(7));
|
||||||
|
try {
|
||||||
|
|
||||||
|
int tnt = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
|
||||||
|
int slime = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
|
||||||
|
editSession.flushQueue();
|
||||||
|
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aIn Region " + rgID + " wurden " + tnt + " Blöcke Obsidian zu TNT und " + slime + " Blöcke Grundgestein zu Schleim ersetzt");
|
||||||
|
|
||||||
|
} catch(Exception ex) { ex.printStackTrace(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.info", aliases = "gs.info", inGameOnly = true)
|
||||||
|
public void onInfo(CommandArgs args) {
|
||||||
|
final Player p = args.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(p.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu bist auf keiner Bauwelt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(BauSystem.getInstance(), () -> {
|
||||||
|
Bauwelt welt = Bauwelt.getBauwelt(worldOwner);
|
||||||
|
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "ID§8: §6" + welt.getUserID());
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Besitzer§8: §6" + WarkingUser.get(welt.getUserID()).getUserName());
|
||||||
|
|
||||||
|
if(welt.isTNTDmg())
|
||||||
|
p.sendMessage("TNT-Schaden§8: §aerlaubt");
|
||||||
|
else
|
||||||
|
p.sendMessage("TNT-Schaden§8: §cverboten");
|
||||||
|
if(welt.isFireDmg())
|
||||||
|
p.sendMessage("Feuer-Schaden§8: §aerlaubt");
|
||||||
|
else
|
||||||
|
p.sendMessage("Feuer-Schaden§8: §cverboten");
|
||||||
|
|
||||||
|
List<BauweltMember> memberList = BauweltMember.getMembers(worldOwner);
|
||||||
|
StringBuilder members = new StringBuilder();
|
||||||
|
members.append(BauSystem.PREFIX);
|
||||||
|
members.append("Mitglieder§8: ");
|
||||||
|
for(BauweltMember member : memberList){
|
||||||
|
members.append("§6");
|
||||||
|
members.append(WarkingUser.get(member.getMemberID()).getUserName());
|
||||||
|
members.append("§8, ");
|
||||||
|
}
|
||||||
|
p.sendMessage(members.toString());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.tntdmg", aliases = "gs.tntdmg", inGameOnly = true)
|
||||||
|
public void onTntdmg(CommandArgs args){
|
||||||
|
BauWorld.switchTNT(args.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(name = "bau.firedmg", aliases = "gs.firedmg", inGameOnly = true)
|
||||||
|
public void onFiredmg(CommandArgs args) {
|
||||||
|
BauWorld.switchFire(args.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pasteSchematic(Player player, File schematic, Vector position) {
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
for(ProtectedRegion rg: BauSystem.getWorldGuard().getRegionManager(world).getApplicableRegions(player.getLocation())) {
|
||||||
|
count++;
|
||||||
|
if(count != 0) {
|
||||||
|
|
||||||
|
EditSession session = BauSystem.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(world), Integer.MAX_VALUE);
|
||||||
|
try {
|
||||||
|
|
||||||
|
CuboidClipboard format = MCEditSchematicFormat.getFormat(schematic).load(schematic);
|
||||||
|
format.paste(session, position, false);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
player.sendMessage(ex.getMessage());
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void del(File dir){
|
||||||
|
if (dir.isDirectory()){
|
||||||
|
String[] entries = dir.list();
|
||||||
|
for (String entry : entries) {
|
||||||
|
File aktFile = new File(dir.getPath(), entry);
|
||||||
|
del(aktFile);
|
||||||
|
}
|
||||||
|
dir.delete();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dir.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
128
src/de/warking/bausystem/commands/CommandGamemode.java
Normale Datei
128
src/de/warking/bausystem/commands/CommandGamemode.java
Normale Datei
@ -0,0 +1,128 @@
|
|||||||
|
package de.warking.bausystem.commands;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandGamemode extends BukkitCommand {
|
||||||
|
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
||||||
|
"spectator");
|
||||||
|
|
||||||
|
public CommandGamemode() {
|
||||||
|
super("gm");
|
||||||
|
this.description = "Ändert den Spielmodus eines Spielers";
|
||||||
|
this.usageMessage = "/gm [Spielmodus]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return false;
|
||||||
|
}else if (args.length == 0) {
|
||||||
|
sender.sendMessage(BauSystem.PREFIX + this.usageMessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = (Player) sender;
|
||||||
|
|
||||||
|
WarkingUser user = WarkingUser.get(p.getUniqueId());
|
||||||
|
|
||||||
|
if(p.hasPermission("bau.team")){
|
||||||
|
GameMode mode = createMode(args[0]);
|
||||||
|
|
||||||
|
if(mode == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length == 2){
|
||||||
|
Player target = Bukkit.getPlayerExact(args[1]);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(p.getUniqueId().equals(target)){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
target.setGameMode(mode);
|
||||||
|
}else{
|
||||||
|
p.setGameMode(mode);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else if(args.length > 1){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst nicht den Spielmodus anderer Spieler ändern.");
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(p.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich auf keiner Bauwelt!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!p.getUniqueId().equals(worldOwner)){
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
if(member == null || !member.isChangeGM()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier deinen Spielmodus nicht ändern.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMode mode = createMode(args[0]);
|
||||||
|
|
||||||
|
if(mode == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spielmodus.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
p.setGameMode(mode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GameMode createMode(String modeArg){
|
||||||
|
try {
|
||||||
|
return GameMode.getByValue(Integer.parseInt(modeArg));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c")))
|
||||||
|
return GameMode.CREATIVE;
|
||||||
|
else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a")))
|
||||||
|
return GameMode.ADVENTURE;
|
||||||
|
else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp")))
|
||||||
|
return GameMode.SPECTATOR;
|
||||||
|
else {
|
||||||
|
return GameMode.SURVIVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
||||||
|
Validate.notNull(sender, "Sender cannot be null");
|
||||||
|
Validate.notNull(args, "Arguments cannot be null");
|
||||||
|
Validate.notNull(alias, "Alias cannot be null");
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
return ((List) StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES,
|
||||||
|
new ArrayList(GAMEMODE_NAMES.size())));
|
||||||
|
if (args.length == 2) {
|
||||||
|
return super.tabComplete(sender, alias, args);
|
||||||
|
}
|
||||||
|
return ImmutableList.of();
|
||||||
|
}
|
||||||
|
}
|
558
src/de/warking/bausystem/commands/CommandGui.java
Normale Datei
558
src/de/warking/bausystem/commands/CommandGui.java
Normale Datei
@ -0,0 +1,558 @@
|
|||||||
|
package de.warking.bausystem.commands;
|
||||||
|
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.bausystem.world.BauWorld;
|
||||||
|
import de.warking.hunjy.MySQL.Bauwelt;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
public class CommandGui implements Listener {
|
||||||
|
|
||||||
|
private void handleEvent(InventoryClickEvent e, Player p, String m, Location l){
|
||||||
|
p.teleport(l);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + BauSystem.getInstance().config.cfg.getString(m));
|
||||||
|
e.getView().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerClickInventory(InventoryClickEvent e) {
|
||||||
|
if (e.getCurrentItem().getItemMeta() == null || e.getCurrentItem().getItemMeta().getDisplayName() != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
e.setCancelled(true);
|
||||||
|
String itemName = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||||
|
Player p = (Player) e.getWhoClicked();
|
||||||
|
if (e.getInventory().getTitle().equals("§7Grundstücksregionen")) {
|
||||||
|
if (itemName.equals("§bWarShip §aTestGelände 1"))
|
||||||
|
handleEvent(e, p, "WarShip1.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarShip1.loc.z")));
|
||||||
|
else if (itemName.equals("§bWarShip §aTestGelände 2"))
|
||||||
|
handleEvent(e, p, "WarShip2.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarShip2.loc.z")));
|
||||||
|
else if (itemName.equals("§bWarGear §aTestGelände 5"))
|
||||||
|
handleEvent(e, p, "WarGear5.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear5.loc.z")));
|
||||||
|
else if (itemName.equals("§bWarGear §aTestGelände 6"))
|
||||||
|
handleEvent(e, p, "WarGear6.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear6.loc.z")));
|
||||||
|
else if (itemName.equals("§bWarGear §aTestGelände 7"))
|
||||||
|
handleEvent(e, p, "WarGear7.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear7.loc.z")));
|
||||||
|
else if (itemName.equals("§bWarGear §aTestGelände 8"))
|
||||||
|
handleEvent(e, p, "WarGear8.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("WarGear8.loc.z")));
|
||||||
|
else if (itemName.equals("§bMiniWarGear §aTestGelände 1"))
|
||||||
|
handleEvent(e, p, "MiniWargear1.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear1.loc.z")));
|
||||||
|
else if (itemName.equals("§bMiniWarGear §aTestGelände 2"))
|
||||||
|
handleEvent(e, p, "MiniWargear2.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear2.loc.z")));
|
||||||
|
else if (itemName.equals("§bMiniWarGear §aTestGelände 7"))
|
||||||
|
handleEvent(e, p, "MiniWargear7.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear7.loc.z")));
|
||||||
|
else if (itemName.equals("§bMiniWarGear §aTestGelände 8"))
|
||||||
|
handleEvent(e, p, "MiniWargear8.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("MiniWargear8.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 1"))
|
||||||
|
handleEvent(e, p, "AirShip1.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip1.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 2"))
|
||||||
|
handleEvent(e, p, "AirShip2.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip2.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 3"))
|
||||||
|
handleEvent(e, p, "AirShip3.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip3.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 4"))
|
||||||
|
handleEvent(e, p, "AirShip4.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip4.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 5"))
|
||||||
|
handleEvent(e, p, "AirShip5.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip5.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 6"))
|
||||||
|
handleEvent(e, p, "AirShip6.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip6.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 7"))
|
||||||
|
handleEvent(e, p, "AirShip7.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip7.loc.z")));
|
||||||
|
else if (itemName.equals("§bAirShip §aTestGelände 8"))
|
||||||
|
handleEvent(e, p, "AirShip8.Message",
|
||||||
|
new Location(p.getWorld(), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.x"), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.y"), BauSystem.getInstance().config.cfg.getDouble("AirShip8.loc.z")));
|
||||||
|
else if (itemName.equals("§bZurück")){
|
||||||
|
e.getView().close();
|
||||||
|
p.openInventory(mainmenu());
|
||||||
|
}
|
||||||
|
}else if (e.getInventory().getTitle().equals("§7Weltoptionen")) {
|
||||||
|
if (itemName.equals("§aTNT-Schaden")) {
|
||||||
|
BauWorld.switchTNT(p);
|
||||||
|
e.getView().close();
|
||||||
|
p.openInventory(weltoption(p));
|
||||||
|
}else if (itemName.equals("§aFeuer-Schaden")) {
|
||||||
|
BauWorld.switchFire(p);
|
||||||
|
e.getView().close();
|
||||||
|
p.openInventory(weltoption(p));
|
||||||
|
}else if (itemName.equals("§bZurück")) {
|
||||||
|
e.getView().close();
|
||||||
|
p.openInventory(mainmenu());
|
||||||
|
}
|
||||||
|
}else if (e.getInventory().getTitle().equals("§aBauoptionen")) {
|
||||||
|
if (itemName.equals("§bBauregionen")) {
|
||||||
|
p.openInventory(bauabteilung());
|
||||||
|
}else if (itemName.equals("§bWelten Optionen")) {
|
||||||
|
p.openInventory(weltoption(p));
|
||||||
|
}else if (itemName.equals("§bSpieler Optionen")) {
|
||||||
|
p.openInventory(spieleroption(p));
|
||||||
|
}
|
||||||
|
}else if (e.getInventory().getTitle().equals("§bSpieler Optionen")) {
|
||||||
|
if (itemName.equals("§bZurück")) {
|
||||||
|
e.getView().close();
|
||||||
|
p.openInventory(mainmenu());
|
||||||
|
}else if (e.getCurrentItem() != null) {
|
||||||
|
Material material = e.getCurrentItem().getType();
|
||||||
|
if (material == Material.SKULL_ITEM) {
|
||||||
|
SkullMeta skullMeta = (SkullMeta) getSkull(material.getData().getCanonicalName()).getItemMeta();
|
||||||
|
SkullTeleport(p, e.getCurrentItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else if (itemName.equals("§bZurück")) {
|
||||||
|
e.getView().close();
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(spieleroption(p));
|
||||||
|
}else{
|
||||||
|
for (BauweltMember member : BauweltMember.getMembers(p.getUniqueId())) {
|
||||||
|
if (e.getInventory().getTitle().equals(WarkingUser.get(member.getMemberID()).getUserName())) {
|
||||||
|
ItemStack skull = new ItemStack(Material.SKULL_ITEM);
|
||||||
|
if (itemName.equals("§aSpieler hinzufügen")) {
|
||||||
|
/*if(member != null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else{
|
||||||
|
new BauweltMember(p.getUniqueId(),target.getUniqueId(), true, false, false, false, false);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDu hast " + target.getName() + " §azu der Welt hinzugefügt");
|
||||||
|
target.sendMessage(BauSystem.PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}*/
|
||||||
|
}else if (member == null){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist kein Mitglied auf deiner Welt");
|
||||||
|
}else if (itemName.equals("§aToggle Worldedit")) {
|
||||||
|
BauWorld.toggleWE(p, member);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else if (itemName.equals("§aToggle Teleport")) {
|
||||||
|
BauWorld.toggleTP(p, member);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else if (itemName.equals("§aToggle Build")) {
|
||||||
|
BauWorld.toggleBuild(p, member);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else if (itemName.equals("§aToggle ChangeGamemode")) {
|
||||||
|
BauWorld.toggleGM(p, member);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else if (itemName.equals("§aToggle Replace") || itemName.equals("§aToggle Reset") || itemName.equals("§aToggle TestBlock")){
|
||||||
|
BauWorld.toggleTestblock(p, member);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(skullOwnerInventory(member, p));
|
||||||
|
}else if (itemName.equals("§cSpieler entfernen")){
|
||||||
|
BauWorld.removePlayer(p, WarkingUser.get(member.getMemberID()).getUUID());
|
||||||
|
p.openInventory(spieleroption(p));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack getSkull(String name) {
|
||||||
|
ItemStack skull = new ItemStack(397, 1, (short) 3);
|
||||||
|
SkullMeta skullmeta = (SkullMeta) skull.getItemMeta();
|
||||||
|
skullmeta.setDisplayName(name);
|
||||||
|
skullmeta.setOwner(name);
|
||||||
|
skull.setItemMeta(skullmeta);
|
||||||
|
return skull;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SkullTeleport(Player player, ItemStack item) {
|
||||||
|
SkullMeta skullmeta = (SkullMeta) item.getItemMeta();
|
||||||
|
if (skullmeta.getDisplayName() != null) {
|
||||||
|
if (Bukkit.getPlayer(skullmeta.getDisplayName()) != null) {
|
||||||
|
Player target = Bukkit.getPlayer(skullmeta.getDisplayName());
|
||||||
|
player.openInventory(skullOwnerInventory(BauweltMember.getBauMember(player.getUniqueId(), target.getUniqueId()), player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Inventory skullOwnerInventory(BauweltMember member, Player player) {
|
||||||
|
|
||||||
|
Inventory inv2 = Bukkit.createInventory(null, 18, WarkingUser.get(member.getMemberID()).getUserName());
|
||||||
|
ItemStack skull = new ItemStack(Material.SKULL_ITEM);
|
||||||
|
ItemMeta meta = skull.getItemMeta();
|
||||||
|
meta = skull.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aSpieler hinzufügen");
|
||||||
|
skull.setItemMeta(meta);
|
||||||
|
inv2.addItem(skull);
|
||||||
|
|
||||||
|
ItemStack skull1 = new ItemStack(Material.SKULL_ITEM);
|
||||||
|
meta = skull1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§cSpieler entfernen");
|
||||||
|
skull1.setItemMeta(meta);
|
||||||
|
inv2.setItem(9, skull1);
|
||||||
|
|
||||||
|
ItemStack togglewe = new ItemStack(Material.WOOD_AXE);
|
||||||
|
meta = togglewe.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle Worldedit");
|
||||||
|
togglewe.setItemMeta(meta);
|
||||||
|
inv2.setItem(1, togglewe);
|
||||||
|
|
||||||
|
ItemStack toggletp = new ItemStack(Material.COMPASS);
|
||||||
|
meta = toggletp.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle Teleport");
|
||||||
|
toggletp.setItemMeta(meta);
|
||||||
|
inv2.setItem(2, toggletp);
|
||||||
|
|
||||||
|
ItemStack togglebuild = new ItemStack(Material.GRASS);
|
||||||
|
meta = togglebuild.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle Build");
|
||||||
|
togglebuild.setItemMeta(meta);
|
||||||
|
inv2.setItem(3, togglebuild);
|
||||||
|
|
||||||
|
ItemStack togglegm = new ItemStack(Material.LADDER);
|
||||||
|
meta = togglegm.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle ChangeGamemode");
|
||||||
|
togglegm.setItemMeta(meta);
|
||||||
|
inv2.setItem(4, togglegm);
|
||||||
|
|
||||||
|
ItemStack togglerep = new ItemStack(Material.BREWING_STAND_ITEM);
|
||||||
|
meta = togglerep.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle Replace");
|
||||||
|
togglerep.setItemMeta(meta);
|
||||||
|
inv2.setItem(5, togglerep);
|
||||||
|
|
||||||
|
ItemStack togglereset = new ItemStack(Material.BARRIER);
|
||||||
|
meta = togglereset.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle Reset");
|
||||||
|
togglereset.setItemMeta(meta);
|
||||||
|
inv2.setItem(6, togglereset);
|
||||||
|
|
||||||
|
ItemStack toggletestblock = new ItemStack(Material.ENDER_STONE);
|
||||||
|
meta = toggletestblock.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§aToggle TestBlock");
|
||||||
|
toggletestblock.setItemMeta(meta);
|
||||||
|
inv2.setItem(7, toggletestblock);
|
||||||
|
|
||||||
|
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
||||||
|
meta = back.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§bZurück");
|
||||||
|
back.setItemMeta(meta);
|
||||||
|
inv2.setItem(8, back);
|
||||||
|
|
||||||
|
if (Bauwelt.getBauwelt(player.getUniqueId()).getUUID() == null) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDu hast keine Welt");
|
||||||
|
}else if (BauweltMember.getBauMember(player.getUniqueId(), WarkingUser.get(member.getMemberID()).getUUID()) == null) {
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
||||||
|
} else {
|
||||||
|
if (member.isWorldEdit()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(10, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(10, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isTeleport()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(11, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(11, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isBuild()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(12, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(12, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isChangeGM()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(13, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(13, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isWorldEdit()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(14, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(14, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isWorldEdit()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(15, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(15, tntst1);
|
||||||
|
}
|
||||||
|
if (member.isWorldEdit()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(16, tntst);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(16, tntst1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inv2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Inventory mainmenu() {
|
||||||
|
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 9, "§aBau Optionen");
|
||||||
|
{
|
||||||
|
ItemStack bau = new ItemStack(Material.COMPASS);
|
||||||
|
ItemMeta meta = bau.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§bBauregionen");
|
||||||
|
bau.setItemMeta(meta);
|
||||||
|
inv.addItem(bau);
|
||||||
|
ItemStack optionen = new ItemStack(Material.ENCHANTED_BOOK);
|
||||||
|
meta = optionen.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWeltoptionen");
|
||||||
|
optionen.setItemMeta(meta);
|
||||||
|
inv.setItem(8, optionen);
|
||||||
|
ItemStack spieler = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = spieler.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.RED + "§bSpieleroptionen");
|
||||||
|
spieler.setItemMeta(meta);
|
||||||
|
inv.setItem(4, spieler);
|
||||||
|
}
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Inventory spieleroption(Player player) {
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 54, "§bSpieleroptionen");
|
||||||
|
{
|
||||||
|
inv.clear();
|
||||||
|
int slot = 0;
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
inv.setItem(slot, getSkull(p.getName()));
|
||||||
|
slot++;
|
||||||
|
}
|
||||||
|
ItemStack skull1 = new ItemStack(Material.SLIME_BALL);
|
||||||
|
ItemMeta meta1 = skull1.getItemMeta();
|
||||||
|
meta1 = skull1.getItemMeta();
|
||||||
|
meta1.setDisplayName(ChatColor.RED + "§bZurück");
|
||||||
|
skull1.setItemMeta(meta1);
|
||||||
|
inv.setItem(53, skull1);
|
||||||
|
}return inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Inventory bauabteilung() {
|
||||||
|
Inventory inv1 = Bukkit.createInventory(null, 54, "§bBauregionen");
|
||||||
|
{
|
||||||
|
ItemStack warship1 = new ItemStack(Material.WATER_BUCKET);
|
||||||
|
ItemMeta meta = warship1.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarShip §aTestGelände 1");
|
||||||
|
warship1.setItemMeta(meta);
|
||||||
|
inv1.addItem(warship1);
|
||||||
|
ItemStack warship2 = new ItemStack(Material.WATER_BUCKET);
|
||||||
|
meta = warship2.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarShip §aTestGelände 2");
|
||||||
|
warship2.setItemMeta(meta);
|
||||||
|
inv1.setItem(1, warship2);
|
||||||
|
ItemStack wargear1 = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = wargear1.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarGear §aTestGelände 5");
|
||||||
|
wargear1.setItemMeta(meta);
|
||||||
|
inv1.setItem(9, wargear1);
|
||||||
|
ItemStack wargear2 = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = wargear2.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarGear §aTestGelände 6");
|
||||||
|
wargear2.setItemMeta(meta);
|
||||||
|
inv1.setItem(10, wargear2);
|
||||||
|
ItemStack wargear3 = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = wargear3.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarGear §aTestGelände 7");
|
||||||
|
wargear3.setItemMeta(meta);
|
||||||
|
inv1.setItem(11, wargear3);
|
||||||
|
ItemStack wargear4 = new ItemStack(Material.REDSTONE_BLOCK);
|
||||||
|
meta = wargear4.getItemMeta();
|
||||||
|
meta.setDisplayName("§bWarGear §aTestGelände 8");
|
||||||
|
wargear4.setItemMeta(meta);
|
||||||
|
inv1.setItem(12, wargear4);
|
||||||
|
ItemStack miniwargear1 = new ItemStack(Material.REDSTONE);
|
||||||
|
meta = miniwargear1.getItemMeta();
|
||||||
|
meta.setDisplayName("§bMiniWarGear §aTestGelände 1");
|
||||||
|
miniwargear1.setItemMeta(meta);
|
||||||
|
inv1.setItem(18, miniwargear1);
|
||||||
|
ItemStack miniwargear2 = new ItemStack(Material.REDSTONE);
|
||||||
|
meta = miniwargear2.getItemMeta();
|
||||||
|
meta.setDisplayName("§bMiniWarGear §aTestGelände 2");
|
||||||
|
miniwargear2.setItemMeta(meta);
|
||||||
|
inv1.setItem(19, miniwargear2);
|
||||||
|
ItemStack miniwargear3 = new ItemStack(Material.REDSTONE);
|
||||||
|
meta = miniwargear3.getItemMeta();
|
||||||
|
meta.setDisplayName("§bMiniWarGear §aTestGelände 7");
|
||||||
|
miniwargear3.setItemMeta(meta);
|
||||||
|
inv1.setItem(20, miniwargear3);
|
||||||
|
ItemStack miniwargear4 = new ItemStack(Material.REDSTONE);
|
||||||
|
meta = miniwargear4.getItemMeta();
|
||||||
|
meta.setDisplayName("§bMiniWarGear §aTestGelände 8");
|
||||||
|
miniwargear4.setItemMeta(meta);
|
||||||
|
inv1.setItem(21, miniwargear4);
|
||||||
|
ItemStack airship1 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship1.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 1");
|
||||||
|
airship1.setItemMeta(meta);
|
||||||
|
inv1.setItem(27, airship1);
|
||||||
|
ItemStack airship2 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship2.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 2");
|
||||||
|
airship2.setItemMeta(meta);
|
||||||
|
inv1.setItem(28, airship2);
|
||||||
|
ItemStack airship3 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship3.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 3");
|
||||||
|
airship3.setItemMeta(meta);
|
||||||
|
inv1.setItem(29, airship3);
|
||||||
|
ItemStack airship4 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship4.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 4");
|
||||||
|
airship4.setItemMeta(meta);
|
||||||
|
inv1.setItem(30, airship4);
|
||||||
|
ItemStack airship5 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship5.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 5");
|
||||||
|
airship5.setItemMeta(meta);
|
||||||
|
inv1.setItem(31, airship5);
|
||||||
|
ItemStack airship6 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship6.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 6");
|
||||||
|
airship6.setItemMeta(meta);
|
||||||
|
inv1.setItem(32, airship6);
|
||||||
|
ItemStack airship7 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship7.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 7");
|
||||||
|
airship7.setItemMeta(meta);
|
||||||
|
inv1.setItem(33, airship7);
|
||||||
|
ItemStack airship8 = new ItemStack(Material.ELYTRA);
|
||||||
|
meta = airship8.getItemMeta();
|
||||||
|
meta.setDisplayName("§bAirShip §aTestGelände 8");
|
||||||
|
airship8.setItemMeta(meta);
|
||||||
|
inv1.setItem(34, airship8);
|
||||||
|
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
||||||
|
ItemMeta meta1 = back.getItemMeta();
|
||||||
|
meta1.setDisplayName("§bZurück");
|
||||||
|
back.setItemMeta(meta1);
|
||||||
|
inv1.setItem(53, back);
|
||||||
|
}return inv1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Inventory weltoption(Player p) {
|
||||||
|
Inventory inv2 = Bukkit.createInventory(null, 18, "§bWeltoptionen");
|
||||||
|
{
|
||||||
|
ItemStack tnt = new ItemStack(Material.TNT);
|
||||||
|
ItemMeta meta = tnt.getItemMeta();
|
||||||
|
meta.setDisplayName("§aTNT Schaden");
|
||||||
|
tnt.setItemMeta(meta);
|
||||||
|
inv2.addItem(tnt);
|
||||||
|
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
||||||
|
meta = back.getItemMeta();
|
||||||
|
meta.setDisplayName("§bZurück");
|
||||||
|
back.setItemMeta(meta);
|
||||||
|
inv2.setItem(4, back);
|
||||||
|
ItemStack fire = new ItemStack(Material.LAVA_BUCKET);
|
||||||
|
meta = fire.getItemMeta();
|
||||||
|
meta.setDisplayName("§aFeuer Schaden");
|
||||||
|
fire.setItemMeta(meta);
|
||||||
|
inv2.setItem(8, fire);
|
||||||
|
p.openInventory(inv2);
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName("§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(9, tntst);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(inv2);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName("§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(9, tntst1);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(inv2);
|
||||||
|
}
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) {
|
||||||
|
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
||||||
|
meta = tntst.getItemMeta();
|
||||||
|
meta.setDisplayName("§eStatus §2An");
|
||||||
|
tntst.setItemMeta(meta);
|
||||||
|
inv2.setItem(17, tntst);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(inv2);
|
||||||
|
} else {
|
||||||
|
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
||||||
|
meta = tntst1.getItemMeta();
|
||||||
|
meta.setDisplayName("§eStatus §4Aus");
|
||||||
|
tntst1.setItemMeta(meta);
|
||||||
|
inv2.setItem(17, tntst1);
|
||||||
|
p.closeInventory();
|
||||||
|
p.openInventory(inv2);
|
||||||
|
}
|
||||||
|
}return inv2;
|
||||||
|
}
|
||||||
|
}
|
99
src/de/warking/bausystem/commands/CommandTeleport.java
Normale Datei
99
src/de/warking/bausystem/commands/CommandTeleport.java
Normale Datei
@ -0,0 +1,99 @@
|
|||||||
|
package de.warking.bausystem.commands;
|
||||||
|
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CommandTeleport extends BukkitCommand {
|
||||||
|
public CommandTeleport() {
|
||||||
|
super("tp");
|
||||||
|
description = "Teleportiert dich zu einem genannten Spieler.";
|
||||||
|
usageMessage = "/tp [Spieler]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
return false;
|
||||||
|
else if ((args.length < 1) || (args.length > 2)) {
|
||||||
|
sender.sendMessage(BauSystem.PREFIX + usageMessage);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = (Player) sender;
|
||||||
|
|
||||||
|
Player target = Bukkit.getPlayerExact(args[0]);
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
WarkingUser user = WarkingUser.get(p.getUniqueId());
|
||||||
|
|
||||||
|
if(p.hasPermission("bau.team")){
|
||||||
|
if(args.length == 1){
|
||||||
|
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
}else{
|
||||||
|
Player target2 = Bukkit.getPlayerExact(args[1]);
|
||||||
|
|
||||||
|
if (target2 == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist derzeit offline.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.teleport(target2, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else if(args.length == 2){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst keine anderen Spieler teleportieren.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p.getUniqueId().equals(target)){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(target.getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler befindet sich auf keiner Bauwelt!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(worldOwner != p.getUniqueId()){
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
if(member == null || !member.isTeleport()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst dich auf dieser Welt nicht teleportieren!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isTeleport()){
|
||||||
|
sender.sendMessage("Die Spieler sind nicht auf der selben Bauwelt.");
|
||||||
|
return false;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||||
|
Validate.notNull(sender, "Sender cannot be null");
|
||||||
|
Validate.notNull(args, "Arguments cannot be null");
|
||||||
|
Validate.notNull(alias, "Alias cannot be null");
|
||||||
|
|
||||||
|
return super.tabComplete(sender, alias, args);
|
||||||
|
}
|
||||||
|
}
|
@ -1,28 +1,26 @@
|
|||||||
package de.quantumnanox.warshipfactory.config;
|
package de.warking.bausystem.config;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
private File file;
|
private final File file;
|
||||||
public FileConfiguration cfg;
|
public final FileConfiguration cfg;
|
||||||
|
|
||||||
public String backupDir;
|
public String backupDir;
|
||||||
public String regionDir;
|
public String regionDir;
|
||||||
public Location spawn;
|
public Location spawn;
|
||||||
public Location pasteloc;
|
private Location pasteloc;
|
||||||
|
|
||||||
public Config() {
|
public Config() {
|
||||||
this.file = new File("plugins/WarShipFactory/config.yml");
|
this.file = new File("plugins/BauSystem/config.yml");
|
||||||
this.cfg = YamlConfiguration.loadConfiguration(this.file);
|
this.cfg = YamlConfiguration.loadConfiguration(this.file);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,76 +37,76 @@ public class Config {
|
|||||||
cfg.addDefault("MiniWargear1.loc.x", -907);
|
cfg.addDefault("MiniWargear1.loc.x", -907);
|
||||||
cfg.addDefault("MiniWargear1.loc.y", 122);
|
cfg.addDefault("MiniWargear1.loc.y", 122);
|
||||||
cfg.addDefault("MiniWargear1.loc.z", -29);
|
cfg.addDefault("MiniWargear1.loc.z", -29);
|
||||||
cfg.addDefault("MiniWargear1.Message", "§7Du wurdest zu MiniWarGear TestGelände 1 Teleportiert");
|
cfg.addDefault("MiniWargear1.Message", "§aDu wurdest zum MiniWarGear-Testgelände 1 teleportiert.");
|
||||||
cfg.addDefault("MiniWargear2.loc.x", -841);
|
cfg.addDefault("MiniWargear2.loc.x", -841);
|
||||||
cfg.addDefault("MiniWargear2.loc.y", 122);
|
cfg.addDefault("MiniWargear2.loc.y", 122);
|
||||||
cfg.addDefault("MiniWargear2.loc.z", -29);
|
cfg.addDefault("MiniWargear2.loc.z", -29);
|
||||||
cfg.addDefault("MiniWargear2.Message", "§7Du wurdest zu MiniWarGear TestGelände 2 Teleportiert");
|
cfg.addDefault("MiniWargear2.Message", "§aDu wurdest zum MiniWarGear-Testgelände 2 teleportiert.");
|
||||||
cfg.addDefault("MiniWargear7.loc.x", -907);
|
cfg.addDefault("MiniWargear7.loc.x", -907);
|
||||||
cfg.addDefault("MiniWargear7.loc.y", 122);
|
cfg.addDefault("MiniWargear7.loc.y", 122);
|
||||||
cfg.addDefault("MiniWargear7.loc.z", -29);
|
cfg.addDefault("MiniWargear7.loc.z", -29);
|
||||||
cfg.addDefault("MiniWargear7.Message", "§7Du wurdest zu MiniWarGear TestGelände 7 Teleportiert");
|
cfg.addDefault("MiniWargear7.Message", "§aDu wurdest zum MiniWarGear-Testgelände 7 teleportiert.");
|
||||||
cfg.addDefault("MiniWargear8.loc.x", -841);
|
cfg.addDefault("MiniWargear8.loc.x", -841);
|
||||||
cfg.addDefault("MiniWargear8.loc.y", 122);
|
cfg.addDefault("MiniWargear8.loc.y", 122);
|
||||||
cfg.addDefault("MiniWargear8.loc.z", -120);
|
cfg.addDefault("MiniWargear8.loc.z", -120);
|
||||||
cfg.addDefault("MiniWargear8.Message", "§7Du wurdest zu MiniWarGear TestGelände 8 Teleportiert");
|
cfg.addDefault("MiniWargear8.Message", "§aDu wurdest zum MiniWarGear-Testgelände 8 teleportiert.");
|
||||||
cfg.addDefault("WarGear5.loc.x", -1332);
|
cfg.addDefault("WarGear5.loc.x", -1332);
|
||||||
cfg.addDefault("WarGear5.loc.y", 122);
|
cfg.addDefault("WarGear5.loc.y", 122);
|
||||||
cfg.addDefault("WarGear5.loc.z", -53);
|
cfg.addDefault("WarGear5.loc.z", -53);
|
||||||
cfg.addDefault("WarGear5.Message", "§7Du wurdest zu WarGear TestGelände 5 Teleportiert");
|
cfg.addDefault("WarGear5.Message", "§aDu wurdest zum WarGear-Testgelände 5 teleportiert.");
|
||||||
cfg.addDefault("WarGear6.loc.x", -1220);
|
cfg.addDefault("WarGear6.loc.x", -1220);
|
||||||
cfg.addDefault("WarGear6.loc.y", 122);
|
cfg.addDefault("WarGear6.loc.y", 122);
|
||||||
cfg.addDefault("WarGear6.loc.z", -53);
|
cfg.addDefault("WarGear6.loc.z", -53);
|
||||||
cfg.addDefault("WarGear6.Message", "§7Du wurdest zu WarGear TestGelände 6 Teleportiert");
|
cfg.addDefault("WarGear6.Message", "§aDu wurdest zum WarGear-Testgelände 6 teleportiert.");
|
||||||
cfg.addDefault("WarGear7.loc.x", -1108);
|
cfg.addDefault("WarGear7.loc.x", -1108);
|
||||||
cfg.addDefault("WarGear7.loc.y", 122);
|
cfg.addDefault("WarGear7.loc.y", 122);
|
||||||
cfg.addDefault("WarGear7.loc.z", -53);
|
cfg.addDefault("WarGear7.loc.z", -53);
|
||||||
cfg.addDefault("WarGear7.Message", "§7Du wurdest zu WarGear TestGelände 7 Teleportiert");
|
cfg.addDefault("WarGear7.Message", "§aDu wurdest zum WarGear-Testgelände 7 teleportiert.");
|
||||||
cfg.addDefault("WarGear8.loc.x", -996);
|
cfg.addDefault("WarGear8.loc.x", -996);
|
||||||
cfg.addDefault("WarGear8.loc.y", 122);
|
cfg.addDefault("WarGear8.loc.y", 122);
|
||||||
cfg.addDefault("WarGear8.loc.z", -53);
|
cfg.addDefault("WarGear8.loc.z", -53);
|
||||||
cfg.addDefault("WarGear8.Message", "§7Du wurdest zu WarGear TestGelände 8 Teleportiert");
|
cfg.addDefault("WarGear8.Message", "§aDu wurdest zum WarGear-Testgelände 8 teleportiert.");
|
||||||
cfg.addDefault("WarShip1.loc.x", -943);
|
cfg.addDefault("WarShip1.loc.x", -943);
|
||||||
cfg.addDefault("WarShip1.loc.y", 122);
|
cfg.addDefault("WarShip1.loc.y", 122);
|
||||||
cfg.addDefault("WarShip1.loc.z", 149);
|
cfg.addDefault("WarShip1.loc.z", 149);
|
||||||
cfg.addDefault("WarShip1.Message", "§7Du wurdest zu WarShip TestGelände 1 Teleportiert");
|
cfg.addDefault("WarShip1.Message", "§aDu wurdest zum WarShip-Testgelände 1 teleportiert.");
|
||||||
cfg.addDefault("WarShip2.loc.x", -1200);
|
cfg.addDefault("WarShip2.loc.x", -1200);
|
||||||
cfg.addDefault("WarShip2.loc.y", 122);
|
cfg.addDefault("WarShip2.loc.y", 122);
|
||||||
cfg.addDefault("WarShip2.loc.z", 149);
|
cfg.addDefault("WarShip2.loc.z", 149);
|
||||||
cfg.addDefault("WarShip2.Message", "§7Du wurdest zu WarShip TestGelände 2 Teleportiert");
|
cfg.addDefault("WarShip2.Message", "§aDu wurdest zum WarShip-Testgelände 2 teleportiert.");
|
||||||
cfg.addDefault("AirShip1.loc.x", -674);
|
cfg.addDefault("AirShip1.loc.x", -674);
|
||||||
cfg.addDefault("AirShip1.loc.y", 122);
|
cfg.addDefault("AirShip1.loc.y", 122);
|
||||||
cfg.addDefault("AirShip1.loc.z", -45);
|
cfg.addDefault("AirShip1.loc.z", -45);
|
||||||
cfg.addDefault("AirShip1.Message", "§7Du wurdest zu AirShip TestGelände 1 Teleportiert");
|
cfg.addDefault("AirShip1.Message", "§aDu wurdest zum AirShip-Testgelände 1 teleportiert.");
|
||||||
cfg.addDefault("AirShip2.loc.x", -487);
|
cfg.addDefault("AirShip2.loc.x", -487);
|
||||||
cfg.addDefault("AirShip2.loc.y", 122);
|
cfg.addDefault("AirShip2.loc.y", 122);
|
||||||
cfg.addDefault("AirShip2.loc.z", -45);
|
cfg.addDefault("AirShip2.loc.z", -45);
|
||||||
cfg.addDefault("AirShip2.Message", "§7Du wurdest zu AirShip TestGelände 2 Teleportiert");
|
cfg.addDefault("AirShip2.Message", "§aDu wurdest zum AirShip-Testgelände 2 teleportiert.");
|
||||||
cfg.addDefault("AirShip3.loc.x", -302);
|
cfg.addDefault("AirShip3.loc.x", -302);
|
||||||
cfg.addDefault("AirShip3.loc.y", 122);
|
cfg.addDefault("AirShip3.loc.y", 122);
|
||||||
cfg.addDefault("AirShip3.loc.z", -45);
|
cfg.addDefault("AirShip3.loc.z", -45);
|
||||||
cfg.addDefault("AirShip3.Message", "§7Du wurdest zu AirShip TestGelände 3 Teleportiert");
|
cfg.addDefault("AirShip3.Message", "§aDu wurdest zum AirShip-Testgelände 3 teleportiert.");
|
||||||
cfg.addDefault("AirShip4.loc.x", -115);
|
cfg.addDefault("AirShip4.loc.x", -115);
|
||||||
cfg.addDefault("AirShip4.loc.y", 122);
|
cfg.addDefault("AirShip4.loc.y", 122);
|
||||||
cfg.addDefault("AirShip4.loc.z", -45);
|
cfg.addDefault("AirShip4.loc.z", -45);
|
||||||
cfg.addDefault("AirShip4.Message", "§7Du wurdest zu AirShip TestGelände 4 Teleportiert");
|
cfg.addDefault("AirShip4.Message", "§aDu wurdest zum AirShip-Testgelände 4 teleportiert.");
|
||||||
cfg.addDefault("AirShip5.loc.x", -115);
|
cfg.addDefault("AirShip5.loc.x", -115);
|
||||||
cfg.addDefault("AirShip5.loc.y", 122);
|
cfg.addDefault("AirShip5.loc.y", 122);
|
||||||
cfg.addDefault("AirShip5.loc.z", 201);
|
cfg.addDefault("AirShip5.loc.z", 201);
|
||||||
cfg.addDefault("AirShip5.Message", "§7Du wurdest zu AirShip TestGelände 5 Teleportiert");
|
cfg.addDefault("AirShip5.Message", "§aDu wurdest zum AirShip-Testgelände 5 teleportiert.");
|
||||||
cfg.addDefault("AirShip6.loc.x", -302);
|
cfg.addDefault("AirShip6.loc.x", -302);
|
||||||
cfg.addDefault("AirShip6.loc.y", 122);
|
cfg.addDefault("AirShip6.loc.y", 122);
|
||||||
cfg.addDefault("AirShip6.loc.z", 201);
|
cfg.addDefault("AirShip6.loc.z", 201);
|
||||||
cfg.addDefault("AirShip6.Message", "§7Du wurdest zu AirShip TestGelände 6 Teleportiert");
|
cfg.addDefault("AirShip6.Message", "§aDu wurdest zum AirShip-Testgelände 6 teleportiert.");
|
||||||
cfg.addDefault("AirShip7.loc.x", -487);
|
cfg.addDefault("AirShip7.loc.x", -487);
|
||||||
cfg.addDefault("AirShip7.loc.y", 122);
|
cfg.addDefault("AirShip7.loc.y", 122);
|
||||||
cfg.addDefault("AirShip7.loc.z", 201);
|
cfg.addDefault("AirShip7.loc.z", 201);
|
||||||
cfg.addDefault("AirShip7.Message", "§7Du wurdest zu AirShip TestGelände 7 Teleportiert");
|
cfg.addDefault("AirShip7.Message", "§aDu wurdest zum AirShip-Testgelände 7 teleportiert.");
|
||||||
cfg.addDefault("AirShip8.loc.x", -674);
|
cfg.addDefault("AirShip8.loc.x", -674);
|
||||||
cfg.addDefault("AirShip8.loc.y", 122);
|
cfg.addDefault("AirShip8.loc.y", 122);
|
||||||
cfg.addDefault("AirShip8.loc.z", 201);
|
cfg.addDefault("AirShip8.loc.z", 201);
|
||||||
cfg.addDefault("AirShip8.Message", "§7Du wurdest zu AirShip TestGelände 8 Teleportiert");
|
cfg.addDefault("AirShip8.Message", "§aDu wurdest zum AirShip-Testgelände 8 teleportiert.");
|
||||||
cfg.addDefault("Lobby.name", "Lobby_1");
|
cfg.addDefault("Lobby.name", "Lobby");
|
||||||
try {
|
try {
|
||||||
this.cfg.save(this.file);
|
this.cfg.save(this.file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -120,7 +118,7 @@ public class Config {
|
|||||||
pasteloc = new Location(null, cfg.getDouble("Coords.loc.x"), cfg.getDouble("Coords.loc.y"), cfg.getDouble("Coords.loc.z"));
|
pasteloc = new Location(null, cfg.getDouble("Coords.loc.x"), cfg.getDouble("Coords.loc.y"), cfg.getDouble("Coords.loc.z"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location toLocation(String configString) {
|
private Location toLocation(String configString) {
|
||||||
String[] splitted = configString.split("/");
|
String[] splitted = configString.split("/");
|
||||||
String wName = splitted[0];
|
String wName = splitted[0];
|
||||||
double x = Double.parseDouble(splitted[1]);
|
double x = Double.parseDouble(splitted[1]);
|
||||||
@ -132,13 +130,4 @@ public class Config {
|
|||||||
Bukkit.createWorld(new WorldCreator(wName));
|
Bukkit.createWorld(new WorldCreator(wName));
|
||||||
return new Location(Bukkit.getWorld(wName), x, y, z, yaw, pitch);
|
return new Location(Bukkit.getWorld(wName), x, y, z, yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
|
||||||
try {
|
|
||||||
this.cfg.save(file);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
195
src/de/warking/bausystem/world/BauWorld.java
Normale Datei
195
src/de/warking/bausystem/world/BauWorld.java
Normale Datei
@ -0,0 +1,195 @@
|
|||||||
|
package de.warking.bausystem.world;
|
||||||
|
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.hunjy.MySQL.Bauwelt;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import de.warking.hunjy.MySQL.WarkingUser;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
public class BauWorld {
|
||||||
|
|
||||||
|
public static void loadWorld(UUID owner) throws IOException{
|
||||||
|
File w = new File("plugins/BauSystem/worlds/" + owner);
|
||||||
|
File region = new File("plugins/WorldGuard/worlds/" + owner);
|
||||||
|
if (!region.exists() || !region.isDirectory()) {
|
||||||
|
FileUtils.copyDirectory(new File(BauSystem.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + owner));
|
||||||
|
}
|
||||||
|
World world;
|
||||||
|
if (w.exists() && w.isDirectory()) {
|
||||||
|
world = Bukkit.createWorld(new WorldCreator(owner.toString()));
|
||||||
|
} else {
|
||||||
|
FileUtils.copyDirectory(new File(BauSystem.getInstance().config.backupDir), new File(owner.toString()));
|
||||||
|
world = Bukkit.createWorld(new WorldCreator(owner.toString()));
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), new LagDetectorRunnable(world, owner), 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void unloadWorld(UUID owner) {
|
||||||
|
World world = Bukkit.getWorld(owner.toString());
|
||||||
|
|
||||||
|
if (world != null) {
|
||||||
|
for (Player p : world.getPlayers()) {
|
||||||
|
p.teleport(BauSystem.getInstance().config.spawn);
|
||||||
|
}
|
||||||
|
|
||||||
|
world.save();
|
||||||
|
|
||||||
|
for (Chunk c : world.getLoadedChunks()) {
|
||||||
|
c.unload();
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.unloadWorld(world, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void broadcast(UUID owner, String string) {
|
||||||
|
for (Player p : getWorld(owner).getPlayers()) {
|
||||||
|
p.sendMessage(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static World getWorld(UUID owner) {
|
||||||
|
return Bukkit.getWorld(owner.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void switchTNT(Player p){
|
||||||
|
Bauwelt welt = Bauwelt.getBauwelt(p.getUniqueId());
|
||||||
|
if (welt.getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast noch keine Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
welt.setTNTDmg(!welt.isTNTDmg());
|
||||||
|
if (welt.isTNTDmg())
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aTNT-Schaden erlaubt");
|
||||||
|
else
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cTNT-Schaden verboten");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void switchFire(Player p){
|
||||||
|
Bauwelt welt = Bauwelt.getBauwelt(p.getUniqueId());
|
||||||
|
if (welt.getUUID() == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu hast noch keine Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
welt.setFireDmg(!welt.isFireDmg());
|
||||||
|
if (welt.isFireDmg())
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aFeuer-Schaden erlaubt");
|
||||||
|
else
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cFeuer-Schaden verboten");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleBuild(Player p, BauweltMember target){
|
||||||
|
target.setBuild(!target.isBuild());
|
||||||
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isBuild()) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a bauen");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c bauen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isBuild()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun bauen");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr bauen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleWE(Player p, BauweltMember target){
|
||||||
|
target.setWorldEdit(!target.isWorldEdit());
|
||||||
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isWorldEdit()) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a WorldEdit verwenden");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c WorldEdit verwenden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isWorldEdit()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun WorldEdit verwenden");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun kein WorldEdit mehr verwenden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleTP(Player p, BauweltMember target){
|
||||||
|
target.setTeleport(!target.isTeleport());
|
||||||
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isTeleport()) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst dich nun auf der Welt von §6" + p.getName() + "§a teleportieren");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst dich nun nicht mehr auf der Welt von §6" + p.getName() + "§c teleportieren");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isTeleport()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf sich nun teleportieren");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf sich nun nicht mehr teleportieren");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleGM(Player p, BauweltMember target){
|
||||||
|
target.setChangeGM(!target.isChangeGM());
|
||||||
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isChangeGM()) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a den Spielmodus wechseln");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c den Spielmodus wechseln");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isChangeGM()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun den Spielmodus wechseln");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr den Spielmodus wechseln");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleTestblock(Player p, BauweltMember target){
|
||||||
|
target.setTestblock(!target.isTestblock());
|
||||||
|
Player z = Bukkit.getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isTestblock()) {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a den Testblock zurücksetzen");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c den Testblock zurücksetzen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isTestblock()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§aDer Spieler darf nun den Testblock zurücksetzen");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler darf nun nicht mehr den Testblock zurücksetzen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removePlayer(Player p, UUID id){
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}else if (BauweltMember.getBauMember(p.getUniqueId(), id) == null) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDieser Spieler ist kein Mitglied auf deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember.getBauMember(p.getUniqueId(), id).remove();
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDer Spieler wurde entfernt");
|
||||||
|
Player z = Bukkit.getPlayer(id);
|
||||||
|
if(z != null){
|
||||||
|
z.sendMessage(BauSystem.PREFIX + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt");
|
||||||
|
if (z.getWorld().getName().equals(p.getUniqueId().toString())) {
|
||||||
|
z.teleport(BauSystem.getInstance().config.spawn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
src/de/warking/bausystem/world/LagDetectorRunnable.java
Normale Datei
62
src/de/warking/bausystem/world/LagDetectorRunnable.java
Normale Datei
@ -0,0 +1,62 @@
|
|||||||
|
package de.warking.bausystem.world;
|
||||||
|
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
class LagDetectorRunnable implements Runnable {
|
||||||
|
|
||||||
|
private final World world;
|
||||||
|
private final UUID worldOwner;
|
||||||
|
private long timerstart = 0;
|
||||||
|
|
||||||
|
public LagDetectorRunnable(World w, UUID owner) {
|
||||||
|
world = w;
|
||||||
|
worldOwner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (world == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
world.setStorm(false);
|
||||||
|
world.setThundering(false);
|
||||||
|
world.setMonsterSpawnLimit(0);
|
||||||
|
world.setAnimalSpawnLimit(0);
|
||||||
|
|
||||||
|
int players = 0;
|
||||||
|
int other = 0;
|
||||||
|
for (Entity e : world.getEntities()) {
|
||||||
|
if (e instanceof Player)
|
||||||
|
players++;
|
||||||
|
else
|
||||||
|
other++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(players == 0 && timerstart == 0) {
|
||||||
|
timerstart = System.currentTimeMillis();
|
||||||
|
}else if(players != 0){
|
||||||
|
timerstart = 0;
|
||||||
|
}else{
|
||||||
|
if (System.currentTimeMillis() - timerstart > 60000) {
|
||||||
|
BauWorld.unloadWorld(worldOwner);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (other > 1000) {
|
||||||
|
for (Entity e : world.getEntities()) {
|
||||||
|
if (e instanceof Player)
|
||||||
|
continue;
|
||||||
|
e.remove();
|
||||||
|
}
|
||||||
|
BauWorld.broadcast(worldOwner, BauSystem.PREFIX +"§cLagverursachung erkannt. Es wurden §6"+other+" Entities§c entfernt.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
139
src/de/warking/bausystem/world/RegionListener.java
Normale Datei
139
src/de/warking/bausystem/world/RegionListener.java
Normale Datei
@ -0,0 +1,139 @@
|
|||||||
|
package de.warking.bausystem.world;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import de.warking.bausystem.BauSystem;
|
||||||
|
import de.warking.hunjy.MySQL.Bauwelt;
|
||||||
|
import de.warking.hunjy.MySQL.BauweltMember;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class RegionListener implements Listener {
|
||||||
|
|
||||||
|
public RegionListener(JavaPlugin plugin) {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void playerCommandHandler(PlayerCommandPreprocessEvent e) {
|
||||||
|
if (!isWorldEditCommand(e.getMessage().split(" ")[0]))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(e.getPlayer().getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.hasPermission("bau.team") || p.getUniqueId().equals(worldOwner))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
|
||||||
|
if(member == null || !member.isWorldEdit()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein Worldedit benutzen.");
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(e.getPlayer().getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.hasPermission("bau.team") || p.getUniqueId().equals(worldOwner))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
|
||||||
|
if (member == null || !member.isBuild()) {
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht bauen.");
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(e.getPlayer().getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p.hasPermission("bau.team") || p.getUniqueId().equals(worldOwner))
|
||||||
|
return;
|
||||||
|
|
||||||
|
BauweltMember member = BauweltMember.getBauMember(worldOwner, p.getUniqueId());
|
||||||
|
|
||||||
|
if(member == null || !member.isBuild()){
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht bauen.");
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isWorldEditCommand(String command) {
|
||||||
|
if (command.startsWith("/")) {
|
||||||
|
command = command.replaceFirst("/", "");
|
||||||
|
}
|
||||||
|
command = command.toLowerCase();
|
||||||
|
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
||||||
|
.getCommandManager().getDispatcher().get(command) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onExplode(EntityExplodeEvent e) {
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(e.getLocation().getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(worldOwner == null || !Bauwelt.getBauwelt(worldOwner).isTNTDmg())
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFireDamage(BlockBurnEvent e) {
|
||||||
|
UUID worldOwner;
|
||||||
|
|
||||||
|
try{
|
||||||
|
worldOwner = UUID.fromString(e.getBlock().getWorld().getName());
|
||||||
|
}catch(IllegalArgumentException E){
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(worldOwner == null || !Bauwelt.getBauwelt(worldOwner).isFireDmg())
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,145 +0,0 @@
|
|||||||
package de.pro_crafting.sawe;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import net.minecraft.server.v1_12_R1.World;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
|
|
||||||
public class RegionListener implements Listener {
|
|
||||||
private JavaPlugin plugin;
|
|
||||||
|
|
||||||
public RegionListener(JavaPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.plugin.getServer().getPluginManager().registerEvents(this, this.plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
|
||||||
public void playerCommandHandler(PlayerCommandPreprocessEvent event) {
|
|
||||||
WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
|
||||||
String command = event.getMessage().split(" ")[0];
|
|
||||||
if (!isWorldEditCommand(command)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player p = event.getPlayer();
|
|
||||||
try {
|
|
||||||
if (p.hasPermission("bau.team")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(event.getPlayer().getWorld().getUID()) == null) {
|
|
||||||
p.sendMessage("§cDu darfst hier kein Worldedit benutzen.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) != null) {
|
|
||||||
if (BauweltMember.getBauMember(event.getPlayer().getWorld().getUID(), p.getUniqueId()).isWorldEdit() == false || Bukkit.getWorld(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage("§cDu darfst hier kein Worldedit benutzen.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.sendMessage("§cDu darfst hier kein Worldedit benutzen.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
|
||||||
public void onBlock(BlockBreakEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
try {
|
|
||||||
if (p.hasPermission("bau.team")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage("§cDu darfst nicht bauen.");
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(e.getPlayer().getWorld().getUID()) != null) {
|
|
||||||
if (BauweltMember.getBauMember(e.getPlayer().getWorld().getUID(), p.getUniqueId()).isBuild() == false) {
|
|
||||||
p.sendMessage("§cDu darfst nicht bauen.");
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
} catch (Exception e1) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e1.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
|
||||||
public void onB(BlockPlaceEvent e) throws SQLException {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
if (p.hasPermission("bau.team")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Bukkit.getWorld(e.getPlayer().getWorld().getUID()) == null) {
|
|
||||||
p.sendMessage("§cDu darfst nicht bauen.");
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) != null) {
|
|
||||||
if (BauweltMember.getBauMember(e.getPlayer().getWorld().getUID(), p.getUniqueId()).isBuild() == false) {
|
|
||||||
p.sendMessage("§cDu darfst nicht bauen.");
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isWorldEditCommand(String command) {
|
|
||||||
if (command.startsWith("/")) {
|
|
||||||
command = command.replaceFirst("/", "");
|
|
||||||
}
|
|
||||||
command = command.toLowerCase();
|
|
||||||
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
|
|
||||||
.getCommandManager().getDispatcher().get(command) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onExplode(EntityExplodeEvent e) {
|
|
||||||
if (Bukkit.getWorld(e.getLocation().getWorld().getUID()) != null) {
|
|
||||||
if (Bauwelt.getBauwelt(Bukkit.getWorld(e.getLocation().getWorld().toString()).getUID()).isTNTDmg() == false) e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onFireDamage(BlockBurnEvent e) {
|
|
||||||
if (Bukkit.getWorld(e.getIgnitingBlock().getWorld().getUID()) != null) {
|
|
||||||
if (Bauwelt.getBauwelt(e.getIgnitingBlock().getWorld().getUID()).isFireDmg() == false) e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,890 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.commands;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.CuboidClipboard;
|
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|
||||||
import com.sk89q.worldedit.schematic.MCEditSchematicFormat;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
import de.quantumnanox.warshipfactory.config.Config;
|
|
||||||
import de.quantumnanox.warshipfactory.content.LagDetectorRunnable;
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import de.warking.hunjy.MySQL.WarkingUser;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import de.pro_crafting.commandframework.Command;
|
|
||||||
import de.quantumnanox.warshipfactory.content.UUIDFetcher;
|
|
||||||
import de.pro_crafting.commandframework.CommandArgs;
|
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
public class CommandBau {
|
|
||||||
@Getter
|
|
||||||
private World wrapped;
|
|
||||||
@Getter
|
|
||||||
private boolean loading;
|
|
||||||
|
|
||||||
private BukkitTask task;
|
|
||||||
public Config config;
|
|
||||||
|
|
||||||
@Command(name = "bau", aliases = "gs")
|
|
||||||
public void onBau(CommandArgs args) {
|
|
||||||
CommandSender s = args.getSender();
|
|
||||||
s.sendMessage(WarShipFactory.S_PREFIX + "BauFactory by Exceptionflug updated by Diamant-ix.de Team v" + "1.2");
|
|
||||||
s.sendMessage(WarShipFactory.S_PREFIX + "Um eine Liste mit Befehlen zu erhalten, gib §t/bau help §7ein.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(name = "bau.help", aliases = "gs.help", inGameOnly = true)
|
|
||||||
public void onHelp(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "Hilfe Seite 1 von 2:");
|
|
||||||
p.sendMessage("§8/bau - §6Zeigt dir Infos über das Plugin");
|
|
||||||
p.sendMessage("§8/bau help - §6Zeigt dir diese Liste");
|
|
||||||
p.sendMessage("§8/bau help 2 - §6Zeigt dir die 2 Seite der Hilfe Seite");
|
|
||||||
p.sendMessage("§8/bau home - §6Teleportiert dich auf deine Welt");
|
|
||||||
p.sendMessage("§8/bau addmember - §6Fügt einen Spieler zu deiner Welt hinzu");
|
|
||||||
p.sendMessage("§8/bau delmember - §6Entfernt einen Spieler von deiner Welt");
|
|
||||||
p.sendMessage("§8/bau tntdmg - §6Erlaubt / verbietet TNT Explosionen");
|
|
||||||
p.sendMessage("§8/bau firedmg - §6Erlaubt / verbietet Feuer Schaden");
|
|
||||||
p.sendMessage("§8/bau testblock - §6Erneuert einen Testblock in der umgebung");
|
|
||||||
p.sendMessage("§8/bau reset - §6Setzt eine region zurück wo man sich befindet");
|
|
||||||
p.sendMessage("§8/bau resetall - §6Resetet deine komplette Welt");
|
|
||||||
p.sendMessage("§8/bau replace - §6Ersetzt in einer Region Obsidian zu TNT und Bedrock zu Schleim");
|
|
||||||
p.sendMessage("§8/bau flyspeed - §6Um dein FlySpeed zu ändern");
|
|
||||||
p.sendMessage("§8/bau tp - §6Teleportiert dich auf eine Welt");
|
|
||||||
p.sendMessage("§8/bau info - §6Zeigt dir Infos über die aktuelle Welt");
|
|
||||||
p.sendMessage("§8/bau gui - §6Öffnet eine GUI");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(name = "bau.help.2", aliases = "gs.help.2", inGameOnly = true)
|
|
||||||
public void onHelp2(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "Hilfe Seite 2 von 2:");
|
|
||||||
p.sendMessage("§8/bau togglewe - §6Ändert den Zustand für: Darf ein Spieler WorldEdit verwenden?");
|
|
||||||
p.sendMessage("§8/bau togglebuild - §6Ändert den Zustand für: Darf ein Spieler bauen?");
|
|
||||||
p.sendMessage("§8/bau toggletp - §6Ändert den Zustand für: Darf ein Spieler sich teleportieren?");
|
|
||||||
p.sendMessage("§8/bau toggletestblock - §6Ändert den Zustand für : Darf ein Spieler einen TestBlock erneuern");
|
|
||||||
p.sendMessage("§8/bau togglereset - §6Ändert den Zustand für : Darf ein Spieler eine Region erneuern");
|
|
||||||
p.sendMessage("§8/bau toggleresetall - §6Ändert den Zustand für : Darf ein Spieler eine ganze Welt erneuern");
|
|
||||||
p.sendMessage("§8/bau togglereplace - §6Ändert den Zustand für : Darf ein Spieler in einer Region replacen");
|
|
||||||
p.sendMessage("§8/bau togglechgm - §6Ändert den Zustand für: Darf ein Spieler seinen Spielmodus ändern?");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(name = "bau.home", aliases = "gs.home", inGameOnly = true)
|
|
||||||
public void onHome(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()) == null) {
|
|
||||||
new Bauwelt(p.getUniqueId(), false, false);
|
|
||||||
}
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()) == null)
|
|
||||||
try {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet.");
|
|
||||||
loading = true;
|
|
||||||
File world = new File("" + p.getUniqueId());
|
|
||||||
File region = new File("plugins/WorldGuard/worlds/" + p.getUniqueId());
|
|
||||||
if (region.exists() && region.isDirectory()) {
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + p.getUniqueId()));
|
|
||||||
}
|
|
||||||
if (world.exists() && world.isDirectory()) {
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + p.getUniqueId()));
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.backupDir), new File("" + p.getUniqueId()));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + p.getUniqueId()));
|
|
||||||
}
|
|
||||||
loading = false;
|
|
||||||
} catch (Exception e) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
p.teleport(Bukkit.getWorld(p.getUniqueId().toString()).getSpawnLocation());
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run () {
|
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
|
||||||
}
|
|
||||||
},20L);
|
|
||||||
|
|
||||||
}
|
|
||||||
@Command(name = "bau.addmember", aliases = "gs.addmember", inGameOnly = true)
|
|
||||||
public void onAdd(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast noch keine Welt.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau addmember <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id) != null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new BauweltMember(p.getUniqueId(), id, true, false, false, false, false);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler wurde zu deiner Welt hinzugefügt.");
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
|
|
||||||
}
|
|
||||||
@Command(name = "bau.delmember", aliases = "gs.delmember", inGameOnly = true)
|
|
||||||
public void onDel(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast noch keine Welt.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau delmember <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDieser Spieler ist kein Mitglied auf deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).remove();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler wurde entfernt.");
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + ChatColor.RED + "§4Du wurdest von der Welt von §6" + p.getName() + ChatColor.RED + " §4entfernt");
|
|
||||||
if (z != null) {
|
|
||||||
if (z.getWorld().getUID().equals(Bukkit.getWorld(p.getUniqueId().toString()).getUID())) {
|
|
||||||
z.teleport(WarShipFactory.getInstance().config.spawn);
|
|
||||||
z.getInventory().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.tp", aliases = "gs.tp", inGameOnly = true)
|
|
||||||
public void onTp(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau tp <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(id);
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler hat keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
if (!p.hasPermission("bau.team")) {
|
|
||||||
if (BauweltMember.getBauMember(id, p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu bist kein Mitglied dieser Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Bukkit.getWorld(id) == null)
|
|
||||||
try {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet.");
|
|
||||||
loading = true;
|
|
||||||
File world = new File("plugins/WarShipFactory/worlds/" + id);
|
|
||||||
File region = new File("plugins/WorldGuard/worlds/" + id);
|
|
||||||
if (region.exists() && region.isDirectory()) {
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + id));
|
|
||||||
}
|
|
||||||
if (world.exists() && world.isDirectory()) {
|
|
||||||
FileUtils.moveDirectory(world, new File("" + id));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + id));
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.backupDir), new File("" + id));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + id));
|
|
||||||
}
|
|
||||||
loading = false;
|
|
||||||
} catch (Exception e) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
p.teleport(Bukkit.getWorld(id.toString()).getSpawnLocation());
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
|
||||||
if (!unloadWorld(p.getUniqueId().toString())) {
|
|
||||||
WarShipFactory.log("FactoryWorld", "Unable to unload " + Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDu wurdest teleportiert.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cFehla.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.flyspeed", aliases = "gs.flyspeed", inGameOnly = true)
|
|
||||||
public void onflyspeed(CommandArgs args){
|
|
||||||
final Player player = args.getPlayer();
|
|
||||||
if (args.length() == 0){
|
|
||||||
player.sendMessage("§8Bitte benutzte §b/bau flyspeed 1|2|3|4|5|6|7|8|9 oder 10");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("1"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.1F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 1 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("2"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.2F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 2 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("3"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.3F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 3 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("4"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.4F);
|
|
||||||
player.sendMessage("§6Fly speed wurde 4 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("5"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.5F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 5 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("6"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.6F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 6 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("7"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.7F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 7 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("8"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.8F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 8 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("9"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(0.9F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 9 gesetzt.");
|
|
||||||
}
|
|
||||||
else if (args.getArgs(0).equals("10"))
|
|
||||||
{
|
|
||||||
player.setFlySpeed(1.0F);
|
|
||||||
player.sendMessage("§6Fly speed wurde auf 10 gesetzt.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.sendMessage("§8Unbekannter Speed bitte benutzte eine Zahl zwischen 1 und 10.");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.gui", aliases = "gs.gui", inGameOnly = true)
|
|
||||||
public boolean ongui(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
Inventory inv = Bukkit.createInventory(null, 9, "§aBau Optionen");
|
|
||||||
ItemStack bau = new ItemStack(Material.COMPASS);
|
|
||||||
ItemMeta meta = bau.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bBau Abteilungen");
|
|
||||||
bau.setItemMeta(meta);
|
|
||||||
inv.addItem(bau);
|
|
||||||
ItemStack optionen = new ItemStack(Material.ENCHANTED_BOOK);
|
|
||||||
meta = optionen.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWelten Optionen");
|
|
||||||
optionen.setItemMeta(meta);
|
|
||||||
inv.setItem(8, optionen);
|
|
||||||
ItemStack spieler = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = spieler.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bSpieler Optionen");
|
|
||||||
spieler.setItemMeta(meta);
|
|
||||||
inv.setItem(4, spieler);
|
|
||||||
p.openInventory(inv);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.togglewe", aliases = "gs.togglewe", inGameOnly = true)
|
|
||||||
public void onToggleWE(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau togglewe <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id);
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit());
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a WorldEdit verwenden.");
|
|
||||||
}else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c WorldEdit verwenden.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf WorldEdit verwenden.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf kein WorldEdit verwenden.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.toggletp", aliases = "gs.toggletp", inGameOnly = true)
|
|
||||||
public void onToggleTP(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau toggletp <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setTeleport(!BauweltMember.getBauMember(p.getUniqueId(), id).isTeleport());
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isTeleport()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a /tp verwenden.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c /tp verwenden.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isTeleport()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf sich teleportieren.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf sich nicht teleportieren.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.togglebuild", aliases = "gs.togglebuild", inGameOnly = true)
|
|
||||||
public void onToggleBD(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau togglebuild <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setTeleport(!BauweltMember.getBauMember(p.getUniqueId(), id).isTeleport());
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isBuild()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a bauen.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c bauen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isBuild()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf bauen.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf nicht bauen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.togglechgm", aliases = "gs.togglechgm", inGameOnly = true)
|
|
||||||
public void onToggleCHG(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau togglechgm <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setChangeGM(!BauweltMember.getBauMember(p.getUniqueId(), id).isChangeGM());
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isChangeGM()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a deinen Spielmodus ändern.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c deinen Spielmodus ändern.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isChangeGM()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf seinen Spielmodus ändern.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf nicht seinen Spielmodus ändern.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.toggletestblock", aliases = "gs.testblock", inGameOnly = true)
|
|
||||||
public void onToggleTestblock(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau toggletestblock <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setTestblock(!BauweltMember.getBauMember(p.getUniqueId(), id).isTestblock());
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isTestblock()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a die TestBlöcke erneuern.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c die TestBlöcke erneuern.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isTestblock()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf nun deine TestBlöcke erneuern.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf keine TestBlöcke mehr reseten.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.togglereset", aliases = "gs.togglereset", inGameOnly = true)
|
|
||||||
public void onTogglereset(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau togglereset <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()) {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a die Regionen erneuern.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c die Regionen erneuern.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf nun deine Regionen erneuern.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf deine Regionen nicht mehr erneuern.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.togglereplace", aliases = "gs.togglereplace", inGameOnly = true)
|
|
||||||
public void onTogglereplace(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (args.length() == 0) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§bBenutzung: /bau togglereplace <Spieler>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = UUIDFetcher.getUUID(args.getArgs(0));
|
|
||||||
if (id == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cUnbekannter Spieler");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), id).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(id);
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()){
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a TNT und Schleim replacen.");
|
|
||||||
} else {
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c TNT und Schleim replacen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), id).isWorldEdit()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf nun in diener Welt TNT und Schleim replacen.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler darf nun in deiner Welt kein TNT und Schleim mehr replacen.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Command(name = "bau.testblock", aliases = "gs.testblock", inGameOnly = true)
|
|
||||||
public boolean ontestblock(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu stehst auf keiner Bauwelt");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).equals(p.getUniqueId())) {
|
|
||||||
if (BauweltMember.getBauMember(Bukkit.getWorld(p.getUniqueId()).getUID(), p.getUniqueId()).isWorldEdit() == false) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§7Du darfst den TestBlock nicht erneuern");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Location playerLocation = p.getLocation();
|
|
||||||
World playerWorld = p.getWorld();
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int count = 0;
|
|
||||||
for (ProtectedRegion rg : WarShipFactory.getPlugin().getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
String rgID = rg.getId().toString();
|
|
||||||
|
|
||||||
if(rgID.equalsIgnoreCase("resetall")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Vector position = new Vector(Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
|
|
||||||
File file = new File(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.testblock"));
|
|
||||||
|
|
||||||
pasteSchematic(p, file, position);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "Testblock erneuert!");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.reset", aliases = "gs.reset", inGameOnly = true)
|
|
||||||
public boolean onReset(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu stehst auf keiner Bauwelt");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
if (BauweltMember.getBauMember(Bukkit.getWorld(p.getUniqueId()).getUID(), p.getUniqueId()).isWorldEdit() == false) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§7Du darfst keine Regionen erneuern");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Location playerLocation = p.getLocation();
|
|
||||||
World playerWorld = p.getWorld();
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
int count = 0;
|
|
||||||
for (ProtectedRegion rg : WarShipFactory.getPlugin().getWorldGuard().getRegionManager(playerWorld).getApplicableRegions(playerLocation)) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
String rgID = rg.getId().toString();
|
|
||||||
|
|
||||||
if(rgID.equalsIgnoreCase("resetall")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Vector position = new Vector(Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.X")), Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.Y")), Integer.parseInt(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".position.Z")));
|
|
||||||
File file = new File(WarShipFactory.getPlugin().getRegionData.getString("regions." + rgID + ".schematic.reset"));
|
|
||||||
|
|
||||||
pasteSchematic(p, file, position);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "Region " + rgID + " wurde resettet!");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.resetall", aliases = "gs.resetall", inGameOnly = true)
|
|
||||||
public boolean onresetall(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu stehst auf keiner Bauwelt");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
for (Player ap : Bukkit.getOnlinePlayers()) {
|
|
||||||
if (ap.getWorld().getName() == p.getName()) {
|
|
||||||
|
|
||||||
Location location = new Location(Bukkit.getWorld("Bauspawn"), 1442, 113, 228, -151.9F, -4.2F);
|
|
||||||
ap.teleport(location);
|
|
||||||
ap.sendMessage(WarShipFactory.S_PREFIX + "Die Welt wird erneuert!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!unloadWorld(p.getUniqueId().toString())) {
|
|
||||||
WarShipFactory.log("FactoryWorld", "Unable to unload " + Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID());
|
|
||||||
}
|
|
||||||
|
|
||||||
File directory = new File("" + p.getUniqueId());
|
|
||||||
del(directory);
|
|
||||||
File directory1 = new File("plugins/WorldGuard/worlds/" + p.getUniqueId());
|
|
||||||
del(directory1);
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()) == null)
|
|
||||||
try {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aEinen Moment bitte... Deine Welt wird vorbereitet.");
|
|
||||||
loading = true;
|
|
||||||
File world = new File("plugins/WarShipFactory/worlds/" + p.getUniqueId());
|
|
||||||
File region = new File("plugins/WorldGuard/worlds/" + p.getUniqueId());
|
|
||||||
if (region.exists() && region.isDirectory()) {
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + p.getUniqueId()));
|
|
||||||
}
|
|
||||||
if (world.exists() && world.isDirectory()) {
|
|
||||||
FileUtils.moveDirectory(world, new File("" + p.getUniqueId()));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + p.getUniqueId()));
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.backupDir), new File("" + p.getUniqueId()));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + p.getUniqueId()));
|
|
||||||
}
|
|
||||||
loading = false;
|
|
||||||
} catch (Exception e) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cBeim Laden der Welt ist ein Fehler aufgetreten.");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
p.teleport(Bukkit.getWorld(p.getUniqueId().toString()).getSpawnLocation());
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run () {
|
|
||||||
p.setGameMode(GameMode.CREATIVE);
|
|
||||||
}
|
|
||||||
},20L);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.replace", aliases = "gs.replace", inGameOnly = true)
|
|
||||||
public boolean onreplace(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu stehst auf keiner Bauwelt");
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
if (!p.getUniqueId().equals(p.getUniqueId())) {
|
|
||||||
World world = Bukkit.getWorld(p.getUniqueId());
|
|
||||||
if (BauweltMember.getBauMember(Bukkit.getWorld(p.getUniqueId()).getUID(), p.getUniqueId()).isWorldEdit() == false) {
|
|
||||||
p.sendMessage("Du darfst in der Welt von " + p.getDisplayName() + " kein TNT und Schleim replacen!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
World world = p.getWorld();
|
|
||||||
int count = 0;
|
|
||||||
for(ProtectedRegion rg : WarShipFactory.getWorldGuard().getRegionManager(world).getApplicableRegions(p.getLocation())) {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if(count != 0) {
|
|
||||||
|
|
||||||
String rgID = rg.getId();
|
|
||||||
|
|
||||||
if(rgID.equalsIgnoreCase("resetall")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
com.sk89q.worldedit.world.World weWorld = new BukkitWorld(p.getWorld());
|
|
||||||
EditSession editSession = WarShipFactory.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(p.getWorld()), Integer.MAX_VALUE);
|
|
||||||
CuboidSelection selection = new CuboidSelection(p.getWorld(), new Location(p.getWorld(), rg.getMinimumPoint().getBlockX(), rg.getMinimumPoint().getBlockY(), rg.getMinimumPoint().getBlockZ()), new Location(p.getWorld(), rg.getMaximumPoint().getBlockX(), rg.getMaximumPoint().getBlockY(), rg.getMaximumPoint().getBlockZ()));
|
|
||||||
|
|
||||||
Set<BaseBlock> targetObsidian = new HashSet<>();
|
|
||||||
targetObsidian.add(new BaseBlock(49));
|
|
||||||
Set<BaseBlock> targetBedrock = new HashSet<>();
|
|
||||||
targetBedrock.add(new BaseBlock(7));
|
|
||||||
try {
|
|
||||||
|
|
||||||
int tnt = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetObsidian, new BaseBlock(46));
|
|
||||||
int slime = editSession.replaceBlocks(selection.getRegionSelector().getRegion(), targetBedrock, new BaseBlock(165));
|
|
||||||
editSession.flushQueue();
|
|
||||||
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "In Region " + rgID + " wurden " + tnt + " Blöcke Obsidian zu TNT und " + slime + " Blöcke Bedrock zu Slime replacet!");
|
|
||||||
|
|
||||||
} catch(Exception ex) { ex.printStackTrace(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
@Command(name = "bau.info", aliases = "gs.info", inGameOnly = true)
|
|
||||||
public void onInfo(CommandArgs args) {
|
|
||||||
final Player p = args.getPlayer();
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu stehst auf keiner Bauwelt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§3--- §6Informationen §3---");
|
|
||||||
p.sendMessage("");
|
|
||||||
StringBuilder members = new StringBuilder();
|
|
||||||
String ownaz = UUIDFetcher.getName(p.getUniqueId());
|
|
||||||
p.sendMessage("§8Registrierungsnummer: §6" + Bauwelt.getBauwelt(p.getUniqueId()).getUUID().toString());
|
|
||||||
p.sendMessage("§8Besitzer: §6" + ownaz);
|
|
||||||
p.sendMessage("§8Mitglieder: §6" + BauweltMember.getMembers(p.getUniqueId()).get(1));
|
|
||||||
p.sendMessage("");
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) {
|
|
||||||
p.sendMessage("§8TNT Schaden: §6" + "§aTNT Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage("§8TNT Schaden: §6" + "§cTNT Schaden verboten.");
|
|
||||||
}
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) {
|
|
||||||
p.sendMessage("§8Feuer Schaden: §6" + "§aFeuer Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage("§8Feuer Schaden: §6" + "§cFeuer Schaden verboten.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(name = "bau.tntdmg", aliases = "gs.tntdmg", inGameOnly = true)
|
|
||||||
public void onTntdmg(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bauwelt.getBauwelt(p.getUniqueId()).setTNTDmg(!Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aTNT Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cTNT Schaden verboten.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(name = "bau.firedmg", aliases = "gs.firedmg", inGameOnly = true)
|
|
||||||
public void onFiredmg(CommandArgs args) {
|
|
||||||
Player p = args.getPlayer();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bauwelt.getBauwelt(p.getUniqueId()).setFireDmg(!Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aFeuer Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cFeuer Schaden verboten.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private boolean isLoaded(String world) {
|
|
||||||
for (World w : Bukkit.getServer().getWorlds()) {
|
|
||||||
if (w.getName().equals(world)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean unloadWorld(String world) {
|
|
||||||
if (isLoaded(world)) {
|
|
||||||
World w = Bukkit.getWorld(world);
|
|
||||||
for (Player p : w.getPlayers()) {
|
|
||||||
p.teleport(WarShipFactory.getInstance().config.spawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Chunk c : w.getLoadedChunks()) {
|
|
||||||
c.unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean unload = Bukkit.unloadWorld(w, true);
|
|
||||||
return unload;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void pasteSchematic(Player player, File schematic, Vector position) {
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
for(ProtectedRegion rg:WarShipFactory.getWorldGuard().getRegionManager(world).getApplicableRegions(player.getLocation())) {
|
|
||||||
count++;
|
|
||||||
if(count != 0) {
|
|
||||||
|
|
||||||
EditSession session = WarShipFactory.getWorldEdit().getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(world), Integer.MAX_VALUE);
|
|
||||||
try {
|
|
||||||
|
|
||||||
CuboidClipboard format = MCEditSchematicFormat.getFormat(schematic).load(schematic);
|
|
||||||
format.paste(session, position, false);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
player.sendMessage(ex.getMessage());
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean del(File dir){
|
|
||||||
if (dir.isDirectory()){
|
|
||||||
String[] entries = dir.list();
|
|
||||||
for (int x=0;x<entries.length;x++){
|
|
||||||
File aktFile = new File(dir.getPath(),entries[x]);
|
|
||||||
del(aktFile);
|
|
||||||
}
|
|
||||||
if (dir.delete())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if (dir.delete())
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.commands;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.defaults.BukkitCommand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
|
|
||||||
public class CommandGamemode extends BukkitCommand {
|
|
||||||
private static final List<String> GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival",
|
|
||||||
"spectator");
|
|
||||||
|
|
||||||
public CommandGamemode() {
|
|
||||||
super("gm");
|
|
||||||
this.description = "Ändert den Spielmodus eines Spielers";
|
|
||||||
this.usageMessage = "/gm <mode> [player]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
|
||||||
|
|
||||||
// SEAGIANTS
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (p.hasPermission("bukkit.command.gamemode") == false) {
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage("Du befindest dich auf keiner Bauwelt!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
BauweltMember.getMembers(p.getUniqueId());
|
|
||||||
if (BauweltMember.getMembers(p.getUniqueId()) == null && !Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
p.sendMessage("Du bist kein Mitglied dieser Welt!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// END
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Benutzung: " + this.usageMessage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String modeArg = args[0];
|
|
||||||
String playerArg = sender.getName();
|
|
||||||
|
|
||||||
if (args.length == 2 && sender.hasPermission("bukkit.command.gamemode")) {
|
|
||||||
playerArg = args[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = Bukkit.getPlayerExact(playerArg);
|
|
||||||
|
|
||||||
if (player != null) {
|
|
||||||
int value = -1;
|
|
||||||
try {
|
|
||||||
value = Integer.parseInt(modeArg);
|
|
||||||
} catch (NumberFormatException localNumberFormatException) {
|
|
||||||
}
|
|
||||||
GameMode mode = GameMode.getByValue(value);
|
|
||||||
|
|
||||||
if (mode == null) {
|
|
||||||
if ((modeArg.equalsIgnoreCase("creative")) || (modeArg.equalsIgnoreCase("c")))
|
|
||||||
mode = GameMode.CREATIVE;
|
|
||||||
else if ((modeArg.equalsIgnoreCase("adventure")) || (modeArg.equalsIgnoreCase("a")))
|
|
||||||
mode = GameMode.ADVENTURE;
|
|
||||||
else if ((modeArg.equalsIgnoreCase("spectator")) || (modeArg.equalsIgnoreCase("sp")))
|
|
||||||
mode = GameMode.SPECTATOR;
|
|
||||||
else {
|
|
||||||
mode = GameMode.SURVIVAL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode != player.getGameMode()) {
|
|
||||||
player.setGameMode(mode);
|
|
||||||
|
|
||||||
if (mode != player.getGameMode()) {
|
|
||||||
sender.sendMessage("Spielmodus setzen für " + player.getName() + " fehlgeschlagen!");
|
|
||||||
} else if (player == sender)
|
|
||||||
Command.broadcastCommandMessage(sender, "Setzte eigenen Spielmodus zu " + mode.toString());
|
|
||||||
else
|
|
||||||
Command.broadcastCommandMessage(sender,
|
|
||||||
"Setzte " + player.getName() + "'s Spielmodus zu " + mode.toString());
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(player.getName() + " ist bereits im " + mode.toString() + " mode");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
sender.sendMessage("Spieler konnte nicht gefunden werden: " + playerArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
|
|
||||||
Validate.notNull(sender, "Sender cannot be null");
|
|
||||||
Validate.notNull(args, "Arguments cannot be null");
|
|
||||||
Validate.notNull(alias, "Alias cannot be null");
|
|
||||||
|
|
||||||
if (args.length == 1)
|
|
||||||
return ((List) StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES,
|
|
||||||
new ArrayList(GAMEMODE_NAMES.size())));
|
|
||||||
if (args.length == 2) {
|
|
||||||
return super.tabComplete(sender, alias, args);
|
|
||||||
}
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,954 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.commands;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
|
||||||
|
|
||||||
public class CommandGui implements Listener {
|
|
||||||
|
|
||||||
public Location warship1;
|
|
||||||
public Location warship2;
|
|
||||||
public Location wargear5;
|
|
||||||
public Location wargear6;
|
|
||||||
public Location wargear7;
|
|
||||||
public Location wargear8;
|
|
||||||
public Location miniwargear1;
|
|
||||||
public Location miniwargear2;
|
|
||||||
public Location miniwargear7;
|
|
||||||
public Location miniwargear8;
|
|
||||||
public Location airship1;
|
|
||||||
public Location airship2;
|
|
||||||
public Location airship3;
|
|
||||||
public Location airship4;
|
|
||||||
public Location airship5;
|
|
||||||
public Location airship6;
|
|
||||||
public Location airship7;
|
|
||||||
public Location airship8;
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerClickInventory(InventoryClickEvent e) {
|
|
||||||
if (e.getInventory().getTitle().equals("§bBau Abteilungen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarShip §aTestGelände 1")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
warship1 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarShip1.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarShip1.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarShip1.loc.z"));
|
|
||||||
p.teleport(warship1);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarShip1.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarShip §aTestGelände 2")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
warship2 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarShip2.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarShip2.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarShip2.loc.z"));
|
|
||||||
p.teleport(warship2);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarShip2.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarGear §aTestGelände 5")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
wargear5 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarGear5.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear5.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear5.loc.z"));
|
|
||||||
p.teleport(wargear5);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarGear5.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarGear §aTestGelände 6")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
wargear6 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarGear6.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear6.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear6.loc.z"));
|
|
||||||
p.teleport(wargear6);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarGear6.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarGear §aTestGelände 7")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
wargear7 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarGear7.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear7.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear7.loc.z"));
|
|
||||||
p.teleport(wargear7);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarGear7.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWarGear §aTestGelände 8")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
wargear8 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("WarGear8.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear8.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("WarGear8.loc.z"));
|
|
||||||
p.teleport(wargear8);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("WarGear8.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bMiniWarGear §aTestGelände 1")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
miniwargear1 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear1.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear1.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear1.loc.z"));
|
|
||||||
p.teleport(miniwargear1);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("MiniWargear1.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bMiniWarGear §aTestGelände 2")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
miniwargear2 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear2.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear2.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear2.loc.z"));
|
|
||||||
p.teleport(miniwargear2);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("MiniWargear2.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bMiniWarGear §aTestGelände 7")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
miniwargear7 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear7.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear7.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear7.loc.z"));
|
|
||||||
p.teleport(miniwargear7);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("MiniWargear7.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bMiniWarGear §aTestGelände 8")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
miniwargear8 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear8.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear8.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("MiniWargear8.loc.z"));
|
|
||||||
p.teleport(miniwargear8);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("MiniWargear8.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 1")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship1 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip1.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip1.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip1.loc.z"));
|
|
||||||
p.teleport(airship1);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip1.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 2")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship2 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip2.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip2.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip2.loc.z"));
|
|
||||||
p.teleport(airship2);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip2.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 3")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship3 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip3.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip3.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip3.loc.z"));
|
|
||||||
p.teleport(airship3);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip3.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 4")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship4 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip4.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip4.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip4.loc.z"));
|
|
||||||
p.teleport(airship4);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip4.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 5")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship5 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip5.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip5.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip5.loc.z"));
|
|
||||||
p.teleport(airship5);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip5.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 6")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship6 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip6.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip6.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip6.loc.z"));
|
|
||||||
p.teleport(airship6);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip6.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 7")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship7 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip7.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip7.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip7.loc.z"));
|
|
||||||
p.teleport(airship7);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip7.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bAirShip §aTestGelände 8")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
airship8 = new Location(p.getWorld(), WarShipFactory.getInstance().config.cfg.getDouble("AirShip8.loc.x"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip8.loc.y"), WarShipFactory.getInstance().config.cfg.getDouble("AirShip8.loc.z"));
|
|
||||||
p.teleport(airship8);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + WarShipFactory.getInstance().config.cfg.getString("AirShip8.Message"));
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bZurück")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
e.getView().close();
|
|
||||||
p.openInventory(mainmenu());
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getInventory().getTitle().equals("§bWelten Optionen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aTNT Schaden")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bauwelt.getBauwelt(p.getUniqueId()).setTNTDmg(!Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aAuf deiner Welt ist jetzt TNT Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cAuf deiner Welt ist jetzt TNT Schaden verboten.");
|
|
||||||
}
|
|
||||||
e.getView().close();
|
|
||||||
p.openInventory(weltoption(p));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aFeuer Schaden")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bauwelt.getBauwelt(p.getUniqueId()).setFireDmg(!Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aAuf deiner Welt ist jetzt Feuer Schaden erlaubt.");
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cAuf deiner Welt ist jetzt Feuer Schaden verboten.");
|
|
||||||
}
|
|
||||||
e.getView().close();
|
|
||||||
p.openInventory(weltoption(p));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§eStatus §2An")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§4Du darfst das nicht");
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§eStatus §4Aus")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§4Das darfst du nicht");
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bZurück")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
e.getView().close();
|
|
||||||
p.openInventory(mainmenu());
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getInventory().getTitle().equals("§aBau Optionen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bBau Abteilungen")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.openInventory(bauabteilung());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getInventory().getTitle().equals("§aBau Optionen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bWelten Optionen")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.openInventory(weltoption(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getInventory().getTitle().equals("§aBau Optionen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bSpieler Optionen")) {
|
|
||||||
//code
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
|
||||||
player.openInventory(spieleroption(player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getInventory().getTitle().equals("§bSpieler Optionen")) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
|
||||||
if (e.getCurrentItem() != null) {
|
|
||||||
Material material = e.getCurrentItem().getType();
|
|
||||||
if (material == Material.SKULL_ITEM) {
|
|
||||||
SkullMeta skullMeta = (SkullMeta) getSkull(material.getData().getCanonicalName()).getItemMeta();
|
|
||||||
SkullTeleport(player, e.getCurrentItem());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bZurück")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
e.getView().close();
|
|
||||||
p.openInventory(mainmenu());
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player target : Bukkit.getOnlinePlayers()) {
|
|
||||||
if (e.getInventory().getTitle().equals(target.getDisplayName())) {
|
|
||||||
if (e.getCurrentItem().getItemMeta() != null) {
|
|
||||||
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName() != null) {
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
|
||||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM);
|
|
||||||
ItemMeta meta = skull.getItemMeta();
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(player.getUniqueId());
|
|
||||||
if (fw == null) {
|
|
||||||
player.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(player.getUniqueId(), target.getUniqueId()) != null) {
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aSpieler hinzufügen")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
|
||||||
p.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aSpieler hinzufügen")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
new BauweltMember(p.getUniqueId(),target.getUniqueId(), true, false, false, false, false);
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + ChatColor.RED + "§aDu hast " + target.getName() + " §azu der Welt §6" + ChatColor.RED + " §ahinzugefügt");
|
|
||||||
target.sendMessage(WarShipFactory.S_PREFIX + ChatColor.RED + "§aDu wurdest zu der Welt von §6" + p.getName() + ChatColor.RED + " §ahinzugefügt");
|
|
||||||
p.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§bZurück")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
player.closeInventory();
|
|
||||||
player.openInventory(spieleroption(p));
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(player.getUniqueId(), target.getUniqueId()) == null) {
|
|
||||||
e.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle Worldedit")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt auf deiner Welt Worldedit benutzten.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a WorldEdit verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt auf deiner Welt kein Worldedit mehr benutzten.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c WorldEdit verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle Teleport")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setTeleport(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isTeleport());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isTeleport())) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler kann sich jetzt auf deiner Welt Teleportieren.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a /tp verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf sich jetzt nicht mehr auf deiner Welt Teleportieren.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c /tp verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle Build")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setBuild(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isBuild());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isBuild())) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt Bauen auf deiner Welt.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a bauen.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt nicht mehr Bauen auf deiner Welt.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c bauen.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle ChangeGamemode")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setChangeGM(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isChangeGM());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isChangeGM())) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt sein Gamemode auf deiner Welt wechseln.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a deinen Spielmodus ändern.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt nicht mehr sein Gamemode auf deiner Welt wechseln.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c deinen Spielmodus ändern.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§cSpieler entfernen")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).remove();
|
|
||||||
target.sendMessage(WarShipFactory.S_PREFIX + ChatColor.RED + "§aDu wurdest von der Welt §6" + p.getName() + ChatColor.RED + " §aentfernt");
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + ChatColor.RED + "Der Spieler " + target.getName() + ChatColor.RED + " wurde von deiner welt entfernt");
|
|
||||||
e.setCancelled(true);
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
if (z != null) {
|
|
||||||
if (z.getWorld().getUID().equals(Bukkit.getWorld(p.getUniqueId().toString()).getUID())) {
|
|
||||||
z.teleport(WarShipFactory.getInstance().config.spawn);
|
|
||||||
z.getInventory().clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.openInventory(spieleroption(p));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle Replace")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit())) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt auf deiner Welt Replacen.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun auf der Welt von §6" + p.getName() + "§c /bau replace verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt nicht mehr auf deiner Welt Replacen.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c /bau replace verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle Reset")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit())) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt auf deiner Welt einzelne Regionen erneuern.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun auf der Welt von §6" + p.getName() + "§c /bau reset verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt nicht mehr auf deiner Welt einzelne Regionen erneuern.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c /bau reset verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§aToggle TestBlock")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).setWorldEdit(!BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit());
|
|
||||||
Player z = Bukkit.getPlayer(target.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isWorldEdit()) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt auf deiner Welt TestBlöcke erneuern.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun auf der Welt von §6" + p.getName() + "§c /bau testblock verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§aDer Spieler darf jetzt nicht mehr auf deiner Welt TestBlöcke erneuern.");
|
|
||||||
z.sendMessage(WarShipFactory.S_PREFIX + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c /bau testblock verwenden.");
|
|
||||||
p.closeInventory();
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§eStatus §4An")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§4Das darfst du nicht");
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.RED + "§eStatus §4Aus")) {
|
|
||||||
//code
|
|
||||||
Player p = (Player) e.getWhoClicked();
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§4Das darfst du nicht");
|
|
||||||
e.getView().close();
|
|
||||||
e.setCancelled(true);
|
|
||||||
player.closeInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getSkull(String name) {
|
|
||||||
ItemStack skull = new ItemStack(397, 1, (short) 3);
|
|
||||||
SkullMeta skullmeta = (SkullMeta) skull.getItemMeta();
|
|
||||||
skullmeta.setDisplayName(name);
|
|
||||||
skullmeta.setOwner(name);
|
|
||||||
skull.setItemMeta(skullmeta);
|
|
||||||
return skull;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SkullTeleport(Player player, ItemStack item) {
|
|
||||||
SkullMeta skullmeta = (SkullMeta) item.getItemMeta();
|
|
||||||
if (skullmeta.getDisplayName() != null) {
|
|
||||||
if (Bukkit.getPlayer(skullmeta.getDisplayName()) != null) {
|
|
||||||
Player target = Bukkit.getPlayer(skullmeta.getDisplayName());
|
|
||||||
player.openInventory(skullOwnerInventory(target, player));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Inventory skullOwnerInventory(Player p, Player player) {
|
|
||||||
|
|
||||||
Inventory inv2 = Bukkit.createInventory(null, 18, p.getDisplayName());
|
|
||||||
ItemStack skull = new ItemStack(Material.SKULL_ITEM);
|
|
||||||
ItemMeta meta = skull.getItemMeta();
|
|
||||||
meta = skull.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aSpieler hinzufügen");
|
|
||||||
skull.setItemMeta(meta);
|
|
||||||
inv2.addItem(skull);
|
|
||||||
|
|
||||||
ItemStack skull1 = new ItemStack(Material.SKULL_ITEM);
|
|
||||||
meta = skull1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§cSpieler entfernen");
|
|
||||||
skull1.setItemMeta(meta);
|
|
||||||
inv2.setItem(9, skull1);
|
|
||||||
|
|
||||||
ItemStack togglewe = new ItemStack(Material.WOOD_AXE);
|
|
||||||
meta = togglewe.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle Worldedit");
|
|
||||||
togglewe.setItemMeta(meta);
|
|
||||||
inv2.setItem(1, togglewe);
|
|
||||||
|
|
||||||
ItemStack toggletp = new ItemStack(Material.COMPASS);
|
|
||||||
meta = toggletp.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle Teleport");
|
|
||||||
toggletp.setItemMeta(meta);
|
|
||||||
inv2.setItem(2, toggletp);
|
|
||||||
|
|
||||||
ItemStack togglebuild = new ItemStack(Material.GRASS);
|
|
||||||
meta = togglebuild.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle Build");
|
|
||||||
togglebuild.setItemMeta(meta);
|
|
||||||
inv2.setItem(3, togglebuild);
|
|
||||||
|
|
||||||
ItemStack togglegm = new ItemStack(Material.LADDER);
|
|
||||||
meta = togglegm.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle ChangeGamemode");
|
|
||||||
togglegm.setItemMeta(meta);
|
|
||||||
inv2.setItem(4, togglegm);
|
|
||||||
|
|
||||||
ItemStack togglerep = new ItemStack(Material.BREWING_STAND_ITEM);
|
|
||||||
meta = togglerep.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle Replace");
|
|
||||||
togglerep.setItemMeta(meta);
|
|
||||||
inv2.setItem(5, togglerep);
|
|
||||||
|
|
||||||
ItemStack togglereset = new ItemStack(Material.BARRIER);
|
|
||||||
meta = togglereset.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle Reset");
|
|
||||||
togglereset.setItemMeta(meta);
|
|
||||||
inv2.setItem(6, togglereset);
|
|
||||||
|
|
||||||
ItemStack toggletestblock = new ItemStack(Material.ENDER_STONE);
|
|
||||||
meta = toggletestblock.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aToggle TestBlock");
|
|
||||||
toggletestblock.setItemMeta(meta);
|
|
||||||
inv2.setItem(7, toggletestblock);
|
|
||||||
|
|
||||||
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
|
||||||
meta = back.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bZurück");
|
|
||||||
back.setItemMeta(meta);
|
|
||||||
inv2.setItem(8, back);
|
|
||||||
|
|
||||||
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(player.getUniqueId());
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDu hast keine Welt");
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), player.getUniqueId()) == null) {
|
|
||||||
p.sendMessage(WarShipFactory.S_PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt");
|
|
||||||
} else {
|
|
||||||
Player z = Bukkit.getPlayer(p.getUniqueId());
|
|
||||||
if (z != null) {
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isWorldEdit())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(10, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(10, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isTeleport())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(11, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(11, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isBuild())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(12, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(12, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isChangeGM())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(13, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(13, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isWorldEdit())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(14, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(14, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isWorldEdit())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(15, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(15, tntst1);
|
|
||||||
}
|
|
||||||
if ((BauweltMember.getBauMember(p.getUniqueId(), p.getUniqueId()).isWorldEdit())) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(16, tntst);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(16, tntst1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return inv2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Inventory mainmenu() {
|
|
||||||
|
|
||||||
Inventory inv = Bukkit.createInventory(null, 9, "§aBau Optionen");
|
|
||||||
{
|
|
||||||
ItemStack bau = new ItemStack(Material.COMPASS);
|
|
||||||
ItemMeta meta = bau.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bBau Abteilungen");
|
|
||||||
bau.setItemMeta(meta);
|
|
||||||
inv.addItem(bau);
|
|
||||||
ItemStack optionen = new ItemStack(Material.ENCHANTED_BOOK);
|
|
||||||
meta = optionen.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWelten Optionen");
|
|
||||||
optionen.setItemMeta(meta);
|
|
||||||
inv.setItem(8, optionen);
|
|
||||||
ItemStack spieler = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = spieler.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bSpieler Optionen");
|
|
||||||
spieler.setItemMeta(meta);
|
|
||||||
inv.setItem(4, spieler);
|
|
||||||
}
|
|
||||||
return inv;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Inventory spieleroption(Player player) {
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(player.getUniqueId());
|
|
||||||
Inventory inv = Bukkit.createInventory(null, 54, "§bSpieler Optionen");
|
|
||||||
{
|
|
||||||
inv.clear();
|
|
||||||
int slot = 0;
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
|
||||||
inv.setItem(slot, getSkull(p.getName()));
|
|
||||||
slot++;
|
|
||||||
}
|
|
||||||
ItemStack skull1 = new ItemStack(Material.SLIME_BALL);
|
|
||||||
ItemMeta meta1 = skull1.getItemMeta();
|
|
||||||
meta1 = skull1.getItemMeta();
|
|
||||||
meta1.setDisplayName(ChatColor.RED + "§bZurück");
|
|
||||||
skull1.setItemMeta(meta1);
|
|
||||||
inv.setItem(53, skull1);
|
|
||||||
}return inv;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Inventory bauabteilung() {
|
|
||||||
Inventory inv1 = Bukkit.createInventory(null, 54, "§bBau Abteilungen");
|
|
||||||
{
|
|
||||||
ItemStack warship1 = new ItemStack(Material.WATER_BUCKET);
|
|
||||||
ItemMeta meta = warship1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarShip §aTestGelände 1");
|
|
||||||
warship1.setItemMeta(meta);
|
|
||||||
inv1.addItem(warship1);
|
|
||||||
ItemStack warship2 = new ItemStack(Material.WATER_BUCKET);
|
|
||||||
meta = warship2.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarShip §aTestGelände 2");
|
|
||||||
warship2.setItemMeta(meta);
|
|
||||||
inv1.setItem(1, warship2);
|
|
||||||
ItemStack wargear1 = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = wargear1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarGear §aTestGelände 5");
|
|
||||||
wargear1.setItemMeta(meta);
|
|
||||||
inv1.setItem(9, wargear1);
|
|
||||||
ItemStack wargear2 = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = wargear2.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarGear §aTestGelände 6");
|
|
||||||
wargear2.setItemMeta(meta);
|
|
||||||
inv1.setItem(10, wargear2);
|
|
||||||
ItemStack wargear3 = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = wargear3.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarGear §aTestGelände 7");
|
|
||||||
wargear3.setItemMeta(meta);
|
|
||||||
inv1.setItem(11, wargear3);
|
|
||||||
ItemStack wargear4 = new ItemStack(Material.REDSTONE_BLOCK);
|
|
||||||
meta = wargear4.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bWarGear §aTestGelände 8");
|
|
||||||
wargear4.setItemMeta(meta);
|
|
||||||
inv1.setItem(12, wargear4);
|
|
||||||
ItemStack miniwargear1 = new ItemStack(Material.REDSTONE);
|
|
||||||
meta = miniwargear1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bMiniWarGear §aTestGelände 1");
|
|
||||||
miniwargear1.setItemMeta(meta);
|
|
||||||
inv1.setItem(18, miniwargear1);
|
|
||||||
ItemStack miniwargear2 = new ItemStack(Material.REDSTONE);
|
|
||||||
meta = miniwargear2.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bMiniWarGear §aTestGelände 2");
|
|
||||||
miniwargear2.setItemMeta(meta);
|
|
||||||
inv1.setItem(19, miniwargear2);
|
|
||||||
ItemStack miniwargear3 = new ItemStack(Material.REDSTONE);
|
|
||||||
meta = miniwargear3.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bMiniWarGear §aTestGelände 7");
|
|
||||||
miniwargear3.setItemMeta(meta);
|
|
||||||
inv1.setItem(20, miniwargear3);
|
|
||||||
ItemStack miniwargear4 = new ItemStack(Material.REDSTONE);
|
|
||||||
meta = miniwargear4.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bMiniWarGear §aTestGelände 8");
|
|
||||||
miniwargear4.setItemMeta(meta);
|
|
||||||
inv1.setItem(21, miniwargear4);
|
|
||||||
ItemStack airship1 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 1");
|
|
||||||
airship1.setItemMeta(meta);
|
|
||||||
inv1.setItem(27, airship1);
|
|
||||||
ItemStack airship2 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship2.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 2");
|
|
||||||
airship2.setItemMeta(meta);
|
|
||||||
inv1.setItem(28, airship2);
|
|
||||||
ItemStack airship3 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship3.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 3");
|
|
||||||
airship3.setItemMeta(meta);
|
|
||||||
inv1.setItem(29, airship3);
|
|
||||||
ItemStack airship4 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship4.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 4");
|
|
||||||
airship4.setItemMeta(meta);
|
|
||||||
inv1.setItem(30, airship4);
|
|
||||||
ItemStack airship5 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship5.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 5");
|
|
||||||
airship5.setItemMeta(meta);
|
|
||||||
inv1.setItem(31, airship5);
|
|
||||||
ItemStack airship6 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship6.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 6");
|
|
||||||
airship6.setItemMeta(meta);
|
|
||||||
inv1.setItem(32, airship6);
|
|
||||||
ItemStack airship7 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship7.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 7");
|
|
||||||
airship7.setItemMeta(meta);
|
|
||||||
inv1.setItem(33, airship7);
|
|
||||||
ItemStack airship8 = new ItemStack(Material.ELYTRA);
|
|
||||||
meta = airship8.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bAirShip §aTestGelände 8");
|
|
||||||
airship8.setItemMeta(meta);
|
|
||||||
inv1.setItem(34, airship8);
|
|
||||||
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
|
||||||
ItemMeta meta1 = back.getItemMeta();
|
|
||||||
meta1 = back.getItemMeta();
|
|
||||||
meta1.setDisplayName(ChatColor.RED + "§bZurück");
|
|
||||||
back.setItemMeta(meta1);
|
|
||||||
inv1.setItem(53, back);
|
|
||||||
}return inv1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Inventory weltoption(Player p) {
|
|
||||||
FactoryWorld fw = WarShipFactory.getInstance().getWorldFromOwner(p.getUniqueId());
|
|
||||||
Inventory inv2 = Bukkit.createInventory(null, 18, "§bWelten Optionen");
|
|
||||||
{
|
|
||||||
ItemStack tnt = new ItemStack(Material.TNT);
|
|
||||||
ItemMeta meta = tnt.getItemMeta();
|
|
||||||
meta = tnt.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aTNT Schaden");
|
|
||||||
tnt.setItemMeta(meta);
|
|
||||||
inv2.addItem(tnt);
|
|
||||||
ItemStack back = new ItemStack(Material.SLIME_BALL);
|
|
||||||
meta = back.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§bZurück");
|
|
||||||
back.setItemMeta(meta);
|
|
||||||
inv2.setItem(4, back);
|
|
||||||
ItemStack fire = new ItemStack(Material.LAVA_BUCKET);
|
|
||||||
meta = fire.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§aFeuer Schaden");
|
|
||||||
fire.setItemMeta(meta);
|
|
||||||
inv2.setItem(8, fire);
|
|
||||||
p.openInventory(inv2);
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isTNTDmg()) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(9, tntst);
|
|
||||||
p.closeInventory();
|
|
||||||
p.openInventory(inv2);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(9, tntst1);
|
|
||||||
p.closeInventory();
|
|
||||||
p.openInventory(inv2);
|
|
||||||
}
|
|
||||||
if (Bauwelt.getBauwelt(p.getUniqueId()).isFireDmg()) {
|
|
||||||
ItemStack tntst = new ItemStack(351, 1, (short) 10);
|
|
||||||
meta = tntst.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §2An");
|
|
||||||
tntst.setItemMeta(meta);
|
|
||||||
inv2.setItem(17, tntst);
|
|
||||||
p.closeInventory();
|
|
||||||
p.openInventory(inv2);
|
|
||||||
} else {
|
|
||||||
ItemStack tntst1 = new ItemStack(351, 1, (short) 8);
|
|
||||||
meta = tntst1.getItemMeta();
|
|
||||||
meta.setDisplayName(ChatColor.RED + "§eStatus §4Aus");
|
|
||||||
tntst1.setItemMeta(meta);
|
|
||||||
inv2.setItem(17, tntst1);
|
|
||||||
p.closeInventory();
|
|
||||||
p.openInventory(inv2);
|
|
||||||
}
|
|
||||||
}return inv2;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,176 +0,0 @@
|
|||||||
/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
|
|
||||||
package de.quantumnanox.warshipfactory.commands;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.defaults.BukkitCommand;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.content.FactoryWorld;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
|
|
||||||
public class CommandTeleport extends BukkitCommand {
|
|
||||||
public CommandTeleport() {
|
|
||||||
super("tp");
|
|
||||||
this.description = "Teleports the given player (or yourself) to another player or coordinates";
|
|
||||||
this.usageMessage = "/tp [player] <target> and/or <x> <y> <z>";
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
|
||||||
if ((args.length < 1) || (args.length > 4)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: " + this.usageMessage);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SEAGIANTS
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (p.hasPermission("bukkit.command.teleport") == false) {
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()).getName() == null) {
|
|
||||||
p.sendMessage("Du befindest dich auf keiner Bauwelt!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(Bukkit.getWorld(p.getUniqueId()).getUID(), p.getUniqueId()) == null && !Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
p.sendMessage("Du bist kein Mitglied dieser Welt!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!Bauwelt.getBauwelt(Bukkit.getWorld(p.getUniqueId()).getUID()).getUUID().equals(p.getUniqueId())) {
|
|
||||||
if (BauweltMember.getBauMember(Bukkit.getWorld(p.getUniqueId()).getUID(), p.getUniqueId()).isTeleport() == false) {
|
|
||||||
p.sendMessage("Du darfst dich auf dieser Welt nicht teleportieren!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// END
|
|
||||||
|
|
||||||
Player player = Bukkit.getPlayerExact(args[0]);
|
|
||||||
|
|
||||||
if (player == null && args.length != 3) {
|
|
||||||
sender.sendMessage("Player not found: " + args[0]);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length == 1 || args.length == 3) {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
player = (Player) sender;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 3) {
|
|
||||||
Player target = Bukkit.getPlayerExact(args[(args.length - 1)]);
|
|
||||||
if (target == null) {
|
|
||||||
sender.sendMessage("Can't find player " + args[(args.length - 1)] + ". No tp.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// SEAGIANTS
|
|
||||||
if (!sender.hasPermission("bukkit.command.teleport")) {
|
|
||||||
if (Bukkit.getWorld(player.getUniqueId()) == null) {
|
|
||||||
sender.sendMessage("Der Spieler befindet sich auf keiner Bauwelt.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (Bukkit.getWorld(target.getUniqueId()) == null) {
|
|
||||||
sender.sendMessage("Der Zielspieler befindet sich auf keiner Bauwelt.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(player.getUniqueId(), target.getUniqueId()).isTeleport() == false){
|
|
||||||
sender.sendMessage("Die Spieler sind nicht auf der selben Bauwelt.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player p = (Player) sender;
|
|
||||||
if (Bukkit.getWorld(p.getUniqueId()) == null) {
|
|
||||||
p.sendMessage("Du bist auf keiner Bauwelt");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (BauweltMember.getBauMember(p.getUniqueId(), target.getUniqueId()).isTeleport() == false) {
|
|
||||||
p.sendMessage("Das Ziel befindet sich nicht auf deiner Welt");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// END
|
|
||||||
|
|
||||||
player.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
|
|
||||||
Command.broadcastCommandMessage(sender,
|
|
||||||
"Teleported " + player.getDisplayName() + " to " + target.getDisplayName());
|
|
||||||
} else if (player.getWorld() != null) {
|
|
||||||
Location playerLocation = player.getLocation();
|
|
||||||
double x = getCoordinate(sender, playerLocation.getX(), args[(args.length - 3)]);
|
|
||||||
double y = getCoordinate(sender, playerLocation.getY(), args[(args.length - 2)], 0, 0);
|
|
||||||
double z = getCoordinate(sender, playerLocation.getZ(), args[(args.length - 1)]);
|
|
||||||
|
|
||||||
if ((x == -30000001.0D) || (y == -30000001.0D) || (z == -30000001.0D)) {
|
|
||||||
sender.sendMessage("Please provide a valid location!");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
playerLocation.setX(x);
|
|
||||||
playerLocation.setY(y);
|
|
||||||
playerLocation.setZ(z);
|
|
||||||
|
|
||||||
player.teleport(playerLocation, PlayerTeleportEvent.TeleportCause.COMMAND);
|
|
||||||
Command.broadcastCommandMessage(sender, String.format("Teleported %s to %.2f, %.2f, %.2f",
|
|
||||||
new Object[] { player.getDisplayName(), Double.valueOf(x), Double.valueOf(y), Double.valueOf(z) }));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getCoordinate(CommandSender sender, double current, String input) {
|
|
||||||
return getCoordinate(sender, current, input, -30000000, 30000000);
|
|
||||||
}
|
|
||||||
|
|
||||||
private double getCoordinate(CommandSender sender, double current, String input, int min, int max) {
|
|
||||||
boolean relative = input.startsWith("~");
|
|
||||||
double result = (relative) ? current : 0.0D;
|
|
||||||
|
|
||||||
if ((!(relative)) || (input.length() > 1)) {
|
|
||||||
boolean exact = input.contains(".");
|
|
||||||
if (relative)
|
|
||||||
input = input.substring(1);
|
|
||||||
|
|
||||||
double testResult = getCoordinate(sender,current, input);
|
|
||||||
if (testResult == -30000001.0D) {
|
|
||||||
return -30000001.0D;
|
|
||||||
}
|
|
||||||
result += testResult;
|
|
||||||
|
|
||||||
if ((!(exact)) && (!(relative)))
|
|
||||||
result += 0.5D;
|
|
||||||
}
|
|
||||||
if ((min != 0) || (max != 0)) {
|
|
||||||
if (result < min) {
|
|
||||||
result = -30000001.0D;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result > max) {
|
|
||||||
result = -30000001.0D;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
|
||||||
Validate.notNull(sender, "Sender cannot be null");
|
|
||||||
Validate.notNull(args, "Arguments cannot be null");
|
|
||||||
Validate.notNull(alias, "Alias cannot be null");
|
|
||||||
|
|
||||||
if ((args.length == 1) || (args.length == 2)) {
|
|
||||||
return super.tabComplete(sender, alias, args);
|
|
||||||
}
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.content;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import de.warking.hunjy.MySQL.Bauwelt;
|
|
||||||
import de.warking.hunjy.MySQL.BauweltMember;
|
|
||||||
import net.minecraft.server.v1_12_R1.PlayerList;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
public class FactoryWorld {
|
|
||||||
|
|
||||||
private int regId;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private World wrapped;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private UUID owner;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean loading;
|
|
||||||
|
|
||||||
|
|
||||||
private BukkitTask task;
|
|
||||||
|
|
||||||
public FactoryWorld() {
|
|
||||||
task = Bukkit.getScheduler().runTaskTimer(WarShipFactory.getInstance(), new LagDetectorRunnable(this), 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load(UUID ownaz) {
|
|
||||||
owner = Bauwelt.getBauwelt(ownaz).getUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadWorld(UUID ownaz) throws IOException {
|
|
||||||
loading = true;
|
|
||||||
File world = new File("plugins/WarShipFactory/worlds/" + ownaz);
|
|
||||||
File region = new File("plugins/WorldGuard/worlds/" + ownaz);
|
|
||||||
if (region.exists() && region.isDirectory()) {
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.regionDir), new File("plugins/WorldGuard/worlds/" + ownaz));
|
|
||||||
}
|
|
||||||
if (world.exists() && world.isDirectory()) {
|
|
||||||
FileUtils.moveDirectory(world, new File("" + ownaz));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + ownaz));
|
|
||||||
} else {
|
|
||||||
FileUtils.copyDirectory(new File(WarShipFactory.getInstance().config.backupDir), new File("" + ownaz));
|
|
||||||
wrapped = Bukkit.createWorld(new WorldCreator("" + ownaz));
|
|
||||||
}
|
|
||||||
loading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unloadWorld(UUID ownaz) {
|
|
||||||
wrapped.save();
|
|
||||||
{
|
|
||||||
if (BauweltMember.getMembers(ownaz) != null) {
|
|
||||||
if (BauweltMember.getMembers(ownaz).equals(wrapped.getUID())) {
|
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!unloadWorld("" + ownaz)) {
|
|
||||||
WarShipFactory.log("FactoryWorld", "Unable to unload " + ownaz);
|
|
||||||
}
|
|
||||||
wrapped = null;
|
|
||||||
try {
|
|
||||||
FileUtils.moveDirectory(new File("" + ownaz), new File("plugins/WarShipFactory/worlds/" + ownaz));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isLoaded(String world) {
|
|
||||||
for (World w : Bukkit.getServer().getWorlds()) {
|
|
||||||
if (w.getName().equals(world)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean unloadWorld(String world) {
|
|
||||||
if (isLoaded(world)) {
|
|
||||||
World w = Bukkit.getWorld(world);
|
|
||||||
for (Player p : w.getPlayers()) {
|
|
||||||
p.teleport(WarShipFactory.getInstance().config.spawn);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Chunk c : w.getLoadedChunks()) {
|
|
||||||
c.unload();
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean unload = Bukkit.unloadWorld(w, true);
|
|
||||||
return unload;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(String string) {
|
|
||||||
for (Player p : wrapped.getPlayers()) {
|
|
||||||
p.sendMessage(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.content;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_12_R1.Material;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
|
|
||||||
public class LagDetectorRunnable implements Runnable {
|
|
||||||
|
|
||||||
private FactoryWorld world;
|
|
||||||
private boolean timeout;
|
|
||||||
private long timerstart = 0;
|
|
||||||
|
|
||||||
public LagDetectorRunnable(FactoryWorld fw) {
|
|
||||||
this.world = fw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (world.getWrapped() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
world.getWrapped().setStorm(false);
|
|
||||||
world.getWrapped().setThundering(false);
|
|
||||||
world.getWrapped().setMonsterSpawnLimit(0);
|
|
||||||
world.getWrapped().setAnimalSpawnLimit(0);
|
|
||||||
int players = 0;
|
|
||||||
int other = 0;
|
|
||||||
for (Entity e : world.getWrapped().getEntities()) {
|
|
||||||
if (e instanceof Player) {
|
|
||||||
players++;
|
|
||||||
} else {
|
|
||||||
other++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(players == 0 && !timeout) {
|
|
||||||
timeout = true;
|
|
||||||
timerstart = System.currentTimeMillis();
|
|
||||||
} else if(players != 0) {
|
|
||||||
timeout = false;
|
|
||||||
}
|
|
||||||
long diff = System.currentTimeMillis() - timerstart;
|
|
||||||
if (players == 0 && timeout && diff > 1000*60) {
|
|
||||||
world.unloadWorld(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (other > 1000) {
|
|
||||||
for (Entity e : world.getWrapped().getEntities()) {
|
|
||||||
if (e instanceof Player) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
e.remove();
|
|
||||||
}
|
|
||||||
world.broadcast(WarShipFactory.S_PREFIX+"§cLagverursachung erkannt. Es wurden §6"+other+" Entities§c entfernt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.content;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import com.mojang.util.UUIDTypeAdapter;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public class UUIDFetcher {
|
|
||||||
/**
|
|
||||||
* Date when name changes were introduced
|
|
||||||
* @see UUIDFetcher#getUUIDAt(String, long)
|
|
||||||
*/
|
|
||||||
public static final long FEBRUARY_2015 = 1422748800000L;
|
|
||||||
|
|
||||||
private static Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create();
|
|
||||||
|
|
||||||
private static final String UUID_URL = "https://api.mojang.com/users/profiles/minecraft/%s?at=%d";
|
|
||||||
private static final String NAME_URL = "https://api.mojang.com/user/profiles/%s/names";
|
|
||||||
private static Map<String, UUID> uuidCache = new HashMap<String, UUID>();
|
|
||||||
private static Map<UUID, String> nameCache = new HashMap<UUID, String>();
|
|
||||||
private static ExecutorService pool = Executors.newCachedThreadPool();
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the uuid asynchronously and passes it to the consumer
|
|
||||||
*
|
|
||||||
* @param name The name
|
|
||||||
* @param action Do what you want to do with the uuid her
|
|
||||||
*/
|
|
||||||
public static void getUUID(String name, Consumer<UUID> action) {
|
|
||||||
pool.execute(() -> action.accept(getUUID(name)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the uuid synchronously and returns it
|
|
||||||
*
|
|
||||||
* @param name The name
|
|
||||||
* @return The uuid
|
|
||||||
*/
|
|
||||||
public static UUID getUUID(String name) {
|
|
||||||
return getUUIDAt(name, System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the uuid synchronously for a specified name and time and passes the result to the consumer
|
|
||||||
*
|
|
||||||
* @param name The name
|
|
||||||
* @param timestamp Time when the player had this name in milliseconds
|
|
||||||
* @param action Do what you want to do with the uuid her
|
|
||||||
*/
|
|
||||||
public static void getUUIDAt(String name, long timestamp, Consumer<UUID> action) {
|
|
||||||
pool.execute(() -> action.accept(getUUIDAt(name, timestamp)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the uuid synchronously for a specified name and time
|
|
||||||
*
|
|
||||||
* @param name The name
|
|
||||||
* @param timestamp Time when the player had this name in milliseconds
|
|
||||||
* @see UUIDFetcher#FEBRUARY_2015
|
|
||||||
*/
|
|
||||||
public static UUID getUUIDAt(String name, long timestamp) {
|
|
||||||
name = name.toLowerCase();
|
|
||||||
if (uuidCache.containsKey(name)) {
|
|
||||||
return uuidCache.get(name);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(String.format(UUID_URL, name, timestamp/1000)).openConnection();
|
|
||||||
connection.setReadTimeout(5000);
|
|
||||||
UUIDFetcher data = gson.fromJson(new BufferedReader(new InputStreamReader(connection.getInputStream())), UUIDFetcher.class);
|
|
||||||
|
|
||||||
uuidCache.put(name, data.id);
|
|
||||||
nameCache.put(data.id, data.name);
|
|
||||||
return data.id;
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches the name asynchronously and passes it to the consumer
|
|
||||||
*
|
|
||||||
* @param uuid The uuid
|
|
||||||
* @param action Do what you want to do with the name her
|
|
||||||
*/
|
|
||||||
public static void getName(UUID uuid, Consumer<String> action) {
|
|
||||||
pool.execute(() -> action.accept(getName(uuid)));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Fetches the name synchronously and returns it
|
|
||||||
*
|
|
||||||
* @param uuid The uuid
|
|
||||||
* @return The name
|
|
||||||
*/
|
|
||||||
public static String getName(UUID uuid) {
|
|
||||||
if (nameCache.containsKey(uuid)) {
|
|
||||||
return nameCache.get(uuid);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) new URL(String.format(NAME_URL, UUIDTypeAdapter.fromUUID(uuid))).openConnection();
|
|
||||||
connection.setReadTimeout(5000);
|
|
||||||
UUIDFetcher[] nameHistory = gson.fromJson(new BufferedReader(new InputStreamReader(connection.getInputStream())), UUIDFetcher[].class);
|
|
||||||
UUIDFetcher currentNameData = nameHistory[nameHistory.length - 1];
|
|
||||||
uuidCache.put(currentNameData.name.toLowerCase(), uuid);
|
|
||||||
nameCache.put(uuid, currentNameData.name);
|
|
||||||
return currentNameData.name;
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.content;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import de.quantumnanox.warshipfactory.main.CobixTagFormatSupported;
|
|
||||||
import de.quantumnanox.warshipfactory.main.WarShipFactory;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.thecobix.tag.TagCompound;
|
|
||||||
|
|
||||||
public class WorldPlayer extends CobixTagFormatSupported {
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private UUID uuid;
|
|
||||||
public boolean canWorldEdit, canChangeGamemode, canBuild, canTeleport, canTestBlock, canReset, canResetAll, canReplace;
|
|
||||||
@Getter
|
|
||||||
private FactoryWorld factoryWorld;
|
|
||||||
|
|
||||||
private int regId;
|
|
||||||
|
|
||||||
public WorldPlayer() {
|
|
||||||
//To be created by registries
|
|
||||||
}
|
|
||||||
|
|
||||||
public WorldPlayer(UUID id, FactoryWorld world) {
|
|
||||||
this.uuid = id;
|
|
||||||
this.factoryWorld = world;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Player getPlayer() {
|
|
||||||
return Bukkit.getPlayer(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagCompound save() {
|
|
||||||
TagCompound tc = new TagCompound(regId+"");
|
|
||||||
tc.putString("uuid", uuid.toString());
|
|
||||||
tc.putShort("canWorldEdit", (short) (canWorldEdit ? 1 : 0));
|
|
||||||
tc.putShort("canTestBlock", (short) (canTestBlock ? 1 : 0));
|
|
||||||
tc.putShort("canResetAll", (short) (canResetAll ? 1 : 0));
|
|
||||||
tc.putShort("canReset", (short) (canReset ? 1 : 0));
|
|
||||||
tc.putShort("canReplace", (short) (canReplace ? 1 : 0));
|
|
||||||
tc.putShort("canChangeGamemode", (short) (canChangeGamemode ? 1 : 0));
|
|
||||||
tc.putShort("canBuild", (short) (canBuild ? 1 : 0));
|
|
||||||
tc.putShort("canTeleport", (short) (canTeleport ? 1 : 0));
|
|
||||||
tc.putString("factoryWorld", factoryWorld.getWorldAddress());
|
|
||||||
return tc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(TagCompound tc) {
|
|
||||||
uuid = UUID.fromString(tc.getTagString("uuid").getValue());
|
|
||||||
canBuild = tc.getTagShort("canBuild").getValue() == 1 ? true : false;
|
|
||||||
canWorldEdit = tc.getTagShort("canWorldEdit").getValue() == 1 ? true : false;
|
|
||||||
canTestBlock = tc.getTagShort("canTestBlock").getValue() == 1 ? true : false;
|
|
||||||
canReset = tc.getTagShort("canReset").getValue() == 1 ? true : false;
|
|
||||||
canReplace = tc.getTagShort("canReplace").getValue() == 1 ? true : false;
|
|
||||||
canResetAll = tc.getTagShort("canResetAll").getValue() == 1 ? true : false;
|
|
||||||
canTeleport = tc.getTagShort("canTeleport").getValue() == 1 ? true : false;
|
|
||||||
canChangeGamemode = tc.getTagShort("canChangeGamemode").getValue() == 1 ? true : false;
|
|
||||||
Bukkit.getScheduler().runTaskLater(WarShipFactory.getInstance(), new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
factoryWorld = WarShipFactory.getInstance().getWorldByAddress(tc.getTagString("factoryWorld").getValue());
|
|
||||||
}
|
|
||||||
}, 20L);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.main;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
|
|
||||||
public class BungeeUtil implements PluginMessageListener {
|
|
||||||
|
|
||||||
private String[] lastPlayerList = null;
|
|
||||||
private boolean wait = false;
|
|
||||||
private boolean lastHasInvitation;
|
|
||||||
|
|
||||||
public BungeeUtil()
|
|
||||||
{
|
|
||||||
Bukkit.getMessenger().registerIncomingPluginChannel(WarShipFactory.getInstance(), "BungeeCord", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendToServer(Player p, String server) {
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
||||||
out.writeUTF("Connect");
|
|
||||||
out.writeUTF(server);
|
|
||||||
p.sendPluginMessage(WarShipFactory.getInstance(), "BungeeCord", out.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void broadcast(String msg, Player from) {
|
|
||||||
sendMessage(msg, from);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(String msg, Player from) {
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
||||||
out.writeUTF("BroadcastWS");
|
|
||||||
out.writeUTF("channelMessage");
|
|
||||||
out.writeUTF(Bukkit.getServerName());
|
|
||||||
out.writeUTF(from.getUniqueId().toString());
|
|
||||||
out.writeUTF(msg);
|
|
||||||
from.sendPluginMessage(WarShipFactory.getInstance(), "BungeeCord", out.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPlayers(String server) {
|
|
||||||
this.wait = true;
|
|
||||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
||||||
out.writeUTF("PlayerList");
|
|
||||||
out.writeUTF(server);
|
|
||||||
Bukkit.getServer().sendPluginMessage(WarShipFactory.getInstance(), "BungeeCord", out.toByteArray());
|
|
||||||
while(this.wait) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.sleep(1);
|
|
||||||
}
|
|
||||||
catch (InterruptedException e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.lastPlayerList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPluginMessageReceived(String channel, Player p, byte[] message)
|
|
||||||
{
|
|
||||||
if(!channel.equals("BungeeCord")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ByteArrayDataInput in = ByteStreams.newDataInput(message);
|
|
||||||
String subchannel = in.readUTF();
|
|
||||||
if(subchannel.equals("PlayerList")) {
|
|
||||||
String server = in.readUTF();
|
|
||||||
String msg = in.readUTF();
|
|
||||||
System.out.println(msg);
|
|
||||||
this.lastPlayerList = msg.split(", ");
|
|
||||||
this.wait = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.main;
|
|
||||||
|
|
||||||
import net.thecobix.tag.TagCompound;
|
|
||||||
|
|
||||||
public abstract class CobixTagFormatSupported {
|
|
||||||
|
|
||||||
public abstract TagCompound save();
|
|
||||||
public abstract void load(TagCompound tc);
|
|
||||||
|
|
||||||
}
|
|
@ -1,118 +0,0 @@
|
|||||||
package de.quantumnanox.warshipfactory.main;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import net.thecobix.tag.Tag;
|
|
||||||
import net.thecobix.tag.TagCompound;
|
|
||||||
|
|
||||||
public class Registry<T extends CobixTagFormatSupported> extends CobixTagFormatSupported {
|
|
||||||
|
|
||||||
Class<T> clazz;
|
|
||||||
|
|
||||||
Field idfield;
|
|
||||||
|
|
||||||
public Registry(Class<T> clazz1, String name) {
|
|
||||||
this.clazz = clazz1;
|
|
||||||
this.name = name;
|
|
||||||
try {
|
|
||||||
this.idfield = clazz.getDeclaredField("regId");
|
|
||||||
} catch (NoSuchFieldException | SecurityException e) {
|
|
||||||
throw new IllegalArgumentException("The class that is extending CobixTagFormatSupported must have a field named regId", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HashMap<Integer, T> entries = new HashMap<>();
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
public int register(T object) {
|
|
||||||
int id = getFreeID();
|
|
||||||
if(id == -1) throw new RuntimeException("Registry limit of "+Integer.MAX_VALUE+" entries exceeded.");
|
|
||||||
if(idfield.isAccessible()) {
|
|
||||||
try {
|
|
||||||
idfield.set(object, id);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
idfield.setAccessible(true);
|
|
||||||
try {
|
|
||||||
idfield.set(object, id);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
idfield.setAccessible(false);
|
|
||||||
}
|
|
||||||
entries.put(id, object);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public T get(int id) {
|
|
||||||
return entries.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap<Integer, T> getAll() {
|
|
||||||
return entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getFreeID() {
|
|
||||||
for (int i = 0; i < Integer.MAX_VALUE; i++) {
|
|
||||||
if(entries.get(i) == null) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TagCompound save() {
|
|
||||||
TagCompound out = new TagCompound(name);
|
|
||||||
for(Integer id : entries.keySet()) {
|
|
||||||
out.put(entries.get(id).save());
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load(TagCompound tc) {
|
|
||||||
if(tc == null) return;
|
|
||||||
for(Tag t : tc) {
|
|
||||||
if(t instanceof TagCompound == false) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
int id = Integer.parseInt(t.getName());
|
|
||||||
T obj = clazz.newInstance();
|
|
||||||
obj.load((TagCompound) t);
|
|
||||||
if(idfield.isAccessible()) {
|
|
||||||
try {
|
|
||||||
idfield.set(obj, id);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
idfield.setAccessible(true);
|
|
||||||
try {
|
|
||||||
idfield.set(obj, id);
|
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
idfield.setAccessible(false);
|
|
||||||
}
|
|
||||||
entries.put(id, obj);
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void unregister(int id) {
|
|
||||||
entries.remove(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getID(T obj) {
|
|
||||||
for(Integer id : entries.keySet()) {
|
|
||||||
if(obj.equals(entries.get(id))) return id;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,146 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public abstract class Extension {
|
|
||||||
|
|
||||||
public static ArrayList<Extension> extensions = new ArrayList<>();
|
|
||||||
|
|
||||||
public abstract Tag readTag(Class<? extends Tag> clazz, byte[] data) throws IOException;
|
|
||||||
public abstract Entry<Class<? extends Tag>, byte[]> splitData(DataInputStream dis, int id, byte[] data, int start) throws IOException;
|
|
||||||
|
|
||||||
protected static byte[] subSequence(byte[] fully, int start, int end) {
|
|
||||||
byte[] out = new byte[(end - start)+2];
|
|
||||||
int ind = -1;
|
|
||||||
for(int i = 0; i < fully.length; i++)
|
|
||||||
{
|
|
||||||
if(i >= start && i <= end) {
|
|
||||||
ind ++;
|
|
||||||
out[ind] = fully[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] readByteArray(DataInputStream in) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return read(in, readVarInt(in));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void writeVarInt(DataOutputStream out, int paramInt) throws IOException {
|
|
||||||
while (true) {
|
|
||||||
if ((paramInt & 0xFFFFFF80) == 0) {
|
|
||||||
out.writeByte(paramInt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeByte(paramInt & 0x7F | 0x80);
|
|
||||||
paramInt >>>= 7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String readString(DataInputStream dis)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
i = readVarInt(dis);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < 0)
|
|
||||||
{
|
|
||||||
throw new NullPointerException("The received encoded string buffer length is less than zero! Weird string!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s = new String(read(dis, i), StandardCharsets.UTF_8);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] read(DataInputStream in, int amount) {
|
|
||||||
byte[] out = new byte[amount];
|
|
||||||
for(int i = 0; i < out.length; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
out[i] = in.readByte();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int readVarInt(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
while (true) {
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int readVarIntSize(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int s = 0;
|
|
||||||
while (true) {
|
|
||||||
s ++;
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Entry<Integer, Integer> readVarIntAndSize(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int s = 0;
|
|
||||||
while (true) {
|
|
||||||
s ++;
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return new AbstractMap.SimpleEntry(s, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isRegistered(Class<? extends Extension> clazz) {
|
|
||||||
for(Extension e : extensions) {
|
|
||||||
try {
|
|
||||||
e.getClass().asSubclass(clazz);
|
|
||||||
return true;
|
|
||||||
} catch(ClassCastException ex) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,164 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public abstract class Tag {
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Tag ids:
|
|
||||||
*
|
|
||||||
* 0x01: String
|
|
||||||
* 0x02: Int
|
|
||||||
* 0x03: Double
|
|
||||||
* 0x04: Long
|
|
||||||
* 0x05: Short
|
|
||||||
* 0x06: Float
|
|
||||||
* 0x07: Compound
|
|
||||||
* 0x08: Serializeable
|
|
||||||
* 0x09: ByteArray
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Tag(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String name;
|
|
||||||
protected Object value;
|
|
||||||
|
|
||||||
protected abstract byte[] write() throws IOException;
|
|
||||||
protected abstract void read(byte[] data) throws IOException;
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void writeString(DataOutputStream out, String string, Charset charset) throws IOException {
|
|
||||||
byte [] bytes = string.getBytes(charset);
|
|
||||||
writeVarInt(out, bytes.length);
|
|
||||||
out.write(bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] readByteArray(DataInputStream in) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return read(in, readVarInt(in));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void writeVarInt(DataOutputStream out, int paramInt) throws IOException {
|
|
||||||
while (true) {
|
|
||||||
if ((paramInt & 0xFFFFFF80) == 0) {
|
|
||||||
out.writeByte(paramInt);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.writeByte(paramInt & 0x7F | 0x80);
|
|
||||||
paramInt >>>= 7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String readString(DataInputStream dis)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
i = readVarInt(dis);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < 0)
|
|
||||||
{
|
|
||||||
throw new NullPointerException("The received encoded string buffer length is less than zero! Weird string!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
String s = new String(read(dis, i), StandardCharsets.UTF_8);
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] read(DataInputStream in, int amount) {
|
|
||||||
byte[] out = new byte[amount];
|
|
||||||
for(int i = 0; i < out.length; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
out[i] = in.readByte();
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int readVarInt(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
while (true) {
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int readVarIntSize(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int s = 0;
|
|
||||||
while (true) {
|
|
||||||
s ++;
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Entry<Integer, Integer> readVarIntAndSize(DataInputStream in) throws IOException {
|
|
||||||
int i = 0;
|
|
||||||
int j = 0;
|
|
||||||
int s = 0;
|
|
||||||
while (true) {
|
|
||||||
s ++;
|
|
||||||
int k = in.readByte();
|
|
||||||
i |= (k & 0x7F) << j++ * 7;
|
|
||||||
if (j > 5) throw new RuntimeException("VarInt too big");
|
|
||||||
if ((k & 0x80) != 128) break;
|
|
||||||
}
|
|
||||||
return new AbstractMap.SimpleEntry(s, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Tag "+name+" with value "+value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagByteArray extends Tag {
|
|
||||||
|
|
||||||
public static final TagByteArray BASE_OBJECT = new TagByteArray("base", "base".getBytes());
|
|
||||||
|
|
||||||
public TagByteArray(String name, byte[] data)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
value = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x09);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
writeVarInt(dos, getValue().length);
|
|
||||||
dos.write(getValue());
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x09)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagByteArray");
|
|
||||||
this.name = readString(dis);
|
|
||||||
setValue(readByteArray(dis));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getValue()
|
|
||||||
{
|
|
||||||
return (byte[]) super.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(byte[] data) {
|
|
||||||
this.value = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,275 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class TagCompound extends Tag implements Iterable<Tag> {
|
|
||||||
|
|
||||||
public static final TagCompound BASE_OBJECT = new TagCompound("base");
|
|
||||||
|
|
||||||
public TagCompound(String name)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new ArrayList<Tag>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x07);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
ArrayList<Byte> bytes = new ArrayList<>();
|
|
||||||
for(Tag t : tags) {
|
|
||||||
byte[] all = t.write();
|
|
||||||
for(int i = 0; i < all.length; i++)
|
|
||||||
{
|
|
||||||
bytes.add(all[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Byte[] ba = bytes.toArray(new Byte[bytes.size()]);
|
|
||||||
writeVarInt(dos, ba.length);
|
|
||||||
dos.write(toPrimitives(ba));
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] toPrimitives(Byte[] oBytes)
|
|
||||||
{
|
|
||||||
byte[] bytes = new byte[oBytes.length];
|
|
||||||
|
|
||||||
for(int i = 0; i < oBytes.length; i++) {
|
|
||||||
bytes[i] = oBytes[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] addElement(byte[] a, byte e) {
|
|
||||||
a = Arrays.copyOf(a, a.length + 1);
|
|
||||||
a[a.length - 1] = e;
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x07)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagCompound");
|
|
||||||
this.name = readString(dis);
|
|
||||||
byte[] ba = readByteArray(dis);
|
|
||||||
this.value = (ArrayList<Tag>) TagInputStream.readTags(ba);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagString getTagString(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagString) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagString) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagInt getTagInt(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagInt) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagInt) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagDouble getTagDouble(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagDouble) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagDouble) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagShort getTagShort(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagShort) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagShort) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagLong getTagLong(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagLong) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagLong) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagFloat getTagFloat(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagFloat) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagFloat) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagByteArray getTagByteArray(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagByteArray) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagByteArray) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagCompound getTagCompound(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagCompound) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagCompound) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TagSerializeableObject getTagSerializeableObject(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t instanceof TagSerializeableObject) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return (TagSerializeableObject) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Tag getTag(String name) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t.getName().equals(name)) {
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(Tag tag) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
Tag t;
|
|
||||||
if((t = getTag(tag.getName())) != null) {
|
|
||||||
((ArrayList<Tag>)this.value).remove(t);
|
|
||||||
}
|
|
||||||
tags.add(tag);
|
|
||||||
this.value = tags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putString(String name, String value) {
|
|
||||||
put(new TagString(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putDouble(String name, Double value) {
|
|
||||||
put(new TagDouble(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putInt(String name, Integer value) {
|
|
||||||
put(new TagInt(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putLong(String name, Long value) {
|
|
||||||
put(new TagLong(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putShort(String name, Short value) {
|
|
||||||
put(new TagShort(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putFloat(String name, Float value) {
|
|
||||||
put(new TagFloat(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putFloat(String name, byte[] value) {
|
|
||||||
put(new TagByteArray(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putSerializeableObject(String name, Serializable value) {
|
|
||||||
put(new TagSerializeableObject(name, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<Tag> iterator()
|
|
||||||
{
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
return new Iterator<Tag>() {
|
|
||||||
|
|
||||||
int index = -1;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasNext()
|
|
||||||
{
|
|
||||||
int vIndex = index;
|
|
||||||
vIndex ++;
|
|
||||||
try {
|
|
||||||
tags.get(vIndex);
|
|
||||||
return true;
|
|
||||||
} catch(Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Tag next()
|
|
||||||
{
|
|
||||||
index ++;
|
|
||||||
return tags.get(index);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T> T getTag(String name, T type) {
|
|
||||||
ArrayList<Tag> tags = (ArrayList<Tag>) this.value;
|
|
||||||
for(Tag t : tags) {
|
|
||||||
if(t.getName().equals(name) && type.getClass().getName().equals(t.getClass().getName())) {
|
|
||||||
return (T) t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagDouble extends Tag {
|
|
||||||
|
|
||||||
public static final TagDouble BASE_OBJECT = new TagDouble("base", 0);
|
|
||||||
|
|
||||||
public TagDouble(String name, double value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new Double(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x03);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
byte[] vl = toByteArray(getValue());
|
|
||||||
writeVarInt(dos, vl.length);
|
|
||||||
dos.write(vl);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] toByteArray(double d) {
|
|
||||||
byte[] bytes = new byte[8];
|
|
||||||
ByteBuffer.wrap(bytes).putDouble(d);
|
|
||||||
return bytes;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double toDouble(byte[] b) {
|
|
||||||
return ByteBuffer.wrap(b).getDouble();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x03)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagDouble");
|
|
||||||
this.name = readString(dis);
|
|
||||||
byte[] ba = readByteArray(dis);
|
|
||||||
this.value = new Double(toDouble(ba));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double getValue() {
|
|
||||||
return (Double) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(double value) {
|
|
||||||
this.value = new Double(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagFloat extends Tag {
|
|
||||||
|
|
||||||
public static final TagFloat BASE_OBJECT = new TagFloat("base", 0);
|
|
||||||
|
|
||||||
public TagFloat(String name, float value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new Float(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x06);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
dos.writeFloat((float) this.value);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x06)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagFloat");
|
|
||||||
this.name = readString(dis);
|
|
||||||
this.value = new Float(dis.readFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Float getValue() {
|
|
||||||
return (Float) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(float value) {
|
|
||||||
this.value = new Float(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,349 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.MappedByteBuffer;
|
|
||||||
import java.util.AbstractMap;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.zip.GZIPInputStream;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipException;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
|
|
||||||
public class TagInputStream extends InputStream {
|
|
||||||
|
|
||||||
private InputStream wrapped;
|
|
||||||
|
|
||||||
public static final int NONE = 0;
|
|
||||||
public static final int GZIP = 1;
|
|
||||||
@Deprecated
|
|
||||||
public static final int ZIP = 2;
|
|
||||||
public static final int BASE64 = 3;
|
|
||||||
|
|
||||||
private boolean base = false;
|
|
||||||
private boolean zip = false;
|
|
||||||
private boolean entry = false;
|
|
||||||
|
|
||||||
public TagInputStream(InputStream in, int compression)
|
|
||||||
{
|
|
||||||
if(compression == GZIP) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.wrapped = new GZIPInputStream(in);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if(compression == ZIP) {
|
|
||||||
throw new RuntimeException("ZIP reading not supported yet.");
|
|
||||||
} else if(compression == BASE64) {
|
|
||||||
this.base = true;
|
|
||||||
}
|
|
||||||
this.wrapped = in;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read() throws IOException
|
|
||||||
{
|
|
||||||
return this.wrapped.read();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] b, int off, int len) throws IOException
|
|
||||||
{
|
|
||||||
return this.wrapped.read(b, off, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int available() throws IOException
|
|
||||||
{
|
|
||||||
return this.wrapped.available();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long skip(long n) throws IOException
|
|
||||||
{
|
|
||||||
return this.wrapped.skip(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean markSupported()
|
|
||||||
{
|
|
||||||
return this.wrapped.markSupported();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void mark(int readlimit)
|
|
||||||
{
|
|
||||||
this.wrapped.mark(readlimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public synchronized void reset() throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int read(byte[] b) throws IOException
|
|
||||||
{
|
|
||||||
return this.wrapped.read(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Tag> readTags() throws IOException {
|
|
||||||
ArrayList<Tag> out = new ArrayList<>();
|
|
||||||
byte[] data = readFully(this.wrapped, -1, true);
|
|
||||||
if(this.base) {
|
|
||||||
data = Base64.getDecoder().decode(data);
|
|
||||||
}
|
|
||||||
ArrayList<Entry<Class<? extends Tag>, byte[]>> mapped = splitData(data);
|
|
||||||
for(Entry<Class<? extends Tag>, byte[]> e : mapped) {
|
|
||||||
Class clazz = e.getKey();
|
|
||||||
if(clazz.getSimpleName().equals("TagString")) {
|
|
||||||
TagString ts = new TagString("", "");
|
|
||||||
ts.read(e.getValue());
|
|
||||||
out.add(ts);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagInt")) {
|
|
||||||
TagInt ti = new TagInt("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagDouble")) {
|
|
||||||
TagDouble ti = new TagDouble("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagLong")) {
|
|
||||||
TagLong ti = new TagLong("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagShort")) {
|
|
||||||
TagShort ti = new TagShort("", (short) 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagFloat")) {
|
|
||||||
TagFloat ti = new TagFloat("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagCompound")) {
|
|
||||||
TagCompound ti = new TagCompound("");
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagSerializeableObject")) {
|
|
||||||
TagSerializeableObject ti = new TagSerializeableObject("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagByteArray")) {
|
|
||||||
TagByteArray ti = new TagByteArray("", new byte[] {});
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else {
|
|
||||||
if(Extension.extensions.size() != 0) {
|
|
||||||
Tag shoutie = null;
|
|
||||||
for(Extension ex : Extension.extensions) {
|
|
||||||
Tag honey = ex.readTag(clazz, e.getValue());
|
|
||||||
if(honey != null) {
|
|
||||||
shoutie = honey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.add(shoutie);
|
|
||||||
} else {
|
|
||||||
System.out.println("[ERROR] Unknown tag with classname "+clazz.getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Tag> readTags(byte[] data) throws IOException {
|
|
||||||
ArrayList<Tag> out = new ArrayList<>();
|
|
||||||
ArrayList<Entry<Class<? extends Tag>, byte[]>> mapped = splitData(data);
|
|
||||||
for(Entry<Class<? extends Tag>, byte[]> e : mapped) {
|
|
||||||
Class clazz = e.getKey();
|
|
||||||
if(clazz.getSimpleName().equals("TagString")) {
|
|
||||||
TagString ts = new TagString("", "");
|
|
||||||
ts.read(e.getValue());
|
|
||||||
out.add(ts);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagInt")) {
|
|
||||||
TagInt ti = new TagInt("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagDouble")) {
|
|
||||||
TagDouble ti = new TagDouble("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagLong")) {
|
|
||||||
TagLong ti = new TagLong("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagShort")) {
|
|
||||||
TagShort ti = new TagShort("", (short) 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagFloat")) {
|
|
||||||
TagFloat ti = new TagFloat("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagCompound")) {
|
|
||||||
TagCompound ti = new TagCompound("");
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagSerializeableObject")) {
|
|
||||||
TagSerializeableObject ti = new TagSerializeableObject("", 0);
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else if(clazz.getSimpleName().equals("TagByteArray")) {
|
|
||||||
TagByteArray ti = new TagByteArray("", new byte[] {});
|
|
||||||
ti.read(e.getValue());
|
|
||||||
out.add(ti);
|
|
||||||
} else {
|
|
||||||
if(Extension.extensions.size() != 0) {
|
|
||||||
Tag shoutie = null;
|
|
||||||
for(Extension ex : Extension.extensions) {
|
|
||||||
Tag honey = ex.readTag(clazz, e.getValue());
|
|
||||||
if(honey != null) {
|
|
||||||
shoutie = honey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out.add(shoutie);
|
|
||||||
} else {
|
|
||||||
System.out.println("[ERROR] Unknown tag with classname "+clazz.getSimpleName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] readFully(InputStream is, int length, boolean readAll)
|
|
||||||
throws IOException {
|
|
||||||
byte[] output = {};
|
|
||||||
if (length == -1) length = Integer.MAX_VALUE;
|
|
||||||
int pos = 0;
|
|
||||||
while (pos < length) {
|
|
||||||
int bytesToRead;
|
|
||||||
if (pos >= output.length) { // Only expand when there's no room
|
|
||||||
bytesToRead = Math.min(length - pos, output.length + 1024);
|
|
||||||
if (output.length < pos + bytesToRead) {
|
|
||||||
output = Arrays.copyOf(output, pos + bytesToRead);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
bytesToRead = output.length - pos;
|
|
||||||
}
|
|
||||||
int cc = is.read(output, pos, bytesToRead);
|
|
||||||
if (cc < 0) {
|
|
||||||
if (readAll && length != Integer.MAX_VALUE) {
|
|
||||||
throw new EOFException("Detect premature EOF");
|
|
||||||
} else {
|
|
||||||
if (output.length != pos) {
|
|
||||||
output = Arrays.copyOf(output, pos);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos += cc;
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ArrayList<Entry<Class<? extends Tag>, byte[]>> splitData(byte[] data) throws IOException {
|
|
||||||
TagCompound tc = new TagCompound("dummy");
|
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(bis);
|
|
||||||
ArrayList<Entry<Class<? extends Tag>, byte[]>> out = new ArrayList<>();
|
|
||||||
while(bis.available() != 0) {
|
|
||||||
try {
|
|
||||||
int start = data.length - bis.available();
|
|
||||||
int id = tc.readVarInt(dis);
|
|
||||||
tc.readString(dis);
|
|
||||||
if(id == 0x01) {
|
|
||||||
tc.readString(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagString.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x02) {
|
|
||||||
tc.readVarInt(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagInt.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x03) {
|
|
||||||
tc.readByteArray(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagDouble.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x04) {
|
|
||||||
tc.readByteArray(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagLong.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x05) {
|
|
||||||
dis.readShort();
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagShort.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x06) {
|
|
||||||
dis.readFloat();
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagFloat.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x07) {
|
|
||||||
tc.readByteArray(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagCompound.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x08) {
|
|
||||||
tc.readByteArray(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagSerializeableObject.class, subSequence(data, start, end)));
|
|
||||||
} else if(id == 0x09) {
|
|
||||||
tc.readByteArray(dis);
|
|
||||||
int end = data.length - bis.available();
|
|
||||||
out.add(new AbstractMap.SimpleEntry(TagByteArray.class, subSequence(data, start, end)));
|
|
||||||
} else {
|
|
||||||
if(Extension.extensions.size() != 0) {
|
|
||||||
Entry<Class<? extends Tag>, byte[]> et = null;
|
|
||||||
for(Extension e : Extension.extensions) {
|
|
||||||
Entry<Class<? extends Tag>, byte[]> tet = e.splitData(dis, id, data, start);
|
|
||||||
if(tet != null) {
|
|
||||||
et = tet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(et != null) {
|
|
||||||
out.add(et);
|
|
||||||
} else {
|
|
||||||
System.out.println("[ERROR] Unknown tag with id "+id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
System.out.println("[ERROR] Unknown tag with id "+id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static byte[] subSequence(byte[] fully, int start, int end) {
|
|
||||||
byte[] out = new byte[(end - start)+2];
|
|
||||||
int ind = -1;
|
|
||||||
for(int i = 0; i < fully.length; i++)
|
|
||||||
{
|
|
||||||
if(i >= start && i <= end) {
|
|
||||||
ind ++;
|
|
||||||
out[ind] = fully[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagInt extends Tag {
|
|
||||||
|
|
||||||
public static final TagInt BASE_OBJECT = new TagInt("base", 0);
|
|
||||||
|
|
||||||
public TagInt(String name, int value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new Integer(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x02);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
writeVarInt(dos, (int) this.value);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x02)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagInt");
|
|
||||||
this.name = readString(dis);
|
|
||||||
this.value = new Integer(readVarInt(dis));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return (Integer) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(int value) {
|
|
||||||
this.value = new Integer(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagLong extends Tag {
|
|
||||||
|
|
||||||
public static final TagLong BASE_OBJECT = new TagLong("base", 0);
|
|
||||||
|
|
||||||
public TagLong(String name, long value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new Long(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x04);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
byte[] b = toByteArray((long) this.value);
|
|
||||||
writeVarInt(dos, b.length);
|
|
||||||
dos.write(b);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] toByteArray(long l) {
|
|
||||||
byte[] b = new byte[8];
|
|
||||||
ByteBuffer.wrap(b).putLong(l);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x04)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagLong");
|
|
||||||
this.name = readString(dis);
|
|
||||||
byte[] ba = readByteArray(dis);
|
|
||||||
this.value = new Long(toLong(ba));
|
|
||||||
}
|
|
||||||
|
|
||||||
private long toLong(byte[] ba)
|
|
||||||
{
|
|
||||||
return ByteBuffer.wrap(ba).getLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getValue() {
|
|
||||||
return (Long) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(long value) {
|
|
||||||
this.value = new Long(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,119 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
|
|
||||||
import javax.print.attribute.standard.Compression;
|
|
||||||
|
|
||||||
public class TagOutputStream extends OutputStream {
|
|
||||||
|
|
||||||
private OutputStream wrapped;
|
|
||||||
|
|
||||||
public static final int NONE = 0;
|
|
||||||
public static final int GZIP = 1;
|
|
||||||
public static final int ZIP = 2;
|
|
||||||
public static final int BASE64 = 3;
|
|
||||||
|
|
||||||
private boolean base = false;
|
|
||||||
private boolean zip = false;
|
|
||||||
private boolean entry = false;
|
|
||||||
|
|
||||||
public TagOutputStream(OutputStream out, int compression)
|
|
||||||
{
|
|
||||||
if(compression == GZIP) {
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.wrapped = new GZIPOutputStream(out);
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if(compression == ZIP) {
|
|
||||||
this.wrapped = new ZipOutputStream(out);
|
|
||||||
this.zip = true;
|
|
||||||
return;
|
|
||||||
} else if(compression == BASE64) {
|
|
||||||
this.base = true;
|
|
||||||
}
|
|
||||||
this.wrapped = out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(int b) throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.write(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(Tag tag) throws IOException {
|
|
||||||
byte[] ba;
|
|
||||||
if(this.base) {
|
|
||||||
ba = Base64.getEncoder().encode(tag.write());
|
|
||||||
} else {
|
|
||||||
ba = tag.write();
|
|
||||||
}
|
|
||||||
if(this.zip) {
|
|
||||||
ZipOutputStream zout = (ZipOutputStream) this.wrapped;
|
|
||||||
if(entry == false) {
|
|
||||||
ZipEntry ze = new ZipEntry("content");
|
|
||||||
zout.putNextEntry(ze);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.wrapped.write(ba);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(List<Tag> tags) throws IOException {
|
|
||||||
for(Tag t : tags) {
|
|
||||||
write(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void write(List<Tag> tags, boolean organizeInCompound) throws IOException {
|
|
||||||
if(organizeInCompound) {
|
|
||||||
TagCompound tc = new TagCompound("root");
|
|
||||||
for(Tag t : tags) {
|
|
||||||
tc.put(t);
|
|
||||||
}
|
|
||||||
write(tc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(Tag t : tags) {
|
|
||||||
write(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(byte[] b) throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.write(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.write(b, off, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flush() throws IOException
|
|
||||||
{
|
|
||||||
this.wrapped.flush();;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() throws IOException
|
|
||||||
{
|
|
||||||
if(this.zip) {
|
|
||||||
ZipOutputStream zout = (ZipOutputStream) this.wrapped;
|
|
||||||
zout.closeEntry();
|
|
||||||
}
|
|
||||||
this.wrapped.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagSerializeableObject extends Tag {
|
|
||||||
|
|
||||||
public static final TagSerializeableObject BASE_OBJECT = new TagSerializeableObject("base", 0);
|
|
||||||
|
|
||||||
public TagSerializeableObject(String name, Serializable obj)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x08);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
byte[] ba = toByteArray((Serializable) this.value);
|
|
||||||
writeVarInt(dos, ba.length);
|
|
||||||
dos.write(ba);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] toByteArray(Serializable obj) throws IOException {
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(bos);
|
|
||||||
oos.writeObject(obj);
|
|
||||||
return bos.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Object toObject(byte[] ba) throws IOException, ClassNotFoundException {
|
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(ba);
|
|
||||||
ObjectInputStream ois = new ObjectInputStream(bis);
|
|
||||||
return ois.readObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x08)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagSerializeableObject");
|
|
||||||
this.name = readString(dis);
|
|
||||||
byte[] ba = readByteArray(dis);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.value = toObject(ba);
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(Serializable obj) {
|
|
||||||
this.value = obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class TagShort extends Tag {
|
|
||||||
|
|
||||||
public static final TagShort BASE_OBJECT = new TagShort("base", (short) 0);
|
|
||||||
|
|
||||||
public TagShort(String name, short value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = new Short(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x05);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
dos.writeShort((short) this.value);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x05)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagShort");
|
|
||||||
this.name = readString(dis);
|
|
||||||
this.value = new Short(dis.readShort());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getValue() {
|
|
||||||
return (Short) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(short value) {
|
|
||||||
this.value = new Short(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
package net.thecobix.tag;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.ReadOnlyFileSystemException;
|
|
||||||
|
|
||||||
public class TagString extends Tag {
|
|
||||||
|
|
||||||
public static final TagString BASE_OBJECT = new TagString("base", "base");
|
|
||||||
|
|
||||||
public TagString(String name, String value)
|
|
||||||
{
|
|
||||||
super(name);
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] write() throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream dos = new DataOutputStream(buffer);
|
|
||||||
writeVarInt(dos, 0x01);
|
|
||||||
writeString(dos, this.name, StandardCharsets.UTF_8);
|
|
||||||
writeString(dos, (String) this.value, StandardCharsets.UTF_8);
|
|
||||||
return buffer.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void read(byte[] data) throws IOException
|
|
||||||
{
|
|
||||||
ByteArrayInputStream buffer = new ByteArrayInputStream(data);
|
|
||||||
DataInputStream dis = new DataInputStream(buffer);
|
|
||||||
if(readVarInt(dis) != 0x01)
|
|
||||||
throw new IllegalStateException("Data is not representing the type TagString");
|
|
||||||
this.name = readString(dis);
|
|
||||||
this.value = readString(dis);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return (String) this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
name: WarShipFactory
|
|
||||||
author: Exceptionflug
|
|
||||||
version: 1.1
|
|
||||||
depend: [Brew, WorldEdit, WorldGuard]
|
|
||||||
|
|
||||||
main: de.quantumnanox.warshipfactory.main.WarShipFactory
|
|
6
src/plugin.yml
Normale Datei
6
src/plugin.yml
Normale Datei
@ -0,0 +1,6 @@
|
|||||||
|
name: BauSystem
|
||||||
|
author: Exceptionflug, RedstoneTechnik, Lixfel
|
||||||
|
version: 1.0
|
||||||
|
depend: [WorldEdit, WorldGuard]
|
||||||
|
|
||||||
|
main: BauSystem
|
@ -1,38 +0,0 @@
|
|||||||
package de.quantumnanox.WarShipFactory;
|
|
||||||
|
|
||||||
import junit.framework.Test;
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import junit.framework.TestSuite;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit test for simple App.
|
|
||||||
*/
|
|
||||||
public class AppTest
|
|
||||||
extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Create the test case
|
|
||||||
*
|
|
||||||
* @param testName name of the test case
|
|
||||||
*/
|
|
||||||
public AppTest( String testName )
|
|
||||||
{
|
|
||||||
super( testName );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the suite of tests being tested
|
|
||||||
*/
|
|
||||||
public static Test suite()
|
|
||||||
{
|
|
||||||
return new TestSuite( AppTest.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rigourous Test :-)
|
|
||||||
*/
|
|
||||||
public void testApp()
|
|
||||||
{
|
|
||||||
assertTrue( true );
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren