SteamWar/SpigotCore
Archiviert
13
0

Extracting BungeeGUI Changes

Dieser Commit ist enthalten in:
Chaoscaot 2020-12-08 17:25:27 +01:00
Ursprung 61a667ae98
Commit 658946d4da
3 geänderte Dateien mit 13 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -24,7 +24,7 @@ import com.google.common.io.ByteStreams;
import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.comms.handlers.BungeeHandler;
import de.steamwar.comms.handlers.InventoryHandler; import de.steamwar.comms.handlers.InventoryHandler;
import de.steamwar.core.Core; import de.steamwar.core.Core;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.*;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener; import org.bukkit.plugin.messaging.PluginMessageListener;

Datei anzeigen

@ -23,11 +23,13 @@ import com.google.common.io.ByteArrayDataInput;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWItem;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import de.steamwar.comms.packets.*; import de.steamwar.comms.packets.*;
import org.bukkit.event.inventory.InventoryType;
import java.util.*; import java.util.*;
@ -45,12 +47,19 @@ public class InventoryHandler implements BungeeHandler {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
JsonObject itemJson = array.get(i).getAsJsonObject(); JsonObject itemJson = array.get(i).getAsJsonObject();
SWItem item = SWItem.getItemFromJson(itemJson); SWItem item = SWItem.getItemFromJson(itemJson);
item.setCallback(click -> new InventoryCallbackPacket(itemJson, click, player).send(Bukkit.getPlayer(player))); item.setCallback(click -> {
new InventoryCallbackPacket(itemJson, click, player).send(Bukkit.getPlayer(player));
});
items.put(itemJson.get("position").getAsInt(), item); items.put(itemJson.get("position").getAsInt(), item);
} }
SWInventory inventory = new SWInventory(Bukkit.getPlayer(player), size, title, items); SWInventory inventory = new SWInventory(Bukkit.getPlayer(player), size, title, items);
inventory.addCloseCallback(click -> new InventoryCallbackPacket(player).send(Bukkit.getPlayer(player))); inventory.addCloseCallback(click -> {
Bukkit.getScheduler().runTaskLaterAsynchronously(Core.getInstance(), () -> {
if(Bukkit.getPlayer(player).getOpenInventory().getType() != InventoryType.CHEST)
new InventoryCallbackPacket(player).send(Bukkit.getPlayer(player));
}, 1);
});
inventory.open(); inventory.open();
} }
} }

Datei anzeigen

@ -138,7 +138,7 @@ public class SWItem {
itemJson.has("color")?itemJson.get("color").getAsByte():0, itemJson.has("color")?itemJson.get("color").getAsByte():0,
itemJson.get("title").getAsString()); itemJson.get("title").getAsString());
}else { }else {
item = new SWItem(Material.valueOf(itemJson.get("material").getAsString()), itemJson.get("title").getAsString()); item = new SWItem(SWItem.getMaterial(itemJson.get("material").getAsString()), itemJson.get("title").getAsString());
} }
}catch (IllegalArgumentException e) { }catch (IllegalArgumentException e) {
item = new SWItem(Material.STONE, itemJson.get("title").getAsString()); item = new SWItem(Material.STONE, itemJson.get("title").getAsString());