mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-12-02 13:23:21 +01:00
Now all on new WorldConfig, implemented the contact_auth feature
This commit is contained in:
parent
c22c9b78db
commit
cc35b1f29f
@ -78,7 +78,7 @@ spawn:
|
||||
|
||||
# Location where you spawn when you join a world
|
||||
worldspawn:
|
||||
use: true
|
||||
use: false
|
||||
spawnpoint:
|
||||
x: 0
|
||||
y: 20
|
||||
|
@ -78,7 +78,7 @@ spawn:
|
||||
|
||||
# Location where you spawn when you join a world
|
||||
worldspawn:
|
||||
use: true
|
||||
use: false
|
||||
spawnpoint:
|
||||
x: 0
|
||||
y: 20
|
||||
|
@ -1,12 +1,13 @@
|
||||
package de.butzlabben.world.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.WorldConfig2;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.WorldPlayer;
|
||||
|
||||
public class WSInfoCommand implements CommandExecutor {
|
||||
@ -17,9 +18,28 @@ public class WSInfoCommand implements CommandExecutor {
|
||||
WorldPlayer wp = new WorldPlayer(p, p.getWorld().getName());
|
||||
if (!wp.isOnSystemWorld()) {
|
||||
p.sendMessage(MessageConfig.getNotOnWorld());
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
WorldConfig2.getInfos(p, p.getWorld().getName());
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(p.getWorld().getName());
|
||||
int id = wc.getId();
|
||||
String owner = wc.getOwnerName();
|
||||
boolean fire = wc.isFire();
|
||||
boolean tnt = wc.isTnt();
|
||||
|
||||
p.sendMessage(MessageConfig.getInfoOwner().replaceAll("%data", owner));
|
||||
p.sendMessage(MessageConfig.getInfoId().replaceAll("%data", "" + id));
|
||||
p.sendMessage(MessageConfig.getInfoTnt().replaceAll("%data",
|
||||
tnt ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
|
||||
p.sendMessage(MessageConfig.getInfoFire().replaceAll("%data",
|
||||
fire ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Iterator<String> it = wc.getMembersWithNames().values().iterator();
|
||||
while (it.hasNext()) {
|
||||
sb.append(it.next());
|
||||
if(it.hasNext())
|
||||
sb.append(" ");
|
||||
}
|
||||
p.sendMessage(MessageConfig.getInfoMember().replaceAll("%data", sb.toString().trim()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -33,14 +33,15 @@ public class PluginConfig {
|
||||
YamlConfiguration cfg = getConfig();
|
||||
if (false == (cfg.isString("worldfolder") && cfg.isString("worldsource") && cfg.isInt("unloadingtime")
|
||||
&& cfg.isBoolean("survival") && cfg.isString("language") && cfg.isString("prefix")
|
||||
&& cfg.isInt("request_expires") && cfg.isBoolean("need_confirm") && cfg.isBoolean("contact_authserver") &&
|
||||
&& cfg.isInt("request_expires") && cfg.isBoolean("need_confirm")
|
||||
&& cfg.isBoolean("contact_authserver") &&
|
||||
|
||||
cfg.isInt("lagsystem.period_in_seconds") && cfg.isInt("lagsystem.entities_per_world")
|
||||
&& cfg.isBoolean("lagsystem.garbagecollector.use")
|
||||
&& cfg.isInt("lagsystem.garbagecollector.period_in_minutes") &&
|
||||
|
||||
cfg.isString("worldgeneration.type") && cfg.isString("worldgeneration.environment")
|
||||
&& cfg.isString("worldgeneration.generation")
|
||||
&& cfg.isString("worldgeneration.generator")
|
||||
&& (cfg.isLong("worldgeneration.seed") || cfg.isInt("worldgeneration.seed")) &&
|
||||
|
||||
cfg.isString("spawn.spawnpoint.world") && cfg.isInt("spawn.gamemode")
|
||||
@ -55,10 +56,7 @@ public class PluginConfig {
|
||||
&& (cfg.isDouble("worldspawn.spawnpoint.y") || cfg.isInt("worldspawn.spawnpoint.y"))
|
||||
&& (cfg.isDouble("worldspawn.spawnpoint.z") || cfg.isInt("worldspawn.spawnpoint.z"))
|
||||
&& (cfg.isDouble("worldspawn.spawnpoint.yaw") || cfg.isInt("worldspawn.spawnpoint.yaw"))
|
||||
&& (cfg.isDouble("worldspawn.spawnpoint.pitch") || cfg.isInt("worldspawn.spawnpoint.pitch"))
|
||||
|
||||
//Should fix #2
|
||||
&& getSpawn().getWorld() != null)) {
|
||||
&& (cfg.isDouble("worldspawn.spawnpoint.pitch") || cfg.isInt("worldspawn.spawnpoint.pitch")))) {
|
||||
try {
|
||||
Files.copy(file.toPath(),
|
||||
new File(file.getParentFile(), "config-broken-"
|
||||
@ -80,6 +78,11 @@ public class PluginConfig {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Should fix #2
|
||||
if (getSpawn().getWorld() == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(getPrefix() + "§cWorld is null in spawn.world!");
|
||||
}
|
||||
}
|
||||
|
||||
private static YamlConfiguration getConfig() {
|
||||
|
@ -9,12 +9,22 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import de.butzlabben.world.GameProfileBuilder;
|
||||
|
||||
/**
|
||||
* This class represents a worldconfig.yml file
|
||||
* Here you can edit and read all things
|
||||
* Get an instance via WorldConfig.getWorldConfig()
|
||||
* @since 01.05.2018
|
||||
*/
|
||||
public class WorldConfig {
|
||||
|
||||
private static File getWorldFile(String worldname) {
|
||||
@ -59,11 +69,11 @@ public class WorldConfig {
|
||||
owner = UUID.fromString(worldname.substring(worldname.length() - 36));
|
||||
id = Integer.parseInt(worldname.split("-")[0].substring(2));
|
||||
}
|
||||
|
||||
|
||||
public static void create(Player p) {
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
String worldname = dc.getWorldname();
|
||||
File file = new File(PluginConfig.getWorlddir() + worldname + "/worldconfig.yml");
|
||||
File file = new File(PluginConfig.getWorlddir() + worldname + "/worldconfig.yml");
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e1) {
|
||||
@ -81,7 +91,7 @@ public class WorldConfig {
|
||||
cfg.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Error while saving worldconfig for " + p.getUniqueId().toString());
|
||||
System.err.println("Error while saving worldconfig for " + p.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +276,9 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Checks wheater a player can build or not
|
||||
* @param player to check
|
||||
*
|
||||
* @param player
|
||||
* to check
|
||||
* @return if the can build or not
|
||||
*/
|
||||
public boolean canBuild(UUID player) {
|
||||
@ -275,8 +287,11 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Allow or disallow a player to build on this world
|
||||
* @param player to edit
|
||||
* @param allowed if he is allowed to build
|
||||
*
|
||||
* @param player
|
||||
* to edit
|
||||
* @param allowed
|
||||
* if he is allowed to build
|
||||
*/
|
||||
public void setBuild(UUID player, boolean allowed) {
|
||||
if (allowed) {
|
||||
@ -287,10 +302,15 @@ public class WorldConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow or disallow a player to build with the permissions of a spefic player
|
||||
* @param player who gets his permission checked
|
||||
* @param target to allow or disallow
|
||||
* @param allowed if he is allowed to build
|
||||
* Allow or disallow a player to build with the permissions of a spefic
|
||||
* player
|
||||
*
|
||||
* @param player
|
||||
* who gets his permission checked
|
||||
* @param target
|
||||
* to allow or disallow
|
||||
* @param allowed
|
||||
* if he is allowed to build
|
||||
* @return if the player has the permissions
|
||||
*/
|
||||
public boolean setBuild(UUID player, UUID target, boolean allowed) {
|
||||
@ -307,7 +327,9 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Checks wheater a player can build on this world or not
|
||||
* @param player to check
|
||||
*
|
||||
* @param player
|
||||
* to check
|
||||
* @return if the player can build
|
||||
*/
|
||||
public boolean canGamemode(UUID player) {
|
||||
@ -316,8 +338,11 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Allow or disallow a player to change his gamemode
|
||||
* @param player to allow or disallow
|
||||
* @param allowed if he is allowed to change his gamemode or not
|
||||
*
|
||||
* @param player
|
||||
* to allow or disallow
|
||||
* @param allowed
|
||||
* if he is allowed to change his gamemode or not
|
||||
*/
|
||||
public void setGamemode(UUID player, boolean allowed) {
|
||||
if (allowed) {
|
||||
@ -340,8 +365,11 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Allow or disallow a player to teleport
|
||||
* @param player to allow or disallow
|
||||
* @param allowed if he is allowed to teleport or not
|
||||
*
|
||||
* @param player
|
||||
* to allow or disallow
|
||||
* @param allowed
|
||||
* if he is allowed to teleport or not
|
||||
*/
|
||||
public void setTeleport(UUID player, boolean allowed) {
|
||||
if (allowed) {
|
||||
@ -362,6 +390,25 @@ public class WorldConfig {
|
||||
return Sets.newHashSet(permissions.keySet());
|
||||
}
|
||||
|
||||
public HashMap<UUID, String> getMembersWithNames() {
|
||||
HashMap<UUID, String> map = new HashMap<>();
|
||||
for (UUID uuid : permissions.keySet()) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
if (op == null || op.getName() == null) {
|
||||
if (PluginConfig.contact_auth()) {
|
||||
try {
|
||||
GameProfile prof = GameProfileBuilder.fetch(uuid);
|
||||
map.put(uuid, prof.getName());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else
|
||||
map.put(uuid, op.getName());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public WorldConfig save() throws IOException {
|
||||
File file = getWorldFile(getWorldName());
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
@ -459,8 +506,10 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Allow or Disallow Fire Damage on this world
|
||||
* @param player
|
||||
* @param fire if fire is enabled
|
||||
*
|
||||
* @param player the player which toggles fire
|
||||
* @param fire
|
||||
* if fire is enabled
|
||||
* @return if the player has the permissions to change the value
|
||||
*/
|
||||
public boolean setFire(UUID player, boolean fire) {
|
||||
@ -480,8 +529,10 @@ public class WorldConfig {
|
||||
|
||||
/**
|
||||
* Allow or Disallow TNT Damage on this world
|
||||
* @param player
|
||||
* @param tnt if tnt is enabled
|
||||
*
|
||||
* @param player which toggles tnt
|
||||
* @param tnt
|
||||
* if tnt is enabled
|
||||
* @return if the player has the permissions to change the value
|
||||
*/
|
||||
public boolean setTnt(UUID player, boolean tnt) {
|
||||
@ -492,7 +543,9 @@ public class WorldConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the id of this world. The id is written in the filename at the xx position: 'IDxx-uuid.yml'
|
||||
* Get the id of this world. The id is written in the filename at the xx
|
||||
* position: 'IDxx-uuid.yml'
|
||||
*
|
||||
* @return id of this world
|
||||
*/
|
||||
public int getId() {
|
||||
|
@ -1,245 +0,0 @@
|
||||
package de.butzlabben.world.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import de.butzlabben.event.WorldToggleFireEvent;
|
||||
import de.butzlabben.event.WorldToggleTntEvent;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
|
||||
public class WorldConfig2 {
|
||||
|
||||
// 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");
|
||||
// }
|
||||
// return worldconfig;
|
||||
// }
|
||||
//
|
||||
// public static void saveConfig(YamlConfiguration cfg, File file) {
|
||||
// try {
|
||||
// cfg.save(file);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static HashMap<UUID, String> getMembersWithNames(String worldname) {
|
||||
// File file = getWorldFile(worldname);
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// if (cfg.getConfigurationSection("Members") == null)
|
||||
// return null;
|
||||
// HashMap<UUID, String> map = new HashMap<>();
|
||||
// for (String s : cfg.getConfigurationSection("Members").getKeys(false)) {
|
||||
// map.put(UUID.fromString(s), cfg.getString("Members." + s + ".Actualname"));
|
||||
// }
|
||||
// return map;
|
||||
// }
|
||||
//
|
||||
// public static UUID[] getMembers(String worldname) {
|
||||
// File file = getWorldFile(worldname);
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// Set<String> players = cfg.getConfigurationSection("Members").getKeys(false);
|
||||
// UUID[] uuids = new UUID[players.size()];
|
||||
// int i = 0;
|
||||
// for (String s : players) {
|
||||
// uuids[i] = UUID.fromString(s);
|
||||
// i++;
|
||||
// }
|
||||
// return uuids;
|
||||
// }
|
||||
//
|
||||
// public static boolean isMember(OfflinePlayer op, String worldname) {
|
||||
// File worldconfig = getWorldFile(worldname);
|
||||
// if (!worldconfig.exists())
|
||||
// return false;
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(worldconfig);
|
||||
// UUID uuid1 = UUID.fromString(cfg.getString("Informations.Owner.PlayerUUID"));
|
||||
// cfg.set("Informations.Owner.Actualname", Bukkit.getOfflinePlayer(uuid1).getName());
|
||||
// String uuid = op.getUniqueId().toString();
|
||||
// if (uuid.equals(cfg.getString("Members." + uuid + ".PlayerUUID"))) {
|
||||
// cfg.set("Members." + uuid + ".Actualname", op.getName());
|
||||
// saveConfig(cfg, worldconfig);
|
||||
// return true;
|
||||
// }
|
||||
// saveConfig(cfg, worldconfig);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// public void createConfig(Player p) {
|
||||
// String uuid = p.getUniqueId().toString();
|
||||
// DependenceConfig dc = new DependenceConfig(p);
|
||||
// File file = new File(PluginConfig.getWorlddir() + "ID" + dc.getID() + "-" + uuid + "/worldconfig.yml");
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e1) {
|
||||
// e1.printStackTrace();
|
||||
// System.err.println("Error while creating worldconfig for " + p.getName());
|
||||
// }
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// cfg.set("Informations.ID", dc.getID());
|
||||
// cfg.set("Informations.Owner.PlayerUUID", uuid);
|
||||
// cfg.set("Informations.Owner.Actualname", p.getName());
|
||||
// cfg.set("Settings.TNTDamage", false);
|
||||
// cfg.set("Settings.Fire", false);
|
||||
// cfg.set("Members", null);
|
||||
// try {
|
||||
// cfg.save(file);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// System.err.println("Error while saving worldconfig for " + p.getName());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static boolean hasPermission(UUID setter, UUID world, String permission) {
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// public static void addMember(Player owner, OfflinePlayer target) {
|
||||
// DependenceConfig dc = new DependenceConfig(owner);
|
||||
// String worldname = dc.getWorldname();
|
||||
// File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
// if (!file.exists()) {
|
||||
// worldname = dc.getWorldname();
|
||||
// file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
// }
|
||||
// if (!file.exists())
|
||||
// throw new IllegalArgumentException("This World does not exist");
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// String uuid = target.getUniqueId().toString();
|
||||
// cfg.set("Members." + uuid + ".PlayerUUID", uuid);
|
||||
// cfg.set("Members." + uuid + ".Actualname", target.getName());
|
||||
// cfg.set("Members." + uuid + ".Permissions.ChangeGM", true);
|
||||
// cfg.set("Members." + uuid + ".Permissions.CanBuild", true);
|
||||
// cfg.set("Members." + uuid + ".Permissions.CanTP", false);
|
||||
// saveConfig(cfg, file);
|
||||
// }
|
||||
//
|
||||
// public static void delMember(Player owner, OfflinePlayer target) {
|
||||
// DependenceConfig dc = new DependenceConfig(owner);
|
||||
// String worldname = dc.getWorldname();
|
||||
// File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
// if (!file.exists()) {
|
||||
// worldname = dc.getWorldname();
|
||||
// file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
// }
|
||||
// if (!file.exists())
|
||||
// throw new IllegalArgumentException("This world does not exist");
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// String uuid = target.getUniqueId().toString();
|
||||
// cfg.set("Members." + uuid, null);
|
||||
// try {
|
||||
// cfg.save(file);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void changeTnTDamage(Player p) {
|
||||
// DependenceConfig dc = new DependenceConfig(p);
|
||||
// if (!dc.hasWorld()) {
|
||||
// p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
// return;
|
||||
// }
|
||||
// String worldname = dc.getWorldname();
|
||||
// File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
// if (!file.exists()) {
|
||||
// worldname = dc.getWorldname();
|
||||
// file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
// }
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// WorldToggleTntEvent event = new WorldToggleTntEvent(p, SystemWorld.getSystemWorld(worldname),
|
||||
// cfg.getBoolean("Settings.TNTDamage"));
|
||||
// Bukkit.getPluginManager().callEvent(event);
|
||||
// if (event.isCancelled())
|
||||
// return;
|
||||
// if (cfg.getBoolean("Settings.TNTDamage")) {
|
||||
// cfg.set("Settings.TNTDamage", false);
|
||||
// p.sendMessage(MessageConfig.getToggleTntDisabled());
|
||||
// } else {
|
||||
// cfg.set("Settings.TNTDamage", true);
|
||||
// p.sendMessage(MessageConfig.getToggleTntEnabled());
|
||||
// }
|
||||
// try {
|
||||
// cfg.save(file);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void changeFireDamage(Player p) {
|
||||
// DependenceConfig dc = new DependenceConfig(p);
|
||||
// if (!dc.hasWorld()) {
|
||||
// p.sendMessage(MessageConfig.getNoWorldOwn());
|
||||
// return;
|
||||
// }
|
||||
// String worldname = dc.getWorldname();
|
||||
// File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
// if (!file.exists()) {
|
||||
// worldname = dc.getWorldname();
|
||||
// file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
// }
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// WorldToggleFireEvent event = new WorldToggleFireEvent(p, SystemWorld.getSystemWorld(worldname),
|
||||
// cfg.getBoolean("Settings.TNTDamage"));
|
||||
// Bukkit.getPluginManager().callEvent(event);
|
||||
// if (event.isCancelled())
|
||||
// return;
|
||||
// if (cfg.getBoolean("Settings.Fire")) {
|
||||
// cfg.set("Settings.Fire", false);
|
||||
// p.sendMessage(MessageConfig.getToggleFireDisabled());
|
||||
// } else {
|
||||
// cfg.set("Settings.Fire", true);
|
||||
// p.sendMessage(MessageConfig.getToggleFireEnabled());
|
||||
// }
|
||||
// try {
|
||||
// cfg.save(file);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public static void getInfos(Player p, String worldname) {
|
||||
// File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
// if (!file.exists())
|
||||
// return;
|
||||
// YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
// p.sendMessage(MessageConfig.getInfoOwner().replaceAll("%data", cfg.getString("Informations.Owner.Actualname")));
|
||||
// p.sendMessage(MessageConfig.getInfoId().replaceAll("%data", String.valueOf(cfg.getInt("Informations.ID"))));
|
||||
// p.sendMessage(MessageConfig.getInfoTnt().replaceAll("%data", cfg.getBoolean("Settings.TNTDamage")
|
||||
// ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
|
||||
// p.sendMessage(MessageConfig.getInfoFire().replaceAll("%data",
|
||||
// cfg.getBoolean("Settings.Fire") ? MessageConfig.getInfoEnabled() : MessageConfig.getInfoDisabled()));
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// if (cfg.getConfigurationSection("Members") != null) {
|
||||
// for (String s : cfg.getConfigurationSection("Members").getKeys(false)) {
|
||||
// if (s == null)
|
||||
// continue;
|
||||
// UUID uuid = UUID.fromString(s);
|
||||
// OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
// if (op == null || op.getName() == null) {
|
||||
// try {
|
||||
// GameProfile prof = de.butzlabben.world.GameProfileBuilder.fetch(uuid);
|
||||
// sb.append(prof.getName()).append(" ");
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// } else
|
||||
// sb.append(op.getName()).append(" ");
|
||||
//
|
||||
// }
|
||||
// p.sendMessage(MessageConfig.getInfoMember().replaceAll("%data", sb.toString().trim()));
|
||||
// }
|
||||
// }
|
||||
}
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.butzlabben.world.config.GuiConfig;
|
||||
import de.butzlabben.world.config.WorldConfig2;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.wrapper.SystemWorld;
|
||||
|
||||
/**
|
||||
@ -29,7 +29,7 @@ public class PlayersGUIManager {
|
||||
String worldname = p.getWorld().getName();
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
|
||||
if (sw != null) {
|
||||
HashMap<UUID, String> members = WorldConfig2.getMembersWithNames(worldname);
|
||||
HashMap<UUID, String> members = WorldConfig.getWorldConfig(worldname).getMembersWithNames();
|
||||
if (members == null || members.size() == 0)
|
||||
return null;
|
||||
int pages = Math.round(members.size() / headsPerInv) < 1 ? 1 : Math.round(members.size() / headsPerInv);
|
||||
@ -44,7 +44,7 @@ public class PlayersGUIManager {
|
||||
String worldname = p.getWorld().getName();
|
||||
SystemWorld sw = SystemWorld.getSystemWorld(worldname);
|
||||
if (sw != null) {
|
||||
HashMap<UUID, String> members = WorldConfig2.getMembersWithNames(worldname);
|
||||
HashMap<UUID, String> members = WorldConfig.getWorldConfig(worldname).getMembersWithNames();
|
||||
if (members == null || members.size() == 0)
|
||||
return null;
|
||||
|
||||
|
@ -12,6 +12,13 @@ import com.google.common.base.Preconditions;
|
||||
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
|
||||
/**
|
||||
* This class represents a player, on a systemworld or not
|
||||
* but be carefull when accesing some methods
|
||||
* when the player is not on a systemworld like toggleBuild()
|
||||
* @author Butzlabben
|
||||
* @since 15.03.2018
|
||||
*/
|
||||
public class WorldPlayer {
|
||||
|
||||
private OfflinePlayer p;
|
||||
|
Loading…
Reference in New Issue
Block a user