hm
This commit is contained in:
parent
bb2dfe8be5
commit
8f8b53b3a4
3 changed files with 76 additions and 20 deletions
|
|
@ -40,6 +40,7 @@ public class DeleteCommand extends SubCommand {
|
||||||
return BlockFoxPlugin.PERMISSION_ADMIN;
|
return BlockFoxPlugin.PERMISSION_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// doesnt work??
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String s, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
public boolean onCommand(CommandSender sender, Command command, String s, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
@ -54,7 +55,7 @@ public class DeleteCommand extends SubCommand {
|
||||||
plugin.getDisplayList().removeBlockFoxDisplay(display);
|
plugin.getDisplayList().removeBlockFoxDisplay(display);
|
||||||
MessageUtils.sendSimpleWarningMessage(player, "display.delete.success");
|
MessageUtils.sendSimpleWarningMessage(player, "display.delete.success");
|
||||||
}
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,13 @@ import de.lunarakai.blockfox.BlockFoxPlugin;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
@ -19,6 +22,7 @@ import org.bukkit.entity.Display;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TextDisplay;
|
import org.bukkit.entity.TextDisplay;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class BlockFoxDisplay {
|
public class BlockFoxDisplay {
|
||||||
private final BlockFoxPlugin plugin;
|
private final BlockFoxPlugin plugin;
|
||||||
|
|
@ -31,6 +35,7 @@ public class BlockFoxDisplay {
|
||||||
private ArrayList<URI> savedLinks;
|
private ArrayList<URI> savedLinks;
|
||||||
private Boolean isInFixedMode;
|
private Boolean isInFixedMode;
|
||||||
private List<UUID> displays;
|
private List<UUID> displays;
|
||||||
|
private Map<String, UUID> namedDisplay;
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
|
|
||||||
// Width = 5
|
// Width = 5
|
||||||
|
|
@ -41,6 +46,7 @@ public class BlockFoxDisplay {
|
||||||
this.name = Preconditions.checkNotNull(displaySection.getString("name"));
|
this.name = Preconditions.checkNotNull(displaySection.getString("name"));
|
||||||
this.location = Preconditions.checkNotNull(displaySection.getLocation("location"));
|
this.location = Preconditions.checkNotNull(displaySection.getLocation("location"));
|
||||||
this.displays = new ArrayList<>(); // TODO
|
this.displays = new ArrayList<>(); // TODO
|
||||||
|
this.namedDisplay = new HashMap<>();
|
||||||
this.savedLinks = new ArrayList<>();
|
this.savedLinks = new ArrayList<>();
|
||||||
|
|
||||||
BlockFace orientation = BlockFace.NORTH;
|
BlockFace orientation = BlockFace.NORTH;
|
||||||
|
|
@ -61,13 +67,16 @@ public class BlockFoxDisplay {
|
||||||
default: this.blockFoxDisplayMode = BlockFoxDisplayMode.RSS_FEED;
|
default: this.blockFoxDisplayMode = BlockFoxDisplayMode.RSS_FEED;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> list = displaySection.getStringList("textdisplays");
|
// List<String> list = displaySection.getStringList("textdisplays");
|
||||||
for(int i = 0; i < list.size(); i++) {
|
// for(int i = 0; i < list.size(); i++) {
|
||||||
String textDisplay = list.get(i);
|
// String textDisplay = list.get(i);
|
||||||
if(textDisplay != null) {
|
// if(textDisplay != null) {
|
||||||
displays.set(i, UUID.fromString(textDisplay));
|
// displays.set(i, UUID.fromString(textDisplay));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
@NotNull List<Map<?, ?>> map = displaySection.getMapList("nameddisplays");
|
||||||
|
this.namedDisplay = (Map<String, UUID>) map.getFirst();
|
||||||
|
|
||||||
List<String> savedLinksList = displaySection.getStringList("savedlinks");
|
List<String> savedLinksList = displaySection.getStringList("savedlinks");
|
||||||
for(int i = 0; i < savedLinksList.size(); i++) {
|
for(int i = 0; i < savedLinksList.size(); i++) {
|
||||||
|
|
@ -88,6 +97,7 @@ public class BlockFoxDisplay {
|
||||||
this.name = Preconditions.checkNotNull(name, "name is null");
|
this.name = Preconditions.checkNotNull(name, "name is null");
|
||||||
this.location = Preconditions.checkNotNull(location, "location is null");
|
this.location = Preconditions.checkNotNull(location, "location is null");
|
||||||
this.displays = new ArrayList<>(); // TODO
|
this.displays = new ArrayList<>(); // TODO
|
||||||
|
this.namedDisplay = new HashMap<>();
|
||||||
this.isInFixedMode = isInFixedMode;
|
this.isInFixedMode = isInFixedMode;
|
||||||
|
|
||||||
Preconditions.checkArgument(Math.abs(orientation.getModX()) + Math.abs(orientation.getModZ()) == 1, "no cardinal direction");
|
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();
|
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++) {
|
for (int fy = -1; fy < 3 - 1; fy++) {
|
||||||
loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx);
|
loc.set(location.getX() + d1x * fx, location.getY() + fy, location.getZ() + d1z * fx);
|
||||||
world.setBlockData(loc, block0);
|
world.setBlockData(loc, block0);
|
||||||
|
|
@ -122,8 +132,13 @@ public class BlockFoxDisplay {
|
||||||
*/
|
*/
|
||||||
public void generateDisplays() {
|
public void generateDisplays() {
|
||||||
// Todo:
|
// Todo:
|
||||||
// 2 Text Displays
|
// - 2 Text Displays
|
||||||
// 5 Item Displays + weitere als Buttons für Fediverse Navigation
|
// - 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
|
// s. https://imgur.com/9XJ4XWw
|
||||||
int sizeWidth = 5;
|
int sizeWidth = 5;
|
||||||
int sizeHeight = 3;
|
int sizeHeight = 3;
|
||||||
|
|
@ -151,12 +166,41 @@ public class BlockFoxDisplay {
|
||||||
|
|
||||||
Location loc = location.clone();
|
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 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) {
|
public void save(ConfigurationSection displaySection) {
|
||||||
|
|
@ -168,11 +212,17 @@ public class BlockFoxDisplay {
|
||||||
for(UUID uuid : this.displays) {
|
for(UUID uuid : this.displays) {
|
||||||
textDisplays.add(uuid == null ? null : uuid.toString());
|
textDisplays.add(uuid == null ? null : uuid.toString());
|
||||||
}
|
}
|
||||||
displaySection.set("textdisplays", textDisplays);
|
// displaySection.set("textdisplays", textDisplays);
|
||||||
|
|
||||||
|
displaySection.set("nameddisplays", List.of(this.namedDisplay));
|
||||||
|
|
||||||
List<String> savedLinks = new ArrayList<>();
|
List<String> savedLinks = new ArrayList<>();
|
||||||
for(URI url : this.savedLinks) {
|
if(this.savedLinks != null) {
|
||||||
savedLinks.add(url == null ? null : url.toString());
|
for(URI url : this.savedLinks) {
|
||||||
|
savedLinks.add(url == null ? null : url.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
displaySection.set("savedlinks", savedLinks);
|
displaySection.set("savedlinks", savedLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -233,10 +283,10 @@ public class BlockFoxDisplay {
|
||||||
|
|
||||||
private int getRotationYaw() {
|
private int getRotationYaw() {
|
||||||
return switch (orientation) {
|
return switch (orientation) {
|
||||||
case EAST -> 90;
|
case EAST -> 270;
|
||||||
case SOUTH -> 180;
|
case SOUTH -> 0;
|
||||||
case WEST -> 270;
|
case WEST -> 90;
|
||||||
default -> 0;
|
default -> 180;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,11 @@ public class DisplayList {
|
||||||
return;
|
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();
|
YamlConfiguration conf = new YamlConfiguration();
|
||||||
try {
|
try {
|
||||||
conf.load(this.displayListFile);
|
conf.load(this.displayListFile);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue