Removed world loading bug

Removed WorldEdit version incompatibility
This commit is contained in:
Daniel 2019-05-09 20:00:39 +02:00
parent 0d5364a041
commit bb316449df
3 changed files with 35 additions and 32 deletions

27
pom.xml
View File

@ -19,11 +19,6 @@
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</reporting>
@ -80,7 +75,7 @@
</repository>
<repository>
<id>we-repo</id>
<url>>http://maven.sk89q.com/repo/</url>
<url>http://maven.sk89q.com/repo/</url>
</repository>
<!--Repo for CommandFramework-->
<repository>
@ -132,14 +127,7 @@
<!--
AsyncWorld is not in the api so I have to use a local file
Issue: https://github.com/boy0001/FastAsyncWorldedit/issues/1060
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
<scope>provided</scope>
<version>latest</version>
</dependency>
-->
<dependency>
<groupId>com.sk98q.worldedit</groupId>
<artifactId>FastAsnycWorldEdit</artifactId>
@ -149,9 +137,16 @@
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>6.0.0-SNAPSHOT</version>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

View File

@ -1,11 +1,13 @@
package de.butzlabben.world.listener;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extension.platform.CommandManager;
import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.config.WorldPerm;
import de.butzlabben.world.wrapper.WorldPlayer;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -33,11 +35,14 @@ public class WorldEditListener implements Listener {
}
private boolean isWorldEditCommand(String command) {
WorldEditPlugin plugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
// WorldEdit plugin not foung
if(plugin == null)
return false;
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
.getCommandManager().getDispatcher().get(command) != null;
return plugin.getCommand(command) != null;
}
}

View File

@ -193,20 +193,21 @@ public class SystemWorld {
// Move World into Server dir
String worlddir = PluginConfig.getWorlddir();
File world = new File(worlddir + "/" + worldname);
if (!world.exists()) {
world = new File(Bukkit.getWorldContainer(), worldname);
} else {
if (new File(Bukkit.getWorldContainer(), worldname).exists()
&& new File(PluginConfig.getWorlddir() + "/" + worldname).exists()) {
System.err.println("World " + worldname + " exists twice!");
// try {
// FileUtils.deleteDirectory(new
// File(Bukkit.getWorldContainer(), worldname));
// } catch (IOException e) {
// p.sendMessage(PluginConfig.getPrefix() + "§cError");
// e.printStackTrace();
// }
if (world.exists()) {
// Check for duplicated worlds
File propablyExistingWorld = new File(Bukkit.getWorldContainer(), worldname);
if (propablyExistingWorld.exists()) {
System.err.println("World " + worldname + " existed twice!");
try {
FileUtils.deleteDirectory(propablyExistingWorld);
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError());
e.printStackTrace();
}
}
//Move world if exists
try {
FileUtils.moveDirectoryToDirectory(world, Bukkit.getWorldContainer(), false);
} catch (IOException e) {
@ -216,6 +217,7 @@ public class SystemWorld {
}
}
// Check for old named worlds
if (worldname.charAt(worldname.length() - 37) == ' ') {
StringBuilder myName = new StringBuilder(worldname);
myName.setCharAt(worldname.length() - 37, '-');
@ -223,6 +225,7 @@ public class SystemWorld {
worldname = myName.toString();
}
WorldCreator creator = new WorldCreator(worldname);
String templateKey = WorldConfig.getWorldConfig(worldname).getTemplateKey();