SteamWar/BauSystem2.0
Archiviert
12
0

Merge pull request 'BauGUI (Editor) Improvements' (#142) from gui_improvements into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #142
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
YoyoNow 2022-11-12 12:03:05 +01:00
Commit 532de2291d
4 geänderte Dateien mit 56 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -201,6 +201,7 @@ GUI_EDITOR_ITEM_ROW_M=§e-1 Row
GUI_EDITOR_ITEM_TRASH=§cTrashcan GUI_EDITOR_ITEM_TRASH=§cTrashcan
GUI_EDITOR_ITEM_TRASH_LORE=§7Drop item here GUI_EDITOR_ITEM_TRASH_LORE=§7Drop item here
GUI_EDITOR_ITEM_MORE=§eMore items GUI_EDITOR_ITEM_MORE=§eMore items
GUI_EDITOR_ITEM_CLOSE=§eClose
GUI_EDITOR_TITLE_MORE=Select item GUI_EDITOR_TITLE_MORE=Select item
# Script # Script
@ -949,7 +950,7 @@ RT_ACTIVATE=§7Positions deleted§8.
# Region Items # Region Items
REGION_ITEM_COLOR=§7Color: §e{0} REGION_ITEM_COLOR=§7Color: §e{0}
REGION_ITEM_COLOR_CHOOSE=Choose color REGION_ITEM_COLOR_CHOOSE=Choose color
REGION_ITEM_FIRE_ALLOW=§7Fire: §eAcitvated REGION_ITEM_FIRE_ALLOW=§7Fire: §eActivated
REGION_ITEM_FIRE_DISALLOW=§7Fire: §eDeactivated REGION_ITEM_FIRE_DISALLOW=§7Fire: §eDeactivated
REGION_ITEM_FREEZE_ALLOW=§7Freeze: §eActivated REGION_ITEM_FREEZE_ALLOW=§7Freeze: §eActivated
REGION_ITEM_FREEZE_DISALLOW=§7Freeze: §eDeactivated REGION_ITEM_FREEZE_DISALLOW=§7Freeze: §eDeactivated
@ -1288,3 +1289,6 @@ XRAY_OFF = §cXray deactivated
COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another
TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another
# Schematic
SCHEMATIC_GUI_ITEM=§eSchematics

Datei anzeigen

@ -200,6 +200,7 @@ GUI_EDITOR_ITEM_ROW_M=§e-1 Zeile
GUI_EDITOR_ITEM_TRASH=§cTrashcan GUI_EDITOR_ITEM_TRASH=§cTrashcan
GUI_EDITOR_ITEM_TRASH_LORE=§7Item hier rein Legen GUI_EDITOR_ITEM_TRASH_LORE=§7Item hier rein Legen
GUI_EDITOR_ITEM_MORE=§eMehr Items GUI_EDITOR_ITEM_MORE=§eMehr Items
GUI_EDITOR_ITEM_CLOSE=§eSchließen
GUI_EDITOR_TITLE_MORE=Item auswählen GUI_EDITOR_TITLE_MORE=Item auswählen
# Script # Script
@ -1257,3 +1258,6 @@ XRAY_OFF = §cXray deaktiviert
COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen COLORREPLACE_HELP = §8//§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen
TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen TYPEREPLACE_HELP = §8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen
# Schematics
SCHEMATIC_GUI_ITEM=§eSchematics

Datei anzeigen

@ -39,6 +39,7 @@ import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
@ -72,6 +73,7 @@ public class BauGuiEditor implements Listener {
inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> { inv.setItem(mapping.getSize() + 5, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH", p), Arrays.asList(BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_TRASH_LORE", p)), false, clickType -> {
}).getItemStack()); }).getItemStack());
inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack()); inv.setItem(mapping.getSize() + 6, new SWItem(Material.SCUTE, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_MORE", p)).getItemStack());
inv.setItem(mapping.getSize() + 8, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("GUI_EDITOR_ITEM_CLOSE", p)).getItemStack());
p.openInventory(inv); p.openInventory(inv);
p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor); p.getOpenInventory().setCursor(cursor == null ? new SWItem().getItemStack() : cursor);
@ -155,6 +157,10 @@ public class BauGuiEditor implements Listener {
}); });
inv.open(); inv.open();
break; break;
case 8:
saveMapping(p);
BauGUI.openBauGui(p);
break;
default: default:
} }
} }
@ -188,14 +194,17 @@ public class BauGuiEditor implements Listener {
} }
private void saveMapping(Player p) { private void saveMapping(Player p) {
BauGuiMapping mapping = BauGuiMapping.getGuiMapping(p); saveMapping(p.getOpenInventory(), BauGuiMapping.getGuiMapping(p));
}
private void saveMapping(InventoryView view, BauGuiMapping mapping) {
if (mapping.isSaved()) { if (mapping.isSaved()) {
return; return;
} }
HashMap<Integer, Integer> newMapping = new HashMap<>(); HashMap<Integer, Integer> newMapping = new HashMap<>();
for (int i = 0; i < p.getOpenInventory().getTopInventory().getContents().length; i++) { for (int i = 0; i < view.getTopInventory().getContents().length; i++) {
ItemStack itemStack = p.getOpenInventory().getTopInventory().getContents()[i]; ItemStack itemStack = view.getTopInventory().getContents()[i];
if (itemStack == null || itemStack.getType() == Material.AIR || i >= mapping.getSize()) continue; if (itemStack == null || itemStack.getType() == Material.AIR || i >= mapping.getSize()) continue;
newMapping.put(getId(itemStack), i); newMapping.put(getId(itemStack), i);
} }
@ -218,7 +227,7 @@ public class BauGuiEditor implements Listener {
Player p = (Player) event.getPlayer(); Player p = (Player) event.getPlayer();
saveMapping(p); saveMapping(event.getView(), BauGuiMapping.getGuiMapping(p));
open_Edits.remove(p); open_Edits.remove(p);
} }
} }

Datei anzeigen

@ -0,0 +1,34 @@
package de.steamwar.bausystem.features.util.items;
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;
@Linked
public class SchemBauGuiItem extends BauGuiItem {
public SchemBauGuiItem() {
super(35);
}
@Override
public Permission permission() {
return Permission.WORLDEDIT;
}
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.CHEST, BauSystem.MESSAGE.parse("SCHEMATIC_GUI_ITEM", player)).getItemStack();
}
@Override
public boolean click(ClickType click, Player p) {
p.performCommand("schematic gui");
return false;
}
}