SteamWar/BungeeCore
Archiviert
13
2

Extraced Inventory API Changes from BungeeSchemGUI

Dieser Commit ist enthalten in:
Chaoscaot 2020-12-08 17:09:19 +01:00
Ursprung cacc2f158a
Commit 9a3756f3d0
7 geänderte Dateien mit 37 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -239,9 +239,11 @@ public class BauCommand {
}
private static void delete(ProxiedPlayer p, String[] command){
SWInventory inventory = new SWInventory(p, 9, "§eWirklich Welt löschen?");
inventory.addItem(new SWItem(8, "§cAbbrechen", 1), click -> inventory.close());
inventory.addItem(new SWItem(0, "§aLöschen", 10), click -> {
SWInventory inventory = new SWInventory(p, 9, Message.parse("BAU_DELETE_GUI_NAME", p));
inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click ->
inventory.close()
);
inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> {
if(bau15(p, command, 2)){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.bungeecore.comms;
public class PacketIdManager {
private PacketIdManager(){}
//0x0(X) Standalone Packets
public static final byte PING_PACKET = 0x01;

Datei anzeigen

@ -68,7 +68,7 @@ public class InventoryPacket extends BungeePacket {
JsonArray array = new JsonArray();
for (int i = 0; i < size; i++) {
if(items.get(i) != null)
array.add(items.get(i).writeToString());
array.add(items.get(i).writeToString(i));
}
object.add("items", array);
byteArrayDataOutput.writeUTF(object.toString());

Datei anzeigen

@ -25,7 +25,9 @@ import de.steamwar.bungeecore.comms.packets.InventoryPacket;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class SWInventory {
@ -46,33 +48,26 @@ public class SWInventory {
next = false;
}
public void addItem(SWItem item) {
itemMap.put(item.getPosition(), item);
}
public void addItem(SWItem item, InvCallback callback) {
item.setCallback(callback);
itemMap.put(item.getPosition(), item);
}
public void addItem(int position, SWItem item) {
itemMap.put(position, item);
}
public void addItem(int pos, SWItem item, InvCallback callback) {
addItem(pos, item, new ArrayList<>(), callback);
}
public void addItem(int pos, SWItem item, List<String> lore, InvCallback callback) {
item.setCallback(callback);
item.setLore(lore);
itemMap.put(pos, item);
}
public void addItem(int pos, SWItem item) {
itemMap.put(pos, item);
}
public void addItem(int pos, SWItem item, String name, InvCallback callback) {
item.setName(name);
item.setCallback(callback);
itemMap.put(pos, item);
}
public void removeItem(SWItem item) {
itemMap.remove(item.getPosition());
}
public void removeItem(int position) {
itemMap.remove(position);
}

Datei anzeigen

@ -29,29 +29,26 @@ public class SWItem {
private String material, title, skullOwner;
private boolean enchanted, hideAttributes;
private int position;
private List<String> lore;
private InvCallback callback;
private int color;
public SWItem(String material, int position, String title) {
public SWItem(String material, String title) {
this.material = material.toUpperCase();
lore = new ArrayList<>();
this.position = position;
this.title = title;
color = 0;
}
public SWItem(int position, String title, int color) {
public SWItem(String title, int color) {
this.material = "DYE";
lore = new ArrayList<>();
this.position = position;
this.title = title;
this.color = color;
}
public static SWItem getSkull(String skullOwner) {
SWItem item = new SWItem("SKULL", 1, skullOwner);
SWItem item = new SWItem("SKULL", skullOwner);
item.setSkullOwner(skullOwner);
return item;
}
@ -100,10 +97,6 @@ public class SWItem {
this.hideAttributes = hideAttributes;
}
public int getPosition() {
return position;
}
public void setName(String name) {
title = name;
}
@ -112,7 +105,7 @@ public class SWItem {
this.lore.add(lore);
}
public JsonObject writeToString() {
public JsonObject writeToString(int position) {
JsonObject object = new JsonObject();
object.addProperty("material", material);
object.addProperty("position", position);
@ -152,8 +145,10 @@ public class SWItem {
return false;
if(!item.skullOwner.equals(skullOwner))
return false;
if(item.position != position)
return false;
return true;
}
public void setLore(List<String> lore) {
this.lore = lore;
}
}

Datei anzeigen

@ -43,19 +43,19 @@ public class SWListInv<T> extends SWInventory {
setCallback(-999, (InvCallback.ClickType click) -> close());
if(elements.size() > 54){
if(page != 0)
addItem(45, new SWItem(45, "§eSeite zurück", 10), (InvCallback.ClickType click) -> {
addItem(45, new SWItem("§eSeite zurück", 10), (InvCallback.ClickType click) -> {
page--;
open();
});
else
addItem(45, new SWItem(45, "§7Seite zurück", 8), (InvCallback.ClickType click) -> {});
addItem(45, new SWItem("§7Seite zurück", 8), (InvCallback.ClickType click) -> {});
if(page < elements.size()/45)
addItem(53, new SWItem( 53, "§eSeite vor", 10), "§eSeite vor", (InvCallback.ClickType click) -> {
addItem(53, new SWItem("§eSeite vor", 10), "§eSeite vor", (InvCallback.ClickType click) -> {
page++;
open();
});
else
addItem(53, new SWItem(53, "§eSeite vor", 8), (InvCallback.ClickType click) -> {});
addItem(53, new SWItem("§eSeite vor", 8), (InvCallback.ClickType click) -> {});
}
int ipageLimit = elements.size() - page*45;
@ -119,7 +119,7 @@ public class SWListInv<T> extends SWInventory {
m = "CAULDRON_ITEM";
else
m = s.getSchemItem();
SWItem item = new SWItem(m, 0, "§e" + s.getSchemName());
SWItem item = new SWItem(m, "§e" + s.getSchemName());
schemList.add(new SWListEntry<>(item, s));
}
return schemList;

Datei anzeigen

@ -109,3 +109,8 @@ IGNORE_MESSAGE=§7Du ignorierst nun §e{0}§8.
POLLRESULT_NOPOLL=§cDerzeit läuft keine Umfrage.
POLLRESULT_HEADER=§eEs haben {0} abgestimmt auf die Frage: §7{1}
POLLRESULT_LIST=§e{0}§8: §7{1}
#BauCommand
BAU_DELETE_GUI_NAME=§eWirklich Welt löschen?
BAU_DELETE_GUI_CANCEL=§cAbbrechen
BAU_DELETE_GUI_DELETE=§aLöschen