2.4.0.3: Multi world choose, bug fix on /ws tp <own name>

This commit is contained in:
Butzlabben 2018-12-16 14:13:47 +01:00
parent 55da382353
commit 79bd24a75a
35 changed files with 560 additions and 202 deletions

View File

@ -5,10 +5,30 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" path="src/main/java"/> <classpathentry kind="src" output="target/classes" path="src/main/java">
<classpathentry kind="src" path="src/main/resources"/> <attributes>
<classpathentry kind="src" path="src/test/java"/> <attribute name="optional" value="true"/>
<classpathentry kind="src" path="src/test/resources"/> <attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>

View File

@ -1,7 +1,12 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/java/de/butzlabben/world/WorldSystem.java=UTF-8 encoding//src/main/java/de/butzlabben/world/WorldSystem.java=UTF-8
encoding//src/main/java/de/butzlabben/world/command/WSCommand.java=UTF-8 encoding//src/main/java/de/butzlabben/world/command/WSCommand.java=UTF-8
encoding//src/main/java/de/butzlabben/world/config/GuiConfig.java=Cp1252 encoding//src/main/java/de/butzlabben/world/config/GuiConfig.java=Cp1252
encoding//src/main/java/de/butzlabben/world/config/PluginConfig.java=Cp1252 encoding//src/main/java/de/butzlabben/world/config/PluginConfig.java=Cp1252
encoding//src/main/java/de/butzlabben/world/gui/clicklistener/ComingSoonClickListener.java=Cp1252 encoding//src/main/java/de/butzlabben/world/gui/clicklistener/ComingSoonClickListener.java=Cp1252
encoding//src/main/java/de/butzlabben/world/wrapper/SystemWorld.java=Cp1252 encoding//src/main/java/de/butzlabben/world/wrapper/SystemWorld.java=Cp1252
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -9,4 +9,5 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.butzlabben.world</groupId> <groupId>de.butzlabben.world</groupId>
<artifactId>WorldSystem</artifactId> <artifactId>WorldSystem</artifactId>
<version>2.4.0.3-Dev</version> <version>2.4.0.3</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.number>-</project.build.number> <project.build.number>-</project.build.number>

View File

@ -44,7 +44,7 @@ public class AutoUpdater implements Listener {
confirmNeed = PluginConfig.confirmNeed(); confirmNeed = PluginConfig.confirmNeed();
UpdateInformations ui = UpdateInformations.getInformations(); UpdateInformations ui = UpdateInformations.getInformations();
if (ui == null) { if (ui == null) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cCouldn't contact autoupdate server"); Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cCouldn't contact autoupdate server");
return; return;
} }
Plugin plugin = Bukkit.getPluginManager().getPlugin(ui.getPlugin()); Plugin plugin = Bukkit.getPluginManager().getPlugin(ui.getPlugin());
@ -83,18 +83,18 @@ public class AutoUpdater implements Listener {
Runtime.getRuntime().addShutdownHook(new Thread(au)); Runtime.getRuntime().addShutdownHook(new Thread(au));
if (!ui.isSilent()) if (!ui.isSilent())
Bukkit.getConsoleSender().sendMessage( Bukkit.getConsoleSender().sendMessage(
PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes"); PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes");
confirmed = true; confirmed = true;
} else { } else {
Bukkit.getPluginManager().registerEvents(this, plugin); Bukkit.getPluginManager().registerEvents(this, plugin);
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
p.sendMessage( p.sendMessage(
PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm"); PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm");
p.sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates"); p.sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates");
} }
Bukkit.getConsoleSender().sendMessage( Bukkit.getConsoleSender().sendMessage(
PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm"); PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm");
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates"); Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates");
} }
} else { } else {
confirmNeed = false; confirmNeed = false;
@ -105,8 +105,8 @@ public class AutoUpdater implements Listener {
public void on(PlayerJoinEvent e) { public void on(PlayerJoinEvent e) {
if (e.getPlayer().hasPermission("ws.confirm")) { if (e.getPlayer().hasPermission("ws.confirm")) {
e.getPlayer().sendMessage( e.getPlayer().sendMessage(
PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm"); PluginConfig.getPrefix() + "§aFound new update. Confirm autoupdate with §c/ws confirm");
e.getPlayer().sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates"); e.getPlayer().sendMessage(PluginConfig.getPrefix() + "§aRead changelogs: https://www.spigotmc.org/resources/49756/updates");
} }
} }

View File

@ -9,4 +9,8 @@ public class CostumInv extends OrcInventory{
public CostumInv(String title, int rows) { public CostumInv(String title, int rows) {
super(title, rows); super(title, rows);
} }
public CostumInv(String title, int rows, boolean fill) {
super(title, rows, fill);
}
} }

View File

@ -14,6 +14,7 @@ public abstract class OrcInventory {
protected String title; protected String title;
private int rows; private int rows;
private InventoryType type; private InventoryType type;
private boolean fill = false;
protected HashMap<Integer, OrcItem> items = new HashMap<>(); protected HashMap<Integer, OrcItem> items = new HashMap<>();
@ -29,6 +30,16 @@ public abstract class OrcInventory {
this.rows = rows; this.rows = rows;
} }
public OrcInventory(String title, int rows, boolean fill) {
this(title, rows);
this.fill = fill;
if(this.fill) {
for (int i = 0; i < rows * 9; i++) {
items.put(i, OrcItem.fill);
}
}
}
public OrcInventory(String title, InventoryType type) { public OrcInventory(String title, InventoryType type) {
this(title); this(title);
if (type == null || type == InventoryType.CHEST) { if (type == null || type == InventoryType.CHEST) {

View File

@ -15,8 +15,8 @@ import de.butzlabben.world.wrapper.WorldPlayer;
public class OrcItem { public class OrcItem {
public static OrcItem enabled, disabled, coming_soon, back, error = new OrcItem(Material.BARRIER, null, public static OrcItem enabled, disabled, coming_soon, back, fill, error = new OrcItem(Material.BARRIER, null,
"§cERROR: Item is wrong configured!", "§cPath in config: see Displayname"); "§cERROR: Item is wrong configured!", "§cPath in config: see Displayname");
private ItemStack is; private ItemStack is;
private OrcClickListener listener; private OrcClickListener listener;

View File

@ -29,7 +29,6 @@ import de.butzlabben.world.command.WSToggleBuildCommand;
import de.butzlabben.world.command.WSToggleGMCommand; import de.butzlabben.world.command.WSToggleGMCommand;
import de.butzlabben.world.command.WSToggleTPCommand; import de.butzlabben.world.command.WSToggleTPCommand;
import de.butzlabben.world.config.DependenceConfig; import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.Entry;
import de.butzlabben.world.config.GuiConfig; import de.butzlabben.world.config.GuiConfig;
import de.butzlabben.world.config.MessageConfig; import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig; import de.butzlabben.world.config.PluginConfig;
@ -122,7 +121,7 @@ public class WorldSystem extends JavaPlugin {
System.setProperty("bstats.relocatecheck", "false"); System.setProperty("bstats.relocatecheck", "false");
Metrics m = new Metrics(this); Metrics m = new Metrics(this);
m.addCustomChart(new Metrics.SingleLineChart("worlds", Entry::entrys)); m.addCustomChart(new Metrics.SingleLineChart("worlds", DependenceConfig::getHighestID));
AutoUpdater.startAsync(); AutoUpdater.startAsync();

View File

@ -52,7 +52,7 @@ public class WSAddmemberCommand implements CommandExecutor{
try { try {
wc.save(); wc.save();
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong"); p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace(); e.printStackTrace();
} }
p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName())); p.sendMessage(MessageConfig.getMemberAdded().replaceAll("%player", a.getName()));

View File

@ -16,11 +16,11 @@ public class WSConfirmCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
if (AutoUpdater.getInstance().confirmed()) { if (AutoUpdater.getInstance().confirmed()) {
cs.sendMessage(PluginConfig.getPrefix() + "§cAlready confirmed or no confirm needed"); cs.sendMessage(PluginConfig.getPrefix() + "§cAlready confirmed or no confirm needed");
return true; return true;
} }
AutoUpdater.getInstance().confirm(); AutoUpdater.getInstance().confirm();
cs.sendMessage(PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes"); cs.sendMessage(PluginConfig.getPrefix() + "§aAutoupdate confirmed, §crestart §ato apply changes");
return true; return true;
} }
} }

View File

@ -59,7 +59,7 @@ public class WSDelmemberCommand implements CommandExecutor {
try { try {
wc.save(); wc.save();
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong"); p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace(); e.printStackTrace();
} }
p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName())); p.sendMessage(MessageConfig.getMemberRemoved().replaceAll("%player", a.getName()));

View File

@ -38,7 +38,7 @@ public class WSFireCommand implements CommandExecutor {
try { try {
wc.save(); wc.save();
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong"); p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace(); e.printStackTrace();
} }
fire = wc.isFire(); fire = wc.isFire();

View File

@ -9,14 +9,19 @@ import org.bukkit.entity.Player;
import de.butzlabben.world.WorldSystem; import de.butzlabben.world.WorldSystem;
import de.butzlabben.world.config.DependenceConfig; import de.butzlabben.world.config.DependenceConfig;
import de.butzlabben.world.config.MessageConfig; import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.wrapper.SystemWorld; import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
public class WSGetCommand implements CommandExecutor { public class WSGetCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender cs, Command arg1, String arg2, String[] arg3) { public boolean onCommand(CommandSender cs, Command cmd, String label, String[] args) {
if (!(cs instanceof Player)) if (!(cs instanceof Player))
return true; return true;
Player p = (Player) cs; Player p = (Player) cs;
// create New Entry // create New Entry
DependenceConfig dc = new DependenceConfig(p); DependenceConfig dc = new DependenceConfig(p);
@ -24,11 +29,34 @@ public class WSGetCommand implements CommandExecutor {
p.sendMessage(MessageConfig.getWorldAlreadyExists()); p.sendMessage(MessageConfig.getWorldAlreadyExists());
return true; return true;
} }
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
if (SystemWorld.create(p)) if (PluginConfig.isMultiChoose()) {
p.sendMessage(MessageConfig.getSettingUpWorld()); if (args.length >= 2) {
}); String key = args[1];
WorldTemplate template = WorldTemplateProvider.getInstace().getTemplate(key);
if (template != null) {
create(p, template);
return true;
}
}
p.openInventory(new WorldChooseGUI().getInventory(p));
} else {
WorldTemplate template = WorldTemplateProvider.getInstace()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if(template != null)
create(p, template);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
}
return true; return true;
} }
private void create(Player p, WorldTemplate template) {
Bukkit.getScheduler().runTask(WorldSystem.getInstance(), () -> {
if (SystemWorld.create(p, template))
p.sendMessage(MessageConfig.getSettingUpWorld());
});
}
} }

View File

@ -31,8 +31,8 @@ public class WSLeaveCommand implements CommandExecutor {
if (wp.isOnSystemWorld()) { if (wp.isOnSystemWorld()) {
// Extra safety for #2 // Extra safety for #2
if (PluginConfig.getSpawn().getWorld() == null) { if (PluginConfig.getSpawn().getWorld() == null) {
Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set"); Bukkit.getConsoleSender().sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
cs.sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set"); cs.sendMessage(PluginConfig.getPrefix() + "§cThe spawn is not properly set");
return true; return true;
} }

View File

@ -20,7 +20,10 @@ import de.butzlabben.world.config.MessageConfig;
import de.butzlabben.world.config.PluginConfig; import de.butzlabben.world.config.PluginConfig;
import de.butzlabben.world.config.WorldConfig; import de.butzlabben.world.config.WorldConfig;
import de.butzlabben.world.event.WorldResetEvent; import de.butzlabben.world.event.WorldResetEvent;
import de.butzlabben.world.gui.WorldChooseGUI;
import de.butzlabben.world.wrapper.SystemWorld; import de.butzlabben.world.wrapper.SystemWorld;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
public class WSResetCommand implements CommandExecutor { public class WSResetCommand implements CommandExecutor {
@ -61,15 +64,64 @@ public class WSResetCommand implements CommandExecutor {
} }
File f = new File(PluginConfig.getWorlddir() + "/" + worldname); File f = new File(PluginConfig.getWorlddir() + "/" + worldname);
if (!PluginConfig.isMultiChoose()) {
WorldTemplate template = WorldTemplateProvider.getInstace()
.getTemplate(PluginConfig.getDefaultWorldTemplate());
if (template != null)
createWorld(p, worldname, f, new File(template.getPath()), sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
} else {
WorldChooseGUI.letChoose(p, (template) -> {
if (template != null)
createWorld(p, worldname, f, new File(template.getPath()), sw);
else {
p.sendMessage(PluginConfig.getPrefix() + "§cError in config at \"worldtemplates.default\"");
p.sendMessage(PluginConfig.getPrefix() + "§cPlease contact an administrator");
}
});
}
} else {
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args[0]));
return true;
}
} else if (args.length == 1) {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestAlreadySent());
return true;
}
int time = PluginConfig.getRequestExpire();
p.sendMessage(MessageConfig.getConfirmRequest().replaceAll("%command", "/ws reset confirm"));
p.sendMessage(MessageConfig.getTimeUntilExpires().replaceAll("%time", String.valueOf(time)));
toConfirm.add(p);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestExpired());
toConfirm.remove(p);
}
}, time * 20L);
}
return true;
}
private void createWorld(Player p, String worldname, File f, File exampleworld, SystemWorld sw) {
File[] files = f.listFiles(); File[] files = f.listFiles();
for (File file : files) { for (File file : files) {
if (file.getName().equals("worldconfig.yml")) if (file.getName().equals("worldconfig.yml"))
continue; continue;
FileUtils.deleteQuietly(file); FileUtils.deleteQuietly(file);
} }
File exampleworld = new File(
"plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName());
try { try {
if (exampleworld.isDirectory())
FileUtils.copyDirectory(exampleworld, f); FileUtils.copyDirectory(exampleworld, f);
toConfirm.remove(p); toConfirm.remove(p);
@ -106,30 +158,5 @@ public class WSResetCommand implements CommandExecutor {
p.sendMessage(MessageConfig.getUnknownError()); p.sendMessage(MessageConfig.getUnknownError());
System.err.println("Couldn't reset world of " + p.getName()); System.err.println("Couldn't reset world of " + p.getName());
} }
} else {
p.sendMessage(MessageConfig.getInvalidInput().replaceAll("input", args[0]));
return true;
}
} else if (args.length == 1) {
if (sw.isLoaded())
sw.directUnload(Bukkit.getWorld(worldname));
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestAlreadySent());
return true;
}
int time = PluginConfig.getRequestExpire();
p.sendMessage(MessageConfig.getConfirmRequest().replaceAll("%command", "/ws reset confirm"));
p.sendMessage(MessageConfig.getTimeUntilExpires().replaceAll("%time", String.valueOf(time)));
toConfirm.add(p);
Bukkit.getScheduler().runTaskLater(WorldSystem.getInstance(), () -> {
if (toConfirm.contains(p)) {
p.sendMessage(MessageConfig.getRequestExpired());
toConfirm.remove(p);
}
}, time * 20L);
}
return true;
} }
} }

View File

@ -24,10 +24,14 @@ public class WSTPCommand implements CommandExecutor {
WorldSystem.getInstance().getCommand("ws tp").getUsage())); WorldSystem.getInstance().getCommand("ws tp").getUsage()));
return true; return true;
} }
// There where some problems with /ws tp <own name>
if(args[1].equalsIgnoreCase(p.getName()) || args[1].equalsIgnoreCase(p.getUniqueId().toString())) { if(args[1].equalsIgnoreCase(p.getName()) || args[1].equalsIgnoreCase(p.getUniqueId().toString())) {
p.chat("/ws home"); p.chat("/ws home");
return true; return true;
} }
DependenceConfig dc = new DependenceConfig(args[1]); DependenceConfig dc = new DependenceConfig(args[1]);
String worldname = dc.getWorldNamebyOfflinePlayer(); String worldname = dc.getWorldNamebyOfflinePlayer();
if (!dc.hasWorld()) { if (!dc.hasWorld()) {

View File

@ -38,7 +38,7 @@ public class WSTnTCommand implements CommandExecutor {
try { try {
wc.save(); wc.save();
} catch (IOException e) { } catch (IOException e) {
p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong"); p.sendMessage(PluginConfig.getPrefix() + "§cSomething went wrong");
e.printStackTrace(); e.printStackTrace();
} }
tnt = wc.isTnt(); tnt = wc.isTnt();

View File

@ -40,7 +40,7 @@ public class WSToggleBuildCommand implements CommandExecutor {
} }
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname()); WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) { if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner"); p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return true; return true;
} }
if (wp.toggleBuild()) { if (wp.toggleBuild()) {

View File

@ -40,7 +40,7 @@ public class WSToggleGMCommand implements CommandExecutor {
} }
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname()); WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) { if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner"); p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return true; return true;
} }
if (wp.toggleGamemode()) { if (wp.toggleGamemode()) {

View File

@ -40,7 +40,7 @@ public class WSToggleTPCommand implements CommandExecutor {
} }
WorldPlayer wp = new WorldPlayer(a, dc.getWorldname()); WorldPlayer wp = new WorldPlayer(a, dc.getWorldname());
if (wp.isOwnerofWorld()) { if (wp.isOwnerofWorld()) {
p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner"); p.sendMessage(PluginConfig.getPrefix() + "§cYou are the owner");
return true; return true;
} }
if (wp.toggleTeleport()) { if (wp.toggleTeleport()) {

View File

@ -125,7 +125,7 @@ public class DependenceConfig {
} }
} }
public int getHighestID() { public static int getHighestID() {
File dconfig = new File("plugins//WorldSystem//dependence.yml"); File dconfig = new File("plugins//WorldSystem//dependence.yml");
YamlConfiguration dcfg = YamlConfiguration.loadConfiguration(dconfig); YamlConfiguration dcfg = YamlConfiguration.loadConfiguration(dconfig);
return dcfg.getInt("HighestID"); return dcfg.getInt("HighestID");

View File

@ -49,6 +49,7 @@ public class GuiConfig {
OrcItem.disabled = getDisabled(); OrcItem.disabled = getDisabled();
OrcItem.coming_soon = getComingSoon(); OrcItem.coming_soon = getComingSoon();
OrcItem.back = getBack(); OrcItem.back = getBack();
OrcItem.fill = getFill();
} }
public static YamlConfiguration getConfig() { public static YamlConfiguration getConfig() {
@ -138,6 +139,14 @@ public class GuiConfig {
return getItem("options.back"); return getItem("options.back");
} }
private static OrcItem getFill() {
return getItem("options.fill");
}
public static boolean isFill(String path) {
return getConfig().getBoolean(path + ".fill");
}
public static Material getSkullItem() { public static Material getSkullItem() {
return getMaterial(getConfig(), "options.players.playerhead"); return getMaterial(getConfig(), "options.players.playerhead");
} }

View File

@ -25,19 +25,19 @@ public class MessageConfig {
private static List<String> defaultCmdHelp = new ArrayList<>(20); private static List<String> defaultCmdHelp = new ArrayList<>(20);
{ {
defaultCmdHelp.add("/ws get §8- §7Will give you a World"); defaultCmdHelp.add("/ws get §8- §7Will give you a World");
defaultCmdHelp.add("/ws home §8- §7Teleports you on your World"); defaultCmdHelp.add("/ws home §8- §7Teleports you on your World");
defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home"); defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home");
defaultCmdHelp.add("/ws tp §8- §7Teleports you on a specific World"); defaultCmdHelp.add("/ws tp §8- §7Teleports you on a specific World");
defaultCmdHelp.add("/ws addmember §8- §7Adds a player to your World"); defaultCmdHelp.add("/ws addmember §8- §7Adds a player to your World");
defaultCmdHelp.add("/ws delmember§8 - §7Removes a player from your World"); defaultCmdHelp.add("/ws delmember§8 - §7Removes a player from your World");
defaultCmdHelp.add("/ws tnt §8- §7Allows/Denys TNT on your World"); defaultCmdHelp.add("/ws tnt §8- §7Allows/Denys TNT on your World");
defaultCmdHelp.add("/ws fire §8- §7Allows/Denys Fire on your World"); defaultCmdHelp.add("/ws fire §8- §7Allows/Denys Fire on your World");
defaultCmdHelp.add("/ws togglechgm §8- §7Allows/Denys a player changing gamemode"); defaultCmdHelp.add("/ws togglechgm §8- §7Allows/Denys a player changing gamemode");
defaultCmdHelp.add("/ws togglebuild §8- §7Allows/Denys a player building"); defaultCmdHelp.add("/ws togglebuild §8- §7Allows/Denys a player building");
defaultCmdHelp.add("/ws toggletp §8- §7Allows/Denys a player teleporting"); defaultCmdHelp.add("/ws toggletp §8- §7Allows/Denys a player teleporting");
defaultCmdHelp.add("/ws info §8- §7Shows information about the World"); defaultCmdHelp.add("/ws info §8- §7Shows information about the World");
defaultCmdHelp.add("/ws reset §8- §7Will reset your World"); defaultCmdHelp.add("/ws reset §8- §7Will reset your World");
} }
private static File file; private static File file;
@ -78,11 +78,11 @@ public class MessageConfig {
} }
public static String getNoPermission() { public static String getNoPermission() {
return getMessage("nopermission", "§cYou don't have permissions!"); return getMessage("nopermission", "§cYou don't have permissions!");
} }
public static String getSettingUpWorld() { public static String getSettingUpWorld() {
return getMessage("world.setting_up", "§aSetting up world..."); return getMessage("world.setting_up", "§aSetting up world...");
} }
public static String getPlayerList() { public static String getPlayerList() {
@ -90,27 +90,27 @@ public class MessageConfig {
} }
public static String getLagDetection() { public static String getLagDetection() {
return getMessage("lagdetection", "Lagdetection in world from: §c%world"); return getMessage("lagdetection", "Lagdetection in world from: §c%world");
} }
public static String getWrongUsage() { public static String getWrongUsage() {
return getMessage("wrong_usage", "§c%usage"); return getMessage("wrong_usage", "§c%usage");
} }
public static String getNoWorldOwn() { public static String getNoWorldOwn() {
return getMessage("world.does_not_exists.own", "§cYou don't have a world!"); return getMessage("world.does_not_exists.own", "§cYou don't have a world!");
} }
public static String getNoWorldOther() { public static String getNoWorldOther() {
return getMessage("world.does_not_exists.other", "§cThis player doesn't has a world!"); return getMessage("world.does_not_exists.other", "§cThis player doesn't has a world!");
} }
public static String getNotRegistered() { public static String getNotRegistered() {
return getMessage("not_registered", "§cThis player hasn't joined yet!"); return getMessage("not_registered", "§cThis player hasn't joined yet!");
} }
public static String getAlreadyMember() { public static String getAlreadyMember() {
return getMessage("member.already_added", "§cThis player is already a member!"); return getMessage("member.already_added", "§cThis player is already a member!");
} }
public static String getMemberAdded() { public static String getMemberAdded() {
@ -118,51 +118,51 @@ public class MessageConfig {
} }
public static String getUnknownError() { public static String getUnknownError() {
return getMessage("unknown_error", "§cSomething went wrong..."); return getMessage("unknown_error", "§cSomething went wrong...");
} }
public static String getDeleteWorldOwn() { public static String getDeleteWorldOwn() {
return getMessage("world.delete.own", "§cYour world was deleted!"); return getMessage("world.delete.own", "§cYour world was deleted!");
} }
public static String getDeleteWorldOther() { public static String getDeleteWorldOther() {
return getMessage("world.delete.other", "You deleted the world of §c%player§6!"); return getMessage("world.delete.other", "You deleted the world of §c%player§6!");
} }
public static String getNoMemberOwn() { public static String getNoMemberOwn() {
return getMessage("member.not_added.own", "§cThis player isn't a member!"); return getMessage("member.not_added.own", "§cThis player isn't a member!");
} }
public static String getMemberRemoved() { public static String getMemberRemoved() {
return getMessage("member.removed", "You removed §c%player§6 from your world!"); return getMessage("member.removed", "You removed §c%player§6 from your world!");
} }
public static String getNoMemberAdded() { public static String getNoMemberAdded() {
return getMessage("member.no_one_added", "§cThere are no members added"); return getMessage("member.no_one_added", "§cThere are no members added");
} }
public static String getWorldAlreadyExists() { public static String getWorldAlreadyExists() {
return getMessage("world.already_exists", "§cYou already have a world!"); return getMessage("world.already_exists", "§cYou already have a world!");
} }
public static String getWorldCreated() { public static String getWorldCreated() {
return getMessage("world.created", "Your world is now ready. Get there with §a/ws home"); return getMessage("world.created", "Your world is now ready. Get there with §a/ws home");
} }
public static String getWorldStillCreating() { public static String getWorldStillCreating() {
return getMessage("world.still_creating", "§cWorld is still creating"); return getMessage("world.still_creating", "§cWorld is still creating");
} }
public static String getNotOnWorld() { public static String getNotOnWorld() {
return getMessage("world.not_on", "§cYou are not on a world!"); return getMessage("world.not_on", "§cYou are not on a world!");
} }
public static String getWorldStillLoaded() { public static String getWorldStillLoaded() {
return getMessage("world.still_loaded", "§cYour world is still loaded!"); return getMessage("world.still_loaded", "§cYour world is still loaded!");
} }
public static String getNoRequestSend() { public static String getNoRequestSend() {
return getMessage("request.not_sent", "§cYou didn't send a request!"); return getMessage("request.not_sent", "§cYou didn't send a request!");
} }
public static String getWorldReseted() { public static String getWorldReseted() {
@ -170,27 +170,27 @@ public class MessageConfig {
} }
public static String getInvalidInput() { public static String getInvalidInput() {
return getMessage("request.invalid_input", "§c%input is not a valid input!"); return getMessage("request.invalid_input", "§c%input is not a valid input!");
} }
public static String getRequestAlreadySent() { public static String getRequestAlreadySent() {
return getMessage("request.already_sent", "§cYou already sent a request!"); return getMessage("request.already_sent", "§cYou already sent a request!");
} }
public static String getRequestExpired() { public static String getRequestExpired() {
return getMessage("request.expired", "§cYou request is expired!"); return getMessage("request.expired", "§cYou request is expired!");
} }
public static String getTimeUntilExpires() { public static String getTimeUntilExpires() {
return getMessage("request.until_expire", "§cYour request expires in %time seconds!"); return getMessage("request.until_expire", "§cYour request expires in %time seconds!");
} }
public static String getConfirmRequest() { public static String getConfirmRequest() {
return getMessage("request.confirm", "§cPlease confirm reset of your world: %command"); return getMessage("request.confirm", "§cPlease confirm reset of your world: %command");
} }
public static String getNoMemberOther() { public static String getNoMemberOther() {
return getMessage("member.not_added.other", "§cYou are not added to this world!"); return getMessage("member.not_added.other", "§cYou are not added to this world!");
} }
public static String getInfoOwner() { public static String getInfoOwner() {
@ -214,55 +214,55 @@ public class MessageConfig {
} }
public static String getInfoEnabled() { public static String getInfoEnabled() {
return getRawMessage("info.enabled", "§aOn"); return getRawMessage("info.enabled", "§aOn");
} }
public static String getInfoDisabled() { public static String getInfoDisabled() {
return getRawMessage("info.disabled", "§cOff"); return getRawMessage("info.disabled", "§cOff");
} }
public static String getToggleGameModeEnabled() { public static String getToggleGameModeEnabled() {
return getMessage("toggle.gamemode.enabled", "§a%player§6 can now change his gamemode!"); return getMessage("toggle.gamemode.enabled", "§a%player§6 can now change his gamemode!");
} }
public static String getToggleGameModeDisabled() { public static String getToggleGameModeDisabled() {
return getMessage("toggle.gamemode.disabled", "§c%player§6 can no longer change his gamemode!"); return getMessage("toggle.gamemode.disabled", "§c%player§6 can no longer change his gamemode!");
} }
public static String getToggleTeleportEnabled() { public static String getToggleTeleportEnabled() {
return getMessage("toggle.teleport.enabled", "§a%player§6 can now teleport!"); return getMessage("toggle.teleport.enabled", "§a%player§6 can now teleport!");
} }
public static String getToggleTeleportDisabled() { public static String getToggleTeleportDisabled() {
return getMessage("toggle.teleport.disabled", "§c%player§6 can no longer teleport!"); return getMessage("toggle.teleport.disabled", "§c%player§6 can no longer teleport!");
} }
public static String getToggleBuildEnabled() { public static String getToggleBuildEnabled() {
return getMessage("toggle.build.enabled", "§a%player§6 can now build!"); return getMessage("toggle.build.enabled", "§a%player§6 can now build!");
} }
public static String getToggleBuildDisabled() { public static String getToggleBuildDisabled() {
return getMessage("toggle.build.disabled", "§c%player§6 can no longer build!"); return getMessage("toggle.build.disabled", "§c%player§6 can no longer build!");
} }
public static String getToggleFireEnabled() { public static String getToggleFireEnabled() {
return getMessage("toggle.fire.enabled", "§aYou activated fire!"); return getMessage("toggle.fire.enabled", "§aYou activated fire!");
} }
public static String getToggleFireDisabled() { public static String getToggleFireDisabled() {
return getMessage("toggle.fire.disabled", "§cYou deactivated fire!"); return getMessage("toggle.fire.disabled", "§cYou deactivated fire!");
} }
public static String getToggleTntEnabled() { public static String getToggleTntEnabled() {
return getMessage("toggle.tnt.enabled", "§aYou activated TNT-Damage!"); return getMessage("toggle.tnt.enabled", "§aYou activated TNT-Damage!");
} }
public static String getToggleTntDisabled() { public static String getToggleTntDisabled() {
return getMessage("toggle.tnt.disabled", "§cYou deactivated TNT-Damage!"); return getMessage("toggle.tnt.disabled", "§cYou deactivated TNT-Damage!");
} }
public static String getDeleteCommandHelp() { public static String getDeleteCommandHelp() {
return getMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World"); return getMessage("command_help.delete_command", "/ws delete §8- §7Will delete a World");
} }
public static List<String> getCommandHelp() { public static List<String> getCommandHelp() {

View File

@ -36,11 +36,12 @@ public class PluginConfig {
file = f; file = f;
if (file.exists()) { if (file.exists()) {
YamlConfiguration cfg = getConfig(); YamlConfiguration cfg = getConfig();
if (false == (cfg.isString("worldfolder") && cfg.isString("worldsource") && cfg.isInt("unloadingtime") if (false == (cfg.isString("worldfolder") && cfg.isInt("unloadingtime")
&& cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix") && cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix")
&& cfg.isInt("request_expires") && cfg.isBoolean("need_confirm") && cfg.isInt("request_expires") && cfg.isBoolean("need_confirm")
&& cfg.isBoolean("contact_authserver") && cfg.isBoolean("spawn_teleportation") && cfg.isBoolean("contact_authserver") && cfg.isBoolean("spawn_teleportation")
&& cfg.isInt("delete_after") && && cfg.isInt("delete_after") && cfg.isBoolean("worldtemplates.multi_choose")
&& cfg.isString("worldtemplates.default") &&
cfg.isInt("lagsystem.period_in_seconds") && cfg.isInt("lagsystem.entities_per_world") cfg.isInt("lagsystem.period_in_seconds") && cfg.isInt("lagsystem.entities_per_world")
&& cfg.isBoolean("lagsystem.garbagecollector.use") && cfg.isBoolean("lagsystem.garbagecollector.use")
@ -91,9 +92,10 @@ public class PluginConfig {
} }
} }
private static YamlConfiguration getConfig() { public static YamlConfiguration getConfig() {
try { try {
return YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"))); return YamlConfiguration
.loadConfiguration(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -139,8 +141,12 @@ public class PluginConfig {
return getConfig().getString("worldfolder", "plugins/WorldSystem/Worlds") + "/"; return getConfig().getString("worldfolder", "plugins/WorldSystem/Worlds") + "/";
} }
public static String getExampleWorldName() { public static boolean isMultiChoose() {
return getConfig().getString("worldsource", ""); return getConfig().getBoolean("worldtemplates.multi_choose", false);
}
public static String getDefaultWorldTemplate() {
return getConfig().getString("worldtemplates.default", "");
} }
public static String getLanguage() { public static String getLanguage() {

View File

@ -21,7 +21,7 @@ public class PlayerOptionsGUI extends OrcInventory {
private final static String path = "options.player."; private final static String path = "options.player.";
public PlayerOptionsGUI(Player loader, String otherPlayer, UUID other) { public PlayerOptionsGUI(Player loader, String otherPlayer, UUID other) {
super(GuiConfig.getTitle(GuiConfig.getConfig(), "options.player").replace("%player", otherPlayer), GuiConfig.getRows("options.player")); super(GuiConfig.getTitle(GuiConfig.getConfig(), "options.player").replace("%player", otherPlayer), GuiConfig.getRows("options.player"), GuiConfig.isFill("options.player"));
WorldPlayer wp = new WorldPlayer(Bukkit.getOfflinePlayer(other), loader.getWorld().getName()); WorldPlayer wp = new WorldPlayer(Bukkit.getOfflinePlayer(other), loader.getWorld().getName());
loadItem("build", "/ws togglebuild " + otherPlayer, new BuildStatus(wp)); loadItem("build", "/ws togglebuild " + otherPlayer, new BuildStatus(wp));
loadItem("gamemode", "/ws togglegm " + otherPlayer, new GamemodeStatus(wp)); loadItem("gamemode", "/ws togglegm " + otherPlayer, new GamemodeStatus(wp));

View File

@ -0,0 +1,70 @@
package de.butzlabben.world.gui;
import java.util.function.Consumer;
import org.bukkit.entity.Player;
import de.butzlabben.inventory.OrcClickListener;
import de.butzlabben.inventory.OrcInventory;
import de.butzlabben.inventory.OrcItem;
import de.butzlabben.world.config.GuiConfig;
import de.butzlabben.world.wrapper.WorldTemplate;
import de.butzlabben.world.wrapper.WorldTemplateProvider;
/**
* @author Butzlabben
* @since 15.12.2018
*/
public class WorldChooseGUI extends OrcInventory {
private final static String path = "worldchoose.";
public WorldChooseGUI() {
this(null);
}
public WorldChooseGUI(Consumer<WorldTemplate> onClick) {
super(GuiConfig.getTitle(GuiConfig.getConfig(), "worldchoose"), GuiConfig.getRows("worldchoose"),
GuiConfig.isFill("worldchoose"));
for (WorldTemplate template : WorldTemplateProvider.getInstace().getTemplates()) {
OrcItem icon = template.getIcon();
if(onClick != null)
icon.setOnClick((p, inv, item) -> {
p.closeInventory();
onClick.accept(template);
});
int slot = template.getSlot();
addItem(slot, icon);
}
if (GuiConfig.isEnabled(path + "back")) {
OrcItem back = OrcItem.back.clone();
back.setOnClick((p, inv, item) -> {
p.closeInventory();
});
addItem(GuiConfig.getSlot(path + "back"), back);
}
}
public static void letChoose(Player player, Consumer<WorldTemplate> template) {
player.openInventory(new WorldChooseGUI(template).getInventory(player));
}
public void loadItem(String subpath, OrcClickListener listener) {
if (GuiConfig.isEnabled(path + subpath) == false)
return;
OrcItem item = GuiConfig.getItem(path + subpath);
if (item != null) {
item.setOnClick(listener);
addItem(GuiConfig.getSlot(path + subpath), item);
}
}
public void loadItem(String subpath) {
loadItem(subpath, null);
}
public boolean canOpen(Player p) {
return true;
}
}

View File

@ -23,7 +23,7 @@ public class WorldOptionsGUI extends OrcInventory {
public final static HashMap<UUID, String> data = new HashMap<>(); public final static HashMap<UUID, String> data = new HashMap<>();
public WorldOptionsGUI() { public WorldOptionsGUI() {
super(GuiConfig.getTitle(GuiConfig.getConfig(), "options.world"), GuiConfig.getRows("options.world")); super(GuiConfig.getTitle(GuiConfig.getConfig(), "options.world"), GuiConfig.getRows("options.world"), GuiConfig.isFill("options.world"));
loadItem("fire", "/ws fire", true, new FireStatus()); loadItem("fire", "/ws fire", true, new FireStatus());
loadItem("tnt", "/ws tnt", true, new TntStatus()); loadItem("tnt", "/ws tnt", true, new TntStatus());

View File

@ -16,7 +16,7 @@ public class WorldSystemGUI extends OrcInventory {
public WorldSystemGUI() { public WorldSystemGUI() {
super(GuiConfig.getTitle(GuiConfig.getConfig(), "worldsystem"), GuiConfig.getRows("worldsystem")); super(GuiConfig.getTitle(GuiConfig.getConfig(), "worldsystem"), GuiConfig.getRows("worldsystem"), GuiConfig.isFill("worldsystem"));
loadItem("playeroptions", (p, inv, item) -> { loadItem("playeroptions", (p, inv, item) -> {
p.closeInventory(); p.closeInventory();

View File

@ -260,11 +260,12 @@ public class SystemWorld {
* @param p Player to create the world for * @param p Player to create the world for
* @return whether it succesfull or not * @return whether it succesfull or not
*/ */
public static boolean create(Player p) { public static boolean create(Player p, WorldTemplate template) {
DependenceConfig dc = new DependenceConfig(p); DependenceConfig dc = new DependenceConfig(p);
String uuid = p.getUniqueId().toString(); String uuid = p.getUniqueId().toString();
int id = dc.getHighestID() + 1; int id = DependenceConfig.getHighestID() + 1;
String worldname = "ID" + id + "-" + uuid; String worldname = "ID" + id + "-" + uuid;
WorldCreator creator = PluginConfig.getWorldCreator(worldname); WorldCreator creator = PluginConfig.getWorldCreator(worldname);
@ -277,24 +278,25 @@ public class SystemWorld {
dc.createNewEntry(); dc.createNewEntry();
String worlddir = PluginConfig.getWorlddir(); String worlddir = PluginConfig.getWorlddir();
File exampleworld = new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName()); File exampleworld = new File(template.getPath());
if (new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat") if (new File(template.getPath() + "/uid.dat").exists()) {
.exists()) { new File(template.getPath() + "/uid.dat").delete();
new File("plugins//WorldSystem//worldsources//" + PluginConfig.getExampleWorldName() + "/uid.dat").delete();
} }
File newworld = new File(worlddir + "/" + worldname); File newworld = new File(worlddir + "/" + worldname);
if (exampleworld.isDirectory())
try { try {
FileUtils.copyDirectory(exampleworld, newworld); FileUtils.copyDirectory(exampleworld, newworld);
} catch (IOException e) { } catch (IOException e) {
System.err.println("Couldn't create world for " + p.getName()); System.err.println("Couldn't create world for " + p.getName());
e.printStackTrace(); e.printStackTrace();
} }
else
newworld.mkdirs();
WorldConfig.create(p); WorldConfig.create(p);
if (PluginConfig.getExampleWorldName() == null || PluginConfig.getExampleWorldName().equals("")
|| !exampleworld.exists()) {
// Move World into Server dir // Move World into Server dir
File world = new File(worlddir + "/" + worldname); File world = new File(worlddir + "/" + worldname);
if (!world.exists()) { if (!world.exists()) {
@ -330,14 +332,14 @@ public class SystemWorld {
if (p != null && p.isOnline()) { if (p != null && p.isOnline()) {
p.sendMessage(MessageConfig.getWorldCreated()); p.sendMessage(MessageConfig.getWorldCreated());
SettingsConfig.getCommandsonGet().stream() SettingsConfig.getCommandsonGet().stream()
.map(s -> s.replace("%player", p.getName()).replace("%world", sw.getName()).replace("%uuid", .map(s -> s.replace("%player", p.getName()).replace("%world", sw.getName())
p.getUniqueId().toString())) .replace("%uuid", p.getUniqueId().toString()))
.forEach(s -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s)); .forEach(s -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), s));
} }
}); });
} }
}.runTaskLater(WorldSystem.getInstance(), 1); }.runTaskLater(WorldSystem.getInstance(), 1);
}
return true; return true;
} }

View File

@ -0,0 +1,42 @@
package de.butzlabben.world.wrapper;
import de.butzlabben.inventory.OrcItem;
import de.butzlabben.world.config.GuiConfig;
/**
* @author Butzlabben
* @since 15.12.2018
*/
public class WorldTemplate {
private final String name;
private final OrcItem icon;
private final int slot;
public WorldTemplate(String name) {
this.name = name;
this.icon = GuiConfig.getItem("worldchoose." + name);
this.slot = GuiConfig.getSlot("worldchoose." + name);
icon.setOnClick((p, inv, item) -> {
p.closeInventory();
p.chat("/ws get " + name);
});
}
public int getSlot() {
return slot;
}
public OrcItem getIcon() {
return icon;
}
public String getName() {
return name;
}
public String getPath() {
return "plugins/WorldSystem/worldsources/" + name;
}
}

View File

@ -0,0 +1,39 @@
package de.butzlabben.world.wrapper;
import java.util.Collection;
import java.util.HashMap;
import org.bukkit.configuration.ConfigurationSection;
import de.butzlabben.world.config.PluginConfig;
/**
* @author Butzlabben
* @since 16.12.2018
*/
public class WorldTemplateProvider {
private static WorldTemplateProvider instance = new WorldTemplateProvider();
public static WorldTemplateProvider getInstace() {
return instance;
}
private HashMap<String, WorldTemplate> templates = new HashMap<>();
private WorldTemplateProvider() {
ConfigurationSection section = PluginConfig.getConfig().getConfigurationSection("worldtemplates.templates");
for(String key: section.getKeys(false)) {
String name = section.getString(key + ".name");
templates.put(name, new WorldTemplate(name));
}
}
public WorldTemplate getTemplate(String key) {
return templates.get(key);
}
public Collection<WorldTemplate> getTemplates() {
return templates.values();
}
}

View File

@ -26,8 +26,14 @@ options:
material: BARRIER material: BARRIER
display: '&cBack' display: '&cBack'
# When filling of an inventory is true, how the item should look like
fill:
material: GRAY_STAINED_GLASS_PANE
display: ''
# WorldoptionsGUI # WorldoptionsGUI
world: world:
fill: false
# What the title of the Inv should be # What the title of the Inv should be
title: 'World Options' title: 'World Options'
@ -122,6 +128,7 @@ options:
# PlayerGUI for managing one player on a world # PlayerGUI for managing one player on a world
player: player:
fill: false
title: 'Player options for %player' title: 'Player options for %player'
back: back:
@ -239,6 +246,7 @@ options:
# WorldsystemGUI # WorldsystemGUI
worldsystem: worldsystem:
fill: false
title: 'WorldSystem' title: 'WorldSystem'
rows: 1 rows: 1
@ -263,3 +271,36 @@ worldsystem:
col: 9 col: 9
material: GRASS_BLOCK material: GRASS_BLOCK
display: '&eWorld Options' display: '&eWorld Options'
# GUI for choosing world template
worldchoose:
fill: false
title: 'Choose world template'
back:
enabled: true
slot:
row: 4
col: 5
rows: 4
# The key must be named exactly as in the config.yml
template_default:
enabled: true
slot:
row: 2
col: 3
material: GRASS_BLOCK
display: '&aDefault template'
another_template:
enabled: true
slot:
row: 2
col: 7
material: STONE_BLOCK
display: '&aAnother template'

View File

@ -12,8 +12,19 @@
# Path where the worlds will be saved # Path where the worlds will be saved
worldfolder: 'plugins/WorldSystem/Worlds' worldfolder: 'plugins/WorldSystem/Worlds'
# Name of the template world worldtemplates:
worldsource: '' # Wheter players can decide on different templates
multi_choose: false
# If multi_choose is disabled, which template should be choosen
default: 'template_default'
templates:
# The "1" can be any key
1:
# Name of directory in plugins/WorldSystem/worldsources
# e.g. this would be plugins/WorldSystem/worldsources/template_default
name: 'template_default'
2:
name: 'another_template'
# If a confirm is needed before auto-update # If a confirm is needed before auto-update
need_confirm: true need_confirm: true

View File

@ -30,8 +30,15 @@ options:
material: BARRIER material: BARRIER
display: '&cBack' display: '&cBack'
# When filling of an inventory is true, how the item should look like
fill:
material: STAINED_GLASS_PANE
data: 7
display: ''
# WorldoptionsGUI # WorldoptionsGUI
world: world:
fill: false
# What the title of the Inv should be # What the title of the Inv should be
title: 'World Options' title: 'World Options'
@ -120,6 +127,7 @@ options:
# PlayerGUI for managing one player on a world # PlayerGUI for managing one player on a world
player: player:
fill: false
title: 'Player options for %player' title: 'Player options for %player'
back: back:
@ -237,6 +245,7 @@ options:
# WorldsystemGUI # WorldsystemGUI
worldsystem: worldsystem:
fill: false
title: 'WorldSystem' title: 'WorldSystem'
rows: 1 rows: 1
@ -261,3 +270,33 @@ worldsystem:
col: 9 col: 9
material: GRASS material: GRASS
display: '&eWorld Options' display: '&eWorld Options'
# GUI for choosing world template
worldchoose:
fill: false
title: 'Choose world template'
back:
enabled: true
slot:
row: 4
col: 5
rows: 4
# The key must be named exactly as in the config.yml
template_default:
enabled: true
slot:
row: 2
col: 3
material: GRASS
display: '&aDefault template'
another_template:
enabled: true
slot:
row: 2
col: 7
material: STONE
display: '&aAnother template'