Add Config query database
Fix BauInfoBauGuiItem Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
e127e15304
Commit
1c143f43da
@ -105,10 +105,11 @@ BAU_UNKNOWN-PLAYER = §cUnbekannter Spieler
|
||||
BAU_NO-PLAYER = §cDer Spieler ist kein Mitglied deiner Welt!
|
||||
BAU_NO-WORLD = §cDies ist nicht deine Welt!
|
||||
|
||||
BAU_INFO_ITEM_NAME = §eBau management
|
||||
BAU-INFO_ITEM_NAME = §eBau management
|
||||
## This is used in BauInfoBauGuiItem.java
|
||||
BAU-INFO_ITEM_LORE-TNT = §7TNT §8: §e{0}
|
||||
BAU-INFO_ITEM_LORE-FREEZE = §7Freeze §8: §e{0}
|
||||
BAU-INFO_ITEM_LORE-DAMAGE = §7Damage §8: §e{0}
|
||||
BAU-INFO_ITEM_LORE-FIRE = §7Feuer §8: §e{0}
|
||||
BAU-INFO_ITEM_LORE-COLOR = §7Farbe §8: §e{0}
|
||||
BAU-INFO_ITEM_LORE-PROTECT = §7Protect §8: §e{0}
|
||||
|
@ -2,6 +2,7 @@ package de.steamwar.bausystem.configplayer;
|
||||
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.sql.UserConfig;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,6 +10,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import yapion.hierarchy.output.StringOutput;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
import yapion.parser.YAPIONParser;
|
||||
|
||||
@ -55,14 +57,14 @@ public class Config implements Listener {
|
||||
public YAPIONObject get(Player player) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (!playerConfigurations.containsKey(uuid)) {
|
||||
// TODO: Load call -> Database
|
||||
String s = null;
|
||||
String s = UserConfig.getConfig(uuid, "bausystem");
|
||||
YAPIONObject yapionObject;
|
||||
if (s == null) {
|
||||
yapionObject = ConfigCreator.createDefaultConfig();
|
||||
} else {
|
||||
yapionObject = YAPIONParser.parse(s);
|
||||
}
|
||||
yapionObject = update(yapionObject);
|
||||
playerConfigurations.put(uuid, yapionObject);
|
||||
return yapionObject;
|
||||
}
|
||||
@ -75,7 +77,12 @@ public class Config implements Listener {
|
||||
* @param player the player to save the config.
|
||||
*/
|
||||
public void save(Player player) {
|
||||
// TODO: Save call -> Database
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (playerConfigurations.containsKey(uuid)) {
|
||||
YAPIONObject yapionObject = playerConfigurations.get(uuid);
|
||||
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
||||
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||
}
|
||||
}
|
||||
|
||||
private YAPIONObject update(YAPIONObject yapionObject) {
|
||||
|
@ -46,7 +46,7 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
||||
@Override
|
||||
public ItemStack getItem(Player player) {
|
||||
SWItem itemStack = SWItem.getPlayerSkull(SteamwarUser.get(BauServer.getInstance().getOwner()).getUserName());
|
||||
itemStack.setName(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_NAME", player));
|
||||
itemStack.setName(BauSystem.MESSAGE.parse("BAU-INFO_ITEM_NAME", player));
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
List<String> stringList = new ArrayList<>();
|
||||
for (Flag flag : Flag.getFlags()) {
|
||||
@ -55,7 +55,7 @@ public class BauInfoBauGuiItem extends BauGuiItem {
|
||||
}
|
||||
Flag.Value<?> value = region.get(flag);
|
||||
if (value != null) {
|
||||
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE-" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));
|
||||
stringList.add(BauSystem.MESSAGE.parse("BAU-INFO_ITEM_LORE-" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player)));
|
||||
}
|
||||
}
|
||||
itemStack.setLore(stringList);
|
||||
|
@ -35,6 +35,6 @@ public class CountingwandCommand extends SWCommand {
|
||||
|
||||
@Register
|
||||
public void genericCommand(final Player p) {
|
||||
SWUtils.giveItemToPlayer(p, Countingwand.WAND_ITEM);
|
||||
SWUtils.giveItemToPlayer(p, Countingwand.getWandItem(p));
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren