See 2.1.2.1 and 2.1.2.2

This commit is contained in:
BuildTools 2018-06-08 20:09:37 +02:00
parent 7b7646dcc7
commit 5610b9cf9e
12 changed files with 108 additions and 51 deletions

View File

@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Programmieren/spigot-1.12.jar" sourcepath="C:/Program Files/Java/jdk1.8.0_131/src.zip"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="C:/Programmieren/dynmap-2.5.jar"/>
<classpathentry kind="lib" path="C:/Programmieren/spigot-1.12.jar" sourcepath="C:/Users/jubek/Documents/Development/JavaLibraries/Bukkit_Spigot/BuildTools/Spigot"/>
<classpathentry kind="lib" path="C:/Programmieren/FastAsyncWorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Programmieren/worldedit-bukkit-6.1.7.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,7 +1,8 @@
name: WorldSystem
version: 2.1.2
version: 2.1.2.2
author: Butzlabben
main: de.butzlabben.world.WorldSystem
loadbefore: [FastAsyncWorldEdit, WorldEdit]
commands:
ws:

View File

@ -44,6 +44,8 @@ import de.butzlabben.world.listener.BlockListener;
import de.butzlabben.world.listener.CommandListener;
import de.butzlabben.world.listener.PlayerDeathListener;
import de.butzlabben.world.listener.PlayerLeaveListener;
import de.butzlabben.world.wrapper.AsyncCreatorAdapter;
import de.butzlabben.world.wrapper.CreatorAdapter;
import de.butzlabben.world.wrapper.SystemWorld;
/**
@ -60,6 +62,8 @@ public class WorldSystem extends JavaPlugin {
final private String version = this.getDescription().getVersion();
public static OrcInventory mainGUI;
public static CreatorAdapter creator;
@Override
public void onEnable() {
createConfigs();
@ -126,7 +130,7 @@ public class WorldSystem extends JavaPlugin {
getCommand("ws togglegm").setExecutor(new WSToggleGMCommand());
getCommand("ws togglebuild").setExecutor(new WSToggleBuildCommand());
getCommand("ws delete").setExecutor(new WSDeleteCommand());
getCommand("ws confirm").setExecutor(new WSConfirmCommand());
getCommand("ws gui").setExecutor(new GuiCommand());
@ -136,9 +140,20 @@ public class WorldSystem extends JavaPlugin {
System.setProperty("bstats.relocatecheck", "false");
Metrics m = new Metrics(this);
m.addCustomChart(new Metrics.SingleLineChart("worlds", Entry::entrys));
AutoUpdater.startAsync();
//Choose right creatoradapter for #16
if (Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null
&& Bukkit.getPluginManager().getPlugin("WorldEdit") != null) {
creator = new AsyncCreatorAdapter();
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "Found FAWE! Try now to create worlds async");
} else {
creator = (c) -> {
Bukkit.getWorlds().add(c.createWorld());
};
}
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "Succesfully enabled WorldSystem v" + version);
}

View File

@ -33,7 +33,7 @@ public class WSToggleBuildCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (wc.isMember(a.getUniqueId())) {
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return true;
}

View File

@ -33,7 +33,7 @@ public class WSToggleGMCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (wc.isMember(a.getUniqueId())) {
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return true;
}

View File

@ -33,7 +33,7 @@ public class WSToggleTPCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
if (wc.isMember(a.getUniqueId())) {
if (!wc.isMember(a.getUniqueId())) {
p.sendMessage(MessageConfig.getNoMemberOwn());
return true;
}

View File

@ -27,7 +27,7 @@ import de.butzlabben.world.GameProfileBuilder;
*/
public class WorldConfig {
private static File getWorldFile(String worldname) {
public static File getWorldFile(String worldname) {
File worldconfig = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
if (!worldconfig.exists()) {
worldconfig = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");

View File

@ -2,9 +2,6 @@ package de.butzlabben.world.listener;
import java.io.File;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -14,20 +11,18 @@ import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.wrapper.WorldPlayer;
public class BlockListener implements Listener {
@EventHandler
public void onExplode(EntityExplodeEvent e) {
World w = e.getLocation().getWorld();
File file = new File(Bukkit.getWorldContainer(), w.getName() + "/worldconfig.yml");
if (file.exists()) {
e.setCancelled(true);
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
boolean b = cfg.getBoolean("Settings.TNTDamage");
e.setCancelled(!b);
}
File file = WorldConfig.getWorldFile(e.getLocation().getWorld().getName());
if(!file.exists())
return;
WorldConfig wc = WorldConfig.getWorldConfig(e.getLocation().getWorld().getName());
e.setCancelled(!wc.isTnt());
}
@EventHandler
@ -39,12 +34,10 @@ public class BlockListener implements Listener {
WorldPlayer wp = new WorldPlayer(p, worldname);
if (!wp.isOnSystemWorld())
return;
if(!wp.isMember())
return;
if (!wp.isOwnerofWorld()) {
File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
String uuid = p.getUniqueId().toString();
boolean b = cfg.getBoolean("Members." + uuid + ".Permissions.CanBuild");
e.setCancelled(!b);
e.setCancelled(!wp.canBuild());
}
}
@ -57,33 +50,27 @@ public class BlockListener implements Listener {
WorldPlayer wp = new WorldPlayer(p, worldname);
if (!wp.isOnSystemWorld())
return;
if(!wp.isMember())
return;
if (!wp.isOwnerofWorld()) {
File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
String uuid = p.getUniqueId().toString();
boolean b = cfg.getBoolean("Members." + uuid + ".Permissions.CanBuild");
e.setCancelled(!b);
e.setCancelled(!wp.canBuild());
}
}
@EventHandler
public void onFire(BlockIgniteEvent e) {
World w = e.getBlock().getWorld();
File file = new File(Bukkit.getWorldContainer(), w.getName() + "/worldconfig.yml");
if (file.exists()) {
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
boolean b = cfg.getBoolean("Settings.Fire");
e.setCancelled(!b);
}
File file = WorldConfig.getWorldFile(e.getBlock().getWorld().getName());
if(!file.exists())
return;
WorldConfig wc = WorldConfig.getWorldConfig(e.getBlock().getWorld().getName());
e.setCancelled(!wc.isFire());
}
@EventHandler
public void onFire(BlockBurnEvent e) {
World w = e.getBlock().getWorld();
File file = new File(Bukkit.getWorldContainer(), w.getName() + "/worldconfig.yml");
if (file.exists()) {
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
boolean b = cfg.getBoolean("Settings.Fire");
e.setCancelled(!b);
}
File file = WorldConfig.getWorldFile(e.getBlock().getWorld().getName());
if(!file.exists())
return;
WorldConfig wc = WorldConfig.getWorldConfig(e.getBlock().getWorld().getName());
e.setCancelled(!wc.isFire());
}
}

View File

@ -0,0 +1,37 @@
package de.butzlabben.world.wrapper;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import com.boydti.fawe.bukkit.wrapper.AsyncWorld;
import com.boydti.fawe.util.TaskManager;
/**
* @author Butzlabben
* @since 08.06.2018
*/
public class AsyncCreatorAdapter implements CreatorAdapter{
// Create worlds async to close #16
@Override
public void create(WorldCreator creator) {
TaskManager.IMP.async(new Runnable() {
@Override
public void run() {
// Create or load a world async with the provided WorldCreator settings
AsyncWorld world = AsyncWorld.create(creator);
// AsyncWorld world = AsyncWorld.wrap(bukkitWorld); // Or wrap existing world
Block block = world.getBlockAt(0, 0, 0);
block.setType(Material.BEDROCK);
// When you are done
world.commit();
Bukkit.getWorlds().add(world);
}
});
return;
}
}

View File

@ -0,0 +1,12 @@
package de.butzlabben.world.wrapper;
import org.bukkit.WorldCreator;
/**
* @author Butzlabben
* @since 07.06.2018
*/
public interface CreatorAdapter {
public void create(WorldCreator creator);
}

View File

@ -212,8 +212,9 @@ public class SystemWorld {
world.renameTo(new File(Bukkit.getWorldContainer(), myName.toString()));
worldname = myName.toString();
}
// Teleport the Player
// For #16
WorldSystem.creator.create(new WorldCreator(worldname));
World worldinserver = Bukkit.createWorld(new WorldCreator(worldname));
Bukkit.getServer().getWorlds().add(worldinserver);
w = worldinserver;
@ -307,9 +308,11 @@ public class SystemWorld {
e.printStackTrace();
}
}
World worldinserver = Bukkit.createWorld(event.getWorldCreator());
Bukkit.getServer().getWorlds().add(worldinserver);
//For #16
WorldSystem.creator.create(event.getWorldCreator());
// World worldinserver = Bukkit.createWorld(event.getWorldCreator());
// Bukkit.getServer().getWorlds().add(worldinserver);
}
return true;
}

View File

@ -1,7 +1,8 @@
name: WorldSystem
version: 2.1.2
version: 2.1.2.2
author: Butzlabben
main: de.butzlabben.world.WorldSystem
loadbefore: [FastAsyncWorldEdit, WorldEdit]
commands:
ws: