SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'

Dieser Commit ist enthalten in:
Zeanon 2021-04-17 18:38:10 +02:00
Commit 3efad52ec3
4 geänderte Dateien mit 11 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -36,7 +36,7 @@ public class NightVisionCommand extends SWCommand {
} }
@Register(help = true) @Register(help = true)
public void genericHelp(Player p, String[] args) { public void genericHelp(Player p, String... args) {
p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "nightvision " + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + " Schalte Nightvision an oder aus."); p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "nightvision " + ChatColor.DARK_GRAY + "-" + ChatColor.GRAY + " Schalte Nightvision an oder aus.");
} }

Datei anzeigen

@ -34,7 +34,7 @@ public class SpeedCommand extends SWCommand {
} }
@Register(help = true) @Register(help = true)
public void genericHelp(Player p, String[] args) { public void genericHelp(Player p, String... args) {
p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "speed " + ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "1" + ChatColor.DARK_GRAY + "-" + ChatColor.YELLOW + "10" + ChatColor.DARK_GRAY + "] - " + ChatColor.GRAY + "Setzte deine Flug- und Laufgeschindigkeit."); p.sendMessage(ChatColor.DARK_GRAY + "/" + ChatColor.YELLOW + "speed " + ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "1" + ChatColor.DARK_GRAY + "-" + ChatColor.YELLOW + "10" + ChatColor.DARK_GRAY + "] - " + ChatColor.GRAY + "Setzte deine Flug- und Laufgeschindigkeit.");
p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: " + ChatColor.YELLOW + p.getFlySpeed() * 10F); p.sendMessage(BauSystem.PREFIX + "Aktuelle geschwindigkeit: " + ChatColor.YELLOW + p.getFlySpeed() * 10F);
} }

Datei anzeigen

@ -36,15 +36,17 @@ public class LinkageUtils {
private Map<Class<?>, Object> objectMap = new HashMap<>(); private Map<Class<?>, Object> objectMap = new HashMap<>();
public void link() { public void link() {
internalLinkOrUnlink(false); internalLinkOrUnlink(false, Linked.class);
internalLinkOrUnlink(false, Linked.Linkages.class);
} }
public void unlink() { public void unlink() {
internalLinkOrUnlink(true); internalLinkOrUnlink(true, Linked.Linkages.class);
internalLinkOrUnlink(true, Linked.class);
} }
private void internalLinkOrUnlink(boolean unlink) { private void internalLinkOrUnlink(boolean unlink, Class<?> toLink) {
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + Linked.class.getTypeName())))) { try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/de.steamwar.bausystem/" + toLink.getTypeName().replace("$", "."))))) {
bufferedReader.lines().forEach(s -> { bufferedReader.lines().forEach(s -> {
try { try {
linkOrUnlink(Class.forName(s), unlink); linkOrUnlink(Class.forName(s), unlink);
@ -76,13 +78,12 @@ public class LinkageUtils {
} }
} }
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
if (linkageTypeList.isEmpty()) { if (linkageTypeList.isEmpty()) {
return; return;
} }
linkageTypeList.removeIf(linkageType -> linkageType.isUnlink() != unlink);
linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder)); linkageTypeList.sort(Comparator.comparingInt(LinkageType::getOrder));
Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance); Object object = objectMap.computeIfAbsent(clazz, LinkageUtils::constructInstance);
linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object)); linkageTypeList.forEach(linkageType -> linkageType.getLinkageConsumer().accept(object));
} }

Datei anzeigen

@ -30,6 +30,7 @@ import java.lang.annotation.*;
public @interface Linked { public @interface Linked {
LinkageType value(); LinkageType value();
@IndexAnnotated
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE}) @Target({ElementType.TYPE})
@interface Linkages { @interface Linkages {