SteamWar/BauSystem2.0
Archiviert
12
0

Add /warp feature #55

Zusammengeführt
YoyoNow hat 8 Commits von warp nach master 2021-11-12 19:33:24 +01:00 zusammengeführt
3 geänderte Dateien mit 27 neuen und 17 gelöschten Zeilen
Nur Änderungen aus Commit 8535213deb werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -547,12 +547,23 @@ PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{
PANZERN_DONE = §aZuende gepanzert PANZERN_DONE = §aZuende gepanzert
# Warp # Warp
WARP_DISALLOWED = §cDu darfst hier nicht das Warp System nutzen
WARP_LOC_X = §7X§8: §e{0}
WARP_LOC_Y = §7Y§8: §e{0}
WARP_LOC_Z = §7Z§8: §e{0}
WARP_EXISTS=§7Der Warp mit dem namen §e{0} §7existiert bereits WARP_EXISTS=§7Der Warp mit dem namen §e{0} §7existiert bereits
WARP_NAME_RESERVED=§7Du kannst nicht §c{0} §7als name für einen Warp nutzen WARP_NAME_RESERVED=§7Du kannst nicht §c{0} §7als name für einen Warp nutzen
WARP_CREATED=§7Der Warp §e{0} §7wurde erstellt WARP_CREATED=§7Der Warp §e{0} §7wurde erstellt
WARP_DELETE_HOVER=§e{0} §7löschen
WARP_DELETED=§e{0} §7wurde gelöcht WARP_DELETED=§e{0} §7wurde gelöcht
WARP_TELEPORT_HOVER=§7Zu §e{0} §7teleportieren
WARP_MATERIAL_CHOOSE=Material auswählen
WARP_GUI_NAME=Warps
WARP_GUI_NO=§cHier giebt es noch keine Warps WARP_GUI_NO=§cHier giebt es noch keine Warps
WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke
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_INFO_CREATOR=§7Ersteller: §e{0} WARP_INFO_CREATOR=§7Ersteller: §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

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.ColorConfig;
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.command.SWCommand; import de.steamwar.command.SWCommand;
@ -35,7 +34,6 @@ import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.sql.Timestamp;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -122,23 +120,23 @@ public class WarpCommand extends SWCommand {
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("§7Zu §e" + warp.getName() + " §7teleportieren"))); component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("WARP_TELEPORT_HOVER", player, warp.getName()))));
player.spigot().sendMessage(component); player.spigot().sendMessage(component);
} }
TextComponent beforePage = new TextComponent("««"); TextComponent beforePage = new TextComponent("««");
if (page > 0) { if (page > 0) {
beforePage.setColor(ChatColor.YELLOW); beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create())); 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))); beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + (page - 1)));
} else { } else {
beforePage.setColor(ChatColor.RED); beforePage.setColor(ChatColor.RED);
} }
TextComponent nextPage = new TextComponent(" Seite (" + (page + 1) + "/" + Math.max(pageCount, 1) + ") »»"); TextComponent nextPage = new TextComponent(BauSystem.MESSAGE.parse("WARP_LIST_PAGE", player, page + 1, Math.max(pageCount, 1)));
if (page < pageCount - 1) { if (page < pageCount - 1) {
nextPage.setColor(ChatColor.YELLOW); nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create())); 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))); nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/warp list " + (page + 1)));
} else { } else {
nextPage.setColor(ChatColor.RED); nextPage.setColor(ChatColor.RED);
@ -153,16 +151,16 @@ public class WarpCommand extends SWCommand {
BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, warp.getName()); BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, warp.getName());
BauSystem.MESSAGE.sendPrefixless("WARP_INFO_NAME", player, warp.getName()); BauSystem.MESSAGE.sendPrefixless("WARP_INFO_NAME", player, warp.getName());
BauSystem.MESSAGE.sendPrefixless("WARP_INFO_CREATOR", player, warp.getCreator()); BauSystem.MESSAGE.sendPrefixless("WARP_INFO_CREATOR", player, warp.getCreator());
player.sendMessage("§7X: §e" + warp.getLocation().getX()); BauSystem.MESSAGE.sendPrefixless("WARP_LOC_X", player, warp.getLocation().getX());
player.sendMessage("§7Y: §e" + warp.getLocation().getY()); BauSystem.MESSAGE.sendPrefixless("WARP_LOC_Y", player, warp.getLocation().getY());
player.sendMessage("§7Z: §e" + warp.getLocation().getZ()); BauSystem.MESSAGE.sendPrefixless("WARP_LOC_Z", player, warp.getLocation().getZ());
BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation())); BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation()));
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean permissionCheck(Player player) { private boolean permissionCheck(Player player) {
if (!Permission.hasPermission(player, Permission.WORLD)) { if (!Permission.hasPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + ColorConfig.DISABLE + "Du darfst hier nicht den Warp verändern"); BauSystem.MESSAGE.send("WARP_DISALLOWED", player);
return false; return false;
} }
return true; return true;

Datei anzeigen

@ -38,16 +38,17 @@ public class WarpGui {
Warp.getWarps().forEach(warp -> entries.add(new SWListInv.SWListEntry<>(new SWItem( Warp.getWarps().forEach(warp -> entries.add(new SWListInv.SWListEntry<>(new SWItem(
warp.getMat(), warp.getMat(),
"§e" + warp.getName(), "§e" + warp.getName(),
Arrays.asList("§7X: §e" + (int) warp.getLocation().getX(), Arrays.asList(
"§7Y: §e" + (int) warp.getLocation().getY(), BauSystem.MESSAGE.parse("WARP_LOC_X", player, (int) warp.getLocation().getX()),
"§7Z: §e" + (int) warp.getLocation().getZ(), BauSystem.MESSAGE.parse("WARP_LOC_Y", player, (int) warp.getLocation().getY()),
BauSystem.MESSAGE.parse("WARP_LOC_Z", player, (int) warp.getLocation().getZ()),
BauSystem.MESSAGE.parse("WARP_GUI_DISTANCE", player, (int) warp.getLocation().distance(player.getLocation()))), BauSystem.MESSAGE.parse("WARP_GUI_DISTANCE", player, (int) warp.getLocation().distance(player.getLocation()))),
false, false,
clickType -> { clickType -> {
} }
), warp))); ), warp)));
SWListInv<Warp> inv = new SWListInv<>(player, "Warps", false, entries, (clickType, warp) -> { SWListInv<Warp> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("WARP_GUI_NAME", player), false, entries, (clickType, warp) -> {
if (clickType.isRightClick() && Permission.hasPermission(player, Permission.WORLD)) { if (clickType.isRightClick() && Permission.hasPermission(player, Permission.WORLD)) {
openWarpGui(player, warp); openWarpGui(player, warp);
} else { } else {
@ -65,14 +66,14 @@ public class WarpGui {
public static void openWarpGui(Player player, Warp warp) { public static void openWarpGui(Player player, Warp warp) {
SWInventory inv = new SWInventory(player, 9, warp.getName()); SWInventory inv = new SWInventory(player, 9, warp.getName());
inv.setItem(0, new SWItem(Material.ENDER_PEARL, "§7Zu §e" + warp.getName() + " §7teleportieren", clickType -> { inv.setItem(0, new SWItem(Material.ENDER_PEARL, BauSystem.MESSAGE.parse("WARP_TELEPORT_HOVER", player, warp.getName()), clickType -> {
player.closeInventory(); player.closeInventory();
warp.teleport(player); warp.teleport(player);
})); }));
inv.setItem(2, new SWItem(warp.getMat(), "§e" + warp.getMat().name(), clickType -> changeMaterial(player, warp))); inv.setItem(2, new SWItem(warp.getMat(), "§e" + warp.getMat().name(), clickType -> changeMaterial(player, warp)));
inv.setItem(8, new SWItem(Material.BARRIER, "§e" + warp.getName() + " §7löschen", clickType -> { inv.setItem(8, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("WARP_DELETE_HOVER", player, warp.getName()), clickType -> {
player.closeInventory(); player.closeInventory();
warp.delete(); warp.delete();
})); }));
@ -87,7 +88,7 @@ public class WarpGui {
materials.add(new SWListInv.SWListEntry<>(new SWItem(value, "§e" + value.name()), value)); materials.add(new SWListInv.SWListEntry<>(new SWItem(value, "§e" + value.name()), value));
} }
SWListInv<Material> inv = new SWListInv<>(player, "Material auswählen", materials, (clickType, material) -> { SWListInv<Material> inv = new SWListInv<>(player, BauSystem.MESSAGE.parse("WARP_MATERIAL_CHOOSE", player), materials, (clickType, material) -> {
player.closeInventory(); player.closeInventory();
warp.setMat(material); warp.setMat(material);
}); });