Fix TPSCommand Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
fe4060ce92
Commit
32c78938b6
@ -22,6 +22,10 @@ TIME = HH:mm:ss
|
|||||||
DATE=........
|
DATE=........
|
||||||
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
COMMAND_HELP_HEAD=§7---=== (§e{0}§7) ===---
|
||||||
|
|
||||||
|
PAGE_LIST=§e Seite ({0}/{1}) »»
|
||||||
|
LIST_PREVIOUS_PAGE=§eVorherige Seite
|
||||||
|
LIST_NEXT_PAGE=§eNächste Seite
|
||||||
|
|
||||||
# Permission
|
# Permission
|
||||||
PERMISSION_WORLD = Einstellungen vornehmen
|
PERMISSION_WORLD = Einstellungen vornehmen
|
||||||
PERMISSION_WORLD-EDIT = WorldEdit verwenden
|
PERMISSION_WORLD-EDIT = WorldEdit verwenden
|
||||||
@ -194,7 +198,7 @@ HOTBAR_INVENTORY=Standard Hotbar
|
|||||||
GUI_EDITOR_ITEM-NAME=§eGui Editor
|
GUI_EDITOR_ITEM-NAME=§eGui Editor
|
||||||
GUI_EXPORT_CODE=§eDein Gui-Code:
|
GUI_EXPORT_CODE=§eDein Gui-Code:
|
||||||
GUI_EXPORT_CODE-HOVER=§eKopieren
|
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_IMPORT_CODE-SUCCESSFUL=§eGui-Code eingelesen
|
||||||
GUI_NAME=Bau GUI
|
GUI_NAME=Bau GUI
|
||||||
GUI_NO_PERMISSION=§cDu hast nicht genug Rechte um dies zu tun
|
GUI_NO_PERMISSION=§cDu hast nicht genug Rechte um dies zu tun
|
||||||
@ -566,6 +570,11 @@ TRACE_GUI_POSITION_Y = §7Y§8: §e{0}
|
|||||||
TRACE_GUI_POSITION_Z = §7Z§8: §e{0}
|
TRACE_GUI_POSITION_Z = §7Z§8: §e{0}
|
||||||
TRACE_GUI_POSITION_EXPLODED = §7Explodiert§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
|
||||||
|
|
||||||
# Loader
|
# Loader
|
||||||
LOADER_OFF = §caus
|
LOADER_OFF = §caus
|
||||||
LOADER_SETUP = §eSetup
|
LOADER_SETUP = §eSetup
|
||||||
@ -696,7 +705,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_INVALID=§cBitte gib eine Zahl zwischen 0 und 24000 an
|
||||||
OTHER_TIME_RESULT=§7§oWhooosh
|
OTHER_TIME_RESULT=§7§oWhooosh
|
||||||
OTHER_TPS_HEAD = §7TPS: 1s 10s 1m 5m 10m
|
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_TPS_SINGLE = §8TPS: §e{0}
|
||||||
OTHER_WORLDSPAWN_HELP=§8/§eworldspawn §8-§e Teleportiere dich zum Spawn
|
OTHER_WORLDSPAWN_HELP=§8/§eworldspawn §8-§e Teleportiere dich zum Spawn
|
||||||
# DebugStick
|
# DebugStick
|
||||||
@ -881,9 +890,6 @@ WARP_GUI_NO=§cHier gibt es noch keine Warps
|
|||||||
WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke
|
WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke
|
||||||
WARP_GUI_LCLICK=§7Links klicken zum teleportieren
|
WARP_GUI_LCLICK=§7Links klicken zum teleportieren
|
||||||
WARP_GUI_RCLICK=§7Rechts klicken zum editieren
|
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_INFO_NAME=§7Name: §e{0}
|
||||||
WARP_HELP_1=§8/§ewarp add §8[§7Name§8] - §7Erstelle einen neuen Warp Punkt
|
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
|
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)
|
@Register(help = true)
|
||||||
public void genericCommand(Player p, String... args) {
|
public void genericCommand(Player p, String... args) {
|
||||||
BauSystem.MESSAGE.sendPrefixless("OTHER_TPS_HEAD", p);
|
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.ONE_SECOND),
|
||||||
TPSWarpUtils.getTps(TPSWatcher.TPSType.TEN_SECONDS),
|
TPSWarpUtils.getTps(TPSWatcher.TPSType.TEN_SECONDS),
|
||||||
TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_MINUTE),
|
TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_MINUTE),
|
||||||
|
@ -25,6 +25,7 @@ import de.steamwar.bausystem.linkage.Disable;
|
|||||||
import de.steamwar.bausystem.linkage.Enable;
|
import de.steamwar.bausystem.linkage.Enable;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import de.steamwar.bausystem.utils.ListChatView;
|
||||||
import de.steamwar.bausystem.worlddata.WorldData;
|
import de.steamwar.bausystem.worlddata.WorldData;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
@ -38,7 +39,6 @@ import org.bukkit.entity.Player;
|
|||||||
import yapion.hierarchy.types.YAPIONObject;
|
import yapion.hierarchy.types.YAPIONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
@Linked(LinkageType.DISABLE_LINK)
|
@Linked(LinkageType.DISABLE_LINK)
|
||||||
@ -115,38 +115,20 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
|
|||||||
|
|
||||||
@Register("list")
|
@Register("list")
|
||||||
public void listWarps(Player player, int page) {
|
public void listWarps(Player player, int page) {
|
||||||
List<Warp> warps = Warp.getWarps();
|
ListChatView.chatView(player, Warp.getWarps(), page, warp -> {
|
||||||
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);
|
|
||||||
TextComponent component = new TextComponent();
|
TextComponent component = new TextComponent();
|
||||||
component.setText(warp.getName());
|
component.setText(warp.getName());
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp " + warp.getName()));
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp " + warp.getName()));
|
||||||
component.setColor(ChatColor.YELLOW);
|
component.setColor(ChatColor.YELLOW);
|
||||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("WARP_TELEPORT_HOVER", player, warp.getName()))));
|
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("WARP_TELEPORT_HOVER", player, warp.getName()))));
|
||||||
player.spigot().sendMessage(component);
|
return component;
|
||||||
}
|
}, (beforePageComponent, beforePage) -> {
|
||||||
|
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
|
||||||
TextComponent beforePage = new TextComponent("««");
|
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + beforePage));
|
||||||
if (page > 0) {
|
}, (afterPageComponent, afterPage) -> {
|
||||||
beforePage.setColor(ChatColor.YELLOW);
|
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
|
||||||
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("WARP_LIST_PREVIOUS_PAGE", player)).create()));
|
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + afterPage));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("info")
|
@Register("info")
|
||||||
|
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