Added /ws sethome command

Changes in  settings.yml and messages.yml
This commit is contained in:
BuildTools 2018-08-14 15:08:57 +02:00
parent 1726bb60ef
commit 2ab15b12a6
29 changed files with 172 additions and 26 deletions

View File

@ -19,6 +19,7 @@ world:
setting_up: ""
playerlist: "%players"
still_creating: ""
set_home: ""
member:
removed: "%player"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aBereite Welt vor..."
playerlist: "Spieler in der Welt: %players"
still_creating: "&cWelt wird noch erstellt..."
set_home: "Du hast das Home gesetzt"
member:
removed: "Du hast &c%player&6 von deiner Welt entfernt!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Gibt dir eine Welt"
- "/ws home &8- &7Teleportiert dich auf deine Welt"
- "/ws sethome &8- &7Setzt ein bestimmtes Home"
- "/ws gui &8- &7\u00f6ffnets das GUI-Menu wenn du der Weltenbesitzer bist"
- "/ws tp &8- &7Teleportiert dich auf eine bestimmte Welt"
- "/ws addmember &8- &7F\u00fcgt jemanden zu deiner Welt hinzu"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aLoading world..."
playerlist: "Players in this world: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "You removed &c%player&6 from your world!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the world owner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aConfigurando el mundo..."
playerlist: "Jugadores en este mundo: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Has eliminado a &c%player&6 de tu mundo."
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Obten tu mundo"
- "/ws home &8- &7Ve a tu mundo"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Abre el menu de tu mundo"
- "/ws tp &8- &7Ve a un mundo especifico"
- "/ws addmember &8- &7Agrega jugadores a tu mundo"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aA világ megteremtése..."
playerlist: "Játékos ebben a világban: %player"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Törölted &c%player&6 játékost a világodból!"
@ -68,6 +69,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the worldowner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aWereld word aangemaakt"
playerlist: "speler is in wereld: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Jij hebt &c%player&6 verwijderd van jouw wereld!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the worldowner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aUstawianie świata..."
playerlist: "Gracze na tym świecie: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Usunąłeś &c%player&6 ze swojego świata!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Tworzy Twój świat"
- "/ws home &8- &7Teleportuje Cie na Twój świat"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Otwiera GUI świata jeżeli jesteś jego właścicielem"
- "/ws tp &8- &7Teleportuje Cie na określony świat"
- "/ws addmember &8- &7Dodaj gracza na swój świat"

View File

@ -1,5 +1,5 @@
name: WorldSystem
version: 2.3.1
version: 2.3.1.1
author: Butzlabben
main: de.butzlabben.world.WorldSystem
@ -18,6 +18,9 @@ commands:
usage: /ws help
ws home:
usage: /ws home
ws sethome:
usage: /ws sethome
permission: ws.sethome
ws addmember:
usage: /ws addmember <player>
ws delmember:
@ -66,6 +69,9 @@ permissions:
ws.big: true
ws.large: true
ws.confirm: true
ws.sethome:
default: true
description: 'You can set a different worldspawn'
ws.tp.*:
default: op
description: You can teleport everything

View File

@ -14,6 +14,8 @@ worldborder:
# Set a specialized center which is not the spawn
center:
as_spawn: true
# Should the worldborder move with the home set by the owner
as_home: false
x: 0
y: 20
z: 0

View File

@ -19,6 +19,7 @@ world:
setting_up: ""
playerlist: "%players"
still_creating: ""
set_home: ""
member:
removed: "%player"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aBereite Welt vor..."
playerlist: "Spieler in der Welt: %players"
still_creating: "&cWelt wird noch erstellt..."
set_home: "Du hast das Home gesetzt"
member:
removed: "Du hast &c%player&6 von deiner Welt entfernt!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Gibt dir eine Welt"
- "/ws home &8- &7Teleportiert dich auf deine Welt"
- "/ws sethome &8- &7Setzt ein bestimmtes Home"
- "/ws gui &8- &7\u00f6ffnets das GUI-Menu wenn du der Weltenbesitzer bist"
- "/ws tp &8- &7Teleportiert dich auf eine bestimmte Welt"
- "/ws addmember &8- &7F\u00fcgt jemanden zu deiner Welt hinzu"

View File

@ -24,6 +24,7 @@ import de.butzlabben.world.command.WSHomeCommand;
import de.butzlabben.world.command.WSInfoCommand;
import de.butzlabben.world.command.WSLeaveCommand;
import de.butzlabben.world.command.WSResetCommand;
import de.butzlabben.world.command.WSSethomeCommand;
import de.butzlabben.world.command.WSTPCommand;
import de.butzlabben.world.command.WSTnTCommand;
import de.butzlabben.world.command.WSToggleBuildCommand;
@ -106,6 +107,8 @@ public class WorldSystem extends JavaPlugin {
getCommand("ws addmember").setExecutor(new WSAddmemberCommand());
getCommand("ws delmember").setExecutor(new WSDelmemberCommand());
getCommand("ws home").setExecutor(new WSHomeCommand());
// Here we go for #20 and #22
getCommand("ws sethome").setExecutor(new WSSethomeCommand());
getCommand("ws leave").setExecutor(new WSLeaveCommand());
getCommand("ws fire").setExecutor(new WSFireCommand());
getCommand("ws info").setExecutor(new WSInfoCommand());

View File

@ -31,6 +31,7 @@ public class WSCommand implements CommandExecutor, TabCompleter {
list.add("info");
list.add("leave");
list.add("reset");
list.add("sethome");
list.add("tnt");
list.add("togglegm");
list.add("toggletp");
@ -82,6 +83,10 @@ public class WSCommand implements CommandExecutor, TabCompleter {
if (!(cs instanceof Player))
return true;
WorldSystem.getInstance().getCommand("ws home").execute(cs, label, args);
} else if (subcommand.equals("sethome")) {
if (!(cs instanceof Player))
return true;
WorldSystem.getInstance().getCommand("ws sethome").execute(cs, label, args);
} else if (subcommand.equals("leave")) {
WorldSystem.getInstance().getCommand("ws leave").execute(cs, label, args);
} else if (subcommand.equals("info")) {

View File

@ -0,0 +1,43 @@
package de.butzlabben.world.command;
import java.io.IOException;
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.WorldConfig;
import de.butzlabben.world.wrapper.WorldPlayer;
/**
* @author Butzlabben
* @since 14.08.2018
*/
public class WSSethomeCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender cs, Command cmd, String arg2, String[] args) {
Player p = (Player) cs;
WorldPlayer wp = new WorldPlayer(p);
if (!wp.isOnSystemWorld()) {
p.sendMessage(MessageConfig.getNotOnWorld());
return true;
}
if (!wp.isOwnerofWorld()) {
p.sendMessage(MessageConfig.getNoPermission());
return true;
}
WorldConfig config = WorldConfig.getWorldConfig(p.getWorld().getName());
config.setHome(p.getLocation());
try {
config.save();
p.sendMessage(MessageConfig.getHomeSet());
} catch (IOException e) {
p.sendMessage(MessageConfig.getUnknownError() + ": " + e.getMessage());
e.printStackTrace();
}
return true;
}
}

View File

@ -27,6 +27,7 @@ public class MessageConfig {
{
defaultCmdHelp.add("/ws get §8- §7Will give you a World");
defaultCmdHelp.add("/ws home §8- §7Teleports you on your World");
defaultCmdHelp.add("/ws sethome §8- §7Sets a specific home");
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 delmember§8 - §7Removes a player from your World");
@ -271,4 +272,8 @@ public class MessageConfig {
list = list.stream().map(s -> ChatColor.translateAlternateColorCodes('&', s)).collect(Collectors.toList());
return list;
}
public static String getHomeSet() {
return getMessage("world.set_home", "You set the home");
}
}

View File

@ -61,6 +61,11 @@ public class SettingsConfig {
cfg.getDouble("worldborder.center.y", 20), cfg.getDouble("worldborder.center.z", 0));
w.getWorldBorder().setCenter(loc);
}
if (cfg.getBoolean("worldborder.center.as_home")) {
WorldConfig config = WorldConfig.getWorldConfig(w.getName());
if (config.getHome() != null)
w.getWorldBorder().setCenter(config.getHome());
}
}
if (w.isGameRule("announceAdvancements"))
@ -138,7 +143,8 @@ public class SettingsConfig {
private static YamlConfiguration getConfig() {
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) {
e.printStackTrace();
}

View File

@ -9,6 +9,7 @@ import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
@ -20,9 +21,9 @@ 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()
* 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 {
@ -41,7 +42,8 @@ public class WorldConfig {
/**
* Returns wether a worldconfig exists for this worldname
*
* @param worldname name of the world
* @param worldname
* name of the world
* @return Wether this world has a worldconfig
*/
public static boolean exists(String worldname) {
@ -72,6 +74,8 @@ public class WorldConfig {
private String ownerName;
private boolean fire, tnt;
private Location home = null;
private WorldConfig(String worldname) {
if (exists(worldname) == false)
throw new IllegalArgumentException("WorldConfig doesn't exist");
@ -428,6 +432,14 @@ public class WorldConfig {
cfg.set("Settings.TNTDamage", tnt);
cfg.set("Settings.Fire", fire);
if (home != null) {
cfg.set("Settings.home.x", home.getX());
cfg.set("Settings.home.y", home.getY());
cfg.set("Settings.home.z", home.getZ());
cfg.set("Settings.home.yaw", home.getYaw());
cfg.set("Settings.home.pitch", home.getPitch());
}
cfg.set("Members", null);
for (java.util.Map.Entry<UUID, HashSet<WorldPerm>> entry : permissions.entrySet()) {
@ -455,6 +467,12 @@ public class WorldConfig {
tnt = cfg.getBoolean("Settings.TNTDamage", true);
fire = cfg.getBoolean("Settings.Fire", true);
if (cfg.isSet("Settings.home")) {
home = new Location(null, cfg.getDouble("Settings.home.x"), cfg.getDouble("Settings.home.y"),
cfg.getDouble("Settings.home.z"), (float) cfg.getDouble("Settings.home.yaw"),
(float) cfg.getDouble("Settings.home.pitch"));
}
if (membersOldFormatted(cfg)) {
for (String s : cfg.getConfigurationSection("Members").getKeys(false)) {
HashSet<WorldPerm> perms = new HashSet<>();
@ -497,6 +515,23 @@ public class WorldConfig {
return name != null;
}
/**
* @param loc the new home of the world
*/
public void setHome(Location loc) {
home = loc;
}
/**
* @return the home of the world. If not set returns null
*/
public Location getHome() {
if (home == null)
return null;
return new Location(Bukkit.getWorld(getWorldName()), home.getX(), home.getY(), home.getZ(), home.getYaw(),
home.getPitch());
}
public String getOwnerName() {
return ownerName;
}
@ -516,7 +551,8 @@ public class WorldConfig {
/**
* Allow or Disallow Fire Damage on this world
*
* @param player the player which toggles fire
* @param player
* the player which toggles fire
* @param fire
* if fire is enabled
* @return if the player has the permissions to change the value
@ -539,7 +575,8 @@ public class WorldConfig {
/**
* Allow or Disallow TNT Damage on this world
*
* @param player which toggles tnt
* @param player
* which toggles tnt
* @param tnt
* if tnt is enabled
* @return if the player has the permissions to change the value

View File

@ -96,7 +96,6 @@ public class SystemWorld {
});
return;
}
Preconditions.checkNotNull(w, "world must not be null");
unloading = true;
w.save();
@ -252,16 +251,8 @@ public class SystemWorld {
w = Bukkit.createWorld(creator);
this.w = w;
if (PluginConfig.isSurvival()) {
p.setGameMode(GameMode.SURVIVAL);
} else {
p.setGameMode(GameMode.CREATIVE);
}
if (PluginConfig.useWorldSpawn()) {
p.teleport(PluginConfig.getWorldSpawn(w));
} else {
p.teleport(w.getSpawnLocation());
}
teleportToWorldSpawn(p);
OfflinePlayer owner = Bukkit.getOfflinePlayer(WorldConfig.getWorldConfig(worldname).getOwner());
DependenceConfig dc = new DependenceConfig(owner);
@ -392,11 +383,16 @@ public class SystemWorld {
if (w == null)
return;
WorldConfig config = WorldConfig.getWorldConfig(worldname);
if (config.getHome() != null) {
p.teleport(config.getHome());
} else {
if (PluginConfig.useWorldSpawn()) {
p.teleport(PluginConfig.getWorldSpawn(w));
} else {
p.teleport(w.getSpawnLocation());
}
}
if (PluginConfig.isSurvival()) {
p.setGameMode(GameMode.SURVIVAL);
} else {

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aLoading world..."
playerlist: "Players in this world: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "You removed &c%player&6 from your world!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the world owner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aConfigurando el mundo..."
playerlist: "Jugadores en este mundo: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Has eliminado a &c%player&6 de tu mundo."
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Obten tu mundo"
- "/ws home &8- &7Ve a tu mundo"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Abre el menu de tu mundo"
- "/ws tp &8- &7Ve a un mundo especifico"
- "/ws addmember &8- &7Agrega jugadores a tu mundo"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aAlustetaan maailmaa..."
playerlist: "Pelaajat tässä maailmassa: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Poistit pelaajan &c%player&6 maailmastasi!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Luo sinulle maailman"
- "/ws home &8- &7Teleporttaa sinut maailmaasi"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Avaa sinulle valikon jos omistat tämän maailman"
- "/ws tp &8- &7Teleporttaa sinut tiettyyn maailmaan"
- "/ws addmember &8- &7Lisää pelaajan sinun maailmaasi"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aChargement du monde ..."
playerlist: "Joueurs dans ce monde: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Vous avez supprimé &c%player&6 de votre monde!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Je vais vous donner un monde"
- "/ws home &8- &7Vous téléporte sur votre monde"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Ouvre le menu de l'interface graphique si vous êtes le propriétaire mondial"
- "/ws tp &8- &7Vous téléporte sur un monde spécifique"
- "/ws addmember &8- &7Ajoute un joueur à ton monde"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aA világ megteremtése..."
playerlist: "Játékos ebben a világban: %player"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Törölted &c%player&6 játékost a világodból!"
@ -68,6 +69,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the worldowner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aWereld word aangemaakt"
playerlist: "speler is in wereld: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Jij hebt &c%player&6 verwijderd van jouw wereld!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Will give you a world"
- "/ws home &8- &7Teleports you on your world"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Opens the GUI menu if you are the worldowner"
- "/ws tp &8- &7Teleports you on a specific world"
- "/ws addmember &8- &7Adds a player to your world"

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aUstawianie świata..."
playerlist: "Gracze na tym świecie: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Usunąłeś &c%player&6 ze swojego świata!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Tworzy Twój świat"
- "/ws home &8- &7Teleportuje Cie na Twój świat"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Otwiera GUI świata jeżeli jesteś jego właścicielem"
- "/ws tp &8- &7Teleportuje Cie na określony świat"
- "/ws addmember &8- &7Dodaj gracza na swój świat"

View File

@ -1,5 +1,5 @@
name: WorldSystem
version: 2.3.1
version: 2.3.1.1
author: Butzlabben
main: de.butzlabben.world.WorldSystem
@ -18,6 +18,9 @@ commands:
usage: /ws help
ws home:
usage: /ws home
ws sethome:
usage: /ws sethome
permission: ws.sethome
ws addmember:
usage: /ws addmember <player>
ws delmember:
@ -66,6 +69,9 @@ permissions:
ws.big: true
ws.large: true
ws.confirm: true
ws.sethome:
default: true
description: 'You can set a different worldspawn'
ws.tp.*:
default: op
description: You can teleport everything

View File

@ -19,6 +19,7 @@ world:
setting_up: "&aПриготовлеваю мир..."
playerlist: "Игроков в мире: %players"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "Ты удалил &c%player&6 из твоего мира!"
@ -67,6 +68,7 @@ command_help:
list:
- "/ws get &8- &7Даст тебе мир"
- "/ws home &8- &7Телепортирует тебя в твой мир"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7Открывает ГИП если ты владелец этого мира"
- "/ws tp &8- &7Телепортирует тебя в определенный мир"
- "/ws addmember &8- &7Добавляет кого-то к твоему миру"

View File

@ -14,6 +14,8 @@ worldborder:
# Set a specialized center which is not the spawn
center:
as_spawn: true
# Should the worldborder move with the home set by the owner
as_home: false
x: 0
y: 20
z: 0

View File

@ -18,6 +18,8 @@ world:
other: "&c这个玩家没有世界!"
setting_up: "&a正在建立世界..."
playerlist: "玩家: %players 在这个世界上"
still_creating: "&cWorld is still creating"
set_home: "You set the home"
member:
removed: "玩家 &c%player&6 从你的世界移除!"
@ -65,6 +67,7 @@ command_help:
list:
- "/ws get &8- &7创建一个世界"
- "/ws home &8- &7返回你的世界"
- "/ws sethome &8- &7Sets a specific home"
- "/ws gui &8- &7如果你是世界管理者,使用该指令打开菜单"
- "/ws tp &8- &7传送到指定世界"
- "/ws addmember &8- &7添加一个玩家到你的世界"