From 67b40433d80dfa8e76b96b017bee61ae37fad67a Mon Sep 17 00:00:00 2001 From: jojo Date: Tue, 16 Feb 2021 11:47:13 +0100 Subject: [PATCH] Fix pr stuff --- .../bausystem/world/TNTSimulator_12.java | 42 ++++++++++++++++++ .../bausystem/world/TNTSimulator_15.java | 43 +++++++++++++++++++ .../bausystem/world/TNTSimulator.java | 25 +++++++++-- 3 files changed, 106 insertions(+), 4 deletions(-) create mode 100644 BauSystem_12/src/de/steamwar/bausystem/world/TNTSimulator_12.java create mode 100644 BauSystem_15/src/de/steamwar/bausystem/world/TNTSimulator_15.java diff --git a/BauSystem_12/src/de/steamwar/bausystem/world/TNTSimulator_12.java b/BauSystem_12/src/de/steamwar/bausystem/world/TNTSimulator_12.java new file mode 100644 index 0000000..abd0ba1 --- /dev/null +++ b/BauSystem_12/src/de/steamwar/bausystem/world/TNTSimulator_12.java @@ -0,0 +1,42 @@ +/* + * 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.world; + +import org.bukkit.Material; + +public class TNTSimulator_12 { + + public static Material active() { + return Material.CONCRETE; + } + + public static Material notActive() { + return Material.CONCRETE; + } + + public static Material repeater() { + return Material.DIODE; + } + + public static Material comparator() { + return Material.REDSTONE_COMPARATOR; + } + +} diff --git a/BauSystem_15/src/de/steamwar/bausystem/world/TNTSimulator_15.java b/BauSystem_15/src/de/steamwar/bausystem/world/TNTSimulator_15.java new file mode 100644 index 0000000..7042a86 --- /dev/null +++ b/BauSystem_15/src/de/steamwar/bausystem/world/TNTSimulator_15.java @@ -0,0 +1,43 @@ +/* + * + * 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.world; + +import org.bukkit.Material; + +public class TNTSimulator_15 { + + public static Material active() { + return Material.LIME_CONCRETE; + } + + public static Material notActive() { + return Material.RED_CONCRETE; + } + + public static Material repeater() { + return Material.REPEATER; + } + + public static Material comparator() { + return Material.COMPARATOR; + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java index f0ed328..dc02da4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/TNTSimulator.java @@ -22,6 +22,7 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; +import de.steamwar.core.VersionedCallable; import de.steamwar.inventory.SWAnvilInv; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; @@ -189,21 +190,21 @@ public class TNTSimulator { })); // Repeater before Comparator - swInventory.setItem(4, new SWItem(tntSpawn.isComparator() ? Material.COMPARATOR : Material.REPEATER, "§7Gezündet durch §8- §e" + (tntSpawn.isComparator() ? "Comparator" : "Repeater"), clickType -> { + swInventory.setItem(4, new SWItem(comparatorOrNot(tntSpawn.isComparator()), "§7Gezündet durch §8- §e" + (tntSpawn.isComparator() ? "Comparator" : "Repeater"), clickType -> { tntSpawn.setComparator(!tntSpawn.isComparator()); editTNT(player, tntSpawn); })); // Velocity Settings - swInventory.setItem(13, new SWItem(tntSpawn.isxVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung X §8- " + active(tntSpawn.isxVelocity()), clickType -> { + swInventory.setItem(13, new SWItem(activeOrNot(tntSpawn.isxVelocity()), "§7TNT §eSprung X §8- " + active(tntSpawn.isxVelocity()), clickType -> { tntSpawn.setxVelocity(!tntSpawn.isxVelocity()); editTNT(player, tntSpawn); })); - swInventory.setItem(22, new SWItem(tntSpawn.isyVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Y §8- " + active(tntSpawn.isyVelocity()), clickType -> { + swInventory.setItem(22, new SWItem(activeOrNot(tntSpawn.isyVelocity()), "§7TNT §eSprung Y §8- " + active(tntSpawn.isyVelocity()), clickType -> { tntSpawn.setyVelocity(!tntSpawn.isyVelocity()); editTNT(player, tntSpawn); })); - swInventory.setItem(31, new SWItem(tntSpawn.iszVelocity() ? Material.LIME_CONCRETE : Material.RED_CONCRETE, "§7TNT §eSprung Z §8- " + active(tntSpawn.iszVelocity()), clickType -> { + swInventory.setItem(31, new SWItem(activeOrNot(tntSpawn.iszVelocity()), "§7TNT §eSprung Z §8- " + active(tntSpawn.iszVelocity()), clickType -> { tntSpawn.setzVelocity(!tntSpawn.iszVelocity()); editTNT(player, tntSpawn); })); @@ -268,6 +269,22 @@ public class TNTSimulator { tntSimulator.TNT_SPAWNS.add(tntSpawn); } + private static Material comparatorOrNot(boolean b) { + if (b) { + return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::comparator, 8), new VersionedCallable<>(TNTSimulator_15::comparator, 14)); + } else { + return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::repeater, 8), new VersionedCallable<>(TNTSimulator_15::repeater, 14)); + } + } + + private static Material activeOrNot(boolean b) { + if (b) { + return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::active, 8), new VersionedCallable<>(TNTSimulator_15::active, 14)); + } else { + return VersionedCallable.call(new VersionedCallable<>(TNTSimulator_12::notActive, 8), new VersionedCallable<>(TNTSimulator_15::notActive, 14)); + } + } + private static String active(boolean b) { return b ? "§aan" : "§caus"; }