From 42e8df6b532a8bf8d0003cd1cab42753e50f96db Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 17 Sep 2023 16:20:27 +0200 Subject: [PATCH] Remove Redstonetester since nobody uses it Signed-off-by: yoyosource --- .../redstonetester/RedstoneTesterGuiItem.java | 62 ---------- .../redstonetester/RedstonetesterCommand.java | 40 ------- .../redstonetester/RedstonetesterUtils.java | 108 ------------------ .../redstonetester/RestonetesterListener.java | 94 --------------- 4 files changed, 304 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java deleted file mode 100644 index eebcf0cc..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstoneTesterGuiItem.java +++ /dev/null @@ -1,62 +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.redstonetester; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -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 java.util.Arrays; - -@Linked -public class RedstoneTesterGuiItem extends BauGuiItem { - - public RedstoneTesterGuiItem() { - super(23); - } - - @Override - public ItemStack getItem(Player player) { - return new SWItem(Material.REPEATER, - BauSystem.MESSAGE.parse("RT_ITEM_NAME", player), - Arrays.asList(BauSystem.MESSAGE.parse("RT_ITEM_LORE_1", player), - BauSystem.MESSAGE.parse("RT_ITEM_LORE_2", player), - BauSystem.MESSAGE.parse("RT_ITEM_LORE_3", player)) - , false, null).getItemStack(); - } - - @Override - public boolean click(ClickType click, Player p) { - p.closeInventory(); - p.performCommand("redstonetester"); - return false; - } - - @Override - public Permission permission() { - return Permission.MEMBER; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java deleted file mode 100644 index 0e1c7b63..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterCommand.java +++ /dev/null @@ -1,40 +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.redstonetester; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.command.SWCommand; -import de.steamwar.linkage.Linked; -import org.bukkit.entity.Player; - -@Linked -public class RedstonetesterCommand extends SWCommand { - - public RedstonetesterCommand() { - super("redstonetester", "rt"); - } - - @Register(description = "RT_HELP") - public void genericCommand(Player p) { - BauSystem.MESSAGE.send("RT_GIVEN", p); - SWUtils.giveItemToPlayer(p, RedstonetesterUtils.getWand(p)); - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java deleted file mode 100644 index a70b143b..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RedstonetesterUtils.java +++ /dev/null @@ -1,108 +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.redstonetester; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.utils.ItemUtils; -import de.steamwar.inventory.SWItem; -import lombok.Getter; -import lombok.Setter; -import lombok.experimental.UtilityClass; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Powerable; -import org.bukkit.block.data.type.Piston; -import org.bukkit.block.data.type.RedstoneWire; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -@UtilityClass -public class RedstonetesterUtils { - - public static ItemStack getWand(Player player) { - ItemStack i = new SWItem(Material.BLAZE_ROD, - BauSystem.MESSAGE.parse("RT_ITEM_NAME", player), - Arrays.asList(BauSystem.MESSAGE.parse("RT_ITEM_LORE_1", player), - BauSystem.MESSAGE.parse("RT_ITEM_LORE_2", player), - BauSystem.MESSAGE.parse("RT_ITEM_LORE_3", player)), - false, null).getItemStack(); - ItemUtils.setItem(i, "redstonetester"); - return i; - } - - @Getter - private final Map playerMap = new HashMap<>(); - - public void sendLocation(Player player, String prefix, Location location) { - BauSystem.MESSAGE.send("RT_LOC", player, location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - @SuppressWarnings("BooleanMethodIsAlwaysInverted") - public boolean validBlock(Player player, BlockData block) { - if (block instanceof Powerable) return true; - if (block instanceof Piston) return true; - if (block instanceof RedstoneWire) return true; - BauSystem.MESSAGE.send("RT_INVALID_LOC", player); - return false; - } - - @Getter - @Setter - public static class RedstoneTester { - - private final Player player; - private Location loc1 = null; - private Location loc2 = null; - - private long lastTick = 0; - private Long tick = null; - - public RedstoneTester(Player player) { - this.player = player; - } - - public void activate(Location location) { - if (loc1 == null || loc2 == null) { - tick = null; - return; - } - if (TPSUtils.currentRealTick.get() - lastTick > 100) { - tick = null; - } - if (loc1.equals(location)) { - lastTick = TPSUtils.currentRealTick.get(); - if (tick == null) { - tick = TPSUtils.currentRealTick.get(); - } - return; - } - if (tick != null && loc2.equals(location)) { - BauSystem.MESSAGE.send("RT_RESULT", player, (TPSUtils.currentRealTick.get() - tick), ((TPSUtils.currentRealTick.get() - tick) / 2.0)); - } - } - - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java deleted file mode 100644 index 2ab015b9..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/redstonetester/RestonetesterListener.java +++ /dev/null @@ -1,94 +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.redstonetester; - -import de.steamwar.bausystem.BauSystem; -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; -import org.bukkit.event.Listener; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.block.BlockPistonExtendEvent; -import org.bukkit.event.block.BlockPistonRetractEvent; -import org.bukkit.event.block.BlockRedstoneEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.Objects; - -@Linked -public class RestonetesterListener implements Listener { - - @EventHandler - public void onPlayerInteract(PlayerInteractEvent event) { - if (!ItemUtils.isItem(event.getItem(), "redstonetester")) return; - Player player = event.getPlayer(); - Block block = event.getClickedBlock(); - event.setCancelled(true); - - switch (event.getAction()) { - case RIGHT_CLICK_AIR: - if (player.isSneaking()) { - RedstonetesterUtils.getPlayerMap().remove(event.getPlayer()); - BauSystem.MESSAGE.send("RT_ACTIVATE", player); - } - break; - case LEFT_CLICK_BLOCK: - if (!RedstonetesterUtils.validBlock(event.getPlayer(), Objects.requireNonNull(block).getBlockData())) return; - RedstonetesterUtils.getPlayerMap().computeIfAbsent(event.getPlayer(), RedstonetesterUtils.RedstoneTester::new).setLoc1(block.getLocation()); - RedstonetesterUtils.sendLocation(event.getPlayer(), "POS1", block.getLocation()); - break; - case RIGHT_CLICK_BLOCK: - if (!RedstonetesterUtils.validBlock(event.getPlayer(), Objects.requireNonNull(block).getBlockData())) return; - RedstonetesterUtils.getPlayerMap().computeIfAbsent(event.getPlayer(), RedstonetesterUtils.RedstoneTester::new).setLoc2(block.getLocation()); - RedstonetesterUtils.sendLocation(event.getPlayer(), "POS2", block.getLocation()); - break; - default: - break; - } - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - RedstonetesterUtils.getPlayerMap().remove(event.getPlayer()); - } - - @EventHandler - public void onPistonExtend(BlockPistonExtendEvent e) { - RedstonetesterUtils.getPlayerMap().forEach((player, redstoneTester) -> redstoneTester.activate(e.getBlock().getLocation())); - } - - @EventHandler - public void onPistonRetract(BlockPistonRetractEvent e) { - RedstonetesterUtils.getPlayerMap().forEach((player, redstoneTester) -> redstoneTester.activate(e.getBlock().getLocation())); - } - - @EventHandler - public void onRedstoneEvent(BlockRedstoneEvent e) { - RedstonetesterUtils.getPlayerMap().forEach((player, redstoneTester) -> redstoneTester.activate(e.getBlock().getLocation())); - } - - @EventHandler - public void onBlockDispense(BlockDispenseEvent e) { - RedstonetesterUtils.getPlayerMap().forEach((player, redstoneTester) -> redstoneTester.activate(e.getBlock().getLocation())); - } -} \ No newline at end of file