Merge remote-tracking branch 'origin/master'
Dieser Commit ist enthalten in:
Commit
8f26a96baa
@ -21,30 +21,23 @@ package de.steamwar.bausystem.features.detonator;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
public enum Detoblock {
|
public enum Detoblock {
|
||||||
SWITCH(0, true, "Hebel"),
|
SWITCH(0, true, "DETONATOR_BUTTON_SWITCH"),
|
||||||
WOOD_BUTTON(30, "Knopf"),
|
WOOD_BUTTON(30, "DETONATOR_BUTTON_WOOD-Button"),
|
||||||
STONE_BUTTON(20, "Knopf"),
|
STONE_BUTTON(20, "DETONATOR_BUTTON_STONE-Button"),
|
||||||
PRESSURE_PLATE(30, "Druckplatte"),
|
PRESSURE_PLATE(30, "DETONATOR_BUTTON_PRESSURE-PLATE"),
|
||||||
WEIGHTED_PRESSURE_PLATE(20, "Druckplatte"),
|
WEIGHTED_PRESSURE_PLATE(20, "DETONATOR_BUTTON_WEIGHTED-PRESSURE-PLATE"),
|
||||||
TRIPWIRE(30, "Tripwire"),
|
TRIPWIRE(30, "DETONATOR_BUTTON_TRIPWIRE"),
|
||||||
NOTEBLOCK(1, "Noteblock"),
|
NOTEBLOCK(1, "DETONATOR_BUTTON_NOTEBLOCK"),
|
||||||
DAYLIGHTSENSOR(0, true, "Tageslichtsensor"),
|
DAYLIGHTSENSOR(0, true, "DETONATOR_BUTTON_DAYLIGHTSENSOR"),
|
||||||
POWERABLE(0, true, "Aktivierbarer Block"),
|
INVALID(-1, "DETONATOR_BUTTON_INVALID");
|
||||||
INVALID(-1, "Invalider");
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int time;
|
private final int time;
|
||||||
@Getter
|
private boolean toggle;
|
||||||
private final boolean toggle;
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
Detoblock(int time, String name) {
|
|
||||||
this.time = time;
|
|
||||||
this.name = name;
|
|
||||||
toggle = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@ BAU-INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Gibt Informationen über den Bau
|
|||||||
BAU-INFO_COMMAND_OWNER = §7Besitzer: §e{0}
|
BAU-INFO_COMMAND_OWNER = §7Besitzer: §e{0}
|
||||||
BAU-INFO_COMMAND_MEMBER = §7Mitglieder: §e
|
BAU-INFO_COMMAND_MEMBER = §7Mitglieder: §e
|
||||||
BAU-INFO_COMMAND_FLAG = §e{0} §8: §7{1}
|
BAU-INFO_COMMAND_FLAG = §e{0} §8: §7{1}
|
||||||
|
BAU-INFO_COMMAND_TPS = TPS:§e
|
||||||
|
|
||||||
# Countingwand
|
# Countingwand
|
||||||
COUNTINGWAND_ITEM_NAME = §eZollstock
|
COUNTINGWAND_ITEM_NAME = §eZollstock
|
||||||
@ -127,17 +128,30 @@ COUNTINGWAND_MESSAGE_R-CLICK = §7Erste Position bei: §8[§7{0}§8, §7{1}§8,
|
|||||||
COUNTINGWAND_MESSAGE_L-CLICK = §7Zweite Position bei: §8[§7{0}§8, §7{1}§8, §7{2}§8] ({3})
|
COUNTINGWAND_MESSAGE_L-CLICK = §7Zweite Position bei: §8[§7{0}§8, §7{1}§8, §7{2}§8] ({3})
|
||||||
COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2}
|
COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2}
|
||||||
|
|
||||||
|
# Detonator
|
||||||
|
DETONATOR_LOC_REMOVE = §e{0} entfernt
|
||||||
|
DETONATOR_LOC_ADD = §e{0} hinzugefügt
|
||||||
|
DETONATOR_BUTTON_SWITCH = Hebel
|
||||||
|
DETONATOR_BUTTON_WOOD-Button = Knopf
|
||||||
|
DETONATOR_BUTTON_STONE-Button = Knopf
|
||||||
|
DETONATOR_BUTTON_PRESSURE-PLATE = Druckplatte
|
||||||
|
DETONATOR_BUTTON_WEIGHTED-PRESSURE-PLATE = Druckplatte
|
||||||
|
DETONATOR_BUTTON_TRIPWIRE = Tripwire
|
||||||
|
DETONATOR_BUTTON_NOTEBLOCK = Noteblock
|
||||||
|
DETONATOR_BUTTON_DAYLIGHTSENSOR = Tageslichtsensor
|
||||||
|
DETONATOR_BUTTON_INVALID = Invalider
|
||||||
|
|
||||||
# Hotbar
|
# Hotbar
|
||||||
HOTBAR_SAVED = §7Deine Hotbar wurde als Standard gespeichert
|
HOTBAR_SAVED = §7Deine Hotbar wurde als Standard gespeichert
|
||||||
HOTBAR_LOADED = §7Deine Standard Hotbar wurde geladen
|
HOTBAR_LOADED = §7Deine Standard Hotbar wurde geladen
|
||||||
HOTBAR_INVENTORY = Standard Hotbar
|
HOTBAR_INVENTORY = Standard Hotbar
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
GUI_EDITOR_ITEM-NAME=§eGui Editor
|
GUI_EDITOR_ITEM-NAME = §eGui Editor
|
||||||
GUI_EXPORT_CODE=§eDein Gui-Code:
|
GUI_EXPORT_CODE = §eDein Gui-Code:
|
||||||
GUI_EXPORT_CODE-HOVER=§eKopieren
|
GUI_EXPORT_CODE-HOVER = §eKopieren
|
||||||
GUI_IMPORT_INVALID-CODE=§eInvalieder Gui-Code
|
GUI_IMPORT_INVALID-CODE = §eInvalieder Gui-Code
|
||||||
GUI_IMPORT_CODE-SUCCESSFUL=§eGui-Code eingelesen
|
GUI_IMPORT_CODE-SUCCESSFUL = §eGui-Code eingelesen
|
||||||
|
|
||||||
# Trace
|
# Trace
|
||||||
TRACE_RECORD = §aan
|
TRACE_RECORD = §aan
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bausystem;
|
package de.steamwar.bausystem;
|
||||||
|
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.linkage.LinkageUtils;
|
import de.steamwar.bausystem.linkage.LinkageUtils;
|
||||||
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
import de.steamwar.bausystem.region.loader.PrototypeLoader;
|
||||||
import de.steamwar.bausystem.region.loader.RegionLoader;
|
import de.steamwar.bausystem.region.loader.RegionLoader;
|
||||||
@ -75,6 +76,7 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
LinkageUtils.unlink();
|
LinkageUtils.unlink();
|
||||||
|
|
||||||
RegionLoader.save();
|
RegionLoader.save();
|
||||||
|
Config.getInstance().saveAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fixLogging() {
|
private void fixLogging() {
|
||||||
|
@ -96,6 +96,14 @@ public class Config implements Listener {
|
|||||||
return playerConfigurations.get(uuid);
|
return playerConfigurations.get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void saveAll() {
|
||||||
|
playerConfigurations.forEach((uuid, yapionObject) -> {
|
||||||
|
String string = yapionObject.toYAPION(new StringOutput()).getResult();
|
||||||
|
UserConfig.updatePlayerConfig(uuid, "bausystem", string);
|
||||||
|
});
|
||||||
|
playerConfigurations.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save a PlayerConfig, this does not remove the key value mapping from the map.
|
* Save a PlayerConfig, this does not remove the key value mapping from the map.
|
||||||
*
|
*
|
||||||
|
@ -21,11 +21,15 @@ package de.steamwar.bausystem.configplayer.serializer;
|
|||||||
|
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import yapion.hierarchy.api.groups.YAPIONAnyType;
|
||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
import yapion.serializing.api.SerializerObject;
|
import yapion.serializing.api.SerializerObject;
|
||||||
import yapion.serializing.data.DeserializeData;
|
import yapion.serializing.data.DeserializeData;
|
||||||
import yapion.serializing.data.SerializeData;
|
import yapion.serializing.data.SerializeData;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -46,10 +50,23 @@ public class ConfigurationSerializableSerializer extends SerializerObject<Config
|
|||||||
@Override
|
@Override
|
||||||
public YAPIONObject serialize(SerializeData<ConfigurationSerializable> serializeData) {
|
public YAPIONObject serialize(SerializeData<ConfigurationSerializable> serializeData) {
|
||||||
YAPIONObject yapionObject = new YAPIONObject();
|
YAPIONObject yapionObject = new YAPIONObject();
|
||||||
yapionObject.add(TYPE_IDENTIFIER, type().getTypeName());
|
yapionObject.add(TYPE_IDENTIFIER, serializeData.object.getClass().getTypeName());
|
||||||
|
if (serializeData.object instanceof ItemStack) {
|
||||||
|
yapionObject.add(TYPE_IDENTIFIER, ItemStack.class.getTypeName());
|
||||||
|
}
|
||||||
|
if (serializeData.object instanceof ItemMeta) {
|
||||||
|
yapionObject.add(TYPE_IDENTIFIER, ItemMeta.class.getTypeName());
|
||||||
|
}
|
||||||
Map<String, Object> serializeDataMap = serializeData.object.serialize();
|
Map<String, Object> serializeDataMap = serializeData.object.serialize();
|
||||||
serializeDataMap.forEach((s, o) -> {
|
serializeDataMap.forEach((s, o) -> {
|
||||||
yapionObject.add(s, serializeData.serialize(o));
|
YAPIONAnyType yapionAnyType = serializeData.serialize(o);
|
||||||
|
if (yapionAnyType instanceof YAPIONObject) {
|
||||||
|
YAPIONObject object = (YAPIONObject) yapionAnyType;
|
||||||
|
if (object.containsKey(TYPE_IDENTIFIER) && object.getPlainValue(TYPE_IDENTIFIER).equals("com.google.common.collect.RegularImmutableList")) {
|
||||||
|
object.put(TYPE_IDENTIFIER, ArrayList.class.getTypeName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yapionObject.add(s, yapionAnyType);
|
||||||
});
|
});
|
||||||
return yapionObject;
|
return yapionObject;
|
||||||
}
|
}
|
||||||
@ -58,7 +75,14 @@ public class ConfigurationSerializableSerializer extends SerializerObject<Config
|
|||||||
public ConfigurationSerializable deserialize(DeserializeData<YAPIONObject> deserializeData) {
|
public ConfigurationSerializable deserialize(DeserializeData<YAPIONObject> deserializeData) {
|
||||||
Map<String, Object> deserializeDataMap = new HashMap<>();
|
Map<String, Object> deserializeDataMap = new HashMap<>();
|
||||||
deserializeData.object.forEach((s, yapionAnyType) -> {
|
deserializeData.object.forEach((s, yapionAnyType) -> {
|
||||||
if (s.equals(TYPE_IDENTIFIER)) return;
|
if (s.equals(TYPE_IDENTIFIER)) {
|
||||||
|
if (yapionAnyType.toString().equals("(org.bukkit.inventory.meta.ItemMeta)")) {
|
||||||
|
deserializeDataMap.put("==", "ItemMeta");
|
||||||
|
} else {
|
||||||
|
deserializeDataMap.put("==", deserializeData.deserialize(yapionAnyType));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
deserializeDataMap.put(s, deserializeData.deserialize(yapionAnyType));
|
deserializeDataMap.put(s, deserializeData.deserialize(yapionAnyType));
|
||||||
});
|
});
|
||||||
return ConfigurationSerialization.deserializeObject(deserializeDataMap);
|
return ConfigurationSerialization.deserializeObject(deserializeDataMap);
|
||||||
|
@ -23,16 +23,12 @@ import de.steamwar.bausystem.BauSystem;
|
|||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.bausystem.linkage.LinkedInstance;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
public class AutoStartCommand extends SWCommand {
|
public class AutoStartCommand extends SWCommand {
|
||||||
|
|
||||||
@LinkedInstance
|
|
||||||
private AutostartListener autostartListener;
|
|
||||||
|
|
||||||
public AutoStartCommand() {
|
public AutoStartCommand() {
|
||||||
super("timer", "autostarttimer", "at", "autostart");
|
super("timer", "autostarttimer", "at", "autostart");
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,13 @@ import java.util.Map;
|
|||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.LISTENER)
|
||||||
public class AutostartListener implements Listener {
|
public class AutostartListener implements Listener {
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static AutostartListener instance;
|
||||||
|
|
||||||
|
{
|
||||||
|
instance = this;
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack getWandItem(Player player) {
|
public static ItemStack getWandItem(Player player) {
|
||||||
ItemStack itemStack = new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("AUTOSTART_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("AUTOSTART_ITEM_LORE", player)), false, null).getItemStack();
|
ItemStack itemStack = new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("AUTOSTART_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("AUTOSTART_ITEM_LORE", player)), false, null).getItemStack();
|
||||||
ItemUtils.setItem(itemStack, "autostart");
|
ItemUtils.setItem(itemStack, "autostart");
|
||||||
@ -64,8 +71,11 @@ public class AutostartListener implements Listener {
|
|||||||
if (event.getClickedBlock() == null) {
|
if (event.getClickedBlock() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
activate(event.getPlayer());
|
||||||
Region region = Region.getRegion(event.getClickedBlock().getLocation());
|
}
|
||||||
|
|
||||||
|
public void activate(Player player) {
|
||||||
|
Region region = Region.getRegion(player.getLocation());
|
||||||
if (region.isGlobal()) {
|
if (region.isGlobal()) {
|
||||||
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO-REGION", player);
|
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO-REGION", player);
|
||||||
return;
|
return;
|
||||||
|
@ -63,7 +63,7 @@ public class InfoCommand extends SWCommand {
|
|||||||
p.sendMessage(membermessage.toString());
|
p.sendMessage(membermessage.toString());
|
||||||
|
|
||||||
StringBuilder tpsMessage = new StringBuilder();
|
StringBuilder tpsMessage = new StringBuilder();
|
||||||
tpsMessage.append(BauSystem.PREFIX).append("TPS:§e");
|
tpsMessage.append(BauSystem.MESSAGE.parsePrefixed("BAU-INFO_COMMAND_TPS", p));
|
||||||
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND));
|
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND));
|
||||||
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS));
|
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS));
|
||||||
if (!TPSWarpUtils.isWarping()) {
|
if (!TPSWarpUtils.isWarping()) {
|
||||||
|
@ -22,6 +22,8 @@ package de.steamwar.bausystem.features.detonator;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
|
import de.steamwar.bausystem.features.autostart.AutostartListener;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||||
import de.steamwar.core.VersionedRunnable;
|
import de.steamwar.core.VersionedRunnable;
|
||||||
@ -75,6 +77,10 @@ public class Detonator {
|
|||||||
|
|
||||||
public static void activateDetonator(DetonatorStorage detonator) {
|
public static void activateDetonator(DetonatorStorage detonator) {
|
||||||
Player p = detonator.getPlayer();
|
Player p = detonator.getPlayer();
|
||||||
|
if (Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false)) {
|
||||||
|
AutostartListener.instance.activate(p);
|
||||||
|
}
|
||||||
|
|
||||||
Map<Integer, Set<Block>> deactivate = new HashMap<>();
|
Map<Integer, Set<Block>> deactivate = new HashMap<>();
|
||||||
Set<Location> invalid = new HashSet<>();
|
Set<Location> invalid = new HashSet<>();
|
||||||
|
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.detonator;
|
package de.steamwar.bausystem.features.detonator;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.SWUtils;
|
import de.steamwar.bausystem.SWUtils;
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
|
||||||
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
@ -81,4 +83,11 @@ public class DetonatorCommand extends SWCommand {
|
|||||||
storage.clear();
|
storage.clear();
|
||||||
storage.write();
|
storage.write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register("autostart")
|
||||||
|
public void toggleAutostartTimer(Player p) {
|
||||||
|
boolean current = Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false);
|
||||||
|
Config.getInstance().get(p).put("detonator-autostart", !current);
|
||||||
|
p.sendMessage(BauSystem.PREFIX + "Autostart beim detonate " + (!current ? "§aangeschaltet" : "§causgeschaltet"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,10 +89,10 @@ public class DetonatorListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (detonator.getLocations().contains(location)) {
|
if (detonator.getLocations().contains(location)) {
|
||||||
detonator.removeLocation(location);
|
detonator.removeLocation(location);
|
||||||
SWUtils.sendToActionbar(p, ColorConfig.HIGHLIGHT + detoblock.getName() + " entfernt");
|
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("DETONATOR_LOC_REMOVE", p, BauSystem.MESSAGE.parse(detoblock.getName(), p)));
|
||||||
} else {
|
} else {
|
||||||
detonator.addLocation(location);
|
detonator.addLocation(location);
|
||||||
SWUtils.sendToActionbar(p, ColorConfig.HIGHLIGHT + detoblock.getName() + " hinzugefügt");
|
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("DETONATOR_LOC_ADD", p, BauSystem.MESSAGE.parse(detoblock.getName(), p)));
|
||||||
}
|
}
|
||||||
detonator.write();
|
detonator.write();
|
||||||
}
|
}
|
||||||
|
@ -20,71 +20,57 @@
|
|||||||
package de.steamwar.bausystem.features.hotbar;
|
package de.steamwar.bausystem.features.hotbar;
|
||||||
|
|
||||||
import de.steamwar.bausystem.configplayer.Config;
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import yapion.hierarchy.types.YAPIONArray;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
import yapion.hierarchy.types.YAPIONValue;
|
||||||
|
import yapion.parser.YAPIONParser;
|
||||||
|
import yapion.serializing.YAPIONDeserializer;
|
||||||
|
import yapion.serializing.YAPIONSerializer;
|
||||||
|
|
||||||
import java.io.StringReader;
|
@UtilityClass
|
||||||
|
|
||||||
// TODO: 16.05.2021 @Yoyo muss mal was Fixen, dann Item Save auf Yapion umstellen
|
|
||||||
public class DefaultHotbar {
|
public class DefaultHotbar {
|
||||||
|
|
||||||
public static void updateHotbar(Player p) {
|
private final YAPIONArray DEFAULT_HOTBAR = YAPIONParser.parse("{[{@type(org.bukkit.inventory.ItemStack)v(2230)type(WOODEN_AXE)meta{@type(org.bukkit.inventory.meta.ItemMeta)meta-type(UNSPECIFIC)display-name(WorldEdit Wand)lore{@type(java.util.ArrayList)values[Left click: select pos #1,Right click: select pos #2]}}},{@type(org.bukkit.inventory.ItemStack)v(2230)type(COMPASS)meta{@type(org.bukkit.inventory.meta.ItemMeta)meta-type(UNSPECIFIC)display-name(Navigation Wand)lore{@type(java.util.ArrayList)values[Left click: jump to location,Right click: pass through walls]}}},null,null,null,null,null,null,{@type(org.bukkit.inventory.ItemStack)v(2230)type(NETHER_STAR)meta{@type(org.bukkit.inventory.meta.ItemMeta)meta-type(UNSPECIFIC)display-name(§eBau GUI)}}]}").getArray("");
|
||||||
|
|
||||||
|
public void updateHotbar(Player p) {
|
||||||
ItemStack[] hotbar = new ItemStack[9];
|
ItemStack[] hotbar = new ItemStack[9];
|
||||||
System.arraycopy(p.getInventory().getContents(), 0, hotbar, 0, 9);
|
System.arraycopy(p.getInventory().getContents(), 0, hotbar, 0, 9);
|
||||||
YamlConfiguration configuration = new YamlConfiguration();
|
YAPIONArray yapionArray = new YAPIONArray();
|
||||||
configuration.set("Items", hotbar);
|
for (ItemStack itemStack : hotbar) {
|
||||||
Config.getInstance().get(p).add("hotbar", configuration.saveToString());
|
if (itemStack != null) {
|
||||||
|
yapionArray.add(YAPIONSerializer.serialize(itemStack));
|
||||||
|
} else {
|
||||||
|
yapionArray.add(new YAPIONValue<>(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Config.getInstance().get(p).add("hotbar", yapionArray);
|
||||||
Config.getInstance().save(p);
|
Config.getInstance().save(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setHotbar(Player p) {
|
public void setHotbar(Player p) {
|
||||||
ItemStack[] hotbar = getItems(p);
|
ItemStack[] hotbar = getItems(p);
|
||||||
ItemStack[] inv = p.getInventory().getContents();
|
ItemStack[] inv = p.getInventory().getContents();
|
||||||
System.arraycopy(hotbar, 0, inv, 0, 9);
|
System.arraycopy(hotbar, 0, inv, 0, 9);
|
||||||
p.getInventory().setContents(inv);
|
p.getInventory().setContents(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack[] getItems(Player p) {
|
public ItemStack[] getItems(Player p) {
|
||||||
YamlConfiguration hb = YamlConfiguration.loadConfiguration(new StringReader(Config.getInstance().get(p).getPlainValueOrDefault("hotbar", defaultHotbar())));
|
YAPIONArray yapionArray = Config.getInstance().get(p).getYAPIONArrayOrSetDefault("hotbar", defaultHotbar());
|
||||||
ItemStack[] hotbar = hb.getList("Items").toArray(new ItemStack[9]);
|
ItemStack[] hotbar = new ItemStack[9];
|
||||||
|
yapionArray.forEach((integer, yapionAnyType) -> {
|
||||||
|
if (yapionAnyType instanceof YAPIONValue) {
|
||||||
|
hotbar[integer] = null;
|
||||||
|
} else {
|
||||||
|
hotbar[integer] = (ItemStack) YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType);
|
||||||
|
}
|
||||||
|
});
|
||||||
return hotbar;
|
return hotbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String defaultHotbar() {
|
public YAPIONArray defaultHotbar() {
|
||||||
return "Items:\n" +
|
return DEFAULT_HOTBAR;
|
||||||
"- ==: org.bukkit.inventory.ItemStack\n" +
|
|
||||||
" v: 2230\n" +
|
|
||||||
" type: WOODEN_AXE\n" +
|
|
||||||
" meta:\n" +
|
|
||||||
" ==: ItemMeta\n" +
|
|
||||||
" meta-type: UNSPECIFIC\n" +
|
|
||||||
" display-name: WorldEdit Wand\n" +
|
|
||||||
" lore:\n" +
|
|
||||||
" - 'Left click: select pos #1'\n" +
|
|
||||||
" - 'Right click: select pos #2'\n" +
|
|
||||||
"- ==: org.bukkit.inventory.ItemStack\n" +
|
|
||||||
" v: 2230\n" +
|
|
||||||
" type: COMPASS\n" +
|
|
||||||
" meta:\n" +
|
|
||||||
" ==: ItemMeta\n" +
|
|
||||||
" meta-type: UNSPECIFIC\n" +
|
|
||||||
" display-name: Navigation Wand\n" +
|
|
||||||
" lore:\n" +
|
|
||||||
" - 'Left click: jump to location'\n" +
|
|
||||||
" - 'Right click: pass through walls'\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- null\n" +
|
|
||||||
"- ==: org.bukkit.inventory.ItemStack\n" +
|
|
||||||
" v: 2230\n" +
|
|
||||||
" type: NETHER_STAR\n" +
|
|
||||||
" meta:\n" +
|
|
||||||
" ==: ItemMeta\n" +
|
|
||||||
" meta-type: UNSPECIFIC\n" +
|
|
||||||
" display-name: §eBau GUI\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ public class HotbarListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
System.out.println(event.getPlayer().getInventory().getContents());
|
|
||||||
if (allNull(event.getPlayer().getInventory().getContents())) {
|
if (allNull(event.getPlayer().getInventory().getContents())) {
|
||||||
DefaultHotbar.setHotbar(event.getPlayer());
|
DefaultHotbar.setHotbar(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,12 @@ package de.steamwar.bausystem.features.loader;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
public enum LoaderButton {
|
public enum LoaderButton {
|
||||||
SWITCH(0, true, "LOADER_BUTTON_SWITCH"),
|
SWITCH(0, true, "LOADER_BUTTON_SWITCH"),
|
||||||
WOOD_BUTTON(30, "LOADER_BUTTON_WOOD-Button"),
|
WOOD_BUTTON(30, "LOADER_BUTTON_WOOD-Button"),
|
||||||
@ -35,19 +38,10 @@ public enum LoaderButton {
|
|||||||
DAYLIGHTSENSOR(0, true, "LOADER_BUTTON_DAYLIGHTSENSOR"),
|
DAYLIGHTSENSOR(0, true, "LOADER_BUTTON_DAYLIGHTSENSOR"),
|
||||||
INVALID(-1, "LOADER_BUTTON_INVALID");
|
INVALID(-1, "LOADER_BUTTON_INVALID");
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int time;
|
private final int time;
|
||||||
@Getter
|
private boolean toggle;
|
||||||
private final boolean toggle;
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
LoaderButton(int time, String name) {
|
|
||||||
this.time = time;
|
|
||||||
this.name = name;
|
|
||||||
toggle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoaderButton fromBlock(Block block) {
|
public static LoaderButton fromBlock(Block block) {
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case LEVER:
|
case LEVER:
|
||||||
|
@ -21,20 +21,22 @@ package de.steamwar.bausystem.features.testblock.depthcounter;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.config.ColorConfig;
|
import de.steamwar.bausystem.config.ColorConfig;
|
||||||
|
import de.steamwar.bausystem.configplayer.Config;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.DoubleBinaryOperator;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class DepthCounter {
|
public class DepthCounter {
|
||||||
|
|
||||||
public final Map<Region, Set<Depth>> depthMap = new HashMap<>();
|
public final Map<Region, Set<Depth>> depthMap = new HashMap<>();
|
||||||
public final Map<Player, Set<CountMode>> playerSettings = new HashMap<>();
|
|
||||||
|
private static final YAPIONObject DEFAULT = new YAPIONObject().add("X", "").add("Y", "").add("Z", "");
|
||||||
|
|
||||||
public void toggleMode(final Player p, final CountMode countMode) {
|
public void toggleMode(final Player p, final CountMode countMode) {
|
||||||
if (isActive(p, countMode)) {
|
if (isActive(p, countMode)) {
|
||||||
@ -45,35 +47,29 @@ public class DepthCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive(final Player p, final CountMode countMode) {
|
public boolean isActive(final Player p, final CountMode countMode) {
|
||||||
final Set<CountMode> countModes = playerSettings.get(p);
|
return Config.getInstance().get(p).getYAPIONObjectOrSetDefault("depth-counter", (YAPIONObject) DEFAULT.copy()).containsKey(countMode.name());
|
||||||
return countModes != null && countModes.contains(countMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addMode(final Player p, final CountMode countMode) {
|
public void addMode(final Player p, final CountMode countMode) {
|
||||||
final Set<CountMode> countModes = playerSettings.get(p);
|
if (!isActive(p, countMode)) {
|
||||||
if (countModes != null) {
|
Config.getInstance().get(p).getObject("depth-counter").add(countMode.name(), "");
|
||||||
countModes.add(countMode);
|
|
||||||
} else {
|
|
||||||
playerSettings.put(p, new HashSet<>(Collections.singletonList(countMode)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeMode(final Player p, final CountMode countMode) {
|
public void removeMode(final Player p, final CountMode countMode) {
|
||||||
final Set<CountMode> countModes = playerSettings.get(p);
|
if (isActive(p, countMode)) {
|
||||||
if (countModes != null) {
|
Config.getInstance().get(p).getObject("depth-counter").remove(countMode.name());
|
||||||
countModes.remove(countMode);
|
|
||||||
if (countModes.isEmpty()) {
|
|
||||||
removePlayer(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModes(final Player p, final Set<CountMode> countModes) {
|
public void setModes(final Player p, final Set<CountMode> countModes) {
|
||||||
playerSettings.put(p, countModes);
|
YAPIONObject yapionObject = new YAPIONObject();
|
||||||
|
countModes.forEach(countMode -> yapionObject.put(countMode.name(), ""));
|
||||||
|
Config.getInstance().get(p).put("depth-counter", yapionObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePlayer(final Player p) {
|
public void removePlayer(final Player p) {
|
||||||
playerSettings.remove(p);
|
Config.getInstance().get(p).put("depth-counter", new YAPIONObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector blockVector(Vector vector) {
|
public Vector blockVector(Vector vector) {
|
||||||
@ -81,8 +77,11 @@ public class DepthCounter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<CountMode> getModes(Player p) {
|
public Set<CountMode> getModes(Player p) {
|
||||||
final Set<CountMode> countModes = playerSettings.get(p);
|
Set<CountMode> countModes = new HashSet<>();
|
||||||
return countModes == null ? Collections.emptySet() : countModes.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
|
Config.getInstance().get(p).getYAPIONObjectOrSetDefault("depth-counter", (YAPIONObject) DEFAULT.copy()).forEach((s, yapionAnyType) -> {
|
||||||
|
countModes.add(CountMode.valueOf(s));
|
||||||
|
});
|
||||||
|
return countModes.stream().sorted().collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasModes(Player p) {
|
public boolean hasModes(Player p) {
|
||||||
|
@ -27,28 +27,22 @@ import de.steamwar.bausystem.region.utils.RegionType;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.LISTENER)
|
||||||
public class DepthCounterListener implements Listener {
|
public class DepthCounterListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityExplode(EntityExplodeEvent event) {
|
public void onEntityExplode(EntityExplodeEvent event) {
|
||||||
Region region = Region.getRegion(event.getLocation());
|
Region region = Region.getRegion(event.getLocation());
|
||||||
boolean testblock = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.NORMAL));
|
boolean testblock = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION));
|
||||||
if (!testblock) {
|
if (!testblock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DepthCounter.depthMap.containsKey(region)) {
|
DepthCounter.depthMap.putIfAbsent(region, new HashSet<>());
|
||||||
DepthCounter.depthMap.put(region, new HashSet<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<Depth> depthSet = DepthCounter.depthMap.get(region);
|
Set<Depth> depthSet = DepthCounter.depthMap.get(region);
|
||||||
for (Depth depth : depthSet) {
|
for (Depth depth : depthSet) {
|
||||||
if (depth.update(event.blockList())) {
|
if (depth.update(event.blockList())) {
|
||||||
@ -57,14 +51,4 @@ public class DepthCounterListener implements Listener {
|
|||||||
}
|
}
|
||||||
depthSet.add(new Depth(region, event.blockList()));
|
depthSet.add(new Depth(region, event.blockList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLeave(PlayerQuitEvent event) {
|
|
||||||
DepthCounter.removePlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
|
||||||
DepthCounter.setModes(event.getPlayer(), CountMode.ALL());
|
|
||||||
}
|
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren