diff --git a/src/main/java/de/lunarakai/blockfox/commands/DeleteCommand.java b/src/main/java/de/lunarakai/blockfox/commands/DeleteCommand.java index e488787..12cd820 100644 --- a/src/main/java/de/lunarakai/blockfox/commands/DeleteCommand.java +++ b/src/main/java/de/lunarakai/blockfox/commands/DeleteCommand.java @@ -40,6 +40,7 @@ public class DeleteCommand extends SubCommand { return BlockFoxPlugin.PERMISSION_ADMIN; } + // doesnt work?? @Override public boolean onCommand(CommandSender sender, Command command, String s, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException { Player player = (Player) sender; @@ -54,7 +55,7 @@ public class DeleteCommand extends SubCommand { plugin.getDisplayList().removeBlockFoxDisplay(display); MessageUtils.sendSimpleWarningMessage(player, "display.delete.success"); } - return false; + return true; } @Override diff --git a/src/main/java/de/lunarakai/blockfox/common/BlockFoxDisplay.java b/src/main/java/de/lunarakai/blockfox/common/BlockFoxDisplay.java index 22b4190..41c6a04 100644 --- a/src/main/java/de/lunarakai/blockfox/common/BlockFoxDisplay.java +++ b/src/main/java/de/lunarakai/blockfox/common/BlockFoxDisplay.java @@ -5,10 +5,13 @@ import de.lunarakai.blockfox.BlockFoxPlugin; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; @@ -19,6 +22,7 @@ import org.bukkit.entity.Display; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.TextDisplay; +import org.jetbrains.annotations.NotNull; public class BlockFoxDisplay { private final BlockFoxPlugin plugin; @@ -31,6 +35,7 @@ public class BlockFoxDisplay { private ArrayList savedLinks; private Boolean isInFixedMode; private List displays; + private Map namedDisplay; private Player currentPlayer; // Width = 5 @@ -41,6 +46,7 @@ public class BlockFoxDisplay { this.name = Preconditions.checkNotNull(displaySection.getString("name")); this.location = Preconditions.checkNotNull(displaySection.getLocation("location")); this.displays = new ArrayList<>(); // TODO + this.namedDisplay = new HashMap<>(); this.savedLinks = new ArrayList<>(); BlockFace orientation = BlockFace.NORTH; @@ -61,13 +67,16 @@ public class BlockFoxDisplay { default: this.blockFoxDisplayMode = BlockFoxDisplayMode.RSS_FEED; } - List list = displaySection.getStringList("textdisplays"); - for(int i = 0; i < list.size(); i++) { - String textDisplay = list.get(i); - if(textDisplay != null) { - displays.set(i, UUID.fromString(textDisplay)); - } - } +// List list = displaySection.getStringList("textdisplays"); +// for(int i = 0; i < list.size(); i++) { +// String textDisplay = list.get(i); +// if(textDisplay != null) { +// displays.set(i, UUID.fromString(textDisplay)); +// } +// } + + @NotNull List> map = displaySection.getMapList("nameddisplays"); + this.namedDisplay = (Map) map.getFirst(); List savedLinksList = displaySection.getStringList("savedlinks"); for(int i = 0; i < savedLinksList.size(); i++) { @@ -88,6 +97,7 @@ public class BlockFoxDisplay { this.name = Preconditions.checkNotNull(name, "name is null"); this.location = Preconditions.checkNotNull(location, "location is null"); this.displays = new ArrayList<>(); // TODO + this.namedDisplay = new HashMap<>(); this.isInFixedMode = isInFixedMode; Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction"); @@ -109,7 +119,7 @@ public class BlockFoxDisplay { BlockData block0 = Material.SMOOTH_QUARTZ.createBlockData(); - for (int fx = -1 - 5 - 3; fx < 2; fx++) { + for (int fx = - 3; fx < 2; fx++) { for (int fy = -1; fy < 3 - 1; fy++) { loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx); world.setBlockData(loc, block0); @@ -122,8 +132,13 @@ public class BlockFoxDisplay { */ public void generateDisplays() { // Todo: - // 2 Text Displays - // 5 Item Displays + weitere als Buttons für Fediverse Navigation + // - 2 Text Displays + // - 2 Buttons für Hoch und runter scrollen innerhalb eines Posts + // - 2 Buttons für Navigation zwischen verschiedenen Posts + // - 1 Button um den Link des Posts zu kopieren/öffnen + // - 1 Button um zwischen den Modus bzw RSS Feeds zu wechseln + // - 4 Buttons für (Fediverse) Neuen Post schreiben, Antworten, Fav und Retoot + // ==> Insgesamt 12 Display Entities // s. https://imgur.com/9XJ4XWw int sizeWidth = 5; int sizeHeight = 3; @@ -151,12 +166,41 @@ public class BlockFoxDisplay { Location loc = location.clone(); + loc.set( + location.getX() + -0.5, + location.getY() + 1.25, + location.getZ() + -0.05 + ); TextDisplay textDisplayTitle = world.spawn(loc, TextDisplay.class, textDisplay -> { + textDisplay.text( + Component.text("Titel eines RSS Posts", NamedTextColor.BLUE) + .appendNewline() + .append(Component.text("LunarAkai", NamedTextColor.GOLD)) + .append(Component.text(" | ", NamedTextColor.WHITE)) + .append(Component.text("12:00", NamedTextColor.GOLD)) + .append(Component.text(" | ", NamedTextColor.WHITE)) + .append(Component.text("01.01.2024", NamedTextColor.GOLD)) + .appendNewline() + .append(Component.text("@testuser@mastodon.text", NamedTextColor.GRAY))); + textDisplay.setRotation(rotation, 0); + textDisplay.setBrightness(new Display.Brightness(15, 15)); }); + namedDisplay.put("titlebar", textDisplayTitle.getUniqueId()); - + loc.set( + location.getX() + -0.25, + location.getY() + -0.55, + location.getZ() + -0.05 + ); + TextDisplay textDisplayText = world.spawn(loc, TextDisplay.class, textDisplay -> { + textDisplay.text(Component.text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.")); + textDisplay.setRotation(rotation, 0); + textDisplay.setLineWidth(180); + textDisplay.setBrightness(new Display.Brightness(15, 15)); + }); + namedDisplay.put("text", textDisplayText.getUniqueId()); } public void save(ConfigurationSection displaySection) { @@ -168,11 +212,17 @@ public class BlockFoxDisplay { for(UUID uuid : this.displays) { textDisplays.add(uuid == null ? null : uuid.toString()); } - displaySection.set("textdisplays", textDisplays); +// displaySection.set("textdisplays", textDisplays); + + displaySection.set("nameddisplays", List.of(this.namedDisplay)); + List savedLinks = new ArrayList<>(); - for(URI url : this.savedLinks) { - savedLinks.add(url == null ? null : url.toString()); + if(this.savedLinks != null) { + for(URI url : this.savedLinks) { + savedLinks.add(url == null ? null : url.toString()); + } } + displaySection.set("savedlinks", savedLinks); } @@ -233,10 +283,10 @@ public class BlockFoxDisplay { private int getRotationYaw() { return switch (orientation) { - case EAST -> 90; - case SOUTH -> 180; - case WEST -> 270; - default -> 0; + case EAST -> 270; + case SOUTH -> 0; + case WEST -> 90; + default -> 180; }; } } diff --git a/src/main/java/de/lunarakai/blockfox/common/DisplayList.java b/src/main/java/de/lunarakai/blockfox/common/DisplayList.java index 76982f3..3db3c47 100644 --- a/src/main/java/de/lunarakai/blockfox/common/DisplayList.java +++ b/src/main/java/de/lunarakai/blockfox/common/DisplayList.java @@ -41,6 +41,11 @@ public class DisplayList { return; } + // TODO: + // 21:41:50] [Server thread/ERROR]: [BlockFox] could not load display list file + // org.bukkit.configuration.InvalidConfigurationException: Global tag is not allowed: tag:yaml.org,2002:java.util.UUID + // in 'reader', line 15, column 17: + // - titlebar: !!java.util.UUID '4a547213-21bd- ... YamlConfiguration conf = new YamlConfiguration(); try { conf.load(this.displayListFile);