From 3b3ab508a7bb25786d799e4c48474ae48816c307 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 24 Sep 2022 20:02:01 +0200 Subject: [PATCH 01/33] Add SpigotCore to annotationProcessor Signed-off-by: yoyosource --- BauSystem_Main/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index 34c40b56..781999ba 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -66,4 +66,5 @@ dependencies { compileOnly swdep('Spigot-1.19') compileOnly swdep('WorldEdit-1.15') compileOnly swdep('SpigotCore') + annotationProcessor swdep('SpigotCore') } From ac91c77584764b8944ce9c5aad36382656e3b831 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 24 Sep 2022 20:26:33 +0200 Subject: [PATCH 02/33] Add new linkages that are needed Signed-off-by: yoyosource --- BauSystem_Linkage/build.gradle | 24 +---------- .../bausystem/linkage/LinkageProcessor.java | 1 - .../linkage/ProcessorImplementation.java | 27 ------------- .../linkage/types/BauGuiItem_GENERIC.java | 40 +++++++++++++++++++ .../types/BoundingBoxLoader_GENERIC.java | 39 ++++++++++++++++++ .../types/ConfigConverter_GENERIC.java | 40 +++++++++++++++++++ .../types/PanzernAlgorithm_GENERIC.java | 40 +++++++++++++++++++ .../types/SmartPlaceBehaviour_GENERIC.java | 40 +++++++++++++++++++ .../linkage/types/SpecialCommand_GENERIC.java | 40 +++++++++++++++++++ BauSystem_Main/build.gradle | 5 --- .../slaves/laufbau/BoundingBoxLoader.java | 25 ++++++++++++ 11 files changed, 265 insertions(+), 56 deletions(-) delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java diff --git a/BauSystem_Linkage/build.gradle b/BauSystem_Linkage/build.gradle index 486cb7c7..2169557f 100644 --- a/BauSystem_Linkage/build.gradle +++ b/BauSystem_Linkage/build.gradle @@ -43,27 +43,5 @@ sourceSets { } dependencies { - compileOnly 'org.projectlombok:lombok:1.18.22' - testCompileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - - implementation 'org.atteo.classindex:classindex:3.11' - testImplementation 'org.atteo.classindex:classindex:3.11' - annotationProcessor 'org.atteo.classindex:classindex:3.11' - testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' + compileOnly swdep('SpigotCore') } - -task buildResources { - doLast { - File from = new File("${buildDir}/classes/java/main/META-INF/annotations/de.steamwar.bausystem.linkage.ProcessorImplementation") - File to = new File("${buildDir}/classes/java/main/META-INF/services/javax.annotation.processing.Processor") - to.delete() - to.parentFile.mkdirs() - to.createNewFile() - for (String s : from.readLines()) { - to.append(s + "\n") - } - } -} -classes.finalizedBy(buildResources) \ No newline at end of file diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java index deb7bce7..600ea4c4 100644 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java +++ b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java @@ -30,7 +30,6 @@ import java.io.Writer; import java.util.*; import java.util.stream.Collectors; -@ProcessorImplementation @SupportedAnnotationTypes("de.steamwar.bausystem.linkage.Linked") public class LinkageProcessor extends AbstractProcessor { diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java deleted file mode 100644 index 96cae2d3..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019,2020,2021 yoyosource - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.steamwar.bausystem.linkage; - -import org.atteo.classindex.IndexAnnotated; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@IndexAnnotated -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE}) -public @interface ProcessorImplementation { -} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java new file mode 100644 index 00000000..160a7ca3 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class BauGuiItem_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkGUIItems"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.gui.BauGUI"); + methodBuilder.addLine("BauGUI.addItem(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java new file mode 100644 index 00000000..a86d0cc5 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java @@ -0,0 +1,39 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class BoundingBoxLoader_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkBoundingBox"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { + method.addLine(instance + ".load();"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java new file mode 100644 index 00000000..58db84e7 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class ConfigConverter_GENERIC implements LinkageType { + + @Override + public String method() { + return "link"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.configplayer.Config"); + methodBuilder.addLine("Config.addConfigConverter(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java new file mode 100644 index 00000000..bf701923 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class PanzernAlgorithm_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkPanzern"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.slaves.panzern.Panzern"); + methodBuilder.addLine("Panzern.add(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java new file mode 100644 index 00000000..6edaea3d --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class SmartPlaceBehaviour_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkPanzern"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.smartplace.SmartPlaceListener"); + methodBuilder.addLine("SmartPlaceListener.add(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java new file mode 100644 index 00000000..97c63276 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java @@ -0,0 +1,40 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.linkage.types; + +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.plan.BuildPlan; +import de.steamwar.linkage.plan.MethodBuilder; + +import javax.lang.model.element.TypeElement; + +public class SpecialCommand_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkScriptCommands"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.script.ScriptExecutor"); + methodBuilder.addLine("ScriptExecutor.SPECIAL_COMMANDS.add(" + s + ");"); + } +} diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index be1fcf2f..3f4576bc 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -51,11 +51,6 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.22' testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - implementation 'org.atteo.classindex:classindex:3.11' - testImplementation 'org.atteo.classindex:classindex:3.11' - annotationProcessor 'org.atteo.classindex:classindex:3.11' - testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' - implementation project(":BauSystem_Linkage") annotationProcessor project(":BauSystem_Linkage") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java new file mode 100644 index 00000000..7c2846b2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java @@ -0,0 +1,25 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.slaves.laufbau; + +public interface BoundingBoxLoader { + + void load(); +} From 98925dcb4aae16bc55e1754530aa5582c2b7669c Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 25 Sep 2022 11:30:33 +0200 Subject: [PATCH 03/33] Remove old linkage things Signed-off-by: yoyosource --- .../bausystem/linkage/LinkageProcessor.java | 264 ------------------ .../bausystem/linkage/LinkageType.java | 57 ---- .../de/steamwar/bausystem/linkage/Linked.java | 38 --- .../bausystem/linkage/LinkedInstance.java | 30 -- .../bausystem/linkage/MinVersion.java | 31 -- 5 files changed, 420 deletions(-) delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageType.java delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/Linked.java delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkedInstance.java delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/MinVersion.java diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java deleted file mode 100644 index 600ea4c4..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.linkage; - -import lombok.SneakyThrows; - -import javax.annotation.processing.*; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.*; -import javax.lang.model.type.DeclaredType; -import javax.tools.Diagnostic; -import java.io.Writer; -import java.util.*; -import java.util.stream.Collectors; - -@SupportedAnnotationTypes("de.steamwar.bausystem.linkage.Linked") -public class LinkageProcessor extends AbstractProcessor { - - private Messager messager; - private Writer writer; - private boolean processed = false; - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); - } - - @SneakyThrows - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - writer = processingEnv.getFiler().createSourceFile("de.steamwar.bausystem.linkage.LinkageUtils").openWriter(); - messager = processingEnv.getMessager(); - } - - @SneakyThrows - @Override - public boolean process(Set annotations, RoundEnvironment roundEnv) { - if (processed) return false; - processed = true; - List fields = new ArrayList<>(); - Map> linkLines = new HashMap<>(); - List staticLines = new ArrayList<>(); - - Set elements = roundEnv.getElementsAnnotatedWith(Linked.class); - elements.addAll((Set)roundEnv.getElementsAnnotatedWith(Linked.Linkages.class)); - - Map neededFields = new HashMap<>(); - for (Element element : elements) { - if (element.getKind() != ElementKind.CLASS) { - continue; - } - TypeElement typeElement = (TypeElement) element; - Linked[] linkeds = element.getAnnotationsByType(Linked.class); - if (linkeds.length == 0) { - continue; - } - - if (linkeds.length > 1) { - neededFields.put(typeElement.getQualifiedName().toString(), typeElement); - } - - List variableElements = typeElement.getEnclosedElements().stream().filter(e -> e.getKind() == ElementKind.FIELD).map(VariableElement.class::cast).filter(e -> { - return e.getAnnotation(LinkedInstance.class) != null; - }).collect(Collectors.toList()); - if (variableElements.isEmpty()) { - continue; - } - - for (VariableElement variableElement : variableElements) { - if (!variableElement.getModifiers().contains(Modifier.PUBLIC)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be public", variableElement); - continue; - } - if (variableElement.getModifiers().contains(Modifier.STATIC)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be non static", variableElement); - continue; - } - if (variableElement.getModifiers().contains(Modifier.FINAL)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be non final", variableElement); - continue; - } - neededFields.put(typeElement.getQualifiedName().toString(), typeElement); - TypeElement fieldType = (TypeElement) ((DeclaredType) variableElement.asType()).asElement(); - neededFields.put(fieldType.getQualifiedName().toString(), fieldType); - - System.out.println(getElement(typeElement, neededFields) + "." + variableElement.getSimpleName().toString() + " = " + getElement((TypeElement) ((DeclaredType) variableElement.asType()).asElement(), neededFields)); - staticLines.add(getElement(typeElement, neededFields) + "." + variableElement.getSimpleName().toString() + " = " + getElement((TypeElement) ((DeclaredType) variableElement.asType()).asElement(), neededFields)); - } - } - neededFields.forEach((s, typeElement) -> { - fields.add(typeElement.getQualifiedName().toString() + " " + typeElement.getSimpleName().toString()); - }); - - Map eventClasses = new HashMap<>(); - Map> eventMethods = new HashMap<>(); - for (Element element : elements) { - if (element.getKind() != ElementKind.CLASS) { - continue; - } - TypeElement typeElement = (TypeElement) element; - - typeElement.getEnclosedElements().stream().filter(e -> e.getKind() == ElementKind.METHOD).map(ExecutableElement.class::cast).filter(e -> { - return e.getAnnotationMirrors().stream().anyMatch(annotationMirror -> { - return annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler"); - }); - }).forEach(e -> { - TypeElement current = ((TypeElement)((DeclaredType) e.getParameters().get(0).asType()).asElement()); - eventClasses.put(current.getQualifiedName().toString(), current); - eventMethods.computeIfAbsent(typeElement, k -> new HashMap<>()).put(current, e); - }); - } - if (!eventMethods.isEmpty()) { - List eventLines = new ArrayList<>(); - linkLines.put(LinkageType.LISTENER, eventLines); - eventClasses.forEach((s, typeElement) -> { - eventLines.add("handlerList" + typeElement.getSimpleName().toString() + " = " + typeElement.getQualifiedName().toString() + ".getHandlerList()"); - }); - eventLines.add(""); - eventMethods.forEach((typeElement, map) -> { - String instance = "local" + typeElement.getSimpleName().toString(); - eventLines.add(typeElement.getQualifiedName().toString() + " " + instance + " = " + getElement(typeElement, neededFields)); - map.forEach((typeElement1, executableElement) -> { - AnnotationMirror eventHandler = executableElement.getAnnotationMirrors().stream().filter(annotationMirror -> annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler")).findFirst().orElse(null); - if (eventHandler == null) { - return; - } - String priority = "NORMAL"; - String ignoreCancelled = "false"; - for (Map.Entry entry : eventHandler.getElementValues().entrySet()) { - if (entry.getKey().getSimpleName().toString().equals("priority")) { - priority = entry.getValue().getValue().toString(); - } else if (entry.getKey().getSimpleName().toString().equals("ignoreCancelled")) { - ignoreCancelled = entry.getValue().getValue().toString(); - } - } - eventLines.add(typeElement1.getSimpleName().toString() + "(" + instance + ", " + instance + "::" + executableElement.getSimpleName().toString() + ", org.bukkit.event.EventPriority." + priority + ", " + ignoreCancelled + ")"); - }); - }); - } - - for (Element element : elements) { - if (element.getKind() != ElementKind.CLASS) { - continue; - } - TypeElement typeElement = (TypeElement) element; - Linked[] linkeds = element.getAnnotationsByType(Linked.class); - if (linkeds.length == 0) { - continue; - } - MinVersion minVersion = element.getAnnotation(MinVersion.class); - - System.out.println("Found element: " + typeElement.getQualifiedName().toString()); - - Arrays.stream(linkeds).map(Linked::value).forEach(linkageType -> { - if (linkageType.toRun == null) return; - if (linkageType.className != null) { - if (!typeElement.getSuperclass().toString().equals(linkageType.className)) { - return; - } - } - if (linkageType.interfaceName != null) { - if (typeElement.getInterfaces().stream().noneMatch(i -> i.toString().equals(linkageType.interfaceName))) { - return; - } - } - List strings = linkLines.computeIfAbsent(linkageType, ignore -> new ArrayList<>()); - if (minVersion != null) { - strings.add("if (de.steamwar.core.Core.getVersion() >= " + minVersion.value() + ") {"); - strings.add(" " + linkageType.toRun.replace("$", getElement(typeElement, neededFields))); - strings.add("}"); - } else { - strings.add(linkageType.toRun.replace("$", getElement(typeElement, neededFields))); - } - }); - } - - writer.write("package de.steamwar.bausystem.linkage;\n\n"); - writer.write("public class LinkageUtils {\n"); - for (String s : fields) { - writer.write(" private static " + s + ";\n"); - } - writer.write("\n"); - for (Map.Entry entry : neededFields.entrySet()) { - String field = entry.getValue().getSimpleName().toString(); - writer.write(" public static " + entry.getValue().getQualifiedName().toString() + " " + field + "() {\n"); - writer.write(" if (" + field + " == null) {\n"); - writer.write(" " + field + " = new " + entry.getValue().getQualifiedName().toString() + "();\n"); - writer.write(" }\n"); - writer.write(" return " + field + ";\n"); - writer.write(" }\n"); - writer.write("\n"); - } - writer.write(" private static final java.util.Set LINKED = new java.util.HashSet<>();\n"); - writer.write("\n"); - writer.write(" static {\n"); - for (String s : staticLines) { - writer.write(" " + s + ";\n"); - } - writer.write(" }\n"); - writer.write("\n"); - writer.write(" public static void run(de.steamwar.bausystem.linkage.LinkageType link) {\n"); - writer.write(" if (!LINKED.add(link)) return;\n"); - writer.write(" switch (link) {\n"); - for (LinkageType type : linkLines.keySet()) { - writer.write(" case " + type.name() + ":\n"); - writer.write(" " + type + "();\n"); - writer.write(" break;\n"); - } - writer.write(" default:\n"); - writer.write(" break;\n"); - writer.write(" }\n"); - writer.write(" }\n"); - writer.write("\n"); - for (Map.Entry> entry : linkLines.entrySet()) { - writer.write(" private static void " + entry.getKey() + "() {\n"); - for (String s : entry.getValue()) { - writer.write(" " + s + ";\n"); - } - writer.write(" }\n"); - writer.write("\n"); - } - for (Map.Entry entry : eventClasses.entrySet()) { - writer.write(" private static org.bukkit.event.HandlerList handlerList" + entry.getValue().getSimpleName().toString() + ";\n"); - writer.write(" private static void " + entry.getValue().getSimpleName().toString() + "(org.bukkit.event.Listener listener, java.util.function.Consumer<" + entry.getKey() + "> consumer, org.bukkit.event.EventPriority eventPriority, boolean ignoreCancelled) {\n"); - writer.write(" org.bukkit.plugin.EventExecutor eventExecutor = (l, event) -> {\n"); - writer.write(" if (event instanceof " + entry.getKey() + ") {\n"); - writer.write(" consumer.accept((" + entry.getKey() + ") event);\n"); - writer.write(" }\n"); - writer.write(" };\n"); - writer.write(" handlerList" + entry.getValue().getSimpleName() + ".register(new org.bukkit.plugin.RegisteredListener(listener, eventExecutor, eventPriority, de.steamwar.bausystem.BauSystem.getInstance(), ignoreCancelled));\n"); - writer.write(" }\n"); - writer.write("\n"); - } - writer.write("}\n"); - writer.flush(); - writer.close(); - return true; - } - - private String getElement(TypeElement typeElement, Map neededFields) { - if (neededFields.containsKey(typeElement.getQualifiedName().toString())) { - return typeElement.getSimpleName().toString() + "()"; - } - return "new " + typeElement.getQualifiedName().toString() + "()"; - } -} diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageType.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageType.java deleted file mode 100644 index dbb78910..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.linkage; - -public enum LinkageType { - - // NORMAL - COMMAND("$.setMessage(de.steamwar.bausystem.BauSystem.MESSAGE)", "de.steamwar.command.SWCommand"), - ENABLE_LINK("$.enable()", null, "de.steamwar.bausystem.linkage.Enable"), - DISABLE_LINK("$.disable()", null, "de.steamwar.bausystem.linkage.Disable"), - PLAIN("$", null), - LISTENER(), // Is handled internally from LinkageProcessor - UNLINK_LISTENER("org.bukkit.event.HandlerList.unregisterAll($)", null, "org.bukkit.event.Listener"), - - // SPECIFIC - BAU_GUI_ITEM("de.steamwar.bausystem.features.gui.BauGUI.addItem($)", "de.steamwar.bausystem.linkage.specific.BauGuiItem"), - SCRIPT_COMMAND("de.steamwar.bausystem.features.script.ScriptExecutor.SPECIAL_COMMANDS.add($)", null, "de.steamwar.bausystem.features.script.SpecialCommand"), - CONFIG_CONVERTER("de.steamwar.bausystem.configplayer.Config.addConfigConverter($)", null, "de.steamwar.bausystem.configplayer.ConfigConverter"), - SCOREBOARD(null, null, "de.steamwar.bausystem.linkage.specific.ScoreboardItem"), - PANZERN("de.steamwar.bausystem.features.slaves.panzern.Panzern.add($)", null, "de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm"), - SMART_PLACE("de.steamwar.bausystem.features.smartplace.SmartPlaceListener.add($)", null, "de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour"); - - String toRun = null; - String className = null; - String interfaceName = null; - - LinkageType() { - } - - LinkageType(String toRun, String className) { - this.toRun = toRun; - this.className = className; - } - - LinkageType(String toRun, String className, String interfaceName) { - this.toRun = toRun; - this.className = className; - this.interfaceName = interfaceName; - } -} \ No newline at end of file diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/Linked.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/Linked.java deleted file mode 100644 index 2096d1ac..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/Linked.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.linkage; - -import org.atteo.classindex.IndexAnnotated; - -import java.lang.annotation.*; - -@IndexAnnotated -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -@Repeatable(Linked.Linkages.class) -public @interface Linked { - LinkageType value(); - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.TYPE}) - @interface Linkages { - @SuppressWarnings("unused") Linked[] value() default {}; - } -} \ No newline at end of file diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkedInstance.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkedInstance.java deleted file mode 100644 index 5c26ea4f..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkedInstance.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.linkage; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD}) -public @interface LinkedInstance { -} diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/MinVersion.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/MinVersion.java deleted file mode 100644 index b72e5fe0..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/MinVersion.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.linkage; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface MinVersion { - int value(); -} From ba3293cdc285cb89c37711d27d3ec635f1ac4cef Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 25 Sep 2022 16:32:27 +0200 Subject: [PATCH 04/33] Update to linkage system Signed-off-by: yoyosource --- .../linkage/types/SmartPlaceBehaviour_GENERIC.java | 2 +- .../src/de/steamwar/bausystem/BauSystem.java | 13 +++---------- .../src/de/steamwar/bausystem/config/BauServer.java | 5 ++--- .../de/steamwar/bausystem/configplayer/Config.java | 5 ++--- .../features/autostart/AutoStartCommand.java | 5 ++--- .../features/autostart/AutoStartGuiItem.java | 5 ++--- .../features/autostart/AutostartListener.java | 5 ++--- .../bausystem/features/backup/BackupCommand.java | 5 ++--- .../steamwar/bausystem/features/bau/BauCommand.java | 7 +++---- .../bausystem/features/bau/BauInfoBauGuiItem.java | 5 ++--- .../bausystem/features/bau/InfoCommand.java | 7 +++---- .../features/countingwand/CountingwandCommand.java | 5 ++--- .../features/countingwand/CountingwandGuiItem.java | 5 ++--- .../features/countingwand/CountingwandListener.java | 5 ++--- .../features/detonator/DetonatorBauGuiItem.java | 5 ++--- .../features/detonator/DetonatorCommand.java | 5 ++--- .../features/detonator/DetonatorListener.java | 5 ++--- .../de/steamwar/bausystem/features/gui/BauGUI.java | 3 +-- .../bausystem/features/gui/BauGUICommand.java | 5 ++--- .../bausystem/features/gui/BauGuiBauGuiItem.java | 5 ++--- .../bausystem/features/gui/BauGuiListener.java | 5 ++--- .../bausystem/features/gui/editor/BauGuiEditor.java | 5 ++--- .../features/gui/editor/BauGuiEditorGuiItem.java | 5 ++--- .../bausystem/features/hotbar/HotbarCommand.java | 5 ++--- .../bausystem/features/hotbar/HotbarListener.java | 5 ++--- .../inventoryfiller/InventoryFillBauGuiItem.java | 8 +++----- .../features/inventoryfiller/InventoryFiller.java | 5 ++--- .../inventoryfiller/InventoryFillerCommand.java | 5 ++--- .../bausystem/features/loader/LoaderBauGuiItem.java | 5 ++--- .../bausystem/features/loader/LoaderCommand.java | 8 ++++---- .../features/loadtimer/LoadtimerCommand.java | 5 ++--- .../features/loadtimer/LoadtimerGuiItem.java | 5 ++--- .../features/loadtimer/LoadtimerListener.java | 5 ++--- .../features/observer/ObserverTracerCommand.java | 5 ++--- .../features/observer/ObserverTracerListener.java | 5 ++--- .../redstonetester/RedstoneTesterGuiItem.java | 5 ++--- .../redstonetester/RedstonetesterCommand.java | 5 ++--- .../redstonetester/RestonetesterListener.java | 5 ++--- .../bausystem/features/region/ColorCommand.java | 7 +++---- .../bausystem/features/region/FireCommand.java | 5 ++--- .../bausystem/features/region/FireListener.java | 5 ++--- .../bausystem/features/region/FreezeCommand.java | 5 ++--- .../bausystem/features/region/FreezeListener.java | 5 ++--- .../bausystem/features/region/ProtectCommand.java | 5 ++--- .../bausystem/features/region/ProtectListener.java | 5 ++--- .../bausystem/features/region/RegionCommand.java | 7 +++---- .../bausystem/features/region/RegionListener.java | 5 ++--- .../bausystem/features/region/ResetCommand.java | 5 ++--- .../bausystem/features/region/TNTCommand.java | 5 ++--- .../bausystem/features/region/TNTListener.java | 7 +++---- .../bausystem/features/region/TestblockCommand.java | 5 ++--- .../features/region/items/ColorBauGuiItem.java | 5 ++--- .../features/region/items/FireBauGuiItem.java | 5 ++--- .../features/region/items/FreezeBauGuiItem.java | 5 ++--- .../features/region/items/ProtectBauGuiItem.java | 5 ++--- .../features/region/items/ResetBauGuiItem.java | 7 +++---- .../features/region/items/TestblockBauGuiItem.java | 7 +++---- .../features/region/items/TntBauGuiItem.java | 5 ++--- .../features/script/CustomScriptManager.java | 5 ++--- .../bausystem/features/script/ScriptCommand.java | 7 +++---- .../features/script/ScriptEventListener.java | 7 +++---- .../bausystem/features/script/ScriptExecutor.java | 3 +-- .../bausystem/features/script/ScriptListener.java | 5 ++--- .../features/script/command/arithmetic/Add.java | 5 ++--- .../features/script/command/arithmetic/Div.java | 5 ++--- .../features/script/command/arithmetic/Mul.java | 5 ++--- .../features/script/command/arithmetic/Sub.java | 5 ++--- .../script/command/arithmetic/other/Ceil.java | 5 ++--- .../script/command/arithmetic/other/Floor.java | 5 ++--- .../script/command/arithmetic/other/Round.java | 5 ++--- .../bausystem/features/script/command/io/Echo.java | 5 ++--- .../features/script/command/io/Echoactionbar.java | 5 ++--- .../bausystem/features/script/command/io/Input.java | 5 ++--- .../features/script/command/logic/And.java | 5 ++--- .../features/script/command/logic/Equal.java | 5 ++--- .../features/script/command/logic/Greater.java | 5 ++--- .../features/script/command/logic/Less.java | 5 ++--- .../features/script/command/logic/Not.java | 5 ++--- .../bausystem/features/script/command/logic/Or.java | 5 ++--- .../features/script/command/string/Insert.java | 5 ++--- .../features/script/command/string/Length.java | 5 ++--- .../features/script/command/string/Remove.java | 5 ++--- .../features/script/command/string/Replace.java | 5 ++--- .../features/script/command/string/Substring.java | 5 ++--- .../features/script/command/variable/Const.java | 5 ++--- .../features/script/command/variable/Convert.java | 5 ++--- .../features/script/command/variable/Global.java | 5 ++--- .../features/script/command/variable/Isset.java | 5 ++--- .../features/script/command/variable/Unglobal.java | 5 ++--- .../features/script/command/variable/Unvar.java | 5 ++--- .../features/script/command/variable/Var.java | 5 ++--- .../features/script/command/variable/Vartype.java | 5 ++--- .../features/script/command/world/GetMaterial.java | 5 ++--- .../features/script/command/world/SetMaterial.java | 5 ++--- .../features/script/items/ScriptMenuBauGuiItem.java | 5 ++--- .../features/simulator/SimulatorBauGuiItem.java | 5 ++--- .../features/simulator/SimulatorCommand.java | 5 ++--- .../features/simulator/SimulatorStorage.java | 6 ++---- .../features/simulator/TNTSimulatorListener.java | 5 ++--- .../features/slaves/laufbau/LaufbauCommand.java | 7 +++---- .../features/slaves/laufbau/LaufbauUtils.java | 5 ++--- .../bausystem/features/slaves/panzern/Panzern.java | 5 ++--- .../features/slaves/panzern/PanzernCommand.java | 7 +++---- .../slaves/panzern/algorithms/AdjacentHoney.java | 5 ++--- .../slaves/panzern/algorithms/AdjacentSlime.java | 5 ++--- .../slaves/panzern/algorithms/CarpetWalkWay.java | 5 ++--- .../slaves/panzern/algorithms/LadderWalkWay.java | 5 ++--- .../slaves/panzern/algorithms/PistonLine.java | 5 ++--- .../panzern/algorithms/PowerableActivation.java | 5 ++--- .../slaves/panzern/algorithms/SlabOnRedstone.java | 5 ++--- .../slaves/panzern/algorithms/SlabOnTorch.java | 5 ++--- .../slaves/panzern/algorithms/StairWalkWay.java | 5 ++--- .../features/smartplace/SmartPlaceCommand.java | 5 ++--- .../features/smartplace/SmartPlaceListener.java | 9 ++++----- .../smartplace/behaviour/BlockPlaceBehaviour.java | 5 ++--- .../behaviour/BlockRotatingBehaviour.java | 5 ++--- .../behaviour/ReverseRepeaterBehaviour.java | 5 ++--- .../bausystem/features/team/LockSchemCommand.java | 5 ++--- .../bausystem/features/team/SkinCommand.java | 5 ++--- .../features/techhider/TechHiderCommand.java | 8 +++----- .../testblock/blockcounter/BlockCounterCommand.java | 5 ++--- .../blockcounter/BlockCounterListener.java | 5 ++--- .../testblock/depthcounter/DepthCounterCommand.java | 5 ++--- .../depthcounter/DepthCounterListener.java | 5 ++--- .../features/tpslimit/TPSLimitBauGuiItem.java | 5 ++--- .../features/tpslimit/TPSLimitCommand.java | 6 ++---- .../bausystem/features/tpslimit/TickCommand.java | 5 ++--- .../bausystem/features/tracer/TraceCommand.java | 1 + .../bausystem/features/tracer/TracerBauGuiItem.java | 1 + .../bausystem/features/util/KillAllCommand.java | 1 + .../features/util/items/KillAllBauGuiItem.java | 7 +++---- .../steamwar/bausystem/region/BackupScheduler.java | 5 ++--- 132 files changed, 277 insertions(+), 411 deletions(-) diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java index 6edaea3d..0f50ac45 100644 --- a/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java @@ -29,7 +29,7 @@ public class SmartPlaceBehaviour_GENERIC implements LinkageType { @Override public String method() { - return "linkPanzern"; + return "linkSmartPlace"; } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index da0ae7bc..565f368f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -21,12 +21,11 @@ package de.steamwar.bausystem; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; import de.steamwar.bausystem.worlddata.WorldData; +import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.message.Message; import lombok.Getter; import org.bukkit.Bukkit; @@ -73,12 +72,7 @@ public class BauSystem extends JavaPlugin implements Listener { new Updater(PrototypeLoader.file, PrototypeLoader::load); new Updater(RegionLoader.file, RegionLoader::load); - LinkageUtils.run(LinkageType.PLAIN); - LinkageUtils.run(LinkageType.COMMAND); - LinkageUtils.run(LinkageType.ENABLE_LINK); - LinkageUtils.run(LinkageType.LISTENER); - LinkageUtils.run(LinkageType.CONFIG_CONVERTER); - LinkageUtils.run(LinkageType.SCOREBOARD); + LinkageUtils.link(); // This could disable any watchdog stuff. We need to investigate if this is a problem. /* @@ -100,8 +94,7 @@ public class BauSystem extends JavaPlugin implements Listener { @Override public void onDisable() { - LinkageUtils.run(LinkageType.DISABLE_LINK); - LinkageUtils.run(LinkageType.UNLINK_LISTENER); + LinkageUtils.unlink(); WorldData.write(); Config.getInstance().saveAll(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java b/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java index d644d419..3dc792f0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java @@ -19,15 +19,14 @@ package de.steamwar.bausystem.config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import de.steamwar.providers.BauServerInfo; import de.steamwar.sql.SteamwarUser; import lombok.Getter; import java.util.UUID; -@Linked(LinkageType.PLAIN) +@Linked public class BauServer { @Getter diff --git a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java index bc9cde30..2f929687 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/configplayer/Config.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.configplayer; import de.steamwar.bausystem.configplayer.serializer.ConfigurationSerializableSerializer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import de.steamwar.sql.UserConfig; import lombok.Getter; import org.bukkit.Bukkit; @@ -40,7 +39,7 @@ import java.util.Map; import java.util.UUID; import java.util.logging.Level; -@Linked(LinkageType.LISTENER) +@Linked public class Config implements Listener { static { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java index 552dd816..8e2b8c1a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.autostart; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class AutoStartCommand extends SWCommand { public AutoStartCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java index fab4a2f6..a66e3785 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartGuiItem.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.features.autostart; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class AutoStartGuiItem extends BauGuiItem { public AutoStartGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java index c576d0ba..8d254a3a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutostartListener.java @@ -21,14 +21,13 @@ package de.steamwar.bausystem.features.autostart; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -44,7 +43,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; -@Linked(LinkageType.LISTENER) +@Linked public class AutostartListener implements Listener { @Getter diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java index 7214bd40..9799b628 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -21,8 +21,6 @@ package de.steamwar.bausystem.features.backup; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.tags.Tag; import de.steamwar.command.SWCommand; @@ -31,6 +29,7 @@ import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -42,7 +41,7 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) +@Linked public class BackupCommand extends SWCommand { public BackupCommand() { 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 3e039a90..69ee7af8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -19,13 +19,12 @@ package de.steamwar.bausystem.features.bau; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class BauCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index a9d63e31..7f3c27b9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -22,12 +22,11 @@ package de.steamwar.bausystem.features.bau; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -37,7 +36,7 @@ import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class BauInfoBauGuiItem extends BauGuiItem { public BauInfoBauGuiItem() { 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 58b3dc20..b3de2a11 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -3,13 +3,12 @@ package de.steamwar.bausystem.features.bau; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.command.SWCommand; import de.steamwar.core.TPSWatcher; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; @@ -18,7 +17,7 @@ import java.util.List; import static de.steamwar.bausystem.features.tpslimit.TPSWarpUtils.getTps; -@Linked(LinkageType.COMMAND) +@Linked public class InfoCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java index 2ffab2ff..c7d9b270 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java @@ -20,13 +20,12 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class CountingwandCommand extends SWCommand { public CountingwandCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java index dd709d4e..7772f9c7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandGuiItem.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.features.countingwand; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class CountingwandGuiItem extends BauGuiItem { public CountingwandGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java index ced97677..7233670a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandListener.java @@ -19,9 +19,8 @@ package de.steamwar.bausystem.features.countingwand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Point; +import de.steamwar.linkage.Linked; import org.bukkit.FluidCollisionMode; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,7 +33,7 @@ import org.bukkit.util.RayTraceResult; import java.util.Objects; -@Linked(LinkageType.LISTENER) +@Linked public class CountingwandListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java index 628531d6..2207ce45 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorBauGuiItem.java @@ -20,14 +20,13 @@ package de.steamwar.bausystem.features.detonator; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class DetonatorBauGuiItem extends BauGuiItem { public DetonatorBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java index a016fbd0..bb71245d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java @@ -24,10 +24,9 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.configplayer.Config; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; @@ -35,7 +34,7 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.Arrays; -@Linked(LinkageType.COMMAND) +@Linked public class DetonatorCommand extends SWCommand { public static ItemStack getWAND(Player player) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java index a7d11f69..2e0cbf38 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorListener.java @@ -25,8 +25,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage; import de.steamwar.bausystem.features.detonator.storage.ItemStorage; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -42,7 +41,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -@Linked(LinkageType.LISTENER) +@Linked public class DetonatorListener implements Listener { public static final Class useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java index f5356018..74a915da 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.gui.editor.BauGuiMapping; -import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWInventory; @@ -42,7 +41,7 @@ public class BauGUI { private static final Map ITEMS = new HashMap<>(); public static Map getITEMS() { - LinkageUtils.run(LinkageType.BAU_GUI_ITEM); + if (ITEMS.isEmpty()) LinkageUtils.linkGUIItems(); return ITEMS; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java index 30ae286b..f6810ef7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java @@ -20,13 +20,12 @@ package de.steamwar.bausystem.features.gui; import de.steamwar.bausystem.features.gui.editor.BauGuiEditor; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class BauGUICommand extends SWCommand { public BauGUICommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiBauGuiItem.java index 06da95d6..c03b458a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiBauGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.gui; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class BauGuiBauGuiItem extends BauGuiItem { public BauGuiBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java index e8c48493..5895019f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGuiListener.java @@ -19,14 +19,13 @@ package de.steamwar.bausystem.features.gui; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -@Linked(LinkageType.LISTENER) +@Linked public class BauGuiListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java index 18d5b350..06c4a41c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditor.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.gui.editor; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.gui.BauGUI; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -46,7 +45,7 @@ import org.bukkit.persistence.PersistentDataType; import java.util.*; -@Linked(LinkageType.LISTENER) +@Linked public class BauGuiEditor implements Listener { @Getter diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java index 56eb6d8f..b1a76041 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiEditorGuiItem.java @@ -21,16 +21,15 @@ package de.steamwar.bausystem.features.gui.editor; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class BauGuiEditorGuiItem extends BauGuiItem { public BauGuiEditorGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java index 26b4024b..9b52890c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java @@ -20,14 +20,13 @@ package de.steamwar.bausystem.features.hotbar; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWInventory; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.COMMAND) +@Linked public class HotbarCommand extends SWCommand { public HotbarCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java index 9c6f6bbd..de00331f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarListener.java @@ -19,14 +19,13 @@ package de.steamwar.bausystem.features.hotbar; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; -@Linked(LinkageType.LISTENER) +@Linked public class HotbarListener implements Listener { @EventHandler(priority = EventPriority.LOWEST) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java index d5b7f70e..7e94710a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillBauGuiItem.java @@ -3,12 +3,10 @@ package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.features.inventoryfiller.InventoryFillerCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -16,7 +14,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Collections; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class InventoryFillBauGuiItem extends BauGuiItem { public InventoryFillBauGuiItem() { super(34); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java index dd7c1b01..f72d08f2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFiller.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Material; import org.bukkit.block.Block; @@ -34,7 +33,7 @@ import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.LISTENER) +@Linked public class InventoryFiller implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java index 8ef0d841..4804a9d7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/inventoryfiller/InventoryFillerCommand.java @@ -3,12 +3,11 @@ package de.steamwar.bausystem.features.inventoryfiller; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class InventoryFillerCommand extends SWCommand { public InventoryFillerCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java index 0007bdcf..5dc1df11 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java @@ -21,12 +21,11 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -34,7 +33,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class LoaderBauGuiItem extends BauGuiItem { public LoaderBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index afafed99..ffea7e4f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -21,12 +21,12 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.*; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class LoaderCommand extends SWCommand { public LoaderCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java index 29bf67f2..42d5175c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerCommand.java @@ -19,13 +19,12 @@ package de.steamwar.bausystem.features.loadtimer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class LoadtimerCommand extends SWCommand { public LoadtimerCommand() { super("loadtimer", "lt", "stopuhr"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java index 1035fa75..f190d9f0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerGuiItem.java @@ -21,18 +21,17 @@ package de.steamwar.bausystem.features.loadtimer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class LoadtimerGuiItem extends BauGuiItem { public LoadtimerGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java index 89881af9..ddbaed9a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loadtimer/LoadtimerListener.java @@ -19,9 +19,8 @@ package de.steamwar.bausystem.features.loadtimer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; @@ -33,7 +32,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import static de.steamwar.bausystem.features.loadtimer.Loadtimer.*; -@Linked(LinkageType.LISTENER) +@Linked public class LoadtimerListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java index 76d99616..fd0df724 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class ObserverTracerCommand extends SWCommand { public ObserverTracerCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java index 5070a3ba..b841755b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/observer/ObserverTracerListener.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.observer; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Material; @@ -38,7 +37,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -@Linked(LinkageType.LISTENER) +@Linked public class ObserverTracerListener implements Listener { static Set enabled = new HashSet<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java index 103c7d5f..eebcf0cc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.redstonetester; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -32,7 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class RedstoneTesterGuiItem extends BauGuiItem { public RedstoneTesterGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java index 9917b313..0e1c7b63 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java @@ -21,12 +21,11 @@ package de.steamwar.bausystem.features.redstonetester; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class RedstonetesterCommand extends SWCommand { public RedstonetesterCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java index cef31f42..2ab015b9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java @@ -20,9 +20,8 @@ package de.steamwar.bausystem.features.redstonetester; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ItemUtils; +import de.steamwar.linkage.Linked; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,7 +35,7 @@ import org.bukkit.event.player.PlayerQuitEvent; import java.util.Objects; -@Linked(LinkageType.LISTENER) +@Linked public class RestonetesterListener implements Listener { @EventHandler 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 7d990231..1213a314 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -21,9 +21,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; @@ -32,11 +29,13 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.entity.Player; import java.io.IOException; -@Linked(LinkageType.COMMAND) +@Linked public class ColorCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java index 7d49965c..da5b2665 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireCommand.java @@ -20,17 +20,16 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class FireCommand extends SWCommand { public FireCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java index 9a303881..43aaf626 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FireListener.java @@ -1,16 +1,15 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; +import de.steamwar.linkage.Linked; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockSpreadEvent; -@Linked(LinkageType.LISTENER) +@Linked public class FireListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java index a16c705b..303bc49a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeCommand.java @@ -20,17 +20,16 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class FreezeCommand extends SWCommand { public FreezeCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index 8112cb3e..dc8232b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -1,12 +1,11 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.block.Block; @@ -21,7 +20,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.inventory.InventoryMoveItemEvent; import org.bukkit.event.player.PlayerInteractEvent; -@Linked(LinkageType.LISTENER) +@Linked public class FreezeListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java index d4fa972c..3793d3ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectCommand.java @@ -21,17 +21,16 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class ProtectCommand extends SWCommand { public ProtectCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java index b263fcde..e52d1ebb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ProtectListener.java @@ -1,10 +1,9 @@ package de.steamwar.bausystem.features.region; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; @@ -14,7 +13,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.List; -@Linked(LinkageType.LISTENER) +@Linked public class ProtectListener implements Listener { private void explode(List blockList, Location location) { 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 819db4e0..4bd0faf4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -22,9 +22,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.util.SelectCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -33,6 +30,8 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.sql.SchematicNode; import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; @@ -46,7 +45,7 @@ import java.util.List; import java.util.logging.Level; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) +@Linked public class RegionCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java index 5c43f369..38b6532e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionListener.java @@ -20,10 +20,9 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.tags.Tag; +import de.steamwar.linkage.Linked; import org.bukkit.Location; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -38,7 +37,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.scheduler.BukkitRunnable; -@Linked(LinkageType.LISTENER) +@Linked public class RegionListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java index 38c36463..670facf5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ResetCommand.java @@ -21,14 +21,13 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -36,7 +35,7 @@ import org.bukkit.entity.Player; import java.io.IOException; import java.util.logging.Level; -@Linked(LinkageType.COMMAND) +@Linked public class ResetCommand extends SWCommand { public ResetCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java index 9d748221..a7c11223 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTCommand.java @@ -21,8 +21,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; @@ -31,6 +29,7 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -39,7 +38,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -@Linked(LinkageType.COMMAND) +@Linked public class TNTCommand extends SWCommand { public TNTCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java index ea90e212..92164545 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TNTListener.java @@ -21,15 +21,14 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.features.script.CustomScriptManager; import de.steamwar.bausystem.features.script.EventType; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.block.Block; @@ -43,7 +42,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -@Linked(LinkageType.LISTENER) +@Linked public class TNTListener implements Listener { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java index 26a3727f..80a71346 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/TestblockCommand.java @@ -21,8 +21,6 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.utils.RegionExtensionType; @@ -31,6 +29,7 @@ import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; @@ -44,7 +43,7 @@ import java.util.List; import java.util.Map; import java.util.logging.Level; -@Linked(LinkageType.COMMAND) +@Linked public class TestblockCommand extends SWCommand { public TestblockCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index b59e23d8..a38c397f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -21,8 +21,6 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; @@ -30,6 +28,7 @@ import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -39,7 +38,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class ColorBauGuiItem extends BauGuiItem { public ColorBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java index 8986e806..01714fba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FireBauGuiItem.java @@ -21,19 +21,18 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class FireBauGuiItem extends BauGuiItem { public FireBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java index a107652e..43d1903f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/FreezeBauGuiItem.java @@ -21,19 +21,18 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class FreezeBauGuiItem extends BauGuiItem { public FreezeBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java index ae4b6bdb..f56745f0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java @@ -21,19 +21,18 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class ProtectBauGuiItem extends BauGuiItem { public ProtectBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java index 67d7c20d..4f41809c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java @@ -22,18 +22,17 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.region.ResetCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SchematicSelector; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class ResetBauGuiItem extends BauGuiItem { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java index ed9be915..2b3b863a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TestblockBauGuiItem.java @@ -22,18 +22,17 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.region.TestblockCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SchematicSelector; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class TestblockBauGuiItem extends BauGuiItem { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java index 678da86a..f4626cce 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/TntBauGuiItem.java @@ -21,20 +21,19 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class TntBauGuiItem extends BauGuiItem { public TntBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java index 6b8a58fb..a8bebb34 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/CustomScriptManager.java @@ -22,11 +22,10 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import de.steamwar.sql.UserConfig; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -51,7 +50,7 @@ import yapion.parser.YAPIONParser; import java.util.*; import java.util.stream.Collectors; -@Linked(LinkageType.LISTENER) +@Linked public class CustomScriptManager implements Listener { private final Map> playerMap = Collections.synchronizedMap(new HashMap<>()); // new ConcurrentHashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java index ecf04036..1d19575f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java @@ -1,12 +1,11 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -16,7 +15,7 @@ import java.util.List; import static de.steamwar.bausystem.features.script.ScriptExecutor.SPECIAL_COMMANDS; -@Linked(LinkageType.COMMAND) +@Linked public class ScriptCommand extends SWCommand { public ScriptCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptEventListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptEventListener.java index 32c8d40c..c0852437 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptEventListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptEventListener.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Bukkit; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -43,7 +42,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -@Linked(LinkageType.LISTENER) +@Linked public class ScriptEventListener implements Listener { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java index afb80afb..5e7239a5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptExecutor.java @@ -4,7 +4,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.variables.Constants; import de.steamwar.bausystem.features.script.variables.Context; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageUtils; import lombok.Getter; import lombok.Setter; @@ -21,7 +20,7 @@ public final class ScriptExecutor { public static final Set SPECIAL_COMMANDS = new HashSet<>(); static { - LinkageUtils.run(LinkageType.SCRIPT_COMMAND); + LinkageUtils.linkScriptCommands(); } private String specialCommand = null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java index f2c94291..1c472da6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptListener.java @@ -1,9 +1,8 @@ package de.steamwar.bausystem.features.script; import de.steamwar.bausystem.features.script.variables.Context; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -20,7 +19,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -@Linked(LinkageType.LISTENER) +@Linked public class ScriptListener implements Listener { private static final Map GLOBAL_CONTEXT = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Add.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Add.java index 1fec025b..75006f6d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Add.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Add.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Add implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Div.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Div.java index f4f4cbc8..f50b4e34 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Div.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Div.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Div implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Mul.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Mul.java index bdb382fd..cce89be9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Mul.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Mul.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Mul implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Sub.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Sub.java index c327931b..00d6e694 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Sub.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/Sub.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Sub implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Ceil.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Ceil.java index abe38f4b..b138b9ea 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Ceil.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Ceil.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Ceil implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Floor.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Floor.java index 86ee993a..bebf209b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Floor.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Floor.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Floor implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Round.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Round.java index ed037b8c..31a00aec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Round.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/arithmetic/other/Round.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Round implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echo.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echo.java index e5f0d05e..e403edd8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echo.java @@ -3,12 +3,11 @@ package de.steamwar.bausystem.features.script.command.io; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Echo implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java index 6f45005c..000e1eec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java @@ -3,12 +3,11 @@ package de.steamwar.bausystem.features.script.command.io; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Echoactionbar implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Input.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Input.java index a18b5055..8b0234b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Input.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Input.java @@ -4,13 +4,12 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWAnvilInv; +import de.steamwar.linkage.Linked; import org.bukkit.ChatColor; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Input implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/And.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/And.java index bc28ae90..7f0ea700 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/And.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/And.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class And implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java index 97a9a4e4..9ac6d6b1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Equal.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Equal implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java index 8a30d5ab..be5e7e3f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Greater.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Greater implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java index 711144a5..3368e9dd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Less.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Less implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Not.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Not.java index 6a839005..bc1c0f2d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Not.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Not.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Not implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Or.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Or.java index 040e8d63..bec5950c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Or.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/logic/Or.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Or implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Insert.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Insert.java index 74031871..5405ad42 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Insert.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Insert.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Insert implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Length.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Length.java index 6b0f52f7..05a26a53 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Length.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Length.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Length implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Remove.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Remove.java index 043463f0..b1ed2e14 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Remove.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Remove.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Remove implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Replace.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Replace.java index 53b29323..ec3b6f13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Replace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Replace.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Replace implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Substring.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Substring.java index 1a899434..ab5fd935 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Substring.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/string/Substring.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Substring implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Const.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Const.java index 97f85174..f69a6b34 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Const.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Const.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Constants; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Const implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java index 34334454..90413443 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Convert.java @@ -22,11 +22,10 @@ package de.steamwar.bausystem.features.script.command.variable; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Convert implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Global.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Global.java index b1620146..ec9fdcbb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Global.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Global.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command.variable; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Global implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java index a9d779f7..b246eb83 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Isset.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Isset implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unglobal.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unglobal.java index 496874f6..3fbc712b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unglobal.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unglobal.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command.variable; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Unglobal implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unvar.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unvar.java index 0e1b75ef..016ac170 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unvar.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Unvar.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command.variable; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Unvar implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Var.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Var.java index 313301a7..bedb88da 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Var.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Var.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command.variable; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Var implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java index 5ad79466..46680548 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/variable/Vartype.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Vartype implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/GetMaterial.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/GetMaterial.java index cfbe46b6..60dd9243 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/GetMaterial.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/GetMaterial.java @@ -23,13 +23,12 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class GetMaterial implements SpecialCommand { private final World world = Bukkit.getWorlds().get(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/SetMaterial.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/SetMaterial.java index 18b4ffe2..12dd41c2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/SetMaterial.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/world/SetMaterial.java @@ -22,13 +22,12 @@ package de.steamwar.bausystem.features.script.command.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.World; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class SetMaterial implements SpecialCommand { private final World world = Bukkit.getWorlds().get(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/items/ScriptMenuBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/items/ScriptMenuBauGuiItem.java index 04c13668..437b4760 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/items/ScriptMenuBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/items/ScriptMenuBauGuiItem.java @@ -21,16 +21,15 @@ package de.steamwar.bausystem.features.script.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class ScriptMenuBauGuiItem extends BauGuiItem { public ScriptMenuBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java index ae034549..baae7add 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorBauGuiItem.java @@ -21,17 +21,16 @@ package de.steamwar.bausystem.features.simulator; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class SimulatorBauGuiItem extends BauGuiItem { public SimulatorBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java index db38aabe..f8961d81 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCommand.java @@ -23,19 +23,18 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import java.util.Collection; -@Linked(LinkageType.COMMAND) +@Linked public class SimulatorCommand extends SWCommand { public SimulatorCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java index 074298d8..7091f7b7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java @@ -24,10 +24,9 @@ import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.simulator.tnt.TNTElement; import de.steamwar.bausystem.linkage.Disable; import de.steamwar.bausystem.linkage.Enable; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.Material; @@ -49,8 +48,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -@Linked(LinkageType.ENABLE_LINK) -@Linked(LinkageType.DISABLE_LINK) +@Linked public class SimulatorStorage implements Enable, Disable { public static final World WORLD = Bukkit.getWorlds().get(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java index 8120bd85..d057fd76 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulatorListener.java @@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.simulator; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.simulator.gui.SimulatorSelectionGUI; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.bausystem.utils.RayTraceUtils; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -40,7 +39,7 @@ import org.bukkit.util.RayTraceResult; import java.util.function.Function; -@Linked(LinkageType.LISTENER) +@Linked public class TNTSimulatorListener implements Listener { private boolean permissionCheck(Player player) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java index 3de73826..d188e799 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauCommand.java @@ -22,18 +22,17 @@ package de.steamwar.bausystem.features.slaves.laufbau; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.Pair; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; -@Linked(LinkageType.COMMAND) +@Linked public class LaufbauCommand extends SWCommand { public LaufbauCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java index d0168103..9a9fb24a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauUtils.java @@ -20,9 +20,8 @@ package de.steamwar.bausystem.features.slaves.laufbau; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import de.steamwar.sql.UserConfig; import lombok.Cleanup; import lombok.SneakyThrows; @@ -45,7 +44,7 @@ import java.util.stream.Collectors; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -@Linked(LinkageType.LISTENER) +@Linked public class LaufbauUtils implements Listener { private static Map yapionObjectMap = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index ca667a8b..f8ade838 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -23,9 +23,8 @@ import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageUtils; +import de.steamwar.bausystem.utils.WorldEditUtils; import lombok.Getter; import lombok.SneakyThrows; import org.bukkit.Location; @@ -41,7 +40,7 @@ public class Panzern { private static List panzernAlgorithmList = new ArrayList<>(); static { - LinkageUtils.run(LinkageType.PANZERN); + LinkageUtils.linkPanzern(); } public static void add(PanzernAlgorithm panzernAlgorithm) { panzernAlgorithmList.add(panzernAlgorithm); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java index 83d93f13..9f26830c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/PanzernCommand.java @@ -22,13 +22,12 @@ package de.steamwar.bausystem.features.slaves.panzern; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.Pair; +import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -41,7 +40,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -@Linked(LinkageType.COMMAND) +@Linked public class PanzernCommand extends SWCommand { public PanzernCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java index 3992c3a8..7dd8accd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentHoney.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -30,7 +29,7 @@ import org.bukkit.block.BlockFace; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class AdjacentHoney implements PanzernAlgorithm { private PistonLine pistonLine = new PistonLine(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java index 21469412..f25c55e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/AdjacentSlime.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -30,7 +29,7 @@ import org.bukkit.block.BlockFace; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class AdjacentSlime implements PanzernAlgorithm { private PistonLine pistonLine = new PistonLine(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/CarpetWalkWay.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/CarpetWalkWay.java index 302e951e..58529f2c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/CarpetWalkWay.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/CarpetWalkWay.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -30,7 +29,7 @@ import org.bukkit.block.BlockFace; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class CarpetWalkWay implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/LadderWalkWay.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/LadderWalkWay.java index 37ca6002..2a32bd7a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/LadderWalkWay.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/LadderWalkWay.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -30,7 +29,7 @@ import org.bukkit.block.BlockFace; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class LadderWalkWay implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java index 653ccec2..3fabd420 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PistonLine.java @@ -21,9 +21,8 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -33,7 +32,7 @@ import org.bukkit.block.data.type.Piston; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class PistonLine implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java index 1fa366b1..41b7f69d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/PowerableActivation.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -34,7 +33,7 @@ import org.bukkit.block.data.type.RedstoneWire; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class PowerableActivation implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnRedstone.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnRedstone.java index 74c2ddf3..207f1d57 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnRedstone.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnRedstone.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -30,7 +29,7 @@ import org.bukkit.block.BlockFace; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class SlabOnRedstone implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnTorch.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnTorch.java index 8050303b..beebb532 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnTorch.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/SlabOnTorch.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -32,7 +31,7 @@ import org.bukkit.block.data.Powerable; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class SlabOnTorch implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/StairWalkWay.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/StairWalkWay.java index ee08a485..1f631afe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/StairWalkWay.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/algorithms/StairWalkWay.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.slaves.panzern.algorithms; import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.slaves.panzern.PanzernResult; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -32,7 +31,7 @@ import org.bukkit.block.data.type.Stairs; import java.util.Map; import java.util.Set; -@Linked(LinkageType.PANZERN) +@Linked public class StairWalkWay implements PanzernAlgorithm { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java index 399e21b5..526e59e6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceCommand.java @@ -22,12 +22,11 @@ package de.steamwar.bausystem.features.smartplace; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class SmartPlaceCommand extends SWCommand { public SmartPlaceCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index 98f2c99e..a5ac0456 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -20,9 +20,8 @@ package de.steamwar.bausystem.features.smartplace; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.LinkageUtils; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Directional; @@ -36,7 +35,7 @@ import org.bukkit.event.player.PlayerInteractEvent; import java.util.ArrayList; import java.util.List; -@Linked(LinkageType.LISTENER) +@Linked public class SmartPlaceListener implements Listener { private static List smartPlaceBehaviours = new ArrayList<>(); @@ -48,7 +47,7 @@ public class SmartPlaceListener implements Listener { @EventHandler public void onBlockPlace(BlockPlaceEvent event) { if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; - LinkageUtils.run(LinkageType.SMART_PLACE); + if (smartPlaceBehaviours.isEmpty()) LinkageUtils.linkSmartPlace(); SmartPlaceBehaviour.SmartPlaceResult smartPlaceResult = SmartPlaceBehaviour.SmartPlaceResult.IGNORED; for (SmartPlaceBehaviour smartPlaceBehaviour : smartPlaceBehaviours) { if (smartPlaceBehaviour.getType() == SmartPlaceBehaviour.SmartPlaceType.PLACE) { @@ -63,7 +62,7 @@ public class SmartPlaceListener implements Listener { @EventHandler public void onPlayerInteract(PlayerInteractEvent event) { if (!Config.getInstance().get(event.getPlayer()).getPlainValueOrDefault("smartPlace", false)) return; - LinkageUtils.run(LinkageType.SMART_PLACE); + if (smartPlaceBehaviours.isEmpty()) LinkageUtils.linkSmartPlace(); if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return; if (event.getPlayer().getGameMode() == GameMode.SPECTATOR) return; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockPlaceBehaviour.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockPlaceBehaviour.java index 68830598..97b93b94 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockPlaceBehaviour.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockPlaceBehaviour.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.smartplace.behaviour; import de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.data.BlockData; @@ -29,7 +28,7 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Rotatable; import org.bukkit.event.block.BlockPlaceEvent; -@Linked(LinkageType.SMART_PLACE) +@Linked public class BlockPlaceBehaviour implements SmartPlaceBehaviour { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockRotatingBehaviour.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockRotatingBehaviour.java index fc8a2150..eed4df5a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockRotatingBehaviour.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/BlockRotatingBehaviour.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.smartplace.behaviour; import de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -33,7 +32,7 @@ import org.bukkit.event.Event; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.InventoryHolder; -@Linked(LinkageType.SMART_PLACE) +@Linked public class BlockRotatingBehaviour implements SmartPlaceBehaviour { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/ReverseRepeaterBehaviour.java b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/ReverseRepeaterBehaviour.java index 2c4a071a..13242417 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/ReverseRepeaterBehaviour.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/behaviour/ReverseRepeaterBehaviour.java @@ -20,13 +20,12 @@ package de.steamwar.bausystem.features.smartplace.behaviour; import de.steamwar.bausystem.features.smartplace.SmartPlaceBehaviour; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.data.type.Repeater; import org.bukkit.event.player.PlayerInteractEvent; -@Linked(LinkageType.SMART_PLACE) +@Linked public class ReverseRepeaterBehaviour implements SmartPlaceBehaviour { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java index daa5200f..05e0c408 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/LockSchemCommand.java @@ -20,16 +20,15 @@ package de.steamwar.bausystem.features.team; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SchematicType; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class LockSchemCommand extends SWCommand { public LockSchemCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java index daea307c..c9e2f80f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/team/SkinCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.team; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.UserGroup; import net.md_5.bungee.api.chat.ClickEvent; @@ -41,7 +40,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -@Linked(LinkageType.COMMAND) +@Linked public class SkinCommand extends SWCommand { public SkinCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 4f150ef3..622632fd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -21,12 +21,11 @@ package de.steamwar.bausystem.features.techhider; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.xray.XrayCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.command.SWCommand; import de.steamwar.core.CraftbukkitWrapper; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Material; @@ -41,8 +40,7 @@ import java.io.File; import java.util.*; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.LISTENER) +@Linked public class TechHiderCommand extends SWCommand implements Listener { public TechHiderCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterCommand.java index 6d997edd..a31cba2b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.testblock.blockcounter; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class BlockCounterCommand extends SWCommand { public BlockCounterCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java index f910f935..979e5fe3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounterListener.java @@ -19,11 +19,10 @@ package de.steamwar.bausystem.features.testblock.blockcounter; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,7 +31,7 @@ import org.bukkit.event.entity.EntityExplodeEvent; import java.util.List; import java.util.stream.Collectors; -@Linked(LinkageType.LISTENER) +@Linked public class BlockCounterListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterCommand.java index 5eaa9399..b8fd1e6c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.testblock.depthcounter; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class DepthCounterCommand extends SWCommand { public DepthCounterCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterListener.java index a98176c9..c48142d2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/DepthCounterListener.java @@ -19,11 +19,10 @@ package de.steamwar.bausystem.features.testblock.depthcounter; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.linkage.Linked; import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -34,7 +33,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; -@Linked(LinkageType.LISTENER) +@Linked public class DepthCounterListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitBauGuiItem.java index 8451bf5a..376f9cd4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitBauGuiItem.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.tpslimit; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class TPSLimitBauGuiItem extends BauGuiItem { public TPSLimitBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java index 7950e401..f19c8bcb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java @@ -23,11 +23,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.Enable; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -35,8 +34,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.ENABLE_LINK) +@Linked public class TPSLimitCommand extends SWCommand implements Enable { private final List tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20")); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java index 3f64b398..cf7ca1b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TickCommand.java @@ -21,9 +21,8 @@ package de.steamwar.bausystem.features.tpslimit; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; @@ -31,7 +30,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -@Linked(LinkageType.COMMAND) +@Linked public class TickCommand extends SWCommand { private AtomicInteger ticksLeft = null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index f6a09b88..851632b6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -37,6 +37,7 @@ import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import lombok.AllArgsConstructor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index f0d7b156..4a20b460 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -29,6 +29,7 @@ import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index 736494be..8d8f13ba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -30,6 +30,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionSelectionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.Player; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java index 0e66a163..42a4588a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java @@ -22,12 +22,11 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.util.KillAllCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.utils.RegionSelectionType; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -35,7 +34,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class KillAllBauGuiItem extends BauGuiItem { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index dccde9c9..ded7480d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -21,15 +21,14 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.linkage.Enable; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.tags.Tag; +import de.steamwar.linkage.Linked; import org.bukkit.scheduler.BukkitRunnable; import java.util.Iterator; -@Linked(LinkageType.ENABLE_LINK) +@Linked public class BackupScheduler implements Enable { private static final long INITIAL = 20 * 60 * 5; From c227a676357d468f82b9e2d5c7c5a1a1d89ee75d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 25 Sep 2022 16:32:59 +0200 Subject: [PATCH 05/33] Update to linkage system Signed-off-by: yoyosource --- .../bausystem/features/script/UnsignCommand.java | 5 ++--- .../bausystem/features/script/command/Call.java | 5 ++--- .../bausystem/features/script/command/Exit.java | 5 ++--- .../steamwar/bausystem/features/script/command/If.java | 5 ++--- .../bausystem/features/script/command/Jump.java | 5 ++--- .../bausystem/features/script/command/Return.java | 5 ++--- .../bausystem/features/script/command/Sleep.java | 5 ++--- .../bausystem/features/tracer/TraceCommand.java | 4 +--- .../features/tracer/TraceTNTClickListener.java | 5 ++--- .../bausystem/features/tracer/TracerBauGuiItem.java | 4 +--- .../bausystem/features/util/BookReplaceCommand.java | 5 ++--- .../steamwar/bausystem/features/util/ClearCommand.java | 5 ++--- .../bausystem/features/util/DebugStickCommand.java | 5 ++--- .../bausystem/features/util/DeclutterCommand.java | 5 ++--- .../bausystem/features/util/GamemodeCommand.java | 5 ++--- .../bausystem/features/util/KillAllCommand.java | 4 +--- .../bausystem/features/util/MaterialCommand.java | 6 ++---- .../bausystem/features/util/NightVisionCommand.java | 6 ++---- .../bausystem/features/util/NoClipCommand.java | 6 ++---- .../bausystem/features/util/PistonCalculator.java | 5 ++--- .../features/util/PistonCalculatorCommand.java | 5 ++--- .../bausystem/features/util/SelectCommand.java | 5 ++--- .../steamwar/bausystem/features/util/SkullCommand.java | 5 ++--- .../steamwar/bausystem/features/util/SlotCommand.java | 5 ++--- .../steamwar/bausystem/features/util/SpeedCommand.java | 5 ++--- .../bausystem/features/util/StructureVoidCommand.java | 5 ++--- .../bausystem/features/util/TNTClickListener.java | 5 ++--- .../bausystem/features/util/TeleportCommand.java | 5 ++--- .../steamwar/bausystem/features/util/TimeCommand.java | 5 ++--- .../steamwar/bausystem/features/util/TpsCommand.java | 5 ++--- .../bausystem/features/util/items/ClearBauGuiItem.java | 5 ++--- .../features/util/items/DebugstickBauGuiItem.java | 5 ++--- .../features/util/items/DeclutterBauGuiItem.java | 7 +++---- .../features/util/items/GamemodeBauGuiItem.java | 5 ++--- .../features/util/items/NavWandBauGuiItem.java | 5 ++--- .../features/util/items/NightVisionBauGuiItem.java | 5 ++--- .../features/util/items/SelectBauGuiItem.java | 5 ++--- .../bausystem/features/util/items/SkullBauGuiItem.java | 5 ++--- .../bausystem/features/util/items/SpeedBauGuiItem.java | 5 ++--- .../features/util/items/TeleportBauGuiItem.java | 5 ++--- .../features/util/items/WorldEditBauGuiItem.java | 5 ++--- .../steamwar/bausystem/features/warp/WarpCommand.java | 10 ++++------ .../steamwar/bausystem/features/warp/WarpListener.java | 5 ++--- .../bausystem/features/world/AFKStopperListener.java | 5 ++--- .../bausystem/features/world/AutoShutdownListener.java | 5 ++--- .../bausystem/features/world/BauScoreboard.java | 5 ++--- .../bausystem/features/world/ClipboardListener.java | 5 ++--- .../bausystem/features/world/InventoryListener.java | 5 ++--- .../bausystem/features/world/ItemFrameListener.java | 5 ++--- .../bausystem/features/world/KickallCommand.java | 7 +++---- .../bausystem/features/world/NoCreativeKnockback.java | 5 ++--- .../bausystem/features/world/ReducedDebugInfo.java | 5 ++--- .../bausystem/features/world/RestartCommand.java | 5 ++--- .../de/steamwar/bausystem/features/world/SignEdit.java | 5 ++--- .../bausystem/features/world/SignListener.java | 5 ++--- .../steamwar/bausystem/features/world/StopCommand.java | 5 ++--- .../bausystem/features/world/WorldEditListener.java | 5 ++--- .../features/worldedit/ColorReplaceCommand.java | 5 ++--- .../features/worldedit/TypeReplaceCommand.java | 7 +++---- .../steamwar/bausystem/features/xray/XrayCommand.java | 8 +++----- 60 files changed, 123 insertions(+), 191 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java index 7140c428..5c4ebb6d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java @@ -19,15 +19,14 @@ package de.steamwar.bausystem.features.script; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.COMMAND) +@Linked public class UnsignCommand extends SWCommand { public UnsignCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Call.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Call.java index e5f255b4..9a1f65d8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Call.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Call.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Call implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Exit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Exit.java index 461dd8e2..925d900b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Exit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Exit.java @@ -2,11 +2,10 @@ package de.steamwar.bausystem.features.script.command; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Exit implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java index 48f6d04c..b61189fe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/If.java @@ -4,11 +4,10 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class If implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Jump.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Jump.java index b8f7bc10..bab023e4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Jump.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Jump.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Jump implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Return.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Return.java index 031d729f..742c58dc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Return.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Return.java @@ -3,11 +3,10 @@ package de.steamwar.bausystem.features.script.command; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Return implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Sleep.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Sleep.java index 171e857d..94dd38e6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Sleep.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/Sleep.java @@ -3,12 +3,11 @@ package de.steamwar.bausystem.features.script.command; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.SpecialCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; -@Linked(LinkageType.SCRIPT_COMMAND) +@Linked public class Sleep implements SpecialCommand { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 851632b6..40b28177 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -30,8 +30,6 @@ import de.steamwar.bausystem.features.tracer.show.mode.BlockShowMode; import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode; import de.steamwar.bausystem.features.tracer.show.mode.RawEntityShowMode; import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.command.SWCommand; @@ -51,7 +49,7 @@ import java.util.function.BiFunction; import java.util.function.Supplier; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) +@Linked public class TraceCommand extends SWCommand { public TraceCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java index d6f1c472..9aecedae 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java @@ -23,9 +23,8 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.show.TraceShowManager; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.RayTraceUtils; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.RayTraceResult; @@ -33,7 +32,7 @@ import org.bukkit.util.RayTraceResult; import java.util.HashSet; import java.util.Set; -@Linked(LinkageType.PLAIN) +@Linked public class TraceTNTClickListener { private static final Class useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index 4a20b460..d051afd0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -24,8 +24,6 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; import de.steamwar.bausystem.features.tracer.record.RecordStatus; import de.steamwar.bausystem.features.tracer.show.TraceShowManager; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; @@ -37,7 +35,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class TracerBauGuiItem extends BauGuiItem { public TracerBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java index 34a06d2a..290223a2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/BookReplaceCommand.java @@ -1,8 +1,7 @@ package de.steamwar.bausystem.features.util; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; @@ -10,7 +9,7 @@ import org.bukkit.inventory.meta.ItemMeta; import java.util.List; -@Linked(LinkageType.COMMAND) +@Linked public class BookReplaceCommand extends SWCommand { public BookReplaceCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java index 8da2f7bb..3e8899d6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java @@ -21,15 +21,14 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.COMMAND) +@Linked public class ClearCommand extends SWCommand { public ClearCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java index d7f7ab4e..e2de740f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DebugStickCommand.java @@ -20,14 +20,13 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.COMMAND) +@Linked public class DebugStickCommand extends SWCommand { public DebugStickCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java index a684bab9..7d3f5938 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java @@ -20,9 +20,8 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -30,7 +29,7 @@ import org.bukkit.inventory.ItemStack; import java.util.HashSet; import java.util.Set; -@Linked(LinkageType.COMMAND) +@Linked public class DeclutterCommand extends SWCommand { public DeclutterCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java index 2682d5f9..876586a2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java @@ -19,13 +19,12 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class GamemodeCommand extends SWCommand { public GamemodeCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index 8d8f13ba..49654a05 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -21,8 +21,6 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; @@ -37,7 +35,7 @@ import org.bukkit.entity.Player; import java.util.concurrent.atomic.AtomicLong; -@Linked(LinkageType.COMMAND) +@Linked public class KillAllCommand extends SWCommand { private static final World WORLD = Bukkit.getWorlds().get(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java index 8d5f82d1..3fe740fe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java @@ -20,8 +20,6 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.shared.EnumDisplay; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -29,6 +27,7 @@ import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; @@ -44,8 +43,7 @@ import java.util.*; import java.util.function.BiConsumer; import java.util.function.Predicate; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.LISTENER) +@Linked public class MaterialCommand extends SWCommand implements Listener { public MaterialCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java index 1b28d0fd..0308846d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NightVisionCommand.java @@ -21,9 +21,8 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.configplayer.Config; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,8 +32,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import yapion.hierarchy.types.YAPIONObject; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.LISTENER) +@Linked public class NightVisionCommand extends SWCommand implements Listener { public NightVisionCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index 9b1589d9..46fdf535 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -24,12 +24,11 @@ import com.comphenix.tinyprotocol.TinyProtocol; import com.mojang.authlib.GameProfile; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.bausystem.utils.ProtocolWrapper; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -44,8 +43,7 @@ import org.bukkit.event.player.PlayerToggleFlightEvent; import java.util.*; import java.util.function.BiFunction; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.LISTENER) +@Linked public class NoClipCommand extends SWCommand implements Listener { public static final Class playerInfoPacket = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutPlayerInfo"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java index 41a7050d..281b159f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculator.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.ToString; @@ -44,7 +43,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -@Linked(LinkageType.LISTENER) +@Linked public class PistonCalculator implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java index 1ededcee..8aef617f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/PistonCalculatorCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class PistonCalculatorCommand extends SWCommand { public PistonCalculatorCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java index 5987968e..ce859ec6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SelectCommand.java @@ -2,8 +2,6 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.utils.RegionExtensionType; @@ -11,9 +9,10 @@ import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class SelectCommand extends SWCommand { public SelectCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java index c24c54b5..8ff194a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -35,7 +34,7 @@ import org.bukkit.inventory.meta.SkullMeta; import java.util.List; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) +@Linked public class SkullCommand extends SWCommand { public SkullCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java index c0dafe18..4ea5d62b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.COMMAND) +@Linked public class SlotCommand extends SWCommand { public SlotCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java index a2eef6df..31308830 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SpeedCommand.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class SpeedCommand extends SWCommand { public SpeedCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java index 4146329c..277eb59a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java @@ -20,14 +20,13 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.COMMAND) +@Linked public class StructureVoidCommand extends SWCommand { public StructureVoidCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java index 7a2f0a67..9bb8368f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TNTClickListener.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.TNTPrimed; @@ -30,7 +29,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.EquipmentSlot; -@Linked(LinkageType.LISTENER) +@Linked public class TNTClickListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java index 047a94e2..9294eb20 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; import java.util.Random; -@Linked(LinkageType.COMMAND) +@Linked public class TeleportCommand extends SWCommand { private static final Random RAND = new Random(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java index 82eee50c..15f48590 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java @@ -21,16 +21,15 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.*; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.Arrays; import java.util.List; -@Linked(LinkageType.COMMAND) +@Linked public class TimeCommand extends SWCommand { private static final List tabCompletions = Arrays.asList("0", "6000", "12000", "18000"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java index 877c0da1..302dd7e9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java @@ -21,13 +21,12 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.core.TPSWatcher; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class TpsCommand extends SWCommand { public TpsCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java index ec39cb33..607b7398 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java @@ -21,16 +21,15 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class ClearBauGuiItem extends BauGuiItem { public ClearBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java index d16a6577..725d75b1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DebugstickBauGuiItem.java @@ -22,15 +22,14 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class DebugstickBauGuiItem extends BauGuiItem { public DebugstickBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java index 9ed5a67f..55bd6a02 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java @@ -22,17 +22,16 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.util.DeclutterCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class DeclutterBauGuiItem extends BauGuiItem { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java index fb8bf022..42900af8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class GamemodeBauGuiItem extends BauGuiItem { public GamemodeBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java index e35da4b8..30ac88a2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NavWandBauGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -32,7 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class NavWandBauGuiItem extends BauGuiItem { public NavWandBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java index 70c652ca..76fb5354 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffectType; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class NightVisionBauGuiItem extends BauGuiItem { public NightVisionBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java index 4cc20aef..2e90be13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SelectBauGuiItem.java @@ -21,13 +21,12 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import lombok.AllArgsConstructor; import lombok.Getter; import org.bukkit.Material; @@ -40,7 +39,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class SelectBauGuiItem extends BauGuiItem { private static final Map LAST_SELECT_MAP = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java index ed74b2dd..f9ec57c8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SkullBauGuiItem.java @@ -21,17 +21,16 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class SkullBauGuiItem extends BauGuiItem { public SkullBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedBauGuiItem.java index 33fdd3ee..d24eedf6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/SpeedBauGuiItem.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -33,7 +32,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class SpeedBauGuiItem extends BauGuiItem { public SpeedBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java index a190b0d6..4569ae47 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java @@ -21,11 +21,10 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -34,7 +33,7 @@ import org.bukkit.inventory.ItemStack; import java.util.UUID; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class TeleportBauGuiItem extends BauGuiItem { public TeleportBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java index 2da651fb..ddfa66d7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WorldEditBauGuiItem.java @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; @@ -32,7 +31,7 @@ import org.bukkit.inventory.ItemStack; import java.util.Arrays; -@Linked(LinkageType.BAU_GUI_ITEM) +@Linked public class WorldEditBauGuiItem extends BauGuiItem { public WorldEditBauGuiItem() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index c2ae7528..23f64b97 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -23,11 +23,11 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.Disable; import de.steamwar.bausystem.linkage.Enable; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.*; +import de.steamwar.linkage.LinkageType; +import de.steamwar.linkage.Linked; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; @@ -38,9 +38,7 @@ import yapion.hierarchy.types.YAPIONObject; import java.util.ArrayList; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.DISABLE_LINK) -@Linked(LinkageType.ENABLE_LINK) +@Linked public class WarpCommand extends SWCommand implements Disable, Enable { private static final String[] FORBIDDEN_NAMES = new String[]{ @@ -129,7 +127,7 @@ public class WarpCommand extends SWCommand implements Disable, Enable { }; } - @Linked(LinkageType.COMMAND) + @Linked public static class WarpsLink extends SWCommand { public WarpsLink() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java index 406b8c5e..33f437c4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpListener.java @@ -19,10 +19,9 @@ package de.steamwar.bausystem.features.warp; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.NMSWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -36,7 +35,7 @@ import org.bukkit.util.Vector; import java.util.*; import java.util.function.Consumer; -@Linked(LinkageType.LISTENER) +@Linked public class WarpListener implements Listener { private Map> warpsShown = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AFKStopperListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AFKStopperListener.java index de20516f..426d26bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AFKStopperListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AFKStopperListener.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; -@Linked(LinkageType.LISTENER) +@Linked public class AFKStopperListener implements Listener { private int minutesAfk = 0; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AutoShutdownListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AutoShutdownListener.java index edba5698..54a8bd82 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/AutoShutdownListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/AutoShutdownListener.java @@ -21,8 +21,7 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import de.steamwar.scoreboard.SWScoreboard; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -34,7 +33,7 @@ import org.bukkit.scheduler.BukkitTask; import java.util.logging.Level; -@Linked(LinkageType.LISTENER) +@Linked public class AutoShutdownListener implements Listener { private BukkitTask autoShutdown; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index eb3144d2..c3950cab 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -7,12 +7,11 @@ import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.core.TPSWatcher; +import de.steamwar.linkage.Linked; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; import org.bukkit.entity.Player; @@ -26,7 +25,7 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; -@Linked(LinkageType.LISTENER) +@Linked public class BauScoreboard implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java index 3082b29e..c0e908c6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ClipboardListener.java @@ -19,8 +19,7 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; import org.bukkit.event.EventHandler; @@ -28,7 +27,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -@Linked(LinkageType.LISTENER) +@Linked public class ClipboardListener implements Listener { private static final String CLIPBOARD_SCHEMNAME = "//copy"; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java index 42f25029..6970eed7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/InventoryListener.java @@ -19,9 +19,8 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.NMSWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.attribute.Attribute; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -@Linked(LinkageType.LISTENER) +@Linked public class InventoryListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java index 3858b4cf..9a294708 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ItemFrameListener.java @@ -20,8 +20,7 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.Player; @@ -30,7 +29,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; -@Linked(LinkageType.LISTENER) +@Linked public class ItemFrameListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java index ad5407dc..ee9ace1b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/KickallCommand.java @@ -20,15 +20,14 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class KickallCommand extends SWCommand { @LinkedInstance diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java index 08d1d51b..19417ec2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java @@ -21,12 +21,11 @@ package de.steamwar.bausystem.features.world; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.NMSWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.GameMode; -@Linked(LinkageType.PLAIN) +@Linked public class NoCreativeKnockback { public NoCreativeKnockback() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java index fb1f8499..c1dd3db0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java @@ -20,12 +20,11 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.linkage.Enable; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.GameRule; -@Linked(LinkageType.ENABLE_LINK) +@Linked public class ReducedDebugInfo implements Enable { @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RestartCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RestartCommand.java index 20aec025..cf868a9d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/RestartCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/RestartCommand.java @@ -19,11 +19,10 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; -@Linked(LinkageType.COMMAND) +@Linked public class RestartCommand extends SWCommand { public RestartCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index cb4cd3b8..2f8e154e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -22,8 +22,7 @@ package de.steamwar.bausystem.features.world; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -35,7 +34,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; -@Linked(LinkageType.LISTENER) +@Linked public class SignEdit implements Listener { private static final Class blockPosition = Reflection.getClass("{nms.core}.BlockPosition"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignListener.java index 36058c83..40ad9a66 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignListener.java @@ -19,14 +19,13 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.linkage.Linked; import org.bukkit.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.SignChangeEvent; -@Linked(LinkageType.LISTENER) +@Linked public class SignListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java index 6629e505..f03b0f73 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/StopCommand.java @@ -22,16 +22,15 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeValidator; +import de.steamwar.linkage.Linked; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -@Linked(LinkageType.COMMAND) +@Linked public class StopCommand extends SWCommand { public StopCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java index 2509c16c..f6f25f33 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/WorldEditListener.java @@ -21,9 +21,8 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.linkage.Linked; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -32,7 +31,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import java.util.HashSet; import java.util.Set; -@Linked(LinkageType.LISTENER) +@Linked public class WorldEditListener implements Listener { @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 4f829158..48ceff8a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -27,13 +27,12 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; import lombok.SneakyThrows; import org.bukkit.Material; import org.bukkit.World; @@ -43,7 +42,7 @@ import org.bukkit.entity.Player; import java.util.*; import java.util.stream.Collectors; -@Linked(LinkageType.COMMAND) +@Linked public class ColorReplaceCommand extends SWCommand { public ColorReplaceCommand() { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java index 0940516d..a81cdf96 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/TypeReplaceCommand.java @@ -27,13 +27,12 @@ import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.MinVersion; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.bukkit.Material; @@ -52,7 +51,7 @@ import java.util.stream.Collectors; import static org.bukkit.Material.*; -@Linked(value = LinkageType.COMMAND) +@Linked @MinVersion(18) public class TypeReplaceCommand extends SWCommand { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index 1011bb13..22c19b67 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -23,13 +23,12 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.techhider.TechHiderCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.PlayerMovementWrapper; import de.steamwar.command.SWCommand; import de.steamwar.core.CraftbukkitWrapper; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.techhider.TechHider; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; @@ -47,8 +46,7 @@ import java.io.File; import java.util.*; import java.util.function.BiFunction; -@Linked(LinkageType.COMMAND) -@Linked(LinkageType.LISTENER) +@Linked public class XrayCommand extends SWCommand implements Listener { public XrayCommand() { From b8adf7fb0877671bb528e4c38d21ee9ea363b66f Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 28 Sep 2022 18:57:52 +0200 Subject: [PATCH 06/33] Update BlockBoundingBox impls Signed-off-by: yoyosource --- .../slaves/laufbau/BlockBoundingBox.java | 3 +- .../slaves/laufbau/LaufbauLazyInit.java | 35 ------------------- .../boundingboxes/AmethystBoundingBox.java | 10 ++++-- .../boundingboxes/AzaleaBoundingBox.java | 10 ++++-- .../boundingboxes/BellBoundingBox.java | 8 +++-- .../BrewingStandBoundingBox.java | 8 +++-- .../boundingboxes/CandleBoundingBox.java | 10 ++++-- .../boundingboxes/ChainBoundingBox.java | 10 ++++-- .../boundingboxes/ChorusPlantBoundingBox.java | 8 +++-- .../boundingboxes/DragonEggBoundingBox.java | 10 ++++-- .../boundingboxes/DripLeafBoundingBox.java | 10 ++++-- .../boundingboxes/FencesBoundingBox.java | 8 +++-- .../boundingboxes/GrindstoneBoundingBox.java | 8 +++-- .../boundingboxes/HopperBoundingBox.java | 8 +++-- .../boundingboxes/IronBarBoundingBox.java | 8 +++-- .../boundingboxes/LanternBoundingBox.java | 8 +++-- .../boundingboxes/LecternBoundingBox.java | 8 +++-- .../boundingboxes/StairBoundingBox.java | 8 +++-- .../boundingboxes/WallBoundingBox.java | 8 +++-- 19 files changed, 99 insertions(+), 87 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauLazyInit.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index 8201d369..deeb0196 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.slaves.laufbau; +import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; @@ -264,7 +265,7 @@ public class BlockBoundingBox { eastTrapDoor.setOpen(true); addPixel(eastTrapDoor, 0, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_EAST", "LAUFBAU_OPEN")); - LaufbauLazyInit.init(); + LinkageUtils.linkBoundingBox(); } private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauLazyInit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauLazyInit.java deleted file mode 100644 index d81655a1..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/LaufbauLazyInit.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.steamwar.bausystem.features.slaves.laufbau; - -import de.steamwar.bausystem.features.slaves.laufbau.boundingboxes.*; -import de.steamwar.core.Core; -import lombok.experimental.UtilityClass; - -@UtilityClass -public class LaufbauLazyInit { - - public static void init() { - } - - static { - new BellBoundingBox().enable(); - new BrewingStandBoundingBox().enable(); - new ChorusPlantBoundingBox().enable(); - new FencesBoundingBox().enable(); - new GrindstoneBoundingBox().enable(); - new HopperBoundingBox().enable(); - new IronBarBoundingBox().enable(); - new LanternBoundingBox().enable(); - new StairBoundingBox().enable(); - new WallBoundingBox().enable(); - new LecternBoundingBox().enable(); - - if (Core.getVersion() >= 19) { - new AmethystBoundingBox().enable(); - new ChainBoundingBox().enable(); - new DripLeafBoundingBox().enable(); - new DragonEggBoundingBox().enable(); - new AzaleaBoundingBox().enable(); - new CandleBoundingBox().enable(); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java index 824c103f..5eec07ca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AmethystBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.AmethystCluster; @@ -32,10 +34,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class AmethystBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class AmethystBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { floorSmallAmethystBud(); ceilingSmallAmethystBud(); northSmallAmethystBud(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java index f9ceda2d..8c0409da 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/AzaleaBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -31,10 +33,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class AzaleaBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class AzaleaBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { BlockData blockData = Material.FLOWERING_AZALEA.createBlockData(); List cuboidList = new ArrayList<>(); cuboidList.add(pixelCuboid(0, 8, 0, 16, 8, 16)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BellBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BellBoundingBox.java index 4b247104..b5fcbb41 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BellBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BellBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Bell; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class BellBoundingBox implements Enable { +@Linked +public class BellBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { ceilingBell(); floorNorthBell(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BrewingStandBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BrewingStandBoundingBox.java index 8e729de5..765bea3d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BrewingStandBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/BrewingStandBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.data.type.BrewingStand; @@ -31,10 +32,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class BrewingStandBoundingBox implements Enable { +@Linked +public class BrewingStandBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { BrewingStand brewingStand = (BrewingStand) Material.BREWING_STAND.createBlockData(); List cuboids = new ArrayList<>(); cuboids.add(pixelCuboid(1, 0, 1, 14, 2, 14)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java index 9642ab32..4efaee96 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/CandleBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.Lightable; import org.bukkit.block.data.type.Candle; @@ -32,10 +34,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class CandleBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class CandleBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { caked(); single(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java index bcc6032b..6dd79442 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChainBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Axis; import org.bukkit.Material; import org.bukkit.block.data.Orientable; @@ -32,10 +34,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class ChainBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class ChainBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { bottomTopChain(); northSouthChain(); eastWestChain(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChorusPlantBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChorusPlantBoundingBox.java index e39231ff..b169a455 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChorusPlantBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/ChorusPlantBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.MultipleFacing; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class ChorusPlantBoundingBox implements Enable { +@Linked +public class ChorusPlantBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { for (int nx = 0; nx < 2; nx++) { for (int ny = 0; ny < 2; ny++) { for (int nz = 0; nz < 2; nz++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java index ab3668ad..2bd6a6bb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DragonEggBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -31,10 +33,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class DragonEggBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class DragonEggBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { BlockData blockData = Material.DRAGON_EGG.createBlockData(); List cuboidList = new ArrayList<>(); cuboidList.add(pixelCuboid(1, 0, 1, 14, 16, 14)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java index 488476bb..30198624 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/DripLeafBoundingBox.java @@ -20,8 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; +import de.steamwar.linkage.MinVersion; import org.bukkit.Material; import org.bukkit.block.data.type.BigDripleaf; @@ -31,10 +33,12 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class DripLeafBoundingBox implements Enable { +@Linked +@MinVersion(19) +public class DripLeafBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { tiltNone(); tiltPartial(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/FencesBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/FencesBoundingBox.java index 3873f923..213a2345 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/FencesBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/FencesBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Fence; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class FencesBoundingBox implements Enable { +@Linked +public class FencesBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { for (int nx = 0; nx < 2; nx++) { for (int nz = 0; nz < 2; nz++) { for (int px = 0; px < 2; px++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/GrindstoneBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/GrindstoneBoundingBox.java index 088a97d6..52fa3557 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/GrindstoneBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/GrindstoneBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.FaceAttachable; @@ -33,10 +34,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class GrindstoneBoundingBox implements Enable { +@Linked +public class GrindstoneBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { floorNorthGrindstone(); floorEastGrindstone(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/HopperBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/HopperBoundingBox.java index 324cc016..19a095b3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/HopperBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/HopperBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Hopper; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class HopperBoundingBox implements Enable { +@Linked +public class HopperBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { downHopper(); northHopper(); southHopper(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/IronBarBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/IronBarBoundingBox.java index f7a5147a..e275b7b1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/IronBarBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/IronBarBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Fence; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class IronBarBoundingBox implements Enable { +@Linked +public class IronBarBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { for (int nx = 0; nx < 2; nx++) { for (int nz = 0; nz < 2; nz++) { for (int px = 0; px < 2; px++) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LanternBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LanternBoundingBox.java index ff54c1c1..3bf275b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LanternBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LanternBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.data.type.Lantern; @@ -31,10 +32,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class LanternBoundingBox implements Enable { +@Linked +public class LanternBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { lantern(); hangingLantern(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LecternBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LecternBoundingBox.java index aa886b36..563b9bc6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LecternBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/LecternBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.data.BlockData; @@ -31,10 +32,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class LecternBoundingBox implements Enable { +@Linked +public class LecternBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { BlockData blockData = Material.LECTERN.createBlockData(); List cuboidList = new ArrayList<>(); cuboidList.add(pixelCuboid(0, 0, 0, 16, 2, 16)); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/StairBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/StairBoundingBox.java index d3729a7b..23807176 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/StairBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/StairBoundingBox.java @@ -20,8 +20,9 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Stairs; @@ -32,10 +33,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class StairBoundingBox implements Enable { +@Linked +public class StairBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { straightBottomNorthStair(); straightBottomSouthStair(); straightBottomEastStair(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java index 20d02366..855fe9b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/boundingboxes/WallBoundingBox.java @@ -20,9 +20,10 @@ package de.steamwar.bausystem.features.slaves.laufbau.boundingboxes; import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.BoundingBoxLoader; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.core.Core; +import de.steamwar.linkage.Linked; import org.bukkit.Material; import org.bukkit.block.BlockFace; import org.bukkit.block.data.type.Fence; @@ -34,10 +35,11 @@ import java.util.List; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.pixelCuboid; -public class WallBoundingBox implements Enable { +@Linked +public class WallBoundingBox implements BoundingBoxLoader { @Override - public void enable() { + public void load() { if (Core.getVersion() > 15) { v18(); } else { From c447315b9eb80cdaef0e1f124e0db03081b3f86f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 2 Oct 2022 08:12:49 +0200 Subject: [PATCH 07/33] Hotbar deserialize fix --- .../steamwar/bausystem/features/hotbar/DefaultHotbar.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java index 9fdc9736..25760ccb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/DefaultHotbar.java @@ -70,7 +70,11 @@ public class DefaultHotbar { if (yapionAnyType instanceof YAPIONValue) { hotbar[integer] = null; } else { - hotbar[integer] = (ItemStack) YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType); + try { + hotbar[integer] = YAPIONDeserializer.deserialize((YAPIONObject) yapionAnyType); + } catch (Exception e) { + hotbar[integer] = null; + } } }); return hotbar; From bdda84f333dd71ca5d941e5bb40ace6e8727cf5d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 13:03:27 +0200 Subject: [PATCH 08/33] Fix TraceTNTClickListener and NoCreativeKnockback Signed-off-by: yoyosource --- .../bausystem/features/tracer/TraceTNTClickListener.java | 3 ++- .../steamwar/bausystem/features/world/NoCreativeKnockback.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java index 9aecedae..e79454ac 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java @@ -25,6 +25,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Plain; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.RayTraceResult; @@ -33,7 +34,7 @@ import java.util.HashSet; import java.util.Set; @Linked -public class TraceTNTClickListener { +public class TraceTNTClickListener implements Plain { private static final Class useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity"); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java index 19417ec2..83b33d42 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java @@ -23,10 +23,11 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Plain; import org.bukkit.GameMode; @Linked -public class NoCreativeKnockback { +public class NoCreativeKnockback implements Plain { public NoCreativeKnockback() { TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"), (player, o) -> { From 765584bc9a4b8fafd7952cf6027599efb72232bd Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 13:06:25 +0200 Subject: [PATCH 09/33] Fix ETA message Signed-off-by: yoyosource --- .../bausystem/features/slaves/laufbau/states/LaufbauState.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java index 3401914d..e65bff6b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java @@ -35,6 +35,7 @@ public interface LaufbauState { void next(); default String eta(Player p, long start, int done, int total) { + if (done == 0) return ""; return new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Date.from(Instant.ofEpochMilli((System.currentTimeMillis() - start) / done * total))); } } From 972834152997ee8e9e08d53a4b84f8d9bf85ac06 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 14:21:31 +0200 Subject: [PATCH 10/33] Fix ETA message Signed-off-by: yoyosource --- .../features/slaves/laufbau/states/LaufbauState.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java index e65bff6b..346332fe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java @@ -22,9 +22,8 @@ package de.steamwar.bausystem.features.slaves.laufbau.states; import de.steamwar.bausystem.BauSystem; import org.bukkit.entity.Player; -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.Date; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; public interface LaufbauState { @@ -35,7 +34,8 @@ public interface LaufbauState { void next(); default String eta(Player p, long start, int done, int total) { - if (done == 0) return ""; - return new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Date.from(Instant.ofEpochMilli((System.currentTimeMillis() - start) / done * total))); + if (total == 0) return ""; + long elapsed = System.currentTimeMillis() - start; + return LocalTime.ofNanoOfDay((long) (elapsed / (done / (double) total) - elapsed) * 1000000).format(DateTimeFormatter.ofPattern(BauSystem.MESSAGE.parse("TIME", p))); } } From 41a457920de0451abb35e0f860b8edd4ce8ad53e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 15:46:22 +0200 Subject: [PATCH 11/33] Optimize Laufbau Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 6 +- BauSystem_Main/src/BauSystem_de.properties | 6 +- .../features/slaves/laufbau/Laufbau.java | 53 +---- .../states/CreatingInnerBlocksState.java | 111 ---------- .../laufbau/states/CreatingLaufState.java | 200 ++++++++++++++++++ .../states/CreatingOuterBlocksState.java | 85 -------- .../laufbau/states/ExpandingTracesState.java | 82 ------- .../laufbau/states/ProcessingTracesState.java | 65 ++++-- .../states/ShrinkingOuterPointsState.java | 92 -------- .../laufbau/states/SplittingPointsState.java | 89 -------- 10 files changed, 265 insertions(+), 524 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ExpandingTracesState.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/SplittingPointsState.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index ca7b8228..5fe51591 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -1103,11 +1103,7 @@ LAUFBAU_NO_PERM = §cYou are not allowed to use the barrel building system here LAUFBAU_NO_WORLDEDIT = §cYou don't have a WorldEdit selection LAUFBAU_STATE_FILTERING_TRACES = Filtering traces LAUFBAU_STATE_PROCESSING_TRACES = Connnecting traces -LAUFBAU_STATE_EXPANDING_TRACES = Expanding traces -LAUFBAU_STATE_SPLITTING_POINTS = Splitting points -LAUFBAU_STATE_SHRINKING_POINTS = Shrinking points -LAUFBAU_STATE_CREATING_INNER_BLOCKS = Creating inner blocks -LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Creating outer blocks +LAUFBAU_STATE_CREATE_LAUF = Create Barrel LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} §7Time left§8: §e{3} LAUFBAU_DONE = §aDone diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index be092402..439518b6 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -1081,11 +1081,7 @@ LAUFBAU_NO_PERM = §cDu darfst hier nicht das Laufbau System verwenden LAUFBAU_NO_WORLDEDIT = §cDu hast keine WorldEdit Selection LAUFBAU_STATE_FILTERING_TRACES = Traces filtern LAUFBAU_STATE_PROCESSING_TRACES = Traces verbinden -LAUFBAU_STATE_EXPANDING_TRACES = Traces aufblähen -LAUFBAU_STATE_SPLITTING_POINTS = Punkte trennen -LAUFBAU_STATE_SHRINKING_POINTS = Punkte ausdünnen -LAUFBAU_STATE_CREATING_INNER_BLOCKS = Innenraum füllen -LAUFBAU_STATE_CREATING_OUTER_BLOCKS = Mantel bauen +LAUFBAU_STATE_CREATE_LAUF = Lauf erstellen LAUFBAU_SIMPLE_PROGRESS = §e{0}§8: §e{1}§8/§e{2} §7Übrige Zeit §8: §e{3} LAUFBAU_DONE = §aZuende gebaut diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java index 6c22c4aa..d1e37613 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java @@ -20,8 +20,11 @@ package de.steamwar.bausystem.features.slaves.laufbau; import com.sk89q.worldedit.EditSession; +import de.steamwar.bausystem.features.slaves.laufbau.states.FilteringTracesState; +import de.steamwar.bausystem.features.slaves.laufbau.states.LaufbauState; +import de.steamwar.bausystem.features.slaves.laufbau.states.CreatingLaufState; +import de.steamwar.bausystem.features.slaves.laufbau.states.ProcessingTracesState; import de.steamwar.bausystem.utils.WorldEditUtils; -import de.steamwar.bausystem.features.slaves.laufbau.states.*; import lombok.Getter; import org.bukkit.Location; import org.bukkit.World; @@ -37,15 +40,9 @@ public class Laufbau { private Location pos1; private Location pos2; - private boolean preferingBlastResistance; - private FilteringTracesState filteringTracesState = null; private ProcessingTracesState processingTracesState = null; - private ExpandingTracesState expandingTracesState = null; - private SplittingPointsState splittingPointsState = null; - private ShrinkingOuterPointsState shrinkingOuterPointsState = null; - private CreatingInnerBlocksState creatingInnerBlocksState = null; - private CreatingOuterBlocksState creatingOuterBlocksState = null; + private CreatingLaufState creatingLaufState = null; private List elements; @@ -57,8 +54,6 @@ public class Laufbau { this.pos1 = new Location(world, Math.min(pos1.getBlockX(), pos2.getBlockX()), Math.min(pos1.getBlockY(), pos2.getBlockY()), Math.min(pos1.getBlockZ(), pos2.getBlockZ())); this.pos2 = new Location(world, Math.max(pos1.getBlockX(), pos2.getBlockX()), Math.max(pos1.getBlockY(), pos2.getBlockY()), Math.max(pos1.getBlockZ(), pos2.getBlockZ())); - this.preferingBlastResistance = preferingBlastResistance; - filteringTracesState = new FilteringTracesState(world, this::inRegion); editSession = WorldEditUtils.getEditSession(world); @@ -86,20 +81,8 @@ public class Laufbau { } private LaufbauState getActive() { - if (creatingOuterBlocksState != null) { - return creatingOuterBlocksState; - } - if (creatingInnerBlocksState != null) { - return creatingInnerBlocksState; - } - if (shrinkingOuterPointsState != null) { - return shrinkingOuterPointsState; - } - if (splittingPointsState != null) { - return splittingPointsState; - } - if (expandingTracesState != null) { - return expandingTracesState; + if (creatingLaufState != null) { + return creatingLaufState; } if (processingTracesState != null) { return processingTracesState; @@ -108,30 +91,14 @@ public class Laufbau { } private void createNextState() { - if (creatingOuterBlocksState != null) { - return; - } - if (creatingInnerBlocksState != null) { - creatingOuterBlocksState = new CreatingOuterBlocksState(shrinkingOuterPointsState.getShrunkOuterPoints(), world, editSession); - return; - } - if (shrinkingOuterPointsState != null) { - creatingInnerBlocksState = new CreatingInnerBlocksState(splittingPointsState.getInnerPoints(), world, splittingPointsState.getIntersectedCuboid(), editSession, elements); - return; - } - if (splittingPointsState != null) { - shrinkingOuterPointsState = new ShrinkingOuterPointsState(splittingPointsState.getOuterPoints(), splittingPointsState.getInnerPoints()); - return; - } - if (expandingTracesState != null) { - splittingPointsState = new SplittingPointsState(expandingTracesState.getBlocks(), processingTracesState.getCuboidList()); + if (creatingLaufState != null) { return; } if (processingTracesState != null) { - expandingTracesState = new ExpandingTracesState(processingTracesState.getCuboidList(), world, this::inRegion); + creatingLaufState = new CreatingLaufState(processingTracesState.getBlocks(), processingTracesState.getCuboidList(), world, editSession, elements); return; } - processingTracesState = new ProcessingTracesState(filteringTracesState.getTntPositions()); + processingTracesState = new ProcessingTracesState(filteringTracesState.getTntPositions(), world, this::inRegion); } public String actionBarMessage(Player p) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java deleted file mode 100644 index 6e6b3be1..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.slaves.laufbau.states; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; -import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.region.Point; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.text.SimpleDateFormat; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class CreatingInnerBlocksState implements LaufbauState { - - private long start = System.currentTimeMillis(); - - private List innerBlocks; - private int index = 0; - - private World world; - private Map> intersectedCuboid; - private EditSession editSession; - private List elements; - - public CreatingInnerBlocksState(List innerBlocks, World world, Map> intersectedCuboid, EditSession editSession, List elements) { - this.innerBlocks = innerBlocks; - this.world = world; - this.intersectedCuboid = intersectedCuboid; - this.editSession = editSession; - this.elements = elements; - } - - @Override - public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_INNER_BLOCKS", p), index, innerBlocks.size(), eta(p, start, index, innerBlocks.size())); - } - - @Override - public boolean hasNext() { - return index < innerBlocks.size(); - } - - @Override - public void next() { - Point point = innerBlocks.get(index); - index++; - - List neededCuboids = intersectedCuboid.get(point); - List blockDataWithBoundingBoxList = new ArrayList<>(); - for (BlockBoundingBox blockDataWithBoundingBox : elements) { - List cuboids = blockDataWithBoundingBox.getCuboidList().stream().map(c -> c.add(point)).collect(Collectors.toList()); - - boolean isInCuboid = false; - for (Cuboid cuboid : neededCuboids) { - if (cuboids.stream().anyMatch(cuboid::intersects)) { - isInCuboid = true; - break; - } - } - if (!isInCuboid) { - blockDataWithBoundingBoxList.add(blockDataWithBoundingBox); - break; - } - } - if (blockDataWithBoundingBoxList.isEmpty()) { - return; - } - - BlockBoundingBox highest = blockDataWithBoundingBoxList.get(0); - Location location = new Location(world, point.getX(), point.getY(), point.getZ()); - if (!location.getBlock().getType().isAir()) { - return; - } - try { - editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highest.blockData)); - location.getBlock().setBlockData(highest.blockData, false); - if (highest.blockConsumer != null) highest.blockConsumer.accept(location.getBlock()); - } catch (MaxChangedBlocksException e) { - e.printStackTrace(); - // ignored - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java new file mode 100644 index 00000000..be76c5a7 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingLaufState.java @@ -0,0 +1,200 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.slaves.laufbau.states; + +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.MaxChangedBlocksException; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockTypes; +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox; +import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; +import de.steamwar.bausystem.region.Point; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +public class CreatingLaufState implements LaufbauState { + + private static final Cuboid ONE = new Cuboid(0, 0, 0, 1, 1, 1); + private static final Cuboid ABOVE_HALF = new Cuboid(0, 1, 0, 1, 0.5, 1); + private static final BaseBlock SHELL; + + static { + SHELL = BlockTypes.get("minecraft:end_stone").getDefaultState().toBaseBlock(); + } + + private long start = System.currentTimeMillis(); + + private List blocks; + private List cuboids; + private List outerPoints = new ArrayList<>(); + private Set innerPoints = new HashSet<>(); + private World world; + private EditSession editSession; + private List elements; + + private int operations = 0; + private int totalOperations; + + public CreatingLaufState(Set blocks, List cuboids, World world, EditSession editSession, List elements) { + this.blocks = new ArrayList<>(blocks); + this.cuboids = cuboids; + this.world = world; + this.editSession = editSession; + this.elements = elements; + + totalOperations = blocks.size() * 2; + } + + @Override + public String actionBarMessage(Player p) { + return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATE_LAUF", p), operations, totalOperations, eta(p, start, operations, totalOperations)); + } + + @Override + public boolean hasNext() { + return !blocks.isEmpty() || !outerPoints.isEmpty(); + } + + @Override + public void next() { + operations++; + if (!blocks.isEmpty()) { + Point point = blocks.remove(0); + boolean isInCuboid = false; + Cuboid tempCuboid = ONE.add(point); + Cuboid aboveHalfTempCuboid = ABOVE_HALF.add(point); + List intersectedCuboids = new ArrayList<>(); + for (Cuboid cuboid : cuboids) { + if (cuboid.intersects(tempCuboid)) { + isInCuboid = true; + intersectedCuboids.add(cuboid); + } + if (cuboid.intersects(aboveHalfTempCuboid)) { + intersectedCuboids.add(cuboid); + } + } + if (!isInCuboid) { + if (hasInnerNeighbour(point)) { + operations++; + setShell(point); + } else { + outerPoints.add(point); + } + } else { + innerPoints.add(point); + operations++; + calcInnerBlock(point, intersectedCuboids); + } + } else { + Point point = outerPoints.remove(0); + setShell(point); + } + } + + private void calcInnerBlock(Point point, List neededCuboids) { + List blockDataWithBoundingBoxList = new ArrayList<>(); + for (BlockBoundingBox blockDataWithBoundingBox : elements) { + List cuboids = blockDataWithBoundingBox.getCuboidList().stream().map(c -> c.add(point)).collect(Collectors.toList()); + + boolean isInCuboid = false; + for (Cuboid cuboid : neededCuboids) { + if (cuboids.stream().anyMatch(cuboid::intersects)) { + isInCuboid = true; + break; + } + } + if (!isInCuboid) { + blockDataWithBoundingBoxList.add(blockDataWithBoundingBox); + break; + } + } + if (blockDataWithBoundingBoxList.isEmpty()) { + return; + } + + BlockBoundingBox highest = blockDataWithBoundingBoxList.get(0); + Location location = new Location(world, point.getX(), point.getY(), point.getZ()); + if (!location.getBlock().getType().isAir()) { + return; + } + try { + editSession.setBlock(BukkitAdapter.asBlockVector(location), BukkitAdapter.adapt(highest.blockData)); + location.getBlock().setBlockData(highest.blockData, false); + if (highest.blockConsumer != null) highest.blockConsumer.accept(location.getBlock()); + } catch (MaxChangedBlocksException e) { + e.printStackTrace(); + // ignored + } + } + + private boolean hasInnerNeighbour(Point point) { + Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); + if (innerPoints.contains(p1)) { + return true; + } + Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); + if (innerPoints.contains(p2)) { + return true; + } + Point p3 = new Point(point.getX(), point.getY() - 1, point.getZ()); + if (innerPoints.contains(p3)) { + return true; + } + Point p4 = new Point(point.getX(), point.getY() + 1, point.getZ()); + if (innerPoints.contains(p4)) { + return true; + } + Point p5 = new Point(point.getX(), point.getY(), point.getZ() - 1); + if (innerPoints.contains(p5)) { + return true; + } + Point p6 = new Point(point.getX(), point.getY(), point.getZ() + 1); + if (innerPoints.contains(p6)) { + return true; + } + return false; + } + + private void setShell(Point point) { + if (hasInnerNeighbour(point)) { + Location location = new Location(world, point.getX(), point.getY(), point.getZ()); + if (!location.getBlock().getType().isAir()) { + return; + } + try { + editSession.setBlock(BukkitAdapter.asBlockVector(location), SHELL); + location.getBlock().setType(Material.END_STONE, false); + } catch (MaxChangedBlocksException e) { + e.printStackTrace(); + // ingored + } + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java deleted file mode 100644 index 991ca014..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingOuterBlocksState.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.slaves.laufbau.states; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.MaxChangedBlocksException; -import com.sk89q.worldedit.bukkit.BukkitAdapter; -import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.entity.Player; - -import java.util.List; - -public class CreatingOuterBlocksState implements LaufbauState { - - private static final BaseBlock SHELL; - - static { - SHELL = BlockTypes.get("minecraft:end_stone").getDefaultState().toBaseBlock(); - } - - private long start = System.currentTimeMillis(); - - private List outerBlocks; - private int index = 0; - - private World world; - private EditSession editSession; - - public CreatingOuterBlocksState(List outerBlocks, World world, EditSession editSession) { - this.outerBlocks = outerBlocks; - this.world = world; - this.editSession = editSession; - } - - @Override - public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_CREATING_OUTER_BLOCKS", p), index, outerBlocks.size(), eta(p, start, index, outerBlocks.size())); - } - - @Override - public boolean hasNext() { - return index < outerBlocks.size(); - } - - @Override - public void next() { - Point point = outerBlocks.get(index); - index++; - - Location location = new Location(world, point.getX(), point.getY(), point.getZ()); - if (!location.getBlock().getType().isAir()) { - return; - } - try { - editSession.setBlock(BukkitAdapter.asBlockVector(location), SHELL); - location.getBlock().setType(Material.END_STONE, false); - } catch (MaxChangedBlocksException e) { - e.printStackTrace(); - // ingored - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ExpandingTracesState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ExpandingTracesState.java deleted file mode 100644 index 33a9004d..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ExpandingTracesState.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.slaves.laufbau.states; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.region.Point; -import lombok.Getter; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.BiPredicate; - -public class ExpandingTracesState implements LaufbauState { - - private long start = System.currentTimeMillis(); - - private List cuboidList; - private int totalCuboids; - - private World world; - private BiPredicate inRegionCheck; - - @Getter - private Set blocks = new HashSet<>(); - - public ExpandingTracesState(List cuboidList, World world, BiPredicate inRegionCheck) { - this.cuboidList = new ArrayList<>(cuboidList); - this.totalCuboids = cuboidList.size(); - this.world = world; - this.inRegionCheck = inRegionCheck; - } - - @Override - public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_EXPANDING_TRACES", p), totalCuboids - cuboidList.size(), totalCuboids, eta(p, start, totalCuboids - cuboidList.size(), totalCuboids)); - } - - @Override - public boolean hasNext() { - return !cuboidList.isEmpty(); - } - - @Override - public void next() { - Cuboid cuboid = cuboidList.remove(0); - for (double x = cuboid.getX() - 2; x < cuboid.getX() + cuboid.getDx() + 2; x++) { - for (double y = cuboid.getY() - 2; y < cuboid.getY() + cuboid.getDy() + 2; y++) { - for (double z = cuboid.getZ() - 2; z < cuboid.getZ() + cuboid.getDz() + 2; z++) { - Location location = new Location(world, x, y, z); - if (inRegionCheck.test(new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ()), 0)) { - Point point = new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - blocks.add(point); - } - } - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index ead42c62..bde0c16f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -21,56 +21,97 @@ package de.steamwar.bausystem.features.slaves.laufbau.states; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; +import de.steamwar.bausystem.features.slaves.laufbau.states.LaufbauState; import de.steamwar.bausystem.features.tracer.TNTPosition; +import de.steamwar.bausystem.region.Point; import lombok.Getter; +import org.bukkit.Location; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.util.Vector; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; +import java.util.function.BiPredicate; public class ProcessingTracesState implements LaufbauState { private long start = System.currentTimeMillis(); - private int totalTNTPositions; + private int totalCuboids; private List tntPositionList; + private World world; + private BiPredicate inRegionCheck; + + private List toExpand = new ArrayList<>(); + @Getter private List cuboidList = new ArrayList<>(); - public ProcessingTracesState(List tntPositionList) { + @Getter + private Set blocks = new HashSet<>(); + + public ProcessingTracesState(List tntPositionList, World world, BiPredicate inRegionCheck) { this.tntPositionList = tntPositionList; - this.totalTNTPositions = tntPositionList.size(); + this.totalCuboids = tntPositionList.stream().mapToInt(tntPosition -> tntPosition.getPreviousLocation() == null ? 1 : 3).sum(); + this.world = world; + this.inRegionCheck = inRegionCheck; } @Override public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTNTPositions - tntPositionList.size(), totalTNTPositions, eta(p, start, totalTNTPositions - tntPositionList.size(), totalTNTPositions)); + return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalCuboids - cuboidList.size(), totalCuboids, eta(p, start, totalCuboids - cuboidList.size(), totalCuboids)); } @Override public boolean hasNext() { - return !tntPositionList.isEmpty(); + return !tntPositionList.isEmpty() || !toExpand.isEmpty(); } @Override public void next() { - TNTPosition tntPosition = tntPositionList.remove(0); + if (!toExpand.isEmpty()) { + Cuboid cuboid = toExpand.remove(0); + expandCuboid(cuboid); + } else { + TNTPosition tntPosition = tntPositionList.remove(0); + createCuboid(tntPosition); + } + } + + private void createCuboid(TNTPosition tntPosition) { Vector location = tntPosition.getLocation(); Vector previousLocation = tntPosition.getPreviousLocation(); if (previousLocation == null) { - cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), location.getZ() - 0.49, 0.98, 0.98, 0.98)); + toExpand.add(new Cuboid(location.getX() - 0.49, location.getY(), location.getZ() - 0.49, 0.98, 0.98, 0.98)); } else { Vector movement = location.clone().subtract(previousLocation); - cuboidList.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); + toExpand.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); if (Math.abs(tntPosition.getUpdateVelocity().getX()) >= Math.abs(tntPosition.getUpdateVelocity().getZ())) { - cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); - cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); + toExpand.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); + toExpand.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); } else { - cuboidList.add(new Cuboid(previousLocation.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); - cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), location.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); + toExpand.add(new Cuboid(previousLocation.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); + toExpand.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), location.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); + } + } + } + + private void expandCuboid(Cuboid cuboid) { + cuboidList.add(cuboid); + for (double x = cuboid.getX() - 2; x < cuboid.getX() + cuboid.getDx() + 2; x++) { + for (double y = cuboid.getY() - 2; y < cuboid.getY() + cuboid.getDy() + 2; y++) { + for (double z = cuboid.getZ() - 2; z < cuboid.getZ() + cuboid.getDz() + 2; z++) { + Location location = new Location(world, x, y, z); + if (inRegionCheck.test(new Vector(location.getBlockX(), location.getBlockY(), location.getBlockZ()), 0)) { + Point point = new Point(location.getBlockX(), location.getBlockY(), location.getBlockZ()); + blocks.add(point); + } + } } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java deleted file mode 100644 index 487b9991..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ShrinkingOuterPointsState.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.slaves.laufbau.states; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.region.Point; -import lombok.Getter; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.List; - -public class ShrinkingOuterPointsState implements LaufbauState { - - private long start = System.currentTimeMillis(); - - private List outerPoints; - private List innerPoints; - private int index = 0; - - @Getter - private List shrunkOuterPoints = new ArrayList<>(); - - public ShrinkingOuterPointsState(List outerPoints, List innerPoints) { - this.outerPoints = outerPoints; - this.innerPoints = innerPoints; - } - - @Override - public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SHRINKING_POINTS", p), index, outerPoints.size(), eta(p, start, index, outerPoints.size())); - } - - @Override - public boolean hasNext() { - return index < outerPoints.size(); - } - - @Override - public void next() { - Point point = outerPoints.get(index); - index++; - - Point p1 = new Point(point.getX() - 1, point.getY(), point.getZ()); - if (innerPoints.contains(p1)) { - shrunkOuterPoints.add(point); - return; - } - Point p2 = new Point(point.getX() + 1, point.getY(), point.getZ()); - if (innerPoints.contains(p2)) { - shrunkOuterPoints.add(point); - return; - } - Point p3 = new Point(point.getX(), point.getY() - 1, point.getZ()); - if (innerPoints.contains(p3)) { - shrunkOuterPoints.add(point); - return; - } - Point p4 = new Point(point.getX(), point.getY() + 1, point.getZ()); - if (innerPoints.contains(p4)) { - shrunkOuterPoints.add(point); - return; - } - Point p5 = new Point(point.getX(), point.getY(), point.getZ() - 1); - if (innerPoints.contains(p5)) { - shrunkOuterPoints.add(point); - return; - } - Point p6 = new Point(point.getX(), point.getY(), point.getZ() + 1); - if (innerPoints.contains(p6)) { - shrunkOuterPoints.add(point); - return; - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/SplittingPointsState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/SplittingPointsState.java deleted file mode 100644 index 2a61dd44..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/SplittingPointsState.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.slaves.laufbau.states; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.slaves.laufbau.Cuboid; -import de.steamwar.bausystem.region.Point; -import lombok.Getter; -import org.bukkit.entity.Player; - -import java.util.*; - -public class SplittingPointsState implements LaufbauState { - - private static final Cuboid ONE = new Cuboid(0, 0, 0, 1, 1, 1); - private static final Cuboid ABOVE_HALF = new Cuboid(0, 1, 0, 1, 0.5, 1); - - private long start = System.currentTimeMillis(); - - private List blocks; - private int totalBlocks; - private List cuboidList; - - @Getter - private List innerPoints = new ArrayList<>(); - - @Getter - private List outerPoints = new ArrayList<>(); - - @Getter - private Map> intersectedCuboid = new HashMap<>(); - - public SplittingPointsState(Set blocks, List cuboidList) { - this.blocks = new ArrayList<>(blocks); - this.totalBlocks = blocks.size(); - this.cuboidList = cuboidList; - } - - @Override - public String actionBarMessage(Player p) { - return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_SPLITTING_POINTS", p), totalBlocks - blocks.size(), totalBlocks, eta(p, start, totalBlocks - blocks.size(), totalBlocks)); - } - - @Override - public boolean hasNext() { - return !blocks.isEmpty(); - } - - @Override - public void next() { - Point point = blocks.remove(0); - boolean isInCuboid = false; - Cuboid tempCuboid = ONE.add(point); - Cuboid aboveHalfTempCuboid = ABOVE_HALF.add(point); - List intersectedCuboids = new ArrayList<>(); - for (Cuboid cuboid : cuboidList) { - if (cuboid.intersects(tempCuboid)) { - isInCuboid = true; - intersectedCuboids.add(cuboid); - } - if (cuboid.intersects(aboveHalfTempCuboid)) { - intersectedCuboids.add(cuboid); - } - } - if (!isInCuboid) { - outerPoints.add(point); - } else { - innerPoints.add(point); - intersectedCuboid.put(point, intersectedCuboids); - } - } -} From dd5c932f151f00895008e1346aa33e800e6c425e Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 16:54:01 +0200 Subject: [PATCH 12/33] Fix TraceEntity19.display with ticks Fix TraceTNTClickListener Add Trace isolation Signed-off-by: yoyosource --- .../bausystem/entities/TraceEntity19.java | 4 +- BauSystem_Main/src/BauSystem.properties | 4 ++ BauSystem_Main/src/BauSystem_de.properties | 3 ++ .../features/tracer/TraceCommand.java | 16 +++++++ .../tracer/TraceTNTClickListener.java | 8 +++- .../features/tracer/gui/TraceGui.java | 16 +++++-- .../tracer/show/TraceShowManager.java | 42 +++++++++++++++---- 7 files changed, 79 insertions(+), 14 deletions(-) diff --git a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java b/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java index c5e9b714..e70dba55 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/entities/TraceEntity19.java @@ -45,11 +45,11 @@ public class TraceEntity19 extends BaseEntity19 implements AbstractTraceEntity { public void display(Player player, boolean exploded, int ticks) { if (ticks != -1) { this.n(true); - this.a(IChatMutableComponent.a(new LiteralContents(ticks + ""))); + this.b(IChatMutableComponent.a(new LiteralContents(ticks + ""))); } if (!this.exploded && exploded) { this.n(true); - this.a(IChatMutableComponent.a(new LiteralContents("Bumm"))); + this.b(IChatMutableComponent.a(new LiteralContents("Bumm"))); this.exploded = true; if (referenceCounter.increment() > 0) { sendEntityDestroy(player); diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 5fe51591..9e8ab478 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -696,6 +696,9 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer stopped TRACE_MESSAGE_DELETE = §cAll TNT-positions deleted TRACE_MESSAGE_SHOW = §aAll TNT-positions shown TRACE_MESSAGE_HIDE = §cAll TNT-positions hidden +TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated +TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden +TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Starts recording of all TNT-positions @@ -1243,6 +1246,7 @@ TNT_CLICK_VELOCITY_X = §7Velocity §eX§8: §e{0} TNT_CLICK_VELOCITY_Y = §7Velocity §eY§8: §e{0} TNT_CLICK_VELOCITY_Z = §7Velocity §eZ§8: §e{0} TNT_CLICK_COUNT = §7Count §8: §e{0} +TNT_CLICK_ISOLATE = §eIsolate SELECT_ITEM_CHOOSE_EXTENSION = Choose extension SELECT_ITEM_CHOOSE_SELECTION = Choose selection diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 439518b6..42a240d8 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -676,6 +676,9 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet +TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert +TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet +TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 40b28177..9a3a2b9a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -293,6 +293,22 @@ public class TraceCommand extends SWCommand { BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); } + @Register(value = {"isolate"}, noTabComplete = true) + public void isolateCommand(@Validator Player p, long tntRecordId) { + Record.TNTRecord tntRecord = StoredRecords.getRecords().stream().flatMap(record -> record.getTnt().stream()).filter(record -> record.getId() == tntRecordId).findFirst().orElse(null); + if (tntRecord == null) { + BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", p); + return; + } + if (TraceShowManager.isIsolated(p, tntRecord)) { + TraceShowManager.unisolate(p, tntRecord); + BauSystem.MESSAGE.send("TRACE_MESSAGE_UNISOLATE", p); + } else { + TraceShowManager.isolate(p, tntRecord); + BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", p); + } + } + @ClassValidator(value = Player.class, local = true) public TypeValidator validator() { return (commandSender, player, messageSender) -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java index e79454ac..5974d50e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Plain; +import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.RayTraceResult; @@ -42,8 +43,8 @@ public class TraceTNTClickListener implements Plain { Set playerSet = new HashSet<>(); TinyProtocol.instance.addFilter(useEntity, (player, o) -> { - if (!playerSet.add(player)) return o; Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + if (!playerSet.add(player)) return; RayTraceResult rayTraceResult = RayTraceUtils.trace(player, player.getLocation(), TraceShowManager.getEntities(player)); if (rayTraceResult == null) return; if (rayTraceResult.getHitEntity() == null) return; @@ -58,8 +59,11 @@ public class TraceTNTClickListener implements Plain { BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, tntPosition.getVelocity().getY() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + ""); - playerSet.remove(player); + BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); }, 1); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + playerSet.remove(player); + }, 2); return o; }); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java index 1b87bbf4..04b52da9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java @@ -62,14 +62,24 @@ public class TraceGui { public static void openRecordGui(Player player, Record record) { List> recordList = new ArrayList<>(); record.getTnt().forEach(tntRecord -> { - SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size())); + SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), TraceShowManager.isIsolated(player, tntRecord), clickType -> { + }); recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord)); }); SWListInv tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> { - openTntGui(player, record, tntRecord); + if (clickType.isShiftClick()) { + if (TraceShowManager.isIsolated(player, tntRecord)) { + TraceShowManager.unisolate(player, tntRecord); + } else { + TraceShowManager.isolate(player, tntRecord); + } + openRecordGui(player, record); + } else { + openTntGui(player, record, tntRecord); + } }); tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> { - StoredRecords.getRecords().remove(record); + StoredRecords.remove(record); TraceShowManager.reshow(); openGui(player); })); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index cdb176cf..01135669 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -2,6 +2,7 @@ package de.steamwar.bausystem.features.tracer.show; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; +import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; import de.steamwar.bausystem.shared.ShowMode; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; @@ -10,24 +11,48 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public class TraceShowManager implements Listener { private TraceShowManager() { } + private static final Map> playerIsolatedRecords = new HashMap<>(); private static final Map> showModes = new HashMap<>(); + public static void isolate(Player player, Record.TNTRecord tntRecord) { + playerIsolatedRecords.computeIfAbsent(player, p -> new HashSet<>()).add(tntRecord); + show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter()))); + } + + public static void unisolate(Player player, Record.TNTRecord tntRecord) { + playerIsolatedRecords.computeIfPresent(player, (player1, tntRecords) -> { + tntRecords.remove(tntRecord); + return tntRecords; + }); + show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter()))); + } + + public static boolean isIsolated(Player player, Record.TNTRecord tntRecord) { + return playerIsolatedRecords.getOrDefault(player, Collections.emptySet()).contains(tntRecord); + } + public static void show(Player player, ShowMode traceShowMode) { + Set isolatedRecords = playerIsolatedRecords.get(player); hide(player); showModes.put(player, traceShowMode); - StoredRecords.showAll(traceShowMode); + if (isolatedRecords != null && !isolatedRecords.isEmpty()) { + playerIsolatedRecords.put(player, isolatedRecords); + for (Record.TNTRecord record : isolatedRecords) { + record.getPositions().forEach(traceShowMode::show); + } + } else { + StoredRecords.showAll(traceShowMode); + } } public static void hide(Player player) { + playerIsolatedRecords.remove(player); ShowMode traceShowMode = showModes.remove(player); if (traceShowMode == null) return; @@ -63,12 +88,15 @@ public class TraceShowManager implements Listener { /* Only to be called by record */ static void show(TNTPosition tnt) { - for (ShowMode mode : showModes.values()) - mode.show(tnt); + for (Map.Entry> entry : showModes.entrySet()) { + if (playerIsolatedRecords.containsKey(entry.getKey())) continue; + entry.getValue().show(tnt); + } } /* Only to be called by StoredRecords */ static void clear() { + playerIsolatedRecords.clear(); for (ShowMode mode : showModes.values()) mode.hide(); } From 1e1d8d718a37aa7d7516c48e7d2429aaa2bfbb43 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 Oct 2022 17:02:45 +0200 Subject: [PATCH 13/33] Fix xray and techhider Signed-off-by: yoyosource --- BauSystem_Main/src/de/steamwar/bausystem/region/Region.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index cec37575..906a4499 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -592,7 +592,7 @@ public class Region { public File gameModeConfig() { File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); for (int version = Core.getVersion(); version >= 15; version--) { - File specific = new File(baseFile, getDisplayName() + version + ".yml"); + File specific = new File(baseFile, prototype.getDisplayName() + version + ".yml"); if (specific.exists()) return specific; } return null; From 399c86aa6d1a0f8f16c54122b6356337e6b01dbe Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 17:01:43 +0200 Subject: [PATCH 14/33] Rework tracer Signed-off-by: yoyosource --- .../simulator/SimulatorPreview15.java | 2 +- .../bausystem/utils/NMSWrapper15.java | 5 - .../bausystem/utils/NMSWrapper18.java | 5 - .../simulator/SimulatorPreview19.java | 10 +- .../bausystem/utils/NMSWrapper19.java | 5 - BauSystem_Main/src/BauSystem.properties | 51 +-- BauSystem_Main/src/BauSystem_de.properties | 51 +-- .../features/script/variables/Constants.java | 16 +- .../features/simulator/SimulatorStorage.java | 4 +- .../features/simulator/TNTSimulator.java | 9 +- .../features/tpslimit/TPSLimitCommand.java | 2 +- .../features/tracer/AbstractTraceEntity.java | 2 +- .../features/tracer/TNTPosition.java | 6 +- .../features/tracer/TraceCommand.java | 346 ++++++------------ .../tracer/TraceTNTClickListener.java | 3 +- .../features/tracer/TracerBauGuiItem.java | 33 +- .../features/tracer/gui/TraceGui.java | 31 +- .../features/tracer/gui/TraceShowGui.java | 129 ------- .../tracer/record/ActiveTracer.java} | 7 +- .../record/AutoExplodeTraceRecorder.java} | 17 +- .../record/AutoIgniteTraceRecorder.java | 33 ++ .../tracer/record/AutoTraceRecorder.java | 118 ++++++ .../tracer/record/RecordStateMachine.java | 113 ------ .../features/tracer/record/RecordStatus.java | 56 --- .../features/tracer/record/Recorder.java | 184 +++++++--- .../tracer/record/SimpleTraceRecorder.java | 73 ++++ .../tracer/record/TraceAutoHandler.java | 72 ---- .../features/tracer/record/TraceRecorder.java | 41 +++ .../features/tracer/show/Record.java | 124 +++---- .../tracer/show/ShowModeParameter.java | 57 ++- .../tracer/show/ShowModeParameterType.java | 17 +- .../features/tracer/show/StoredRecords.java | 80 ++-- .../tracer/show/TraceShowManager.java | 150 +++++--- .../tracer/show/mode/BlockShowMode.java | 67 ---- .../show/mode/FactoredEntityShowMode.java | 24 +- .../tracer/show/mode/ParticleShowMode.java | 72 ---- .../bausystem/features/warp/WarpCommand.java | 10 +- .../features/world/BauScoreboard.java | 19 +- .../features/world/ReducedDebugInfo.java | 2 +- .../bausystem/region/BackupScheduler.java | 2 +- .../steamwar/bausystem/utils/NMSWrapper.java | 1 - 41 files changed, 856 insertions(+), 1193 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceShowGui.java rename BauSystem_Main/src/de/steamwar/bausystem/{linkage/Disable.java => features/tracer/record/ActiveTracer.java} (84%) rename BauSystem_Main/src/de/steamwar/bausystem/{linkage/Enable.java => features/tracer/record/AutoExplodeTraceRecorder.java} (64%) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStateMachine.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceAutoHandler.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/BlockShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java b/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java index 200f84ac..f3e38be3 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/features/simulator/SimulatorPreview15.java @@ -25,6 +25,6 @@ public class SimulatorPreview15 implements SimulatorPreview { @Override public Record simulate(TNTSimulator tntSimulator) { - return new Record(false); + return new Record(null); } } diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 9111ee64..15756166 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -118,11 +118,6 @@ public class NMSWrapper15 implements NMSWrapper { ((CraftPlayer) player).getHandle().abilities.canInstantlyBuild = true; } - @Override - public Particle tntPositionParticle() { - return Particle.BARRIER; - } - @Override public Material pathMaterial() { return Material.GRASS_PATH; diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 9b3878e9..4d14fc01 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -123,11 +123,6 @@ public class NMSWrapper18 implements NMSWrapper { ((CraftPlayer) player).getHandle().fs().e = true; } - @Override - public Particle tntPositionParticle() { - return Particle.BLOCK_MARKER; - } - @Override public Material pathMaterial() { return Material.DIRT_PATH; diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java index 34a0b9ea..5a06c342 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/features/simulator/SimulatorPreview19.java @@ -39,7 +39,7 @@ public class SimulatorPreview19 implements SimulatorPreview { @Override public Record simulate(TNTSimulator tntSimulator) { if (true) { - return new Record(false); + return new Record(null); } Map>>> result = new HashMap<>(); @@ -66,11 +66,11 @@ public class SimulatorPreview19 implements SimulatorPreview { } }); if (tntCount.get() > 500) { - return new Record(false); + return new Record(null); } List fakeTNT19s = new ArrayList<>(); - Record record = new Record(false); + Record record = new Record(null); Map tntRecords = new HashMap<>(); int maxTickToCalc = maxTick.get() + 160; @@ -120,11 +120,11 @@ public class SimulatorPreview19 implements SimulatorPreview { fakeTNT19.k(spawnList); TNTPrimed tntPrimed = ((TNTPrimed) (fakeTNT19.getBukkitEntity())); if (tntPrimed.getFuseTicks() <= 0) { - tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed); + tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed); fakeTNT19s.remove(i); i--; } else { - tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn()).explode(tntPrimed); + tntRecords.computeIfAbsent(fakeTNT19, ignore -> record.spawn(0)).explode(tntPrimed); } if (!spawnList.isEmpty()) { fakeTNT19s.addAll(i, spawnList); diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java index 4424f100..4d184f6f 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java @@ -123,11 +123,6 @@ public class NMSWrapper19 implements NMSWrapper { ((CraftPlayer) player).getHandle().fB().e = true; } - @Override - public Particle tntPositionParticle() { - return Particle.BLOCK_MARKER; - } - @Override public Material pathMaterial() { return Material.DIRT_PATH; diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 9e8ab478..34c1d0db 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -681,15 +681,11 @@ TPSLIMIT_INVALID_FROZEN = §c and '0' # Trace TRACE_RECORD=§aon -TRACE_RECORD_AUTO=§aon -TRACE_RECORD_SINGLE=§aon TRACE_IDLE=§coff -TRACE_IDLE_AUTO=§eauto -TRACE_IDLE_SINGLE=§esingle -TRACE_MESSAGE_AUTO_RECORD=§cTNT-Tracer must be stopped -TRACE_MESSAGE_AUTO_RECORD_AUTO=§cTNT-Tracer is not allowed to record -TRACE_MESSAGE_AUTO_IDLE=§cAuto-Tracer stopped -TRACE_MESSAGE_AUTO_IDLE_AUTO = §aAuto-Tracer started +TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) +TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) +TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode started +TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite started TRACE_MESSAGE_START = §aTNT-Tracer started TRACE_MESSAGE_SINGLE = §aSingle-Tracer started TRACE_MESSAGE_STOP = §cTNT-Tracer stopped @@ -700,16 +696,15 @@ TRACE_MESSAGE_ISOLATE = §aTNT-positions isolated TRACE_MESSAGE_UNISOLATE = §cTNT-positions hidden TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here +TRACE_MESSAGE_NO_REGION = §cYou are not in a region TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Starts recording of all TNT-positions TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Starts a single recording of all TNT-positions TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stops the TNT-Tracer TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatic start of recording -TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Shows the trace GUI TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all TNT-positions TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Hides all TNT-positions TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions -TRACE_COMMAND_HELP_LIST = §8/§etrace list §8- §7Trace GUI but in the Chat TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI TRACE_GUI_ITEM_NAME = §eTracer @@ -720,22 +715,8 @@ TRACE_GUI_TRACE_ACTIVE = §eStop Tracer TRACE_GUI_TRACE_ACTIVE_AUTO = §eAuto-Trace is active TRACE_GUI_AUTO_TRACE_INACTIVE = §eacitvate Auto-Tracer TRACE_GUI_AUTO_TRACE_ACTIVE = §edeactivate Auto-Tracer -TRACE_GUI_SHOW_GUI = §eTrace Show Gui TRACE_GUI_DELETE = §eDelete trace -TRACE_SHOW_GUI_TITLE = Trace Show GUI -TRACE_SHOW_GUI_SHOWN = §aTraces shown -TRACE_SHOW_GUI_HIDDEN = §cTraces hidden -TRACE_SHOW_GUI_WATER_ITEM = §eWater §7positions -TRACE_SHOW_GUI_WATER_LORE1 = §7Shows all TNT which -TRACE_SHOW_GUI_WATER_LORE2 = §7exploded in water. -TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM = §eInterpolation §7Y-Axis -TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1 = §7Shows the interpolation -TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2 = §7on the Y-Axis. -TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM = §eInterpolation §7XZ-Achsis -TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1 = §7Shows the interpolation -TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2 = §7ont the XZ-Achsis. - TRACE_GUI_TITLE = Trace GUI TRACE_GUI_ITEM_BACK = §eBack TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT @@ -746,29 +727,9 @@ TRACE_GUI_POSITION_ITEM = §ePosition TRACE_GUI_POSITION_X = §7X§8: §e{0} TRACE_GUI_POSITION_Y = §7Y§8: §e{0} TRACE_GUI_POSITION_Z = §7Z§8: §e{0} +TRACE_GUI_POSITION_SOURCE = §7Source§8: §e{0} TRACE_GUI_POSITION_EXPLODED = §7Exploded§8: §e{0} -TRACE_RECORD_LIST_ELEMENT = §eTrace §8- §e{0} §7TNT -TRACE_RECORD_LIST_ELEMENT_HOVER = §7Shows all §eTNT §7from this trace -TRACE_RECORD_LIST_ELEMENT_DELETE = §7 §cDelete -TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER = §cDelete §7trace -TRACE_RECORD_DELETE = §7Trace deleted -TRACE_RECORD_NOT_FOUND = §7Unknown trace -TRACE_RECORD_ELEMENT = §eTNT §8- §e{0} §7Positions -TRACE_RECORD_ELEMENT_HOVER = §7Shows all §ePositions §7from this TNT -TRACE_RECORD_ELEMENT_DELETE = §7 §cDelete -TRACE_RECORD_ELEMENT_DELETE_HOVER = §cDelete §7trace -TRACE_RECORD_TNT_NOT_FOUND = §7Unknown TNT -TRACE_TNT_ELEMENT = §ePosition §8- §e{0} §7FuseTicks -TRACE_TNT_DELETE = §7TNT deleted -TRACE_TNT_ELEMENT_HOVER = §7Shows information on the §ePosition -TRACE_RECORD_TNT_POSITION_NOT_FOUND = §7Unknown TNT Position -TRACE_CHAT_POSITION_HEAD = §ePosition -TRACE_CHAT_POSITION_X = §7X§8: §e{0} -TRACE_CHAT_POSITION_Y = §7Y§8: §e{0} -TRACE_CHAT_POSITION_Z = §7Z§8: §e{0} -TRACE_CHAT_POSITION_EXPLODED = §7Exploded§8: §e{0} - # Loader LOADER_OFF = §coff LOADER_SETUP = §eSetup diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 42a240d8..d9804ad9 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -661,15 +661,11 @@ TPSLIMIT_INVALID_FROZEN = §c und '0' # Trace TRACE_RECORD=§aan -TRACE_RECORD_AUTO=§aan -TRACE_RECORD_SINGLE=§aan TRACE_IDLE=§caus -TRACE_IDLE_AUTO=§eauto -TRACE_IDLE_SINGLE=§esingle -TRACE_MESSAGE_AUTO_RECORD=§cTNT-Tracer muss gestoppt werden -TRACE_MESSAGE_AUTO_RECORD_AUTO=§cTNT-Tracer darf nicht aufnehmen -TRACE_MESSAGE_AUTO_IDLE=§cAuto-Tracer gestoppt -TRACE_MESSAGE_AUTO_IDLE_AUTO = §aAuto-Tracer gestartet +TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) +TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) +TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode gestartet +TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite gestartet TRACE_MESSAGE_START = §aTNT-Tracer gestartet TRACE_MESSAGE_SINGLE = §aSingle-Tracer gestartet TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt @@ -680,16 +676,15 @@ TRACE_MESSAGE_ISOLATE = §aTNT-Positionen isoliert TRACE_MESSAGE_UNISOLATE = §cTNT-Positionen ausgeblendet TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen +TRACE_MESSAGE_NO_REGION = §cDu bist in keiner Region TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stoppt den TNT-Tracer TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart -TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show gui TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle TNT-Positionen TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Versteckt alle TNT-Positionen TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen -TRACE_COMMAND_HELP_LIST = §8/§etrace list §8- §7Trace GUI nur im Chat TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an TRACE_GUI_ITEM_NAME = §eTracer @@ -700,22 +695,8 @@ TRACE_GUI_TRACE_ACTIVE = §eTracer Stoppen TRACE_GUI_TRACE_ACTIVE_AUTO = §eAuto-Trace ist Aktiv TRACE_GUI_AUTO_TRACE_INACTIVE = §eAuto-Tracer Aktivieren TRACE_GUI_AUTO_TRACE_ACTIVE = §eAuto-Tracer Deaktivieren -TRACE_GUI_SHOW_GUI = §eTrace Show Gui TRACE_GUI_DELETE = §eTrace Löschen -TRACE_SHOW_GUI_TITLE = Trace Show GUI -TRACE_SHOW_GUI_SHOWN = §aTraces angezeigt -TRACE_SHOW_GUI_HIDDEN = §cTraces ausgeblendet -TRACE_SHOW_GUI_WATER_ITEM = §eWasser §7Positionen -TRACE_SHOW_GUI_WATER_LORE1 = §7Zeigt alles TNT, welches -TRACE_SHOW_GUI_WATER_LORE2 = §7im Wasser explodiert ist. -TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM = §eInterpolation §7Y-Achse -TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1 = §7Zeigt die Interpolation -TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2 = §7auf der Y-Achse. -TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM = §eInterpolation §7XZ-Achse -TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1 = §7Zeigt die Interpolation -TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2 = §7auf der XZ-Achse. - TRACE_GUI_TITLE = Trace GUI TRACE_GUI_ITEM_BACK = §eBack TRACE_GUI_ITEM = §eTrace §8- §e{0} §7TNT @@ -726,29 +707,9 @@ TRACE_GUI_POSITION_ITEM = §ePosition TRACE_GUI_POSITION_X = §7X§8: §e{0} TRACE_GUI_POSITION_Y = §7Y§8: §e{0} TRACE_GUI_POSITION_Z = §7Z§8: §e{0} +TRACE_GUI_POSITION_SOURCE = §7Ursprung§8: §e{0} TRACE_GUI_POSITION_EXPLODED = §7Explodiert§8: §e{0} -TRACE_RECORD_LIST_ELEMENT = §eTrace §8- §e{0} §7TNT -TRACE_RECORD_LIST_ELEMENT_HOVER = §7Zeige alle §eTNT §7aus diesem Trace -TRACE_RECORD_LIST_ELEMENT_DELETE = §7 §cLöschen -TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER = §7Trace §clöschen -TRACE_RECORD_DELETE = §7Trace gelöscht -TRACE_RECORD_NOT_FOUND = §7Unbekannter Trace -TRACE_RECORD_ELEMENT = §eTNT §8- §e{0} §7Positionen -TRACE_RECORD_ELEMENT_HOVER = §7Zeige alle §ePositionen §7aus diesem TNT -TRACE_RECORD_ELEMENT_DELETE = §7 §cLöschen -TRACE_RECORD_ELEMENT_DELETE_HOVER = §7Trace §clöschen -TRACE_RECORD_TNT_NOT_FOUND = §7Unbekanntes TNT -TRACE_TNT_ELEMENT = §ePosition §8- §e{0} §7FuseTicks -TRACE_TNT_DELETE = §7TNT gelöscht -TRACE_TNT_ELEMENT_HOVER = §7Zeige Infos zur §ePosition §7an -TRACE_RECORD_TNT_POSITION_NOT_FOUND = §7Unbekannte TNT Position -TRACE_CHAT_POSITION_HEAD = §ePosition -TRACE_CHAT_POSITION_X = §7X§8: §e{0} -TRACE_CHAT_POSITION_Y = §7Y§8: §e{0} -TRACE_CHAT_POSITION_Z = §7Z§8: §e{0} -TRACE_CHAT_POSITION_EXPLODED = §7Explodiert§8: §e{0} - # Loader LOADER_OFF = §caus LOADER_SETUP = §eEinrichtung diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java index ed242ace..a47b3231 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java @@ -1,6 +1,8 @@ package de.steamwar.bausystem.features.script.variables; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.features.tracer.record.ActiveTracer; +import de.steamwar.bausystem.features.tracer.record.AutoTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; @@ -218,10 +220,18 @@ public class Constants { static { CONSTANTS.put("trace", player -> { - return new ConstantBooleanValue(RecordStateMachine.getRecordStatus()::isTracing); + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return new ConstantBooleanValue(() -> false); + } + return new ConstantBooleanValue(() -> Recorder.INSTANCE.get(region) instanceof ActiveTracer); }); CONSTANTS.put("autotrace", player -> { - return new ConstantBooleanValue(RecordStateMachine.getRecordStatus()::isAutoTrace); + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return new ConstantBooleanValue(() -> false); + } + return new ConstantBooleanValue(() -> Recorder.INSTANCE.get(region) instanceof AutoTraceRecorder); }); CONSTANTS.put("tnt", player -> { return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java index 7091f7b7..8c965f97 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorStorage.java @@ -22,11 +22,11 @@ package de.steamwar.bausystem.features.simulator; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.simulator.tnt.TNTElement; -import de.steamwar.bausystem.linkage.Disable; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.utils.ItemUtils; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Disable; +import de.steamwar.linkage.api.Enable; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.Material; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 210c66f5..045fb75b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -27,7 +27,8 @@ import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; import de.steamwar.bausystem.features.simulator.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.tnt.TNTGroup; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; import lombok.Getter; @@ -228,13 +229,17 @@ public class TNTSimulator { return; } + AtomicBoolean needsAutoTrace = new AtomicBoolean(); playerShowMode.forEach((player, simulatorEntityShowMode) -> { boolean simulatorAutoTrace = Config.getInstance().get(player).getPlainValueOrDefault("simulatorAutoTrace", false); if (simulatorAutoTrace) { - RecordStateMachine.commandSingle(); + needsAutoTrace.set(true); player.performCommand("trace show"); } }); + if (needsAutoTrace.get()) { + Recorder.INSTANCE.set(region, new AutoExplodeTraceRecorder()); + } AtomicInteger maxTick = new AtomicInteger(0); Map>>> toSpawn = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java index f19c8bcb..778b6f82 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSLimitCommand.java @@ -22,11 +22,11 @@ package de.steamwar.bausystem.features.tpslimit; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; import de.steamwar.command.TypeMapper; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Enable; import org.bukkit.Bukkit; import org.bukkit.entity.Player; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java index ef0df4aa..10179551 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/AbstractTraceEntity.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java index 09b882ee..38b6f844 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -53,15 +53,17 @@ public class TNTPosition extends Position { private final Vector previousLocation; private final Vector velocity; private final CachingSupplier updateVelocity; + private final boolean source; private final boolean exploded; - public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier updateVelocity, boolean exploded) { + public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier updateVelocity, boolean source, boolean exploded) { super(entity.getLocation().toVector()); this.record = record; this.fuseTicks = entity.getFuseTicks(); this.previousLocation = previousLocation; this.velocity = velocity; this.updateVelocity = updateVelocity; + this.source = source; this.exploded = exploded; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 9a3a2b9a..6278649d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -1,46 +1,45 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.gui.TraceGui; -import de.steamwar.bausystem.features.tracer.gui.TraceShowGui; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.*; -import de.steamwar.bausystem.features.tracer.show.mode.BlockShowMode; -import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode; +import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.AutoIgniteTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.Recorder; +import de.steamwar.bausystem.features.tracer.record.SimpleTraceRecorder; +import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; +import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; +import de.steamwar.bausystem.features.tracer.show.StoredRecords; +import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.features.tracer.show.mode.RawEntityShowMode; import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; -import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import lombok.AllArgsConstructor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -56,6 +55,79 @@ public class TraceCommand extends SWCommand { super("trace", "trail"); } + @LinkedInstance + public Recorder recorder; + + @Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START") + public void startCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + recorder.set(region, new SimpleTraceRecorder()); + BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); + } + + @Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP") + public void stopCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + recorder.remove(region); + BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p); + } + + @Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO") + @Register({"toggleauto"}) + public void autoCommand(@Validator Player p, @OptionalValue("-explode") @StaticValue({"-explode", "-ignite"}) String type) { + Region region = Region.getRegion(p.getLocation()); + switch (type) { + case "-explode": + recorder.set(region, new AutoExplodeTraceRecorder()); + BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_EXPLODE", p); + break; + case "-ignite": + recorder.set(region, new AutoIgniteTraceRecorder()); + BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_IGNITE", p); + break; + default: + break; + } + } + + @Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW") + public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) { + ShowModeParameter showModeParameter = new ShowModeParameter(); + for (ShowModeParameterType showModeParameterType : showModeParameterTypes) { + showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); + } + TraceShowManager.show(p, showModeType.showModeBiFunction.apply(p, showModeParameter)); + BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p); + } + + @Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE") + public void hideCommand(@Validator Player p) { + TraceShowManager.hide(p); + BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); + } + + @Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE") + @Register({"clear"}) + public void deleteCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + StoredRecords.clear(region); + BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); + } + + @Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI") + public void guiCommand(@Validator Player p) { + TraceGui.openGui(p); + } + + @AllArgsConstructor + private enum ShowModeType { + ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), + RAW(RawEntityShowMode::new, new ShowModeParameterType[]{}); + + private BiFunction> showModeBiFunction; + private ShowModeParameterType[] removedTypes; + } + @ClassMapper(value = ShowModeParameterType.class, local = true) public TypeMapper showModeParameterTypesTypeMapper() { Map> showModeParameterTypeListMap = new EnumMap<>(ShowModeParameterType.class); @@ -104,215 +176,19 @@ public class TraceCommand extends SWCommand { }; } - @Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI") - public void guiCommand(@Validator Player p) { - TraceGui.openGui(p); - } - - @Register(value = {"record", "list"}) - @Register(value = {"list"}, description = "TRACE_COMMAND_HELP_LIST") - public void listCommand(@Validator Player player, @OptionalValue("0") int page) { - ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> { - TextComponent component = new TextComponent(); - component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size())); - component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId())); - component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_HOVER", player)))); - - TextComponent deleteComponent = new TextComponent(); - deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE", player)); - deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record delete " + record.getId())); - deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER", player)))); - component.addExtra(deleteComponent); - return component; - }, (beforePageComponent, beforePage) -> { - beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create())); - beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + beforePage)); - }, (afterPageComponent, afterPage) -> { - afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create())); - afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + afterPage)); - }); - } - - @Register(value = {"record", "delete"}, noTabComplete = true) - public void recordDelete(@Validator Player p, int id) { - StoredRecords.remove(id); - BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p); - } - - @Register(value = "record", noTabComplete = true) - public void recordList(@Validator Player player, int recordID, @OptionalValue("0") int page) { - Record traceRecord = StoredRecords.get(recordID); - if (traceRecord == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); - return; - } - ListChatView.chatView(player, traceRecord.getTnt(), page, tntRecord -> { - TextComponent component = new TextComponent(); - component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT", player, tntRecord.getPositions().size())); - component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " tnt " + tntRecord.getId())); - component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_HOVER", player)))); - - TextComponent deleteComponent = new TextComponent(); - deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE", player)); - deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record tnt delete " + traceRecord.getId() + " " + tntRecord.getId())); - deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE_HOVER", player)))); - component.addExtra(deleteComponent); - return component; - }, (beforePageComponent, beforePage) -> { - beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create())); - beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " " + beforePage)); - }, (afterPageComponent, afterPage) -> { - afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create())); - afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + traceRecord.getId() + " " + afterPage)); - }); - } - - @Register(value = {"record", "tnt", "delete"}, noTabComplete = true) - public void deleteRecordTNT(@Validator Player player, int recordID, int tntID) { - Record record = StoredRecords.get(recordID); - if (record == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); - return; - } - record.remove(tntID); - BauSystem.MESSAGE.send("TRACE_TNT_DELETE", player); - } - - @Register(value = "record", noTabComplete = true) - public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @OptionalValue("0") int page) { - Record record = StoredRecords.get(recordID); - if (record == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); - return; - } - Record.TNTRecord tntRecord = record.get(tntID); - if (tntRecord == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player); - return; - } - ListChatView.chatView(player, tntRecord.getPositions(), page, tntPosition -> { - TextComponent component = new TextComponent(); - component.setText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT", player, tntPosition.getFuseTicks())); - component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + tntRecord.getId() + " fuse " + tntPosition.getFuseTicks())); - component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT_HOVER", player)))); - return component; - }, (beforePageComponent, beforePage) -> { - beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create())); - beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + beforePage)); - }, (afterPageComponent, afterPage) -> { - afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create())); - afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + afterPage)); - }); - } - - @Register(value = "record", noTabComplete = true) - public void recordTNTPositions(@Validator Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) { - Record record = StoredRecords.get(recordID); - if (record == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); - return; - } - Record.TNTRecord tntRecord = record.get(tntID); - if (tntRecord == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player); - return; - } - TNTPosition tntPosition = tntRecord.get(fuseTicks); - if (tntPosition == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_TNT_POSITION_NOT_FOUND", player); - return; - } - BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_HEAD", player); - BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_X", player, tntPosition.getLocation().getX()); - BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Y", player, tntPosition.getLocation().getY()); - BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Z", player, tntPosition.getLocation().getZ()); - BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_EXPLODED", player, tntPosition.isExploded()); - } - - @Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START") - public void startCommand(@Validator Player p) { - RecordStateMachine.commandStart(); - BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); - } - - @Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE") - public void singleCommand(@Validator Player p) { - RecordStateMachine.commandSingle(); - BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p); - } - - @Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP") - public void stopCommand(@Validator Player p) { - RecordStateMachine.commandStop(); - BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p); - } - - @Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO") - @Register({"toggleauto"}) - public void autoCommand(@Validator Player p) { - RecordStateMachine.commandAuto(); - BauSystem.MESSAGE.send(RecordStateMachine.getRecordStatus().getAutoMessage(), p); - } - - @Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE") - @Register({"clear"}) - public void deleteCommand(@Validator Player p) { - StoredRecords.clear(); - BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); - } - - @Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW") - public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) { - ShowModeParameter showModeParameter = new ShowModeParameter(); - for (ShowModeParameterType showModeParameterType : showModeParameterTypes) { - showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); - } - TraceShowManager.show(p, showModeType.showModeBiFunction.apply(p, showModeParameter)); - BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p); - } - - @AllArgsConstructor - private enum ShowModeType { - ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), - RAW(RawEntityShowMode::new, new ShowModeParameterType[]{}), - PARTICLE(ParticleShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS}), - BLOCK(BlockShowMode::new, new ShowModeParameterType[]{ShowModeParameterType.TICKS}); - - private BiFunction> showModeBiFunction; - private ShowModeParameterType[] removedTypes; - } - - @Register(value = {"show", "gui"}, description = "TRACE_COMMAND_HELP_SHOW_GUI") - public void showGuiCommand(@Validator Player p) { - TraceShowGui.openGui(p); - } - - @Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE") - public void hideCommand(@Validator Player p) { - TraceShowManager.hide(p); - BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); - } - - @Register(value = {"isolate"}, noTabComplete = true) - public void isolateCommand(@Validator Player p, long tntRecordId) { - Record.TNTRecord tntRecord = StoredRecords.getRecords().stream().flatMap(record -> record.getTnt().stream()).filter(record -> record.getId() == tntRecordId).findFirst().orElse(null); - if (tntRecord == null) { - BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", p); - return; - } - if (TraceShowManager.isIsolated(p, tntRecord)) { - TraceShowManager.unisolate(p, tntRecord); - BauSystem.MESSAGE.send("TRACE_MESSAGE_UNISOLATE", p); - } else { - TraceShowManager.isolate(p, tntRecord); - BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", p); - } - } - @ClassValidator(value = Player.class, local = true) public TypeValidator validator() { return (commandSender, player, messageSender) -> { - return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "TRACE_MESSAGE_DISALLOWED"); + if (!Permission.hasPermission(player, Permission.WORLD)) { + messageSender.send("TRACE_MESSAGE_DISALLOWED", player); + return false; + } + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + messageSender.send("TRACE_MESSAGE_NO_REGION", player); + return false; + } + return true; }; } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java index 5974d50e..9938565b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java @@ -26,7 +26,6 @@ import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Plain; -import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.RayTraceResult; @@ -59,7 +58,7 @@ public class TraceTNTClickListener implements Plain { BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, tntPosition.getVelocity().getY() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); + // BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); }, 1); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { playerSet.remove(player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index d051afd0..3a188e9a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -21,10 +21,9 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; -import de.steamwar.bausystem.features.tracer.record.RecordStatus; -import de.steamwar.bausystem.features.tracer.show.TraceShowManager; +import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.linkage.specific.BauGuiItem; +import de.steamwar.bausystem.region.Region; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; @@ -34,6 +33,7 @@ import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; import java.util.Arrays; +import java.util.Collections; @Linked public class TracerBauGuiItem extends BauGuiItem { @@ -44,15 +44,21 @@ public class TracerBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), player))), false, clickType -> { + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> { + }).getItemStack(); + } + return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> { }).getItemStack(); } private static void open(Player p) { - RecordStatus status = RecordStateMachine.getRecordStatus(); + Region region = Region.getRegion(p.getLocation()); + TraceRecorder traceRecorder = Recorder.INSTANCE.get(region); SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("TRACE_GUI_NAME", p)); - if (status.isTracing()) { - if (status.isAutoTrace()) { + if (traceRecorder instanceof ActiveTracer) { + if (traceRecorder instanceof AutoTraceRecorder) { inv.setItem(1, new SWItem(Material.GRAY_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE_AUTO", p))); } else { inv.setItem(1, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE", p), clickType -> { @@ -66,7 +72,7 @@ public class TracerBauGuiItem extends BauGuiItem { open(p); })); } - if (status.isAutoTrace()) { + if (traceRecorder instanceof AutoTraceRecorder) { inv.setItem(3, new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("TRACE_GUI_AUTO_TRACE_ACTIVE", p), clickType -> { p.performCommand("trace auto"); open(p); @@ -77,15 +83,6 @@ public class TracerBauGuiItem extends BauGuiItem { open(p); })); } - if (TraceShowManager.hasActiveShow(p)) { - inv.setItem(5, new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_GUI_SHOW_GUI", p), clickType -> { - p.performCommand("trace show gui"); - })); - } else { - inv.setItem(5, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("TRACE_GUI_SHOW_GUI", p), clickType -> { - p.performCommand("trace show gui"); - })); - } inv.setItem(7, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("TRACE_GUI_DELETE", p), clickType -> { p.performCommand("trace delete"); open(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java index 04b52da9..58758114 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.StoredRecords; import de.steamwar.bausystem.features.tracer.show.TraceShowManager; +import de.steamwar.bausystem.region.Region; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import lombok.experimental.UtilityClass; @@ -38,8 +39,9 @@ import java.util.List; public class TraceGui { public static void openGui(Player player) { + Region region = Region.getRegion(player.getLocation()); List> recordList = new ArrayList<>(); - StoredRecords.getRecords().forEach(record -> { + StoredRecords.getRecords(region).forEach(record -> { if (record.getTnt().isEmpty()) { return; } @@ -49,24 +51,23 @@ public class TraceGui { SWListInv recordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, record) -> { openRecordGui(player, record); }); - recordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> { - StoredRecords.clear(); + recordSWListInv.setItem(49, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_CLEAR", player), clickType -> { + StoredRecords.clear(region); player.getOpenInventory().close(); })); - recordSWListInv.setItem(50, new SWItem(Material.GLASS, "§e" + BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_TITLE", player), clickType -> { - TraceShowGui.openGui(player); - })); recordSWListInv.open(); } public static void openRecordGui(Player player, Record record) { + Region region = Region.getRegion(player.getLocation()); List> recordList = new ArrayList<>(); record.getTnt().forEach(tntRecord -> { - SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), TraceShowManager.isIsolated(player, tntRecord), clickType -> { + SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), false, clickType -> { }); recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord)); }); SWListInv tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> { + /* if (clickType.isShiftClick()) { if (TraceShowManager.isIsolated(player, tntRecord)) { TraceShowManager.unisolate(player, tntRecord); @@ -75,18 +76,18 @@ public class TraceGui { } openRecordGui(player, record); } else { - openTntGui(player, record, tntRecord); } + */ + openTntGui(player, record, tntRecord); }); tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> { - StoredRecords.remove(record); - TraceShowManager.reshow(); + StoredRecords.remove(region, record); + TraceShowManager.reshow(region); openGui(player); })); - tntRecordSWListInv.setItem(49, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> { + tntRecordSWListInv.setItem(50, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_BACK", player), clickType -> { openGui(player); })); - // 48, 51 tntRecordSWListInv.open(); } @@ -98,7 +99,9 @@ public class TraceGui { BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_X", player, tntPosition.getLocation().getX()), BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Y", player, tntPosition.getLocation().getY()), BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_Z", player, tntPosition.getLocation().getZ()), - BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_EXPLODED", player, tntPosition.isExploded()))); + BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_SOURCE", player, tntPosition.isSource()), + BauSystem.MESSAGE.parse("TRACE_GUI_POSITION_EXPLODED", player, tntPosition.isExploded()) + )); positionList.add(new SWListInv.SWListEntry<>(swItem, tntPosition)); }); SWListInv tntPositionSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, positionList, (clickType, tntPosition) -> { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceShowGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceShowGui.java deleted file mode 100644 index 2fdc1c5a..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceShowGui.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.tracer.gui; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.TraceShowManager; -import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import lombok.experimental.UtilityClass; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -@UtilityClass -public class TraceShowGui { - - private static final Map ShowModeParameterMap = new HashMap<>(); - - public static void openGui(Player player) { - ShowModeParameter playerShowMode = new ShowModeParameter(); - playerShowMode.setInterpolate_Y(false); - playerShowMode.setInterpolate_XZ(false); - ShowModeParameterMap.put(player, playerShowMode); - - SWInventory swInventory = new SWInventory(player, 9, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_TITLE", player)); - swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player)); - setActiveShow(player, swInventory); - - SWItem water = new SWItem(Material.TNT, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_WATER_LORE2", player)), false, clickType -> { - }); - swInventory.setItem(5, water); - swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water)); - - SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_Y_LORE2", player)), false, clickType -> { - }); - swInventory.setItem(6, interpolateY); - swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY)); - - Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial(); - SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_ITEM", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE1", player), BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_INTERPOLATE_XZ_LORE2", player)), false, clickType -> { - }); - swInventory.setItem(7, interpolateXZ); - swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ)); - // Water Bucket (-water) - // TNT (-water-exploded) - // Quartz_Stair (-interpolate-y) - // Quartz_Slab (-interpolate-xz) - swInventory.open(); - } - - private static void setActiveShow(Player player, SWInventory swInventory) { - if (TraceShowManager.hasActiveShow(player)) { - Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial(); - SWItem shown = new SWItem(showMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_SHOWN", player), new ArrayList<>(), false, clickType -> { - TraceShowManager.hide(player); - BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player); - setActiveShow(player, swInventory); - }); - swInventory.setItem(1, shown); - } else { - Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial(); - SWItem hidden = new SWItem(hideMaterial, BauSystem.MESSAGE.parse("TRACE_SHOW_GUI_HIDDEN", player), new ArrayList<>(), false, clickType -> { - show(player); - BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player); - setActiveShow(player, swInventory); - }); - swInventory.setItem(1, hidden); - } - } - - private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setWater(!showModeParameter.isWater()); - show(player); - - swItem.setEnchanted(showModeParameter.isWater()); - swInventory.setItem(5, swItem); - swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem)); - } - - private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y()); - show(player); - - swItem.setEnchanted(showModeParameter.isInterpolate_Y()); - swInventory.setItem(6, swItem); - swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem)); - } - - private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) { - ShowModeParameter showModeParameter = ShowModeParameterMap.get(player); - showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ()); - show(player); - - swItem.setEnchanted(showModeParameter.isInterpolate_XZ()); - swInventory.setItem(7, swItem); - swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem)); - } - - private static void show(Player player) { - TraceShowManager.show(player, new TraceEntityShowMode(player, ShowModeParameterMap.get(player))); - } - -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/Disable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java similarity index 84% rename from BauSystem_Main/src/de/steamwar/bausystem/linkage/Disable.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java index ef3377d4..b0dfeeed 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/Disable.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,8 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.linkage; +package de.steamwar.bausystem.features.tracer.record; -public interface Disable { - void disable(); +public interface ActiveTracer { } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/Enable.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java similarity index 64% rename from BauSystem_Main/src/de/steamwar/bausystem/linkage/Enable.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java index e1c5aa5b..7e24f441 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/Enable.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,8 +17,17 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.linkage; +package de.steamwar.bausystem.features.tracer.record; -public interface Enable { - void enable(); +public class AutoExplodeTraceRecorder extends AutoTraceRecorder { + + @Override + protected String getInactivityMessage() { + return "TRACE_IDLE_AUTO_EXPLODE"; + } + + @Override + protected boolean shouldStartRecording(StartType startType) { + return startType == StartType.EXPLODE; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java new file mode 100644 index 00000000..45988d3e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java @@ -0,0 +1,33 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +public class AutoIgniteTraceRecorder extends AutoTraceRecorder implements ActiveTracer { + + @Override + protected String getInactivityMessage() { + return "TRACE_IDLE_AUTO_IGNITE"; + } + + @Override + protected boolean shouldStartRecording(StartType startType) { + return startType == StartType.IGNITE; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java new file mode 100644 index 00000000..55d43d03 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -0,0 +1,118 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.features.tracer.show.Record; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +public abstract class AutoTraceRecorder implements TraceRecorder { + + private boolean recording = false; + private long startTime = TPSUtils.currentTick.get(); + private long lastExplosion = 0; + + private final Map recordMap = new HashMap<>(); + private Record record; + private Supplier recordSupplier; + + private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { + return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime)); + } + + protected abstract String getInactivityMessage(); + protected abstract boolean shouldStartRecording(StartType startType); + + @Override + public final String scoreboard(Player player) { + if (recording) { + return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); + } else { + return BauSystem.MESSAGE.parse(getInactivityMessage(), player); + } + } + + private void startRecording() { + lastExplosion = 0; + recording = true; + startTime = TPSUtils.currentTick.get(); + record = recordSupplier.get(); + } + + @Override + public void recordSupplier(Supplier recordSupplier) { + this.recordSupplier = recordSupplier; + } + + @Override + public Record postClear() { + recordMap.clear(); + return record; + } + + @Override + public final void spawn(TNTPrimed tntPrimed) { + if (!recording && shouldStartRecording(StartType.IGNITE)) { + startRecording(); + } + if (recording) { + getRecord(tntPrimed).source(tntPrimed); + } + } + + @Override + public final void tick(TNTPrimed tntPrimed) { + if (recording) { + getRecord(tntPrimed).location(tntPrimed); + } + } + + @Override + public final void explode(TNTPrimed tntPrimed) { + if (!recording && shouldStartRecording(StartType.EXPLODE)) { + startRecording(); + } + if (recording) { + getRecord(tntPrimed).explode(tntPrimed); + } + lastExplosion = 0; + } + + @Override + public final void tick() { + lastExplosion++; + if (recording && lastExplosion > 80) { + recording = false; + recordMap.clear(); + record = null; + } + } + + protected enum StartType { + IGNITE, + EXPLODE + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStateMachine.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStateMachine.java deleted file mode 100644 index 0a22711a..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStateMachine.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.features.tracer.record; - -import lombok.experimental.UtilityClass; - -@UtilityClass -public class RecordStateMachine { - private static final TraceAutoHandler autoHandler = new TraceAutoHandler(); - - private static RecordStatus recordStatus = RecordStatus.IDLE; - private static Recorder recorder = null; - - public static void commandStart() { - autoHandler.disable(); - recordStart(); - recordStatus = RecordStatus.RECORD; - } - - public static void commandStop() { - autoHandler.disable(); - recordStop(); - recordStatus = RecordStatus.IDLE; - } - - public static void commandAuto() { - if (recordStatus.isTracing()) - return; - - if (recordStatus == RecordStatus.IDLE_AUTO) { - recordStatus = RecordStatus.IDLE; - autoHandler.disable(); - } else { - recordStatus = RecordStatus.IDLE_AUTO; - autoHandler.enable(); - } - } - - public static void commandSingle() { - if (recordStatus.isTracing()) - return; - - if (recordStatus != RecordStatus.IDLE_SINGLE) { - recordStatus = RecordStatus.IDLE_SINGLE; - autoHandler.enable(); - } - } - - static void autoRecord() { - recordStart(); - if (recordStatus == RecordStatus.IDLE_AUTO) { - recordStatus = RecordStatus.RECORD_AUTO; - } else { - recordStatus = RecordStatus.RECORD_SINGLE; - } - } - - static void autoIdle() { - recordStop(); - if (recordStatus == RecordStatus.RECORD_AUTO) { - recordStatus = RecordStatus.IDLE_AUTO; - } else { - autoHandler.disable(); - recordStatus = RecordStatus.IDLE; - } - } - - private static void recordStart() { - if (recordStatus.isTracing()) return; - recorder = new Recorder(); - } - - private static void recordStop() { - if (!recordStatus.isTracing()) return; - recorder.stopRecording(); - } - - public static RecordStatus getRecordStatus() { - return recordStatus; - } - - public static int size() { - if (recorder == null) return 0; - return recorder.size(); - } - - public static long getStartTime() { - if (recorder == null) return 0; - return recorder.getStartTime(); - } - - public static void postClear() { - if (recorder == null) return; - recorder.postClear(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java deleted file mode 100644 index 2cab4679..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.features.tracer.record; - -public enum RecordStatus { - - RECORD("TRACE_RECORD", true, "TRACE_MESSAGE_AUTO_RECORD"), - RECORD_AUTO("TRACE_RECORD_AUTO", true, "TRACE_MESSAGE_AUTO_RECORD_AUTO"), - RECORD_SINGLE("TRACE_RECORD_SINGLE", true, "TRACE_MESSAGE_AUTO_RECORD"), - IDLE("TRACE_IDLE", false, "TRACE_MESSAGE_AUTO_IDLE"), - IDLE_AUTO("TRACE_IDLE_AUTO", false, "TRACE_MESSAGE_AUTO_IDLE_AUTO"), - IDLE_SINGLE("TRACE_IDLE_SINGLE", false, "TRACE_MESSAGE_AUTO_IDLE"); - - String name; - boolean tracing; - String autoMessage; - - RecordStatus(String value, boolean tracing, String autoMessage) { - this.name = value; - this.tracing = tracing; - this.autoMessage = autoMessage; - } - - public String getName() { - return name; - } - - public boolean isTracing() { - return tracing; - } - - public boolean isAutoTrace() { - return this == RECORD_AUTO || this == IDLE_AUTO; - } - - public String getAutoMessage() { - return autoMessage; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index ca49bb9e..c61ba208 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -1,96 +1,162 @@ /* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ package de.steamwar.bausystem.features.tracer.record; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.StoredRecords; +import de.steamwar.bausystem.region.Region; +import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.scheduler.BukkitTask; +import org.bukkit.event.entity.EntitySpawnEvent; import java.util.HashMap; import java.util.Map; +import java.util.stream.Collectors; +@Linked public class Recorder implements Listener { - private static final World world = Bukkit.getWorlds().get(0); + public static Recorder INSTANCE; - private final Map recordMap = new HashMap<>(); - private final BukkitTask task; - private final Record record; - - Recorder() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1); - record = new Record(); - - // To trace TNT initial positions with AutoTracer - run(); + { + INSTANCE = this; } - void stopRecording() { - HandlerList.unregisterAll(this); - task.cancel(); + private static class NoopTraceRecorder implements TraceRecorder { + @Override + public String scoreboard(Player player) { + return null; + } + + @Override + public void spawn(TNTPrimed tntPrimed) { + } + + @Override + public void tick(TNTPrimed tntPrimed) { + } + + @Override + public void explode(TNTPrimed tntPrimed) { + } + } + private static final NoopTraceRecorder NOOP = new NoopTraceRecorder(); + + private static class DisabledTracerRecorder implements TraceRecorder { + @Override + public String scoreboard(Player player) { + return BauSystem.MESSAGE.parse("TRACE_IDLE", player); + } + + @Override + public void spawn(TNTPrimed tntPrimed) { + } + + @Override + public void tick(TNTPrimed tntPrimed) { + } + + @Override + public void explode(TNTPrimed tntPrimed) { + } + } + private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder(); + + static Recorder instance; + + { + instance = this; } - int size() { - return record.size(); + private final World world = Bukkit.getWorlds().get(0); + + private Map regionTraceRecorderMap = new HashMap<>(); + private Map tntTraceRecorderMap = new HashMap<>(); + + private TraceRecorder get(TNTPrimed tntPrimed) { + return get(tntTraceRecorderMap.computeIfAbsent(tntPrimed, e -> Region.getRegion(e.getLocation()))); } - long getStartTime() { - return record.getStartTime(); + public TraceRecorder get(Region region) { + return regionTraceRecorderMap.getOrDefault(region, region.isGlobal() ? NOOP : DISABLED); } - void postClear() { - record.clear(); - recordMap.clear(); - StoredRecords.add(record); + public void set(Region region, TraceRecorder traceRecorder) { + regionTraceRecorderMap.put(region, traceRecorder); + traceRecorder.recordSupplier(() -> { + Record record = new Record(region); + StoredRecords.add(region, record); + return record; + }); } - private void run() { - world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed)); + public void remove(Region region) { + regionTraceRecorderMap.remove(region); + } + + public void postClear(Region region) { + TraceRecorder traceRecorder = get(region); + Record record = traceRecorder.postClear(); + if (record != null) { + StoredRecords.add(region, record); + } + } + + @EventHandler + public void onEntitySpawn(EntitySpawnEvent event) { + Entity entity = event.getEntity(); + if (!(entity instanceof TNTPrimed)) { + return; + } + get((TNTPrimed) entity).spawn((TNTPrimed) entity); + } + + { + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> { + get(tntPrimed).tick(tntPrimed); + }); + tntTraceRecorderMap.keySet() + .stream() + .filter(e -> !e.isValid()) + .collect(Collectors.toList()) + .forEach(tntTraceRecorderMap::remove); + regionTraceRecorderMap.values().forEach(TraceRecorder::tick); + }, 1, 1); } @EventHandler public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) + Entity entity = event.getEntity(); + if (!(entity instanceof TNTPrimed)) { return; - TNTPrimed tntPrimed = (TNTPrimed) event.getEntity(); - - get(tntPrimed).explode(tntPrimed); - recordMap.remove(tntPrimed); - } - - private Record.TNTRecord get(TNTPrimed tntPrimed) { - Record.TNTRecord tntRecord = recordMap.get(tntPrimed); - if (tntRecord != null) - return tntRecord; - - tntRecord = this.record.spawn(); - recordMap.put(tntPrimed, tntRecord); - return tntRecord; + } + get((TNTPrimed) entity).explode((TNTPrimed) entity); + tntTraceRecorderMap.remove(entity); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java new file mode 100644 index 00000000..d4aa228e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java @@ -0,0 +1,73 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.features.tpslimit.TPSUtils; +import de.steamwar.bausystem.features.tracer.show.Record; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import java.util.HashMap; +import java.util.Map; +import java.util.function.Supplier; + +public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { + + private final long startTime = TPSUtils.currentTick.get(); + private final Map recordMap = new HashMap<>(); + private Record record; + + @Override + public String scoreboard(Player player) { + return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); + } + + @Override + public void recordSupplier(Supplier recordSupplier) { + record = recordSupplier.get(); + } + + @Override + public Record postClear() { + recordMap.clear(); + return record; + } + + private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { + return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn(TPSUtils.currentTick.get() - startTime)); + } + + @Override + public void spawn(TNTPrimed tntPrimed) { + getRecord(tntPrimed).source(tntPrimed); + } + + @Override + public void tick(TNTPrimed tntPrimed) { + getRecord(tntPrimed).location(tntPrimed); + } + + @Override + public void explode(TNTPrimed tntPrimed) { + getRecord(tntPrimed).explode(tntPrimed); + recordMap.remove(tntPrimed); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceAutoHandler.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceAutoHandler.java deleted file mode 100644 index 298dde87..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceAutoHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.bausystem.features.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import org.bukkit.Bukkit; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.scheduler.BukkitTask; - -public class TraceAutoHandler implements Listener { - /* This listener handles the en- and disabling of the Tracer in AUTO mode */ - - private BukkitTask task; - private int lastExplosion = 0; // Time since the last explosion in ticks - - public void enable() { - Bukkit.getPluginManager().registerEvents(this, BauSystem.getInstance()); - } - - public void disable() { - HandlerList.unregisterAll(this); - if (task != null) { - task.cancel(); - task = null; - } - } - - @EventHandler - public void onEntityExplode(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) - return; - - lastExplosion = 0; - if (task == null) { - RecordStateMachine.autoRecord(); - task = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), this::run, 1, 1); - } - } - - private void run() { - lastExplosion++; - - if (lastExplosion > 80) { - RecordStateMachine.autoIdle(); - if (task != null) { - task.cancel(); - task = null; - } - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java new file mode 100644 index 00000000..29340eae --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.features.tracer.show.Record; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; + +import java.util.function.Supplier; + +public interface TraceRecorder { + + String scoreboard(Player player); + default void recordSupplier(Supplier recordSupplier) { + } + default Record postClear() { + return null; + } + void spawn(TNTPrimed tntPrimed); + void tick(TNTPrimed tntPrimed); + void explode(TNTPrimed tntPrimed); + default void tick() { + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java index 8ed2061b..d4ad77f9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -1,26 +1,26 @@ /* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ package de.steamwar.bausystem.features.tracer.show; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tracer.TNTPosition; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -30,40 +30,23 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; -@Getter +@RequiredArgsConstructor public class Record { - private static long idNumber = 0; - - private final long id = idNumber++; - private final long startTime = TPSUtils.currentTick.get(); + @Getter private final List tnt = new ArrayList<>(); - - private final boolean trace; + private final Region region; public int size() { return tnt.size(); } - public void showAll(ShowMode mode) { - for (TNTRecord record : tnt) - record.showAll(mode); + public void showAll(ShowMode traceShowMode) { + tnt.forEach(tntRecord -> tntRecord.getPositions().forEach(traceShowMode::show)); } - /* The following methods should only be called by a recorder */ - public Record() { - this(true); - } - - public Record(boolean trace) { - if (trace) { - StoredRecords.add(this); - } - this.trace = trace; - } - - public TNTRecord spawn() { - TNTRecord record = new TNTRecord(trace); + public TNTRecord spawn(long offset) { + TNTRecord record = new TNTRecord(offset, region); tnt.add(record); return record; } @@ -72,46 +55,35 @@ public class Record { tnt.clear(); } - public TNTRecord get(long id) { - for (TNTRecord record : tnt) { - if (record.getId() == id) return record; - } - return null; - } - - public void remove(long id) { - tnt.removeIf(record -> record.getId() == id); - } - - @Getter - @RequiredArgsConstructor public static class TNTRecord { - private final long id = idNumber++; - private final List positions = new ArrayList<>(41); - private final boolean trace; + @Getter + private final long offset; + private final Region region; + @Getter + private final List positions = new ArrayList<>(82); - public void showAll(ShowMode mode) { - for (TNTPosition position : positions) - mode.show(position); + public TNTRecord(long offset, Region region) { + this.offset = offset; + this.region = region; } - public TNTPosition get(int fuseTicks) { - for (TNTPosition position : positions) { - if (position.getFuseTicks() == fuseTicks) return position; - } - return null; + public void source(TNTPrimed tntPrimed) { + add(tntPrimed, true, false); } - /* The following methods should only be called by a recorder */ - public void add(TNTPrimed tntPrimed) { - add(tntPrimed, false); + public void location(TNTPrimed tntPrimed) { + add(tntPrimed, false, false); } - private void add(TNTPrimed tntPrimed, boolean exploded) { + public void explode(TNTPrimed tntPrimed) { + add(tntPrimed, false, true); + } + + private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) { TNTPosition position; if (positions.isEmpty()) { - position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), exploded); + position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), source, exploded); } else { int currentSize = positions.size() + 1; TNTPosition.CachingSupplier velocitySupplier = new TNTPosition.CachingSupplier<>(() -> { @@ -125,16 +97,10 @@ public class Record { } return current; }); - position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, exploded); + position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, source, exploded); } positions.add(position); - if (trace) { - TraceShowManager.show(position); - } - } - - public void explode(TNTPrimed tntPrimed) { - add(tntPrimed, true); + TraceShowManager.show(region, position); } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java index 2663d947..99dc8392 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -1,35 +1,56 @@ /* + * This file is a part of the SteamWar software. * - * This file is a part of the SteamWar software. + * Copyright (C) 2022 SteamWar.de-Serverteam * - * Copyright (C) 2020 SteamWar.de-Serverteam + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * / + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . */ package de.steamwar.bausystem.features.tracer.show; import lombok.Getter; -import lombok.Setter; @Getter -@Setter public class ShowModeParameter { private boolean water = false; - private boolean interpolate_Y = false; - private boolean interpolate_XZ = false; + private boolean interpolateY = false; + private boolean interpolateXZ = false; + private boolean sourceOnly = false; private boolean explodeOnly = false; private boolean ticks = false; + + public void enableWater() { + this.water = true; + } + + public void enableInterpolateY() { + this.interpolateY = true; + } + + public void enableInterpolateXZ() { + this.interpolateXZ = true; + } + + public void enableSourceOnly() { + this.sourceOnly = true; + } + + public void enableExplodeOnly() { + this.explodeOnly = true; + } + + public void enableTicks() { + this.ticks = true; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java index 8fe05406..e49b9abb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2020 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -29,15 +29,16 @@ import java.util.function.Supplier; public enum ShowModeParameterType { - WATER(showModeParameter -> showModeParameter.setWater(true), Arrays.asList("-water"), "EXPLODE"), - INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true), Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"), - INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true), Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"), + WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE"), + INTERPOLATE_Y(ShowModeParameter::enableInterpolateY, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"), + INTERPOLATE_XZ(ShowModeParameter::enableInterpolateXZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"), ADVANCED(showModeParameter -> { - showModeParameter.setInterpolate_Y(true); - showModeParameter.setInterpolate_XZ(true); + showModeParameter.enableInterpolateY(); + showModeParameter.enableInterpolateXZ(); }, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"), - EXPLODE(showModeParameter -> showModeParameter.setExplodeOnly(true), Arrays.asList("-explode", "-explodeonly"), "WATER", "TICKS"), - TICKS(showModeParameter -> showModeParameter.setTicks(true), Arrays.asList("-ticks", "-t"), "EXPLODE"); + SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), + EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), + TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE"); @Getter private final Consumer showModeParameterConsumer; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index beaf1c1e..be1aab51 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -1,63 +1,63 @@ /* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ package de.steamwar.bausystem.features.tracer.show; import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.features.tracer.record.Recorder; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; -import lombok.Getter; +import lombok.experimental.UtilityClass; -import java.util.ArrayList; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; +@UtilityClass public class StoredRecords { - @Getter - private static final List records = new ArrayList<>(); + private static final Map> records = new HashMap<>(); - public static void add(Record record) { - records.add(record); + public static void add(Region region, Record record) { + records.computeIfAbsent(region, k -> new ArrayList<>()).add(record); } - public static void remove(Record record) { - records.remove(record); + public static void remove(Region region, Record record) { + records.computeIfAbsent(region, k -> new ArrayList<>()).remove(record); } - public static void remove(long id) { - records.removeIf(record -> record.getId() == id); + public static void clear(Region region) { + records.remove(region); + TraceShowManager.clear(region); + Recorder.INSTANCE.postClear(region); } - public static Record get(long id) { - for (Record record : records) { - if (record.getId() == id) return record; - } - return null; + public static List getRecords() { + return records.values().stream() + .flatMap(Collection::stream) + .collect(Collectors.toList()); } - public static void showAll(ShowMode mode) { - for (Record record : records) record.showAll(mode); + public static List getRecords(Region region) { + return records.getOrDefault(region, Collections.emptyList()); } - public static void clear() { - records.clear(); - TraceShowManager.clear(); - RecordStateMachine.postClear(); + static void show(Region region, ShowMode traceShowMode) { + records.getOrDefault(region, new ArrayList<>()).forEach(record -> record.showAll(traceShowMode)); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 01135669..2d0cac98 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -1,8 +1,27 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + package de.steamwar.bausystem.features.tracer.show; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import org.bukkit.Bukkit; import org.bukkit.entity.Entity; @@ -11,56 +30,55 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerQuitEvent; -import java.util.*; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class TraceShowManager implements Listener { private TraceShowManager() { } - private static final Map> playerIsolatedRecords = new HashMap<>(); - private static final Map> showModes = new HashMap<>(); - - public static void isolate(Player player, Record.TNTRecord tntRecord) { - playerIsolatedRecords.computeIfAbsent(player, p -> new HashSet<>()).add(tntRecord); - show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter()))); - } - - public static void unisolate(Player player, Record.TNTRecord tntRecord) { - playerIsolatedRecords.computeIfPresent(player, (player1, tntRecords) -> { - tntRecords.remove(tntRecord); - return tntRecords; - }); - show(player, showModes.getOrDefault(player, new TraceEntityShowMode(player, new ShowModeParameter()))); - } - - public static boolean isIsolated(Player player, Record.TNTRecord tntRecord) { - return playerIsolatedRecords.getOrDefault(player, Collections.emptySet()).contains(tntRecord); - } + private static final Map>> showModes = new HashMap<>(); public static void show(Player player, ShowMode traceShowMode) { - Set isolatedRecords = playerIsolatedRecords.get(player); hide(player); - showModes.put(player, traceShowMode); - if (isolatedRecords != null && !isolatedRecords.isEmpty()) { - playerIsolatedRecords.put(player, isolatedRecords); - for (Record.TNTRecord record : isolatedRecords) { - record.getPositions().forEach(traceShowMode::show); - } - } else { - StoredRecords.showAll(traceShowMode); + + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return; } + Map> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>()); + regionalShowModes.put(player, traceShowMode); + StoredRecords.show(region, traceShowMode); } public static void hide(Player player) { - playerIsolatedRecords.remove(player); - ShowMode traceShowMode = showModes.remove(player); - if (traceShowMode == null) + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { return; - traceShowMode.hide(); + } + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + ShowMode showMode = regionalShowModes.get(player); + if (showMode == null) { + return; + } + showMode.hide(); } public static List getEntities(Player player) { - ShowMode showMode = showModes.get(player); + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return Collections.emptyList(); + } + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return Collections.emptyList(); + } + ShowMode showMode = regionalShowModes.get(player); if (showMode == null) { return Collections.emptyList(); } @@ -71,7 +89,15 @@ public class TraceShowManager implements Listener { } public static TNTPosition getTNTPosition(Player player, Entity entity) { - ShowMode showMode = showModes.get(player); + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return null; + } + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return null; + } + ShowMode showMode = regionalShowModes.get(player); if (showMode == null) { return null; } @@ -81,24 +107,33 @@ public class TraceShowManager implements Listener { return null; } - public static void reshow() { - Map> current = new HashMap<>(showModes); - current.forEach(TraceShowManager::show); - } - - /* Only to be called by record */ - static void show(TNTPosition tnt) { - for (Map.Entry> entry : showModes.entrySet()) { - if (playerIsolatedRecords.containsKey(entry.getKey())) continue; - entry.getValue().show(tnt); + public static void reshow(Region region) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + for (Map.Entry> entry : regionalShowModes.entrySet()) { + entry.getValue().hide(); + StoredRecords.show(region, entry.getValue()); } } + /* Only to be called by record */ + static void show(Region region, TNTPosition tnt) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt)); + } + /* Only to be called by StoredRecords */ - static void clear() { - playerIsolatedRecords.clear(); - for (ShowMode mode : showModes.values()) - mode.hide(); + static void clear(Region region) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + regionalShowModes.values().forEach(ShowMode::hide); } /* Internal if player leaves*/ @@ -108,11 +143,14 @@ public class TraceShowManager implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { - showModes.remove(event.getPlayer()); + Region region = Region.getRegion(event.getPlayer().getLocation()); + if (region.isGlobal()) { + return; + } + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + regionalShowModes.remove(event.getPlayer()); } - - public static boolean hasActiveShow(Player player) { - return showModes.containsKey(player); - } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/BlockShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/BlockShowMode.java deleted file mode 100644 index 3cfe1f38..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/BlockShowMode.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.tracer.show.mode; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.region.Point; -import de.steamwar.bausystem.shared.ShowMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.Player; - -import java.util.HashSet; -import java.util.Set; - -public class BlockShowMode implements ShowMode { - - protected final Player player; - protected final ShowModeParameter showModeParameter; - - private Set positionSet = new HashSet<>(); - - public BlockShowMode(Player player, ShowModeParameter showModeParameter) { - this.player = player; - this.showModeParameter = showModeParameter; - } - - @Override - public void show(TNTPosition position) { - if (showModeParameter.isExplodeOnly() && !position.isExploded()) { - return; - } - Location location = position.getLocation().toLocation(player.getWorld()); - Point point = Point.fromLocation(location); - if (positionSet.contains(point)) { - return; - } - positionSet.add(point); - player.sendBlockChange(location, Material.RED_STAINED_GLASS.createBlockData()); - } - - @Override - public void hide() { - positionSet.forEach(point -> { - Location location = point.toLocation(player.getWorld()); - player.sendBlockChange(location, location.getBlock().getBlockData()); - }); - positionSet.clear(); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java index 523fc92d..1029b648 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java @@ -56,13 +56,23 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode { @Override public void show(TNTPosition position) { if (showModeParameter.isExplodeOnly()) { - if (!position.isExploded()) { + if (position.isExploded()) { + RoundedPosition roundedPosition = new RoundedPosition(position, factor); + AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true)); + tntPositionMap.put(entity.getBukkitEntity(), position); + entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1); + } + if (!showModeParameter.isSourceOnly()) { return; } - RoundedPosition roundedPosition = new RoundedPosition(position, factor); - AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true)); - tntPositionMap.put(entity.getBukkitEntity(), position); - entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1); + } + if (showModeParameter.isSourceOnly()) { + if (position.isSource()) { + RoundedPosition roundedPosition = new RoundedPosition(position, factor); + AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedPosition, pos -> createEntity(player, position.getLocation(), true)); + tntPositionMap.put(entity.getBukkitEntity(), position); + entity.display(player, position.isExploded(), showModeParameter.isTicks() ? position.getFuseTicks() : -1); + } return; } if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) { @@ -107,14 +117,14 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode { private void applyOnPosition(TNTPosition position, Consumer function) { if (position.getPreviousLocation() == null) return; - if (showModeParameter.isInterpolate_Y()) { + if (showModeParameter.isInterpolateY()) { Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY()); if (!position.getLocation().equals(updatePointY)) { function.accept(updatePointY); } } - if (showModeParameter.isInterpolate_XZ()) { + if (showModeParameter.isInterpolateXZ()) { Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ()) ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) : position.getLocation().clone().setX(position.getPreviousLocation().getX()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java deleted file mode 100644 index d897b45c..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/ParticleShowMode.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.tracer.show.mode; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.shared.ShowMode; -import de.steamwar.bausystem.utils.NMSWrapper; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitTask; -import org.bukkit.util.Vector; - -import java.util.HashSet; -import java.util.Set; - -public class ParticleShowMode implements ShowMode { - - protected final Player player; - protected final ShowModeParameter showModeParameter; - - private Set positionSet = new HashSet<>(); - - private BukkitTask bukkitTask; - - public ParticleShowMode(Player player, ShowModeParameter showModeParameter) { - this.player = player; - this.showModeParameter = showModeParameter; - } - - @Override - public void show(TNTPosition position) { - if (showModeParameter.isExplodeOnly() && !position.isExploded()) { - return; - } - if (positionSet.contains(position.getLocation())) { - return; - } - positionSet.add(position.getLocation()); - if (bukkitTask == null) { - bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - positionSet.forEach(p -> player.spawnParticle(NMSWrapper.impl.tntPositionParticle(), p.toLocation(player.getWorld()), 1, 0, 0, 0, 0)); - }, 40L, 40L); - } - } - - @Override - public void hide() { - positionSet.clear(); - if (bukkitTask != null) { - bukkitTask.cancel(); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index 23f64b97..cf44f51f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -21,13 +21,15 @@ package de.steamwar.bausystem.features.warp; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.Disable; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.bausystem.worlddata.WorldData; -import de.steamwar.command.*; -import de.steamwar.linkage.LinkageType; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Disable; +import de.steamwar.linkage.api.Enable; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ComponentBuilder; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index c3950cab..d44a3cb0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -4,14 +4,14 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.tpslimit.FreezeUtils; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; -import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.core.TPSWatcher; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.LinkedInstance; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; import org.bukkit.entity.Player; @@ -28,6 +28,9 @@ import java.util.List; @Linked public class BauScoreboard implements Listener { + @LinkedInstance + public Recorder recorder; + @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); @@ -74,12 +77,10 @@ public class BauScoreboard implements Listener { } strings.add("§3"); - StringBuilder st = new StringBuilder(); - st.append(colorCode).append(BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p)).append("§8: ").append(BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p)); - if (RecordStateMachine.getRecordStatus().isTracing()) { - st.append(" §8| §e").append(traceTicks()).append(" §7").append(BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p)); + String traceScore = recorder.get(region).scoreboard(p); + if (traceScore != null) { + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + traceScore); } - strings.add(st.toString()); Loader loader = Loader.getLoader(p); strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p)); @@ -99,10 +100,6 @@ public class BauScoreboard implements Listener { return result; } - private long traceTicks() { - return TPSUtils.currentTick.get() - RecordStateMachine.getStartTime(); - } - private String tpsColor() { double tps = TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND); if (tps > TPSLimitUtils.getCurrentTPSLimit() * 0.9) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java index c1dd3db0..c3def14b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/ReducedDebugInfo.java @@ -19,8 +19,8 @@ package de.steamwar.bausystem.features.world; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Enable; import org.bukkit.Bukkit; import org.bukkit.GameRule; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java index ded7480d..44b57332 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/BackupScheduler.java @@ -20,9 +20,9 @@ package de.steamwar.bausystem.region; import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.Enable; import de.steamwar.bausystem.region.tags.Tag; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.api.Enable; import org.bukkit.scheduler.BukkitRunnable; import java.util.Iterator; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java index 24fe02f6..c3062009 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/utils/NMSWrapper.java @@ -48,7 +48,6 @@ public interface NMSWrapper { void setGameStateChangeReason(Object packet); void setPlayerBuildAbilities(Player player); - Particle tntPositionParticle(); Material pathMaterial(); boolean checkItemStack(ItemStack item); From ad8cd863388ba27d5c825dd8df692398d84874de Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 17:22:45 +0200 Subject: [PATCH 15/33] Add SingleTraceRecorder Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 1 + BauSystem_Main/src/BauSystem_de.properties | 1 + .../features/simulator/TNTSimulator.java | 4 +- .../features/tracer/TraceCommand.java | 12 +++-- .../tracer/record/AutoTraceRecorder.java | 3 ++ .../tracer/record/SingleTraceRecorder.java | 46 +++++++++++++++++++ 6 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 34c1d0db..d7574fa7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -682,6 +682,7 @@ TPSLIMIT_INVALID_FROZEN = §c and '0' # Trace TRACE_RECORD=§aon TRACE_IDLE=§coff +TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode started diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index d9804ad9..b9373877 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -662,6 +662,7 @@ TPSLIMIT_INVALID_FROZEN = §c und '0' # Trace TRACE_RECORD=§aan TRACE_IDLE=§caus +TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode gestartet diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index 045fb75b..4a92058a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -27,8 +27,8 @@ import de.steamwar.bausystem.features.simulator.show.SimulatorEntityShowMode; import de.steamwar.bausystem.features.simulator.tnt.SimulatorElement; import de.steamwar.bausystem.features.simulator.tnt.TNTElement; import de.steamwar.bausystem.features.simulator.tnt.TNTGroup; -import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; import de.steamwar.bausystem.features.tracer.record.Recorder; +import de.steamwar.bausystem.features.tracer.record.SingleTraceRecorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.Pair; import lombok.Getter; @@ -238,7 +238,7 @@ public class TNTSimulator { } }); if (needsAutoTrace.get()) { - Recorder.INSTANCE.set(region, new AutoExplodeTraceRecorder()); + Recorder.INSTANCE.set(region, new SingleTraceRecorder(region)); } AtomicInteger maxTick = new AtomicInteger(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 6278649d..bc6f5abf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -22,10 +22,7 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.gui.TraceGui; -import de.steamwar.bausystem.features.tracer.record.AutoExplodeTraceRecorder; -import de.steamwar.bausystem.features.tracer.record.AutoIgniteTraceRecorder; -import de.steamwar.bausystem.features.tracer.record.Recorder; -import de.steamwar.bausystem.features.tracer.record.SimpleTraceRecorder; +import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; import de.steamwar.bausystem.features.tracer.show.StoredRecords; @@ -65,6 +62,13 @@ public class TraceCommand extends SWCommand { BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); } + @Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE") + public void singleCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + recorder.set(region, new SingleTraceRecorder(region)); + BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p); + } + @Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP") public void stopCommand(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 55d43d03..4d43a30e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -45,6 +45,8 @@ public abstract class AutoTraceRecorder implements TraceRecorder { protected abstract String getInactivityMessage(); protected abstract boolean shouldStartRecording(StartType startType); + protected void stoppedRecording() { + } @Override public final String scoreboard(Player player) { @@ -108,6 +110,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { recording = false; recordMap.clear(); record = null; + stoppedRecording(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java new file mode 100644 index 00000000..6df0716f --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java @@ -0,0 +1,46 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.region.Region; + +public class SingleTraceRecorder extends AutoTraceRecorder { + + private Region region; + + public SingleTraceRecorder(Region region) { + this.region = region; + } + + @Override + protected String getInactivityMessage() { + return "TRACE_IDLE_SINGLE"; + } + + @Override + protected boolean shouldStartRecording(StartType startType) { + return startType == StartType.EXPLODE; + } + + @Override + protected void stoppedRecording() { + Recorder.INSTANCE.remove(region); + } +} From f438b4aa778c79291acc2d2b9b0d1b42a90bb5b6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 18:06:26 +0200 Subject: [PATCH 16/33] Add TraceCommand.isolate Signed-off-by: yoyosource --- .../features/tracer/TraceCommand.java | 14 ++++++ .../tracer/TraceTNTClickListener.java | 3 +- .../features/tracer/gui/TraceGui.java | 12 ++--- .../features/tracer/show/Record.java | 7 +++ .../features/tracer/show/StoredRecords.java | 50 ++++++++++++++++++- .../tracer/show/TraceShowManager.java | 17 ++++++- 6 files changed, 89 insertions(+), 14 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index bc6f5abf..bf385f06 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.gui.TraceGui; import de.steamwar.bausystem.features.tracer.record.*; +import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; import de.steamwar.bausystem.features.tracer.show.StoredRecords; @@ -107,6 +108,7 @@ public class TraceCommand extends SWCommand { @Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE") public void hideCommand(@Validator Player p) { TraceShowManager.hide(p); + StoredRecords.hideIsolated(Region.getRegion(p.getLocation()), p); BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); } @@ -115,6 +117,7 @@ public class TraceCommand extends SWCommand { public void deleteCommand(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); StoredRecords.clear(region); + StoredRecords.hideIsolated(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); } @@ -123,6 +126,17 @@ public class TraceCommand extends SWCommand { TraceGui.openGui(p); } + @Register(value = "isolate", noTabComplete = true) + public void isolate(Player p, String s) { + try { + UUID uuid = UUID.fromString(s); + Record.TNTRecord tntRecord = StoredRecords.getRecord(uuid); + StoredRecords.toggleIsolate(p, tntRecord); + } catch (Exception e) { + // Ignore + } + } + @AllArgsConstructor private enum ShowModeType { ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java index 9938565b..5974d50e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceTNTClickListener.java @@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.tracer.show.TraceShowManager; import de.steamwar.bausystem.utils.RayTraceUtils; import de.steamwar.linkage.Linked; import de.steamwar.linkage.api.Plain; +import net.md_5.bungee.api.chat.ClickEvent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.util.RayTraceResult; @@ -58,7 +59,7 @@ public class TraceTNTClickListener implements Plain { BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, tntPosition.getVelocity().getY() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + ""); - // BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); + BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); }, 1); Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { playerSet.remove(player); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java index 58758114..fc4500af 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/gui/TraceGui.java @@ -62,23 +62,17 @@ public class TraceGui { Region region = Region.getRegion(player.getLocation()); List> recordList = new ArrayList<>(); record.getTnt().forEach(tntRecord -> { - SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), false, clickType -> { + SWItem swItem = new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_ITEM", player, tntRecord.getPositions().size()), new ArrayList<>(), StoredRecords.isIsolated(player, tntRecord), clickType -> { }); recordList.add(new SWListInv.SWListEntry<>(swItem, tntRecord)); }); SWListInv tntRecordSWListInv = new SWListInv<>(player, BauSystem.MESSAGE.parse("TRACE_GUI_TITLE", player), false, recordList, (clickType, tntRecord) -> { - /* if (clickType.isShiftClick()) { - if (TraceShowManager.isIsolated(player, tntRecord)) { - TraceShowManager.unisolate(player, tntRecord); - } else { - TraceShowManager.isolate(player, tntRecord); - } + StoredRecords.toggleIsolate(player, tntRecord); openRecordGui(player, record); } else { + openTntGui(player, record, tntRecord); } - */ - openTntGui(player, record, tntRecord); }); tntRecordSWListInv.setItem(48, new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("TRACE_GUI_RECORD_CLEAR", player), clickType -> { StoredRecords.remove(region, record); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java index d4ad77f9..13a8e0af 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -29,6 +29,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.UUID; @RequiredArgsConstructor public class Record { @@ -57,9 +58,15 @@ public class Record { public static class TNTRecord { + @Getter + private final UUID id = UUID.randomUUID(); + @Getter private final long offset; + + @Getter private final Region region; + @Getter private final List positions = new ArrayList<>(82); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index be1aab51..f56acb7b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import lombok.experimental.UtilityClass; +import org.bukkit.entity.Player; import java.util.*; import java.util.stream.Collectors; @@ -31,6 +32,7 @@ import java.util.stream.Collectors; @UtilityClass public class StoredRecords { + private static final Map>> isolatedTNT = new HashMap<>(); private static final Map> records = new HashMap<>(); public static void add(Region region, Record record) { @@ -57,7 +59,51 @@ public class StoredRecords { return records.getOrDefault(region, Collections.emptyList()); } - static void show(Region region, ShowMode traceShowMode) { - records.getOrDefault(region, new ArrayList<>()).forEach(record -> record.showAll(traceShowMode)); + public Record.TNTRecord getRecord(UUID id) { + return records.values().stream() + .flatMap(Collection::stream) + .map(Record::getTnt) + .flatMap(Collection::stream) + .filter(tntRecord -> tntRecord.getId().equals(id)) + .findFirst() + .orElse(null); + } + + public static boolean isIsolated(Player p, Record.TNTRecord tntRecord) { + return isolatedTNT.values() + .stream() + .filter(map -> map.containsKey(p)) + .anyMatch(map -> map.get(p).contains(tntRecord)); + } + + public static void toggleIsolate(Player p, Record.TNTRecord tntRecord) { + List tntRecords = isolatedTNT.computeIfAbsent(tntRecord.getRegion(), k -> new HashMap<>()) + .computeIfAbsent(p, k -> new ArrayList<>()); + if (tntRecords.contains(tntRecord)) { + tntRecords.remove(tntRecord); + } else { + tntRecords.add(tntRecord); + } + TraceShowManager.reshow(tntRecord.getRegion(), p); + } + + public static void hideIsolated(Region region) { + isolatedTNT.remove(region); + } + + public static void hideIsolated(Region region, Player player) { + Map> regionalIsolatedTNT = isolatedTNT.get(region); + if (regionalIsolatedTNT == null) { + return; + } + regionalIsolatedTNT.remove(player); + } + + static void show(Region region, Player player, ShowMode traceShowMode) { + if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) { + isolatedTNT.get(region).get(player).forEach(record -> record.getPositions().forEach(traceShowMode::show)); + } else { + records.getOrDefault(region, new ArrayList<>()).forEach(record -> record.showAll(traceShowMode)); + } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 2d0cac98..0de6aaba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -50,7 +50,7 @@ public class TraceShowManager implements Listener { } Map> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>()); regionalShowModes.put(player, traceShowMode); - StoredRecords.show(region, traceShowMode); + StoredRecords.show(region, player, traceShowMode); } public static void hide(Player player) { @@ -107,6 +107,19 @@ public class TraceShowManager implements Listener { return null; } + public static void reshow(Region region, Player p) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes == null) { + return; + } + ShowMode showMode = regionalShowModes.get(p); + if (showMode == null) { + return; + } + showMode.hide(); + StoredRecords.show(region, p, showMode); + } + public static void reshow(Region region) { Map> regionalShowModes = showModes.get(region); if (regionalShowModes == null) { @@ -114,7 +127,7 @@ public class TraceShowManager implements Listener { } for (Map.Entry> entry : regionalShowModes.entrySet()) { entry.getValue().hide(); - StoredRecords.show(region, entry.getValue()); + StoredRecords.show(region, entry.getKey(), entry.getValue()); } } From e894ed08f655ba8d78608e18725a7a9c2545461a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 18:58:40 +0200 Subject: [PATCH 17/33] Add simple Trace replay Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 4 ++ BauSystem_Main/src/BauSystem_de.properties | 4 ++ .../features/tracer/TraceCommand.java | 38 ++++++++++++-- .../features/tracer/show/StoredRecords.java | 49 ++++++++++++++++++- .../tracer/show/TraceShowManager.java | 1 + 5 files changed, 89 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index d7574fa7..84378b95 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -707,6 +707,10 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Hides all TNT-positions TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI +TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replays your recording +TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stops the replay +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Jump one tick forward +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Jump one tick back TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index b9373877..b7b50a7a 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -687,6 +687,10 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Versteckt alle TNT-Positionen TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an +TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8- §7Replayes die Aufnahme +TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stoppt das Replay +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8- §7Springe ein Tick vor +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8- §7Springe ein Tick zurück TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index bf385f06..564f7cc7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -24,10 +24,7 @@ import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.gui.TraceGui; import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameter; -import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType; -import de.steamwar.bausystem.features.tracer.show.StoredRecords; -import de.steamwar.bausystem.features.tracer.show.TraceShowManager; +import de.steamwar.bausystem.features.tracer.show.*; import de.steamwar.bausystem.features.tracer.show.mode.RawEntityShowMode; import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode; import de.steamwar.bausystem.region.Region; @@ -108,7 +105,9 @@ public class TraceCommand extends SWCommand { @Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE") public void hideCommand(@Validator Player p) { TraceShowManager.hide(p); - StoredRecords.hideIsolated(Region.getRegion(p.getLocation()), p); + Region region = Region.getRegion(p.getLocation()); + StoredRecords.hideIsolated(region, p); + StoredRecords.removeReplayTime(region, p); BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); } @@ -118,6 +117,7 @@ public class TraceCommand extends SWCommand { Region region = Region.getRegion(p.getLocation()); StoredRecords.clear(region); StoredRecords.hideIsolated(region); + StoredRecords.removeReplayTime(region); BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); } @@ -137,6 +137,34 @@ public class TraceCommand extends SWCommand { } } + @Register(value = "replay", description = "TRACE_COMMAND_HELP_REPLAY") + public void replay(@Validator Player p, @OptionalValue("0") int replayTick) { + Region region = Region.getRegion(p.getLocation()); + if (replayTick < 0) replayTick = 0; + StoredRecords.setReplayTime(region, p, replayTick); + } + + @Register(value = {"replay", "disable"}, description = "TRACE_COMMAND_HELP_REPLAY_DISABLE") + public void replayDisable(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + StoredRecords.removeReplayTime(region, p); + } + + @Register(value = {"replay", "next"}, description = "TRACE_COMMAND_HELP_REPLAY_NEXT") + public void replayNext(@Validator Player p, @OptionalValue("1") int step) { + Region region = Region.getRegion(p.getLocation()); + int replayTick = StoredRecords.getReplayTime(region, p); + StoredRecords.setReplayTime(region, p, replayTick + step); + } + + @Register(value = {"replay", "previous"}, description = "TRACE_COMMAND_HELP_REPLAY_PREVIOUS") + public void replayPrevious(@Validator Player p, @OptionalValue("1") int step) { + Region region = Region.getRegion(p.getLocation()); + int replayTick = StoredRecords.getReplayTime(region, p) - step; + if (replayTick < 0) replayTick = 0; + StoredRecords.setReplayTime(region, p, replayTick); + } + @AllArgsConstructor private enum ShowModeType { ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index f56acb7b..ba087107 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -27,12 +27,14 @@ import lombok.experimental.UtilityClass; import org.bukkit.entity.Player; import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; @UtilityClass public class StoredRecords { private static final Map>> isolatedTNT = new HashMap<>(); + private static final Map> replayTime = new HashMap<>(); private static final Map> records = new HashMap<>(); public static void add(Region region, Record record) { @@ -99,11 +101,54 @@ public class StoredRecords { regionalIsolatedTNT.remove(player); } + public static int getReplayTime(Region region, Player player) { + return replayTime.computeIfAbsent(region, k -> new HashMap<>()).getOrDefault(player, -1); + } + + public static void removeReplayTime(Region region) { + replayTime.remove(region); + } + + public static void removeReplayTime(Region region, Player player) { + Map regionalReplayTime = replayTime.get(region); + if (regionalReplayTime == null) { + return; + } + regionalReplayTime.remove(player); + } + + public static void setReplayTime(Region region, Player player, int time) { + if (time < 0) { + removeReplayTime(region, player); + return; + } + replayTime.computeIfAbsent(region, k -> new HashMap<>()).put(player, time); + TraceShowManager.reshow(region, player); + } + static void show(Region region, Player player, ShowMode traceShowMode) { + Predicate replayTimeFilter = tntPosition -> true; + if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) { + int time = replayTime.get(region).get(player); + replayTimeFilter = tntPosition -> (80 - tntPosition.getFuseTicks()) + tntPosition.getRecord().getOffset() == time; + } + Predicate finalReplayTimeFilter = replayTimeFilter; if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) { - isolatedTNT.get(region).get(player).forEach(record -> record.getPositions().forEach(traceShowMode::show)); + isolatedTNT.get(region).get(player).forEach(record -> { + record.getPositions() + .stream() + .filter(finalReplayTimeFilter) + .forEach(traceShowMode::show); + }); } else { - records.getOrDefault(region, new ArrayList<>()).forEach(record -> record.showAll(traceShowMode)); + records.getOrDefault(region, new ArrayList<>()).forEach(record -> { + record.getTnt().forEach(tntRecord -> { + tntRecord.getPositions() + .stream() + .filter(finalReplayTimeFilter) + .forEach(traceShowMode::show); + }); + }); } } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index 0de6aaba..fa7306cd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -137,6 +137,7 @@ public class TraceShowManager implements Listener { if (regionalShowModes == null) { return; } + // TODO: Fix show with replay regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt)); } From b0690d28d32aeb07a364f7c0b2026cc74a666218 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 19:03:21 +0200 Subject: [PATCH 18/33] Update messages Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 4 ++-- BauSystem_Main/src/BauSystem_de.properties | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 84378b95..fb2d1386 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -709,8 +709,8 @@ TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-position TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replays your recording TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stops the replay -TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Jump one tick forward -TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Jump one tick back +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Jump one§8/§7step tick forward +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Jump one§8/§7step tick back TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index b7b50a7a..62d5742a 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -689,8 +689,8 @@ TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positio TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8- §7Replayes die Aufnahme TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stoppt das Replay -TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8- §7Springe ein Tick vor -TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8- §7Springe ein Tick zurück +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8- §7Springe einen§8/§7step Tick vor +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8- §7Springe einen§8/§7step Tick zurück TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} From 5e9b11d140a66cf9214e57505de2c8c53123a849 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 21:05:18 +0200 Subject: [PATCH 19/33] Add trace replay loop Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 7 ++-- BauSystem_Main/src/BauSystem_de.properties | 7 ++-- .../features/tracer/TraceCommand.java | 42 +++++++++++++++++++ .../features/tracer/show/StoredRecords.java | 35 ++++++++++++++-- 4 files changed, 82 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index fb2d1386..19b53de7 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -707,10 +707,11 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Shows all TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Hides all TNT-positions TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Deletes all TNT-positions TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Shows the Trace GUI -TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replays your recording +TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7tick§8] §8- §7Replays your recording TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stops the replay -TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Jump one§8/§7step tick forward -TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Jump one§8/§7step tick back +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7step§8] §8- §7Jump one§8/§7step tick forward +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7step§8] §8- §7Jump one§8/§7step tick back +TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Loop the replay TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 62d5742a..4936643e 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -687,10 +687,11 @@ TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8<§eParameter§8> - §7Zeigt alle TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Versteckt alle TNT-Positionen TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an -TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8- §7Replayes die Aufnahme +TRACE_COMMAND_HELP_REPLAY = §8/§etrace replay §8[§7Tick§8] §8- §7Replayes die Aufnahme TRACE_COMMAND_HELP_REPLAY_DISABLE = §8/§etrace replay disable §8- §7Stoppt das Replay -TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8- §7Springe einen§8/§7step Tick vor -TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8- §7Springe einen§8/§7step Tick zurück +TRACE_COMMAND_HELP_REPLAY_NEXT = §8/§etrace replay next §8[§7Step§8] §8- §7Springe einen§8/§7step Tick vor +TRACE_COMMAND_HELP_REPLAY_PREVIOUS = §8/§etrace replay previous §8[§7Step§8] §8- §7Springe einen§8/§7step Tick zurück +TRACE_COMMAND_HELP_REPLAY_LOOP = §8/§etrace replay loop §8<§7start§8> §8<§7end§8> §8[§7speed§8] §8- §7Spielt die Aufnahme in einer Schleife ab TRACE_GUI_ITEM_NAME = §eTracer TRACE_GUI_ITEM_LORE = §7Status§8: {0} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 564f7cc7..ced48fde 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -165,6 +165,48 @@ public class TraceCommand extends SWCommand { StoredRecords.setReplayTime(region, p, replayTick); } + @Register(value = {"replay", "loop"}, description = "TRACE_COMMAND_HELP_REPLAY_LOOP") + public void replayLoop(@Validator Player p, int start, int end, @OptionalValue("0") int speed) { + Region region = Region.getRegion(p.getLocation()); + + if (start < 0) start = 0; + if (end < 0) end = 0; + + int initial = StoredRecords.getReplayTime(region, p); + if (!(Math.min(start, end) < initial && Math.max(start, end) > initial)) { + initial = start; + } + int finalInitial = initial; + + int finalStart = start; + int finalEnd = end; + Supplier supplier = new Supplier() { + int temp = speed; + int current = finalInitial; + + @Override + public Integer get() { + if (temp-- > 0) { + return current; + } + temp = speed; + if (finalEnd > finalStart) { + current++; + if (current > finalEnd) { + current = finalStart; + } + } else { + current--; + if (current < finalEnd) { + current = finalStart; + } + } + return current; + } + }; + StoredRecords.setReplayLoop(region, p, supplier); + } + @AllArgsConstructor private enum ShowModeType { ENTITY(TraceEntityShowMode::new, new ShowModeParameterType[]{}), diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index ba087107..43e563d8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -19,15 +19,18 @@ package de.steamwar.bausystem.features.tracer.show; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import lombok.experimental.UtilityClass; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import java.util.*; import java.util.function.Predicate; +import java.util.function.Supplier; import java.util.stream.Collectors; @UtilityClass @@ -35,8 +38,21 @@ public class StoredRecords { private static final Map>> isolatedTNT = new HashMap<>(); private static final Map> replayTime = new HashMap<>(); + private static final Map>> replayLoops = new HashMap<>(); private static final Map> records = new HashMap<>(); + static { + Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { + replayLoops.forEach((region, playerSupplierMap) -> { + playerSupplierMap.forEach((player, integerSupplier) -> { + int tick = integerSupplier.get(); + replayTime.computeIfAbsent(region, __ -> new HashMap<>()).put(player, tick); + TraceShowManager.reshow(region, player); + }); + }); + }, 1, 1); + } + public static void add(Region region, Record record) { records.computeIfAbsent(region, k -> new ArrayList<>()).add(record); } @@ -107,14 +123,18 @@ public class StoredRecords { public static void removeReplayTime(Region region) { replayTime.remove(region); + replayLoops.remove(region); } public static void removeReplayTime(Region region, Player player) { Map regionalReplayTime = replayTime.get(region); - if (regionalReplayTime == null) { - return; + if (regionalReplayTime != null) { + regionalReplayTime.remove(player); + } + Map> regionalReplayLoops = replayLoops.get(region); + if (regionalReplayLoops != null) { + regionalReplayLoops.remove(player); } - regionalReplayTime.remove(player); } public static void setReplayTime(Region region, Player player, int time) { @@ -124,6 +144,15 @@ public class StoredRecords { } replayTime.computeIfAbsent(region, k -> new HashMap<>()).put(player, time); TraceShowManager.reshow(region, player); + + Map> regionalReplayLoops = replayLoops.get(region); + if (regionalReplayLoops != null) { + regionalReplayLoops.remove(player); + } + } + + public static void setReplayLoop(Region region, Player player, Supplier loop) { + replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop); } static void show(Region region, Player player, ShowMode traceShowMode) { From 31f04ef07b8087db7a2139c4430c3351600d737a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 21:24:23 +0200 Subject: [PATCH 20/33] Add trace ShowModeParameterType.BUILD_DESTROY_ONLY Signed-off-by: yoyosource --- .../features/tracer/record/AutoTraceRecorder.java | 6 ++++-- .../bausystem/features/tracer/record/Recorder.java | 10 +++++++--- .../features/tracer/record/SimpleTraceRecorder.java | 6 ++++-- .../features/tracer/record/TraceRecorder.java | 2 +- .../bausystem/features/tracer/show/Record.java | 5 +++++ .../features/tracer/show/ShowModeParameter.java | 5 +++++ .../features/tracer/show/ShowModeParameterType.java | 5 +++-- .../features/tracer/show/StoredRecords.java | 12 ++++++++---- .../features/tracer/show/TraceShowManager.java | 7 +++++-- .../tracer/show/mode/FactoredEntityShowMode.java | 3 +++ 10 files changed, 45 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 4d43a30e..c8e66bac 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -93,12 +93,14 @@ public abstract class AutoTraceRecorder implements TraceRecorder { } @Override - public final void explode(TNTPrimed tntPrimed) { + public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { if (!recording && shouldStartRecording(StartType.EXPLODE)) { startRecording(); } if (recording) { - getRecord(tntPrimed).explode(tntPrimed); + Record.TNTRecord tntRecord = getRecord(tntPrimed); + if (inBuildRegion) tntRecord.setInBuildArea(true); + tntRecord.explode(tntPrimed); } lastExplosion = 0; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index c61ba208..2942483b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -23,6 +23,8 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.features.tracer.show.StoredRecords; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.linkage.Linked; import org.bukkit.Bukkit; import org.bukkit.World; @@ -62,7 +64,7 @@ public class Recorder implements Listener { } @Override - public void explode(TNTPrimed tntPrimed) { + public void explode(TNTPrimed tntPrimed, boolean b) { } } private static final NoopTraceRecorder NOOP = new NoopTraceRecorder(); @@ -82,7 +84,7 @@ public class Recorder implements Listener { } @Override - public void explode(TNTPrimed tntPrimed) { + public void explode(TNTPrimed tntPrimed, boolean b) { } } private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder(); @@ -156,7 +158,9 @@ public class Recorder implements Listener { if (!(entity instanceof TNTPrimed)) { return; } - get((TNTPrimed) entity).explode((TNTPrimed) entity); + TraceRecorder traceRecorder = get((TNTPrimed) entity); + Region region = tntTraceRecorderMap.get((TNTPrimed) entity); + traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); tntTraceRecorderMap.remove(entity); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java index d4aa228e..edd6dd48 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java @@ -66,8 +66,10 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { } @Override - public void explode(TNTPrimed tntPrimed) { - getRecord(tntPrimed).explode(tntPrimed); + public void explode(TNTPrimed tntPrimed, boolean inBuildRegion) { + Record.TNTRecord tntRecord = getRecord(tntPrimed); + if (inBuildRegion) tntRecord.setInBuildArea(true); + tntRecord.explode(tntPrimed); recordMap.remove(tntPrimed); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java index 29340eae..f89562ef 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java @@ -35,7 +35,7 @@ public interface TraceRecorder { } void spawn(TNTPrimed tntPrimed); void tick(TNTPrimed tntPrimed); - void explode(TNTPrimed tntPrimed); + void explode(TNTPrimed tntPrimed, boolean inBuildRegion); default void tick() { } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java index 13a8e0af..71b19f1d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -24,6 +24,7 @@ import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; import lombok.Getter; import lombok.RequiredArgsConstructor; +import lombok.Setter; import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; @@ -70,6 +71,10 @@ public class Record { @Getter private final List positions = new ArrayList<>(82); + @Getter + @Setter + private boolean inBuildArea = false; + public TNTRecord(long offset, Region region) { this.offset = offset; this.region = region; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java index 99dc8392..100e58c3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -29,6 +29,7 @@ public class ShowModeParameter { private boolean sourceOnly = false; private boolean explodeOnly = false; private boolean ticks = false; + private boolean buildDestroyOnly = false; public void enableWater() { this.water = true; @@ -53,4 +54,8 @@ public class ShowModeParameter { public void enableTicks() { this.ticks = true; } + + public void enableBuildDestroyOnly() { + this.buildDestroyOnly = true; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java index e49b9abb..5f4bcb46 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java @@ -29,7 +29,7 @@ import java.util.function.Supplier; public enum ShowModeParameterType { - WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE"), + WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE", "BUILD_DESTROY_ONLY"), INTERPOLATE_Y(ShowModeParameter::enableInterpolateY, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"), INTERPOLATE_XZ(ShowModeParameter::enableInterpolateXZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"), ADVANCED(showModeParameter -> { @@ -38,7 +38,8 @@ public enum ShowModeParameterType { }, Arrays.asList("-advanced", "-a", "advanced"), "INTERPOLATE_Y", "INTERPOLATE_XZ"), SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "TICKS", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), - TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE"); + TICKS(ShowModeParameter::enableTicks, Arrays.asList("-ticks", "-t"), "EXPLODE", "SOURCE"), + BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER"); @Getter private final Consumer showModeParameterConsumer; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index 43e563d8..ef0a449b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -155,18 +155,22 @@ public class StoredRecords { replayLoops.computeIfAbsent(region, k -> new HashMap<>()).put(player, loop); } - static void show(Region region, Player player, ShowMode traceShowMode) { + static Predicate replayTimeFilter(Region region, Player player) { Predicate replayTimeFilter = tntPosition -> true; if (replayTime.containsKey(region) && replayTime.get(region).containsKey(player)) { int time = replayTime.get(region).get(player); replayTimeFilter = tntPosition -> (80 - tntPosition.getFuseTicks()) + tntPosition.getRecord().getOffset() == time; } - Predicate finalReplayTimeFilter = replayTimeFilter; + return replayTimeFilter; + } + + static void show(Region region, Player player, ShowMode traceShowMode) { + Predicate replayTimeFilter = replayTimeFilter(region, player); if (isolatedTNT.containsKey(region) && isolatedTNT.get(region).containsKey(player)) { isolatedTNT.get(region).get(player).forEach(record -> { record.getPositions() .stream() - .filter(finalReplayTimeFilter) + .filter(replayTimeFilter) .forEach(traceShowMode::show); }); } else { @@ -174,7 +178,7 @@ public class StoredRecords { record.getTnt().forEach(tntRecord -> { tntRecord.getPositions() .stream() - .filter(finalReplayTimeFilter) + .filter(replayTimeFilter) .forEach(traceShowMode::show); }); }); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index fa7306cd..d04ee169 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -34,6 +34,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; public class TraceShowManager implements Listener { private TraceShowManager() { @@ -137,8 +138,10 @@ public class TraceShowManager implements Listener { if (regionalShowModes == null) { return; } - // TODO: Fix show with replay - regionalShowModes.values().forEach(tntPositionShowMode -> tntPositionShowMode.show(tnt)); + regionalShowModes.forEach((player, tntPositionShowMode) -> { + Predicate replayTimeFilter = StoredRecords.replayTimeFilter(region, player); + if (replayTimeFilter.test(tnt)) tntPositionShowMode.show(tnt); + }); } /* Only to be called by StoredRecords */ diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java index 1029b648..93dbaa0c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java @@ -55,6 +55,9 @@ public abstract class FactoredEntityShowMode implements EntityTraceShowMode { @Override public void show(TNTPosition position) { + if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) { + return; + } if (showModeParameter.isExplodeOnly()) { if (position.isExploded()) { RoundedPosition roundedPosition = new RoundedPosition(position, factor); From 7c79b47d6170bdcc031e8c48b1e80365c00fa563 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 21:38:05 +0200 Subject: [PATCH 21/33] Hotfix memory leak Signed-off-by: yoyosource --- .../features/tracer/show/StoredRecords.java | 6 ++++++ .../features/tracer/show/TraceShowManager.java | 13 ++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index ef0a449b..16601bdf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -53,6 +53,12 @@ public class StoredRecords { }, 1, 1); } + static void cleanup(Player player) { + isolatedTNT.forEach((region, playerListMap) -> playerListMap.remove(player)); + replayTime.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player)); + replayLoops.forEach((region, playerIntegerMap) -> playerIntegerMap.remove(player)); + } + public static void add(Region region, Record record) { records.computeIfAbsent(region, k -> new ArrayList<>()).add(record); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java index d04ee169..565db661 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java @@ -161,13 +161,12 @@ public class TraceShowManager implements Listener { @EventHandler public void onLeave(PlayerQuitEvent event) { Region region = Region.getRegion(event.getPlayer().getLocation()); - if (region.isGlobal()) { - return; + if (!region.isGlobal()) { + Map> regionalShowModes = showModes.get(region); + if (regionalShowModes != null) { + regionalShowModes.remove(event.getPlayer()); + } } - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - regionalShowModes.remove(event.getPlayer()); + StoredRecords.cleanup(event.getPlayer()); } } From 95af58e60edb550710a7413e57b1435495a2ccf1 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 3 Oct 2022 21:45:59 +0200 Subject: [PATCH 22/33] Hotfix isolated tnt Signed-off-by: yoyosource --- .../bausystem/features/tracer/show/StoredRecords.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java index 16601bdf..ce90aad7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java @@ -105,6 +105,12 @@ public class StoredRecords { .computeIfAbsent(p, k -> new ArrayList<>()); if (tntRecords.contains(tntRecord)) { tntRecords.remove(tntRecord); + if (tntRecords.isEmpty()) { + isolatedTNT.get(tntRecord.getRegion()).remove(p); + if (isolatedTNT.get(tntRecord.getRegion()).isEmpty()) { + isolatedTNT.remove(tntRecord.getRegion()); + } + } } else { tntRecords.add(tntRecord); } From 2b4cd8731d414d7f31ac3ad2aff5179de67939ee Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 4 Oct 2022 15:50:21 +0200 Subject: [PATCH 23/33] =?UTF-8?q?=E2=80=9EBauSystem=5FMain/src/de/steamwar?= =?UTF-8?q?/bausystem/features/tracer/record/Recorder.java=E2=80=9C=20?= =?UTF-8?q?=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../de/steamwar/bausystem/features/tracer/record/Recorder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 2942483b..22a716ce 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -38,6 +38,7 @@ import org.bukkit.event.entity.EntitySpawnEvent; import java.util.HashMap; import java.util.Map; +import java.util.ArrayList; import java.util.stream.Collectors; @Linked @@ -148,7 +149,7 @@ public class Recorder implements Listener { .filter(e -> !e.isValid()) .collect(Collectors.toList()) .forEach(tntTraceRecorderMap::remove); - regionTraceRecorderMap.values().forEach(TraceRecorder::tick); + new ArrayList<>(regionTraceRecorderMap.values()).forEach(TraceRecorder::tick); }, 1, 1); } From e7bda055b8336cc2248bdb61d69b1ca4f79d63c6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 4 Oct 2022 17:12:59 +0200 Subject: [PATCH 24/33] Hotfix weird trace show behaviour when cleared Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/AutoTraceRecorder.java | 1 + 1 file changed, 1 insertion(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index c8e66bac..0ff1a171 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -72,6 +72,7 @@ public abstract class AutoTraceRecorder implements TraceRecorder { @Override public Record postClear() { recordMap.clear(); + record = recordSupplier.get(); return record; } From f2ef3c463431b2dd0b1f76c91a99e039f536e4b0 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 5 Oct 2022 15:58:16 +0200 Subject: [PATCH 25/33] Hotfix recorder Signed-off-by: yoyosource --- .../steamwar/bausystem/features/tracer/record/Recorder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 22a716ce..8362839e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -114,6 +114,11 @@ public class Recorder implements Listener { traceRecorder.recordSupplier(() -> { Record record = new Record(region); StoredRecords.add(region, record); + tntTraceRecorderMap.forEach((tntPrimed, region1) -> { + if (region1 == region) { + traceRecorder.tick(tntPrimed); + } + }); return record; }); } From f944fbd8cd153d5963bc6cf1b3436bc3b3aab006 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 5 Oct 2022 16:10:39 +0200 Subject: [PATCH 26/33] Hotfix recorder Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/AutoTraceRecorder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 0ff1a171..90e436ee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -59,9 +59,9 @@ public abstract class AutoTraceRecorder implements TraceRecorder { private void startRecording() { lastExplosion = 0; - recording = true; startTime = TPSUtils.currentTick.get(); record = recordSupplier.get(); + recording = true; } @Override From a57cd0287ae66ed84b6554f169306cbfa4e3ded3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 9 Oct 2022 13:35:16 +0200 Subject: [PATCH 27/33] Update custom model data Signed-off-by: yoyosource --- BauSystem_Main/src/de/steamwar/bausystem/SWUtils.java | 9 +++++++++ .../bausystem/features/loader/LoaderBauGuiItem.java | 4 +++- .../features/region/items/ProtectBauGuiItem.java | 5 +++-- .../bausystem/features/region/items/ResetBauGuiItem.java | 3 ++- .../bausystem/features/tracer/TracerBauGuiItem.java | 9 +++++---- .../features/util/items/NightVisionBauGuiItem.java | 4 +++- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/SWUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/SWUtils.java index cb816cd9..c7c9183f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/SWUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/SWUtils.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem; +import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.Setter; import lombok.experimental.UtilityClass; @@ -29,6 +30,7 @@ import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.Plugin; import java.util.function.Function; @@ -59,6 +61,13 @@ public class SWUtils { } } + public static SWItem setCustomModelData(SWItem item, int customModelData) { + ItemMeta itemMeta = item.getItemMeta(); + itemMeta.setCustomModelData(customModelData); + item.setItemMeta(itemMeta); + return item; + } + public static void sendToActionbar(Player p, String message) { p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java index 5dc1df11..55370c3f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; @@ -30,6 +31,7 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import java.util.Arrays; @@ -42,7 +44,7 @@ public class LoaderBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)), 1).getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java index f56745f0..652c2fb2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ProtectBauGuiItem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; @@ -43,9 +44,9 @@ public class ProtectBauGuiItem extends BauGuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) { - return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack(); } else { - return new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java index 4f41809c..79f6537a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ResetBauGuiItem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.region.ResetCommand; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; @@ -44,7 +45,7 @@ public class ResetBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, BauSystem.MESSAGE.parse("REGION_ITEM_RESET", player)).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, BauSystem.MESSAGE.parse("REGION_ITEM_RESET", player)), 1).getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index 3a188e9a..d309b132 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; @@ -46,11 +47,11 @@ public class TracerBauGuiItem extends BauGuiItem { public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); if (region.isGlobal()) { - return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> { - }).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> { + }), 1).getItemStack(); } - return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> { - }).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> { + }), 1).getItemStack(); } private static void open(Player p) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java index 76fb5354..d9cab51e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/NightVisionBauGuiItem.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; @@ -47,10 +48,11 @@ public class NightVisionBauGuiItem extends BauGuiItem { meta.setColor(PotionEffectType.NIGHT_VISION.getColor()); meta.setDisplayName(BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_ON", player)); meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); + meta.setCustomModelData(1); itemStack.setItemMeta(meta); return itemStack; } else { - return new SWItem(Material.GLASS_BOTTLE, BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_OFF", player)).getItemStack(); + return SWUtils.setCustomModelData(new SWItem(Material.GLASS_BOTTLE, BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_OFF", player)), 1).getItemStack(); } } From fca07eba75bc58b70fea44d52f240f13644c63d9 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 9 Oct 2022 21:13:22 +0200 Subject: [PATCH 28/33] Fix laufbautool Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/Recorder.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 8362839e..d3a1fcba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -146,9 +146,7 @@ public class Recorder implements Listener { { Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> { - world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> { - get(tntPrimed).tick(tntPrimed); - }); + tick(); tntTraceRecorderMap.keySet() .stream() .filter(e -> !e.isValid()) @@ -158,6 +156,12 @@ public class Recorder implements Listener { }, 1, 1); } + private void tick() { + world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> { + get(tntPrimed).tick(tntPrimed); + }); + } + @EventHandler public void onEntityExplode(EntityExplodeEvent event) { Entity entity = event.getEntity(); @@ -168,5 +172,6 @@ public class Recorder implements Listener { Region region = tntTraceRecorderMap.get((TNTPrimed) entity); traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); tntTraceRecorderMap.remove(entity); + tick(); } } From 9bb4cf548bba54f825e9ae6119e30e8e567a1471 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 13 Oct 2022 17:12:03 +0200 Subject: [PATCH 29/33] Hotfix Recorder NPE Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/Recorder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index d3a1fcba..faabcc62 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -114,13 +114,13 @@ public class Recorder implements Listener { traceRecorder.recordSupplier(() -> { Record record = new Record(region); StoredRecords.add(region, record); - tntTraceRecorderMap.forEach((tntPrimed, region1) -> { - if (region1 == region) { - traceRecorder.tick(tntPrimed); - } - }); return record; }); + tntTraceRecorderMap.forEach((tntPrimed, region1) -> { + if (region1 == region) { + traceRecorder.spawn(tntPrimed); + } + }); } public void remove(Region region) { From 4f2a6a70c484606e08ad618f732b932adc4afa99 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 16 Oct 2022 18:12:51 +0200 Subject: [PATCH 30/33] Possible optimization of trace recorder Signed-off-by: yoyosource --- .../bausystem/features/tracer/record/Recorder.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index faabcc62..06a84e46 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -36,9 +36,7 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; -import java.util.HashMap; -import java.util.Map; -import java.util.ArrayList; +import java.util.*; import java.util.stream.Collectors; @Linked @@ -135,12 +133,19 @@ public class Recorder implements Listener { } } + private Set activeTNTs = new HashSet<>(); + + { + activeTNTs.addAll(world.getEntitiesByClass(TNTPrimed.class)); + } + @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof TNTPrimed)) { return; } + activeTNTs.add((TNTPrimed) entity); get((TNTPrimed) entity).spawn((TNTPrimed) entity); } @@ -157,7 +162,7 @@ public class Recorder implements Listener { } private void tick() { - world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> { + activeTNTs.forEach(tntPrimed -> { get(tntPrimed).tick(tntPrimed); }); } @@ -172,6 +177,7 @@ public class Recorder implements Listener { Region region = tntTraceRecorderMap.get((TNTPrimed) entity); traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); tntTraceRecorderMap.remove(entity); + activeTNTs.remove(entity); tick(); } } From 566c612327199fb0710b4110b966af52183c45d4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 16:40:08 +0200 Subject: [PATCH 31/33] Add TNTPrimedIterator Signed-off-by: yoyosource --- .../tracer/record/TNTPrimedIterator15.java | 39 ++++++++++++++++++ .../tracer/record/TNTPrimedIterator18.java | 41 +++++++++++++++++++ .../tracer/record/TNTPrimedIterator19.java | 41 +++++++++++++++++++ .../features/tracer/record/Recorder.java | 10 +---- .../tracer/record/TNTPrimedIterator.java | 32 +++++++++++++++ 5 files changed, 154 insertions(+), 9 deletions(-) create mode 100644 BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java create mode 100644 BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java create mode 100644 BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java diff --git a/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java b/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java new file mode 100644 index 00000000..36c53f40 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator15.java @@ -0,0 +1,39 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import net.minecraft.server.v1_15_R1.EntityTNTPrimed; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; +import org.bukkit.entity.TNTPrimed; + +import java.util.stream.Stream; + +public class TNTPrimedIterator15 implements TNTPrimedIterator { + + private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0); + + @Override + public Stream iterator() { + return WORLD.getHandle().entitiesById.values().stream() + .filter(EntityTNTPrimed.class::isInstance) + .map(entity -> (TNTPrimed) entity.getBukkitEntity()); + } +} diff --git a/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java b/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java new file mode 100644 index 00000000..e6771471 --- /dev/null +++ b/BauSystem_18/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator18.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import net.minecraft.world.entity.item.EntityTNTPrimed; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_18_R2.CraftWorld; +import org.bukkit.entity.TNTPrimed; + +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class TNTPrimedIterator18 implements TNTPrimedIterator { + + private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0); + + @Override + public Stream iterator() { + return StreamSupport.stream(WORLD.getHandle().H().a().spliterator(), false) + .filter(EntityTNTPrimed.class::isInstance) + .map(entity -> (TNTPrimed) entity.getBukkitEntity()); + } +} + diff --git a/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java b/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java new file mode 100644 index 00000000..b56e04b3 --- /dev/null +++ b/BauSystem_19/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator19.java @@ -0,0 +1,41 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import net.minecraft.world.entity.item.EntityTNTPrimed; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.v1_19_R1.CraftWorld; +import org.bukkit.entity.TNTPrimed; + +import java.util.stream.Stream; +import java.util.stream.StreamSupport; + +public class TNTPrimedIterator19 implements TNTPrimedIterator { + + private static final CraftWorld WORLD = (CraftWorld) Bukkit.getWorlds().get(0); + + @Override + public Stream iterator() { + return StreamSupport.stream(WORLD.getHandle().F().a().spliterator(), false) + .filter(EntityTNTPrimed.class::isInstance) + .map(entity -> (TNTPrimed) entity.getBukkitEntity()); + } +} + diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 06a84e46..d24d8a1c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -133,19 +133,12 @@ public class Recorder implements Listener { } } - private Set activeTNTs = new HashSet<>(); - - { - activeTNTs.addAll(world.getEntitiesByClass(TNTPrimed.class)); - } - @EventHandler public void onEntitySpawn(EntitySpawnEvent event) { Entity entity = event.getEntity(); if (!(entity instanceof TNTPrimed)) { return; } - activeTNTs.add((TNTPrimed) entity); get((TNTPrimed) entity).spawn((TNTPrimed) entity); } @@ -162,7 +155,7 @@ public class Recorder implements Listener { } private void tick() { - activeTNTs.forEach(tntPrimed -> { + TNTPrimedIterator.impl.iterator().forEach(tntPrimed -> { get(tntPrimed).tick(tntPrimed); }); } @@ -177,7 +170,6 @@ public class Recorder implements Listener { Region region = tntTraceRecorderMap.get((TNTPrimed) entity); traceRecorder.explode((TNTPrimed) entity, !event.blockList().isEmpty() && region.inRegion(event.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); tntTraceRecorderMap.remove(entity); - activeTNTs.remove(entity); tick(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java new file mode 100644 index 00000000..a6f05b5e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java @@ -0,0 +1,32 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2022 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.tracer.record; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.core.VersionDependent; +import org.bukkit.entity.TNTPrimed; + +import java.util.stream.Stream; + +public interface TNTPrimedIterator { + TNTPrimedIterator impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); + + Stream iterator(); +} From 9275fd552cfd894ead8f14b03a80b1339423e081 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:06:02 +0200 Subject: [PATCH 32/33] Add unmoveable flag for MaterialCommand Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 2 ++ .../bausystem/features/util/MaterialCommand.java | 8 +++++++- .../bausystem/features/util/MaterialLazyInit.java | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 19b53de7..903ebb5a 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -918,6 +918,7 @@ MATERIAL_SEARCH_INTERACTEABLE=§eInteractable MATERIAL_SEARCH_FLAMMABLE=§eFlammable MATERIAL_SEARCH_BURNABLE=§eBurnable MATERIAL_SEARCH_WATERLOGGABLE=§eWaterloggable +MATERIAL_SEARCH_UNMOVEABLE=§eUnmoveable MATERIAL_SEARCH_BLASTRESISTANCE=§eBlast resistance MATERIAL_SEARCH_VALUE=§8: §e{0} MATERIAL_BLAST_RESISTANCE=§8- §eBlast resistance§8: §7{0} @@ -932,6 +933,7 @@ MATERIAL_INTERACTABLE=§8- §eInteractable block MATERIAL_FLAMMABLE=§8- §eFlammable block MATERIAL_BURNABLE=§8- §eBurnable block MATERIAL_WATERLOGGABLE=§8- §eWaterloggable block +MATERIAL_UNMOVABLE=§8- §eUnmovable block # Redstonetester RT_HELP=§8/§eredstonetester §8-§7 Gives you the redstone tester RT_GIVEN=§7Measure the time between activation of components diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java index 3fe740fe..dd221bae 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialCommand.java @@ -63,6 +63,7 @@ public class MaterialCommand extends SWCommand implements Listener { SearchType flammable = SearchType.IGNORE; SearchType burnable = SearchType.IGNORE; SearchType waterloggable = SearchType.IGNORE; + SearchType unmoveable = SearchType.IGNORE; String blastResistance = ">=0"; String name = ""; @@ -110,6 +111,7 @@ public class MaterialCommand extends SWCommand implements Listener { elements.put("-flammable", (search, searchType) -> search.flammable = searchType); elements.put("-burnable", (search, searchType) -> search.burnable = searchType); elements.put("-waterloggable", (search, searchType) -> search.waterloggable = searchType); + elements.put("-unmoveable", (search, searchType) -> search.unmoveable = searchType); } @Register @@ -235,7 +237,11 @@ public class MaterialCommand extends SWCommand implements Listener { search.waterloggable = search.waterloggable.next(); searchGUI(p); })); - swInventory.setItem(30, new SWItem(Material.NETHER_BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistance), clickType -> { + swInventory.setItem(29, new SWItem(Material.PISTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_UNMOVEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.unmoveable.getChatValue(), p)), clickType -> { + search.unmoveable = search.unmoveable.next(); + searchGUI(p); + })); + swInventory.setItem(34, new SWItem(Material.NETHER_BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistance), clickType -> { SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistance); swAnvilInv.setCallback(s -> { if (s.isEmpty() || s.matches("((([><]=?)|!|=)\\d+(\\.|,\\d+)?)( ((([><]=?)|!|=)\\d+(\\.|,\\d+)?))*")) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialLazyInit.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialLazyInit.java index 05732896..8beb38b1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialLazyInit.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/MaterialLazyInit.java @@ -22,7 +22,11 @@ package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.PistonMoveReaction; +import org.bukkit.block.TileState; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Waterlogged; import org.bukkit.entity.Player; @@ -62,6 +66,7 @@ public class MaterialLazyInit { private boolean flammable; private boolean burnable; private boolean waterloggable; + private boolean unmoveable; public MaterialData(Material material) { this.originalMaterial = material; @@ -78,6 +83,11 @@ public class MaterialLazyInit { burnable = material.isBurnable(); BlockData blockData = material.createBlockData(); waterloggable = blockData instanceof Waterlogged; + if (material.isBlock()) { + Block block = Bukkit.getWorlds().get(0).getBlockAt(0, 0, 0); + block.setType(material); + unmoveable = block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getState() instanceof TileState; + } if (material.isItem() && material != Material.AIR) { this.material = material; @@ -115,6 +125,9 @@ public class MaterialLazyInit { if (waterloggable) { lore.add(BauSystem.MESSAGE.parse("MATERIAL_WATERLOGGABLE", p)); } + if (unmoveable) { + lore.add(BauSystem.MESSAGE.parse("MATERIAL_UNMOVABLE", p)); + } return new SWListInv.SWListEntry<>(new SWItem(material, "§e" + name, lore, false, clickType -> { }), originalMaterial); } @@ -129,6 +142,7 @@ public class MaterialLazyInit { result &= search.flammable.test(flammable); result &= search.burnable.test(burnable); result &= search.waterloggable.test(waterloggable); + result &= search.unmoveable.test(unmoveable); if (!result) { return false; } From 23ded823f0f9cf6826a7b4034bb7d4bae836ef30 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 24 Oct 2022 17:25:00 +0200 Subject: [PATCH 33/33] Fix coral death while freeze is active Signed-off-by: yoyosource --- .../steamwar/bausystem/features/region/FreezeListener.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index dc8232b3..f8e811aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -175,4 +175,11 @@ public class FreezeListener implements Listener { } } } + + @EventHandler + public void onBlockFade(BlockFadeEvent event) { + if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + event.setCancelled(true); + } + } }