From 949da15d6ae37a28c83f62dfbab9667d0eb5292c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 1 May 2021 10:53:01 +0200 Subject: [PATCH] Update LinkedInstance --- .../src/de/steamwar/bausystem/features/bau/BauCommand.java | 4 ++-- .../src/de/steamwar/bausystem/features/bau/InfoCommand.java | 2 +- .../de/steamwar/bausystem/features/region/ColorCommand.java | 2 +- .../de/steamwar/bausystem/features/region/RegionCommand.java | 4 ++-- .../src/de/steamwar/bausystem/linkage/LinkageUtils.java | 5 +---- .../src/de/steamwar/bausystem/linkage/LinkedInstance.java | 1 - .../src/de/steamwar/bausystem/region/RegionUtils.java | 4 ++++ 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java index 994cb395..0d05392c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -37,10 +37,10 @@ import java.util.stream.Collectors; @Linked(LinkageType.COMMAND) public class BauCommand extends SWCommand { - @LinkedInstance(BauServer.class) + @LinkedInstance private BauServer bauServer; - @LinkedInstance(InfoCommand.class) + @LinkedInstance private InfoCommand infoCommand; public BauCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index edbcb6f3..dd98229c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -21,7 +21,7 @@ import static de.steamwar.bausystem.features.tpslimit.TPSWarpUtils.getTps; @Linked(LinkageType.COMMAND) public class InfoCommand extends SWCommand { - @LinkedInstance(BauServer.class) + @LinkedInstance private BauServer bauServer; public InfoCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index 97004bfe..b743b821 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -14,7 +14,7 @@ import org.bukkit.entity.Player; @Linked(LinkageType.COMMAND) public class ColorCommand extends SWCommand { - @LinkedInstance(BauServer.class) + @LinkedInstance private BauServer bauServer; public ColorCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index 65d28207..a4bda941 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -21,10 +21,10 @@ import java.util.logging.Level; @Linked(LinkageType.COMMAND) public class RegionCommand extends SWCommand { - @LinkedInstance(SelectCommand.class) + @LinkedInstance private SelectCommand selectCommand; - @LinkedInstance(ColorCommand.class) + @LinkedInstance private ColorCommand colorCommand; public RegionCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java index 922850a1..03b0ffc0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageUtils.java @@ -73,7 +73,7 @@ public class LinkageUtils { if (linkedInstance == null) { continue; } - Object object = objectMap.getOrDefault(linkedInstance.value(), null); + Object object = objectMap.getOrDefault(field.getType(), null); Object source = objectMap.getOrDefault(field.getDeclaringClass(), null); try { field.setAccessible(true); @@ -122,9 +122,6 @@ public class LinkageUtils { if (linkedInstance == null) { continue; } - if (!field.getType().isAssignableFrom(linkedInstance.value())) { - continue; - } fieldsToLink.add(field); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkedInstance.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkedInstance.java index 7cfa2857..5c26ea4f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkedInstance.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkedInstance.java @@ -27,5 +27,4 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface LinkedInstance { - Class value(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java index 2a409002..25238294 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java @@ -20,6 +20,10 @@ public class RegionUtils { Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } + public static void message(Region region, String s) { + Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.sendMessage(s)); + } + static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) { return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15)); }