Remove Redstonetester since nobody uses it
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
91960f501b
Commit
42e8df6b53
@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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<Player, RedstoneTester> 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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren