mirror of
https://github.com/trainerlord/WorldSystem.git
synced 2024-11-30 13:03:23 +01:00
Added in config contact_auth option. WorldPlayer is now on WorldConfig
This commit is contained in:
parent
ce19aad211
commit
c22c9b78db
@ -34,6 +34,11 @@ language: en
|
||||
# Prefix which will be shown before each message
|
||||
prefix: '&8[&3WorldSystem&8] &6'
|
||||
|
||||
# Whether WorldSystem should contact the Mojang authserver
|
||||
# If not, some unknown playernames will not be displayed
|
||||
# eg. in the gui or in /ws info
|
||||
contact_authserver: true
|
||||
|
||||
# Options for the LagSystem:
|
||||
# period_in_seconds - how often will be checked for entities in seconds
|
||||
# entities_per_world - maximal allowed entities per world
|
||||
|
@ -34,6 +34,11 @@ language: en
|
||||
# Prefix which will be shown before each message
|
||||
prefix: '&8[&3WorldSystem&8] &6'
|
||||
|
||||
# Whether WorldSystem should contact the Mojang authserver
|
||||
# If not, some unknown playernames will not be displayed
|
||||
# eg. in the gui or in /ws info
|
||||
contact_authserver: true
|
||||
|
||||
# Options for the LagSystem:
|
||||
# period_in_seconds - how often will be checked for entities in seconds
|
||||
# entities_per_world - maximal allowed entities per world
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
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 WSToggleBuildCommand implements CommandExecutor {
|
||||
@ -32,7 +32,8 @@ public class WSToggleBuildCommand implements CommandExecutor {
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!WorldConfig2.isMember(a, dc.getWorldname())) {
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return true;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
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 WSToggleGMCommand implements CommandExecutor {
|
||||
@ -20,9 +20,10 @@ public class WSToggleGMCommand implements CommandExecutor {
|
||||
if (!(cs instanceof Player))
|
||||
return true;
|
||||
Player p = (Player) cs;
|
||||
if(args.length != 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage", WorldSystem.getInstance().getCommand("ws togglegm").getUsage()));
|
||||
return true;
|
||||
if (args.length != 2) {
|
||||
p.sendMessage(MessageConfig.getWrongUsage().replaceAll("%usage",
|
||||
WorldSystem.getInstance().getCommand("ws togglegm").getUsage()));
|
||||
return true;
|
||||
}
|
||||
DependenceConfig dc = new DependenceConfig(p);
|
||||
if (!dc.hasWorld()) {
|
||||
@ -31,7 +32,8 @@ public class WSToggleGMCommand implements CommandExecutor {
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!WorldConfig2.isMember(a, dc.getWorldname())) {
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return true;
|
||||
}
|
||||
@ -44,4 +46,3 @@ public class WSToggleGMCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import de.butzlabben.world.WorldSystem;
|
||||
import de.butzlabben.world.config.DependenceConfig;
|
||||
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 WSToggleTPCommand implements CommandExecutor {
|
||||
@ -32,7 +32,8 @@ public class WSToggleTPCommand implements CommandExecutor {
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer a = Bukkit.getOfflinePlayer(args[1]);
|
||||
if (!WorldConfig2.isMember(a, dc.getWorldname())) {
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(dc.getWorldname());
|
||||
if (wc.isMember(a.getUniqueId())) {
|
||||
p.sendMessage(MessageConfig.getNoMemberOwn());
|
||||
return true;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ 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.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")
|
||||
@ -196,4 +196,7 @@ public class PluginConfig {
|
||||
return getConfig().getBoolean("need_confirm", true);
|
||||
}
|
||||
|
||||
public static boolean contact_auth() {
|
||||
return getConfig().getBoolean("contact_authserver", true);
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,6 @@ public class WorldConfig {
|
||||
fire = cfg.getBoolean("Settings.Fire", true);
|
||||
|
||||
if (membersOldFormatted(cfg)) {
|
||||
System.out.println("sfdjkl");
|
||||
for (String s : cfg.getConfigurationSection("Members").getKeys(false)) {
|
||||
HashSet<WorldPerm> perms = new HashSet<>();
|
||||
perms.add(WorldPerm.MEMBER);
|
||||
|
@ -3,6 +3,7 @@ package de.butzlabben.world.wrapper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import de.butzlabben.event.WorldCreateEvent;
|
||||
@ -22,7 +24,6 @@ import de.butzlabben.world.config.DependenceConfig;
|
||||
import de.butzlabben.world.config.MessageConfig;
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
import de.butzlabben.world.config.WorldConfig2;
|
||||
|
||||
/**
|
||||
* This class represents a systemworld, loaded or not
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import de.butzlabben.world.config.PluginConfig;
|
||||
import de.butzlabben.world.config.WorldConfig;
|
||||
|
||||
public class WorldPlayer {
|
||||
|
||||
@ -30,24 +30,20 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean toggleBuild() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
if (!file.exists()) {
|
||||
file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
}
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (cfg.getString("Members." + uuid + ".PlayerUUID") == null)
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
if (!wc.isMember(p.getUniqueId()))
|
||||
return false;
|
||||
|
||||
boolean teleport = cfg.getBoolean("Members." + uuid + ".Permissions.CanBuild");
|
||||
teleport = !teleport;
|
||||
cfg.set("Members." + uuid + ".Permissions.CanBuild", teleport);
|
||||
boolean build = wc.canBuild(p.getUniqueId());
|
||||
build = !build;
|
||||
wc.setBuild(p.getUniqueId(), build);
|
||||
try {
|
||||
cfg.save(file);
|
||||
wc.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return teleport;
|
||||
return build;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,11 +51,8 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean canBuild() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
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");
|
||||
return b;
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.canBuild(p.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,20 +61,16 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean toggleTeleport() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
if (!file.exists()) {
|
||||
file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
}
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (cfg.getString("Members." + uuid + ".PlayerUUID") == null)
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
if (!wc.isMember(p.getUniqueId()))
|
||||
return false;
|
||||
|
||||
boolean teleport = cfg.getBoolean("Members." + uuid + ".Permissions.CanTP");
|
||||
boolean teleport = wc.canTeleport(p.getUniqueId());
|
||||
teleport = !teleport;
|
||||
cfg.set("Members." + uuid + ".Permissions.CanTP", teleport);
|
||||
wc.setTeleport(p.getUniqueId(), teleport);
|
||||
try {
|
||||
cfg.save(file);
|
||||
wc.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -93,11 +82,8 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean canTeleport() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
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.CanTP");
|
||||
return b;
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.canTeleport(p.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,20 +92,17 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean toggleGamemode() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
File file = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
if (!file.exists()) {
|
||||
file = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
}
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(file);
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (cfg.getString("Members." + uuid + ".PlayerUUID") == null)
|
||||
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
if (!wc.isMember(p.getUniqueId()))
|
||||
return false;
|
||||
|
||||
boolean changeGamemode = cfg.getBoolean("Members." + uuid + ".Permissions.ChangeGM");
|
||||
boolean changeGamemode = wc.canGamemode(p.getUniqueId());
|
||||
changeGamemode = !changeGamemode;
|
||||
cfg.set("Members." + uuid + ".Permissions.ChangeGM", changeGamemode);
|
||||
wc.setGamemode(p.getUniqueId(), changeGamemode);
|
||||
try {
|
||||
cfg.save(file);
|
||||
wc.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -131,11 +114,8 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean canChangeGamemode() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
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.ChangeGM");
|
||||
return b;
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.canGamemode(p.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,22 +123,9 @@ public class WorldPlayer {
|
||||
*/
|
||||
public boolean isMember() {
|
||||
Preconditions.checkArgument(isOnSystemWorld(), "player must be for this on a systemworld");
|
||||
File worldconfig = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
if (!worldconfig.exists()) {
|
||||
worldconfig = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
}
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(worldconfig);
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (uuid.equals(cfg.getString("Members." + uuid + ".PlayerUUID"))) {
|
||||
cfg.set("Members." + uuid + ".Actualname", p.getName());
|
||||
try {
|
||||
cfg.save(worldconfig);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.isMember(p.getUniqueId());
|
||||
}
|
||||
|
||||
public WorldPlayer(OfflinePlayer p, String worldname) {
|
||||
@ -197,20 +164,8 @@ public class WorldPlayer {
|
||||
* @return if he ist the owner
|
||||
*/
|
||||
public boolean isOwnerofWorld() {
|
||||
File worldconfig = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(worldconfig);
|
||||
if (p.getUniqueId().toString().equals(cfg.getString("Informations.Owner.PlayerUUID"))) {
|
||||
String playerName = p.getName();
|
||||
cfg.set("Informations.Owner.Actualname", playerName);
|
||||
try {
|
||||
cfg.save(worldconfig);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.getOwner().equals(p.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,16 +173,8 @@ public class WorldPlayer {
|
||||
* @return worldname if he is the owner of the specified world
|
||||
*/
|
||||
public boolean isMemberofWorld(String worldname) {
|
||||
File worldconfig = new File(Bukkit.getWorldContainer(), worldname + "/worldconfig.yml");
|
||||
if (!worldconfig.exists()) {
|
||||
worldconfig = new File(PluginConfig.getWorlddir() + "/" + worldname + "/worldconfig.yml");
|
||||
}
|
||||
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(worldconfig);
|
||||
String uuid = p.getUniqueId().toString();
|
||||
if (uuid.equals(cfg.getString("Members." + uuid + ".PlayerUUID"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
WorldConfig wc = WorldConfig.getWorldConfig(worldname);
|
||||
return wc.isMember(p.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user