Schemnodes #56
@ -23,6 +23,10 @@ DATE=........
|
||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||
ONLY_SCHEMS=§cDu kannst hier keinen Ordner angeben
|
||||
|
||||
PAGE_LIST=§e Seite ({0}/{1}) »»
|
||||
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||
LIST_NEXT_PAGE=§eNächste Seite
|
||||
|
||||
# Permission
|
||||
PERMISSION_WORLD = Einstellungen vornehmen
|
||||
PERMISSION_WORLD-EDIT = WorldEdit verwenden
|
||||
@ -195,7 +199,7 @@ HOTBAR_INVENTORY=Standard Hotbar
|
||||
GUI_EDITOR_ITEM-NAME=§eGui Editor
|
||||
GUI_EXPORT_CODE=§eDein Gui-Code:
|
||||
GUI_EXPORT_CODE-HOVER=§eKopieren
|
||||
GUI_IMPORT_INVALID-CODE=§eInvalieder Gui-Code
|
||||
GUI_IMPORT_INVALID-CODE=§eInvalider Gui-Code
|
||||
GUI_IMPORT_CODE-SUCCESSFUL=§eGui-Code eingelesen
|
||||
GUI_NAME=Bau GUI
|
||||
GUI_NO_PERMISSION=§cDu hast nicht genug Rechte um dies zu tun
|
||||
@ -507,6 +511,14 @@ SMART_PLACE_INFO = §7Plaziert rotierbare Blöcke beim §esneaken§7 von dir §e
|
||||
SMART_PLACE_ENABLE = §aSmartPlace aktiviert
|
||||
SMART_PLACE_DISABLE = §cSmartPlace deaktiviert
|
||||
|
||||
# BlockCounter
|
||||
BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus
|
||||
BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an
|
||||
BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus
|
||||
BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s
|
||||
BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht
|
||||
BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht
|
||||
|
||||
# Trace
|
||||
TRACE_RECORD=§aan
|
||||
TRACE_RECORD-AUTO=§aan
|
||||
@ -531,6 +543,7 @@ TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show
|
||||
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8- <§e-water§8|§e-interpolate-xz§8|-interpolate-y§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_NAME = Tracer Gui
|
||||
@ -567,6 +580,27 @@ TRACE_GUI_POSITION_Y = §7Y§8: §e{0}
|
||||
TRACE_GUI_POSITION_Z = §7Z§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 = §eSetup
|
||||
@ -686,7 +720,7 @@ OTHER_KILLALL_HELP_SELF=§8/§ekillall §8- §7Entferne alle Entities aus deiner
|
||||
OTHER_KILLALL_HELP_ALL=§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global
|
||||
OTHER_KILLALL_REGION=§a{0} Entities aus der Region entfernt
|
||||
OTHER_KILLALL_GLOBAL=§a{0} Entities aus der Global entfernt
|
||||
OTHER_TELEPORT_HELP = §8/§etp §8[§8Player§8] §8-§7 Teleportiere dich zu einem Spieler
|
||||
OTHER_TELEPORT_HELP = §8/§etp §8[§7Player§8] §8-§7 Teleportiere dich zu einem Spieler
|
||||
OTHER_TELEPORT_SELF_0=§cSei eins mit dir selbst!
|
||||
OTHER_TELEPORT_SELF_1=§cDu brauchst Leute zum spielen? Wir haben auch einen TeamSpeak!
|
||||
OTHER_TELEPORT_SELF_2=§cNoch zu reisende Blöcke: 0; ETA: 0:00
|
||||
@ -697,7 +731,7 @@ OTHER_TIME_NO_PERM=§cDu darfst hier nicht die Zeit ändern
|
||||
OTHER_TIME_INVALID=§cBitte gib eine Zahl zwischen 0 und 24000 an
|
||||
OTHER_TIME_RESULT=§7§oWhooosh
|
||||
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
||||
OTHER_TPS_MESSAGE = §7 §e{0}§7 §e{1}§7 §e{2}§7 §e{3}§7 §e{4}
|
||||
OTHER_TPS_MESSAGE = §7 §e{0}§7 §e{1}§7 §e{2}§7 §e{3}§7 §e{4}
|
||||
OTHER_TPS_SINGLE = §8TPS: §e{0}
|
||||
OTHER_WORLDSPAWN_HELP=§8/§eworldspawn §8-§e Teleportiere dich zum Spawn
|
||||
# DebugStick
|
||||
@ -882,9 +916,6 @@ WARP_GUI_NO=§cHier gibt es noch keine Warps
|
||||
WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke
|
||||
WARP_GUI_LCLICK=§7Links klicken zum teleportieren
|
||||
WARP_GUI_RCLICK=§7Rechts klicken zum editieren
|
||||
WARP_LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||
WARP_LIST_PAGE=§e Seite ({0}/{1}) »»
|
||||
WARP_LIST_NEXT_PAGE=§eNächste Seite
|
||||
WARP_INFO_NAME=§7Name: §e{0}
|
||||
WARP_HELP_1=§8/§ewarp add §8[§7Name§8] - §7Erstelle einen neuen Warp Punkt
|
||||
WARP_HELP_2=§8/§ewarp §8[§7Name§8] - §7Teleportiere dich zu einen Warp-Punkt
|
||||
|
@ -39,7 +39,7 @@ public class TpsCommand extends SWCommand {
|
||||
@Register(help = true)
|
||||
public void genericCommand(Player p, String... args) {
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p);
|
||||
BauSystem.MESSAGE.send("OTHER_TPS_MESSAGE", p,
|
||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_MESSAGE", p,
|
||||
TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND),
|
||||
TPSWarpUtils.getTps(TPSWatcher.TPSType.TEN_SECONDS),
|
||||
TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_MINUTE),
|
||||
|
@ -34,19 +34,19 @@ import java.util.Set;
|
||||
public class AdjacentHoney implements PanzernAlgorithm {
|
||||
|
||||
private PistonLine pistonLine = new PistonLine();
|
||||
private SlabOnRedstone slabOnRedstone = new SlabOnRedstone();
|
||||
private SlabOnTorch slabOnTorch = new SlabOnTorch();
|
||||
|
||||
@Override
|
||||
public PanzernResult check(Block source, Map<BlockFace, Block> adjacent, Set<Material> adjacentMaterials) {
|
||||
if (adjacentMaterials.contains(Material.HONEY_BLOCK)) {
|
||||
for (BlockFace face : HORIZONTAL_FACES) {
|
||||
if (!adjacent.containsKey(face)) continue;
|
||||
if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) {
|
||||
PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials);
|
||||
if (panzernResult == PanzernResult.DEFAULT) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
return panzernResult;
|
||||
}
|
||||
PanzernResult result = slabOnRedstone.check(source, adjacent, adjacentMaterials);
|
||||
if (result == PanzernResult.SLAB) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
result = slabOnTorch.check(source, adjacent, adjacentMaterials);
|
||||
if (result == PanzernResult.SLAB) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials);
|
||||
if (panzernResult == PanzernResult.DEFAULT) {
|
||||
|
@ -34,19 +34,19 @@ import java.util.Set;
|
||||
public class AdjacentSlime implements PanzernAlgorithm {
|
||||
|
||||
private PistonLine pistonLine = new PistonLine();
|
||||
private SlabOnRedstone slabOnRedstone = new SlabOnRedstone();
|
||||
private SlabOnTorch slabOnTorch = new SlabOnTorch();
|
||||
|
||||
@Override
|
||||
public PanzernResult check(Block source, Map<BlockFace, Block> adjacent, Set<Material> adjacentMaterials) {
|
||||
if (adjacentMaterials.contains(Material.SLIME_BLOCK)) {
|
||||
for (BlockFace face : HORIZONTAL_FACES) {
|
||||
if (!adjacent.containsKey(face)) continue;
|
||||
if (adjacent.get(face).getType() == Material.REDSTONE_WIRE) {
|
||||
PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials);
|
||||
if (panzernResult == PanzernResult.DEFAULT) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
return panzernResult;
|
||||
}
|
||||
PanzernResult result = slabOnRedstone.check(source, adjacent, adjacentMaterials);
|
||||
if (result == PanzernResult.SLAB) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
result = slabOnTorch.check(source, adjacent, adjacentMaterials);
|
||||
if (result == PanzernResult.SLAB) {
|
||||
return PanzernResult.UNMOVABLE_SLAB;
|
||||
}
|
||||
PanzernResult panzernResult = pistonLine.check(source, adjacent, adjacentMaterials);
|
||||
if (panzernResult == PanzernResult.DEFAULT) {
|
||||
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.testblock.blockcounter;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.RegionUtils;
|
||||
import lombok.ToString;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ToString
|
||||
public class BlockCount {
|
||||
|
||||
private static BukkitTask bukkitTask = null;
|
||||
|
||||
private Region region;
|
||||
private int count = 0;
|
||||
private int tntCount = 0;
|
||||
private final long tick = TPSUtils.currentTick.get();
|
||||
|
||||
private long lastUpdate = TPSUtils.currentTick.get();
|
||||
|
||||
public BlockCount(Region region) {
|
||||
this.region = region;
|
||||
|
||||
if (bukkitTask == null) {
|
||||
bukkitTask = Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
|
||||
Set<Region> toRemove = new HashSet<>();
|
||||
for (BlockCount blockCount : BlockCounter.blockCountMap.values()) {
|
||||
if (TPSUtils.currentTick.get() - blockCount.lastUpdate < 60) {
|
||||
continue;
|
||||
}
|
||||
toRemove.add(region);
|
||||
|
||||
if (count > 10) {
|
||||
RegionUtils.message(blockCount.region, player -> BlockCounter.getMessage(player, blockCount.count, blockCount.tntCount, blockCount.tick, blockCount.lastUpdate));
|
||||
}
|
||||
}
|
||||
toRemove.forEach(BlockCounter.blockCountMap::remove);
|
||||
if (BlockCounter.blockCountMap.isEmpty()) {
|
||||
bukkitTask.cancel();
|
||||
bukkitTask = null;
|
||||
}
|
||||
}, 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(List<Block> blocks) {
|
||||
count += blocks.size();
|
||||
tntCount++;
|
||||
lastUpdate = TPSUtils.currentTick.get();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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.testblock.blockcounter;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.configplayer.Config;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@UtilityClass
|
||||
public class BlockCounter {
|
||||
|
||||
public final Map<Region, BlockCount> blockCountMap = new HashMap<>();
|
||||
|
||||
public boolean isActive(final Player p) {
|
||||
if (!Config.getInstance().get(p).containsKey("blockCounter")) {
|
||||
return false;
|
||||
}
|
||||
return Config.getInstance().get(p).getPlainValue("blockCounter");
|
||||
}
|
||||
|
||||
public void enable(final Player p) {
|
||||
Config.getInstance().get(p).put("blockCounter", true);
|
||||
}
|
||||
|
||||
public void disable(final Player p) {
|
||||
Config.getInstance().get(p).put("blockCounter", false);
|
||||
}
|
||||
|
||||
public String getMessage(Player player, int count, int tntCount, long tick, long lastTick) {
|
||||
double countPerTNT = (double) count / tntCount;
|
||||
double countPerTick = (double) count / Math.max((lastTick - tick), 1);
|
||||
if (isActive(player)) {
|
||||
return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 10) / 200.0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.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 org.bukkit.entity.Player;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class BlockCounterCommand extends SWCommand {
|
||||
|
||||
public BlockCounterCommand() {
|
||||
super("blockcounter", "blockcount", "bcounter", "bcount");
|
||||
}
|
||||
|
||||
@Register(description = "BLOCK_COUNTER_HELP_TOGGLE")
|
||||
public void defaultCommand(Player p) {
|
||||
if (BlockCounter.isActive(p)) {
|
||||
disableCommand(p);
|
||||
} else {
|
||||
enableCommand(p);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "enable", description = "BLOCK_COUNTER_HELP_ENABLE")
|
||||
public void enableCommand(Player p) {
|
||||
BlockCounter.enable(p);
|
||||
BauSystem.MESSAGE.send("BLOCK_COUNTER_ENABLE", p);
|
||||
}
|
||||
|
||||
@Register(value = "disable", description = "BLOCK_COUNTER_HELP_DISABLE")
|
||||
public void disableCommand(Player p) {
|
||||
BlockCounter.disable(p);
|
||||
BauSystem.MESSAGE.send("BLOCK_COUNTER_DISABLE", p);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.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 org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Linked(LinkageType.LISTENER)
|
||||
public class BlockCounterListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
List<Block> blockList = event.blockList();
|
||||
blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList());
|
||||
if (blockList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
BlockCounter.blockCountMap.computeIfAbsent(region, BlockCount::new).update(blockList);
|
||||
}
|
||||
}
|
@ -128,5 +128,4 @@ public class Depth {
|
||||
maxVector.setY(Math.max(maxVector.getY(), block.getY()));
|
||||
maxVector.setZ(Math.max(maxVector.getZ(), block.getZ()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,39 +21,30 @@ package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.shared.Position;
|
||||
import org.bukkit.entity.Entity;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@Getter
|
||||
public class TNTPosition extends Position {
|
||||
|
||||
private final Record.TNTRecord record;
|
||||
private final int fuseTicks;
|
||||
private final Vector previousLocation;
|
||||
private final boolean exploded;
|
||||
|
||||
public TNTPosition(Record.TNTRecord record, Entity entity, Vector previousLocation, boolean exploded) {
|
||||
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, boolean exploded) {
|
||||
super(entity.getLocation().toVector());
|
||||
this.record = record;
|
||||
this.fuseTicks = entity.getFuseTicks();
|
||||
this.previousLocation = previousLocation;
|
||||
this.exploded = exploded;
|
||||
}
|
||||
|
||||
public Vector getPreviousLocation() {
|
||||
return previousLocation;
|
||||
}
|
||||
|
||||
public boolean isExploded() {
|
||||
return exploded;
|
||||
}
|
||||
|
||||
public Record.TNTRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Position{" +
|
||||
"location=" + super.getLocation() +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,25 +24,25 @@ 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.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.BlockShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode;
|
||||
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.utils.ListChatView;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import lombok.NonNull;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class TraceCommand extends SWCommand {
|
||||
@ -97,9 +97,8 @@ public class TraceCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_HIDE", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_DELETE", p);
|
||||
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_LIST", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_GUI", p);
|
||||
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
|
||||
}
|
||||
|
||||
@Register({"gui"})
|
||||
@ -108,6 +107,148 @@ public class TraceCommand extends SWCommand {
|
||||
TraceGui.openGui(p);
|
||||
}
|
||||
|
||||
@Register({"record", "list"})
|
||||
@Register({"list"})
|
||||
public void listCommand(Player p) {
|
||||
listCommand(p, 0);
|
||||
}
|
||||
|
||||
@Register({"record", "list"})
|
||||
@Register({"list"})
|
||||
public void listCommand(Player player, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
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({"record", "delete"})
|
||||
public void recordDelete(Player p, int id) {
|
||||
if (!permissionCheck(p)) return;
|
||||
StoredRecords.remove(id);
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordList(Player p, int record) {
|
||||
recordList(p, record, 0);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordList(Player player, int recordID, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
Record record = StoredRecords.get(recordID);
|
||||
if (record == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
ListChatView.chatView(player, record.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 " + record.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 " + record.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 " + record.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 " + record.getId() + " " + afterPage));
|
||||
});
|
||||
}
|
||||
|
||||
@Register({"record", "tnt", "delete"})
|
||||
public void deleteRecordTNT(Player player, int recordID, int tntID) {
|
||||
if (!permissionCheck(player)) return;
|
||||
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("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID) {
|
||||
recordTNTPositions(player, recordID, tnt, tntID, 0);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
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("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID, @Mapper("fuse") String fuse, int fuseTicks) {
|
||||
if (!permissionCheck(player)) return;
|
||||
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({"start"})
|
||||
public void startCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
@ -219,4 +360,40 @@ public class TraceCommand extends SWCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Mapper(value = "tnt", local = true)
|
||||
public TypeMapper<String> tntTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (s.equals("tnt")) {
|
||||
return "tnt";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return Collections.singletonList("tnt");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper(value = "fuse", local = true)
|
||||
public TypeMapper<String> fuseTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (s.equals("fuse")) {
|
||||
return "fuse";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return Collections.singletonList("fuse");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,21 +28,19 @@ import org.bukkit.entity.TNTPrimed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class Record {
|
||||
|
||||
private final long startTime;
|
||||
private static long idNumber = 0;
|
||||
|
||||
@Getter
|
||||
private final long id = idNumber++;
|
||||
private final long startTime = TPSUtils.currentTick.get();
|
||||
private final List<TNTRecord> tnt = new ArrayList<>();
|
||||
|
||||
public int size() {
|
||||
return tnt.size();
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void showAll(ShowMode<TNTPosition> mode) {
|
||||
for (TNTRecord record : tnt)
|
||||
record.showAll(mode);
|
||||
@ -50,7 +48,6 @@ public class Record {
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public Record() {
|
||||
startTime = TPSUtils.currentTick.get();
|
||||
StoredRecords.add(this);
|
||||
}
|
||||
|
||||
@ -64,9 +61,21 @@ public class Record {
|
||||
tnt.clear();
|
||||
}
|
||||
|
||||
public TNTRecord get(int id) {
|
||||
for (TNTRecord record : tnt) {
|
||||
if (record.getId() == id) return record;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void remove(int id) {
|
||||
tnt.removeIf(record -> record.getId() == id);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class TNTRecord {
|
||||
|
||||
@Getter
|
||||
private final long id = idNumber++;
|
||||
private final List<TNTPosition> positions = new ArrayList<>(41);
|
||||
|
||||
public void showAll(ShowMode<TNTPosition> mode) {
|
||||
@ -74,6 +83,13 @@ public class Record {
|
||||
mode.show(position);
|
||||
}
|
||||
|
||||
public TNTPosition get(int fuseTicks) {
|
||||
for (TNTPosition position : positions) {
|
||||
if (position.getFuseTicks() == fuseTicks) return position;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public void add(TNTPrimed tntPrimed) {
|
||||
add(tntPrimed, false);
|
||||
|
@ -36,6 +36,21 @@ public class StoredRecords {
|
||||
records.add(record);
|
||||
}
|
||||
|
||||
public static void remove(Record record) {
|
||||
records.remove(record);
|
||||
}
|
||||
|
||||
public static void remove(int id) {
|
||||
records.removeIf(record -> record.getId() == id);
|
||||
}
|
||||
|
||||
public static Record get(int id) {
|
||||
for (Record record : records) {
|
||||
if (record.getId() == id) return record;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void showAll(ShowMode<TNTPosition> mode) {
|
||||
for (Record record : records) record.showAll(mode);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ 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.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
@ -38,7 +39,6 @@ import org.bukkit.entity.Player;
|
||||
import yapion.hierarchy.types.YAPIONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
@Linked(LinkageType.DISABLE_LINK)
|
||||
@ -115,38 +115,20 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
|
||||
|
||||
@Register("list")
|
||||
public void listWarps(Player player, int page) {
|
||||
List<Warp> warps = Warp.getWarps();
|
||||
int pageCount = (int) Math.ceil(warps.size() / 18d);
|
||||
for (int i = page * 18; i < warps.size() && i < (page + 1) * 18; i++) {
|
||||
Warp warp = warps.get(i);
|
||||
ListChatView.chatView(player, Warp.getWarps(), page, warp -> {
|
||||
TextComponent component = new TextComponent();
|
||||
component.setText(warp.getName());
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp " + warp.getName()));
|
||||
component.setColor(ChatColor.YELLOW);
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("WARP_TELEPORT_HOVER", player, warp.getName()))));
|
||||
player.spigot().sendMessage(component);
|
||||
}
|
||||
|
||||
TextComponent beforePage = new TextComponent("««");
|
||||
if (page > 0) {
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("WARP_LIST_PREVIOUS_PAGE", player)).create()));
|
||||
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + (page - 1)));
|
||||
} else {
|
||||
beforePage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
TextComponent nextPage = new TextComponent(BauSystem.MESSAGE.parse("WARP_LIST_PAGE", player, page + 1, Math.max(pageCount, 1)));
|
||||
if (page < pageCount - 1) {
|
||||
nextPage.setColor(ChatColor.YELLOW);
|
||||
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("WARP_LIST_NEXT_PAGE", player)).create()));
|
||||
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + (page + 1)));
|
||||
} else {
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
beforePage.addExtra(nextPage);
|
||||
player.spigot().sendMessage(beforePage);
|
||||
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, "/warp 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, "/warp list " + afterPage));
|
||||
});
|
||||
}
|
||||
|
||||
@Register("info")
|
||||
|
@ -129,12 +129,20 @@ public class Region {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (regionConfig.containsKey("prototype")) {
|
||||
prototypes.add(regionConfig.getPlainValue("prototype"));
|
||||
}
|
||||
|
||||
this.flagStorage = flagStorage;
|
||||
Point point = null;
|
||||
if (regionConfig.containsKey("minX", Integer.class) && regionConfig.containsKey("minY", Integer.class) && regionConfig.containsKey("minZ", Integer.class)) {
|
||||
point = new Point(regionConfig.getPlainValue("minX"), regionConfig.getPlainValue("minY"), regionConfig.getPlainValue("minZ"));
|
||||
}
|
||||
generatePrototypeData(prototype, point);
|
||||
if (prototype != null && prototypes.contains(prototype.getName())) {
|
||||
generatePrototypeData(prototype, point);
|
||||
} else if (regionConfig.containsKey("prototype")) {
|
||||
generatePrototypeData(Prototype.getByName(regionConfig.getPlainValue("prototype")), point);
|
||||
}
|
||||
|
||||
if (!hasType(RegionType.BUILD) || !hasType(RegionType.TESTBLOCK)) {
|
||||
flagStorage.set(Flag.TNT, TNTMode.DENY);
|
||||
@ -283,7 +291,7 @@ public class Region {
|
||||
}
|
||||
|
||||
public boolean setPrototype(@NonNull Prototype prototype) {
|
||||
if (!prototypes.contains(prototype.getName()) && !prototypes.isEmpty()) {
|
||||
if (!prototypes.contains(prototype.getName())) {
|
||||
return false;
|
||||
}
|
||||
return _setPrototype(prototype);
|
||||
@ -292,10 +300,6 @@ public class Region {
|
||||
boolean _setPrototype(@NonNull Prototype prototype) {
|
||||
generatePrototypeData(prototype, minPoint);
|
||||
RegionUtils.save(this);
|
||||
setLinkedRegion(region -> {
|
||||
region.generatePrototypeData(prototype, region.minPoint);
|
||||
return true;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
61
BauSystem_Main/src/de/steamwar/bausystem/utils/ListChatView.java
Normale Datei
61
BauSystem_Main/src/de/steamwar/bausystem/utils/ListChatView.java
Normale Datei
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@UtilityClass
|
||||
public class ListChatView {
|
||||
|
||||
public static <T> void chatView(Player player, List<T> elements, int page, Function<T, TextComponent> elementConverter, BiConsumer<TextComponent, Integer> beforePageConsumer, BiConsumer<TextComponent, Integer> afterPageConsumer) {
|
||||
int pageCount = (int) Math.ceil(elements.size() / 18d);
|
||||
for (int i = page * 18; i < elements.size() && i < (page + 1) * 18; i++) {
|
||||
T element = elements.get(i);
|
||||
player.spigot().sendMessage(elementConverter.apply(element));
|
||||
}
|
||||
|
||||
TextComponent beforePage = new TextComponent("««");
|
||||
if (page > 0) {
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
beforePageConsumer.accept(beforePage, page - 1);
|
||||
} else {
|
||||
beforePage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
TextComponent nextPage = new TextComponent(BauSystem.MESSAGE.parse("PAGE_LIST", player, page + 1, Math.max(pageCount, 1)));
|
||||
if (page < pageCount - 1) {
|
||||
nextPage.setColor(ChatColor.YELLOW);
|
||||
afterPageConsumer.accept(nextPage, page + 1);
|
||||
} else {
|
||||
nextPage.setColor(ChatColor.RED);
|
||||
}
|
||||
|
||||
beforePage.addExtra(nextPage);
|
||||
player.spigot().sendMessage(beforePage);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren