SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Moved Item' (#119) from packet-system into master

Reviewed-by: YoyoNow <jwsteam@nidido.de>
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2020-09-26 20:56:43 +02:00
Commit 7b7f4e8d17
4 geänderte Dateien mit 21 neuen und 8 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

@ -20,10 +20,13 @@
package de.steamwar.bungeecore.comms.handlers;
import com.google.common.io.ByteArrayDataInput;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.comms.SpigotHandler;
import de.steamwar.bungeecore.comms.packets.CloseInventoryPacket;
import de.steamwar.bungeecore.inventory.InvCallback;
import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.ProxyServer;
import java.util.HashMap;
import java.util.Map;
@ -36,6 +39,13 @@ public class InventoryCallbackHandler implements SpigotHandler {
public void handle(ByteArrayDataInput byteArrayDataInput) {
SteamwarUser owner = SteamwarUser.get(byteArrayDataInput.readInt());
CallbackType type = CallbackType.valueOf(byteArrayDataInput.readUTF());
if(!inventoryHashMap.containsKey(owner.getId())) {
BungeeCore.send(ProxyServer.getInstance().getPlayer(owner.getUuid()), BungeeCore.CHAT_PREFIX + "§cBitte erneut versuchen. Durch ein Softwareupdate konnte die übliche Aktion nicht durchgeführt werden.");
if(type == CallbackType.CLICK) {
new CloseInventoryPacket(owner.getId()).send(ProxyServer.getInstance().getPlayer(owner.getUuid()));
}
return;
}
if(type == CallbackType.CLICK) {
int pos = byteArrayDataInput.readInt();
InvCallback.ClickType clickType = InvCallback.ClickType.valueOf(byteArrayDataInput.readUTF());

Datei anzeigen

@ -22,24 +22,22 @@ package de.steamwar.bungeecore.comms.packets;
import com.google.common.io.ByteArrayDataOutput;
import de.steamwar.bungeecore.comms.BungeePacket;
import de.steamwar.bungeecore.comms.PacketIdManager;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class CloseInventoryPacket extends BungeePacket {
final ProxiedPlayer player;
final int player;
@Override
public int getId() {
return PacketIdManager.INVENTORY_CLOSE_PACKET;
}
public CloseInventoryPacket(ProxiedPlayer player) {
public CloseInventoryPacket(int player) {
this.player = player;
}
@Override
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
byteArrayDataOutput.writeInt(SteamwarUser.get(player).getId());
byteArrayDataOutput.writeInt(player);
}
}

Datei anzeigen

@ -50,6 +50,11 @@ public class SWInventory {
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);
}
@ -116,7 +121,7 @@ public class SWInventory {
}
public void close() {
new CloseInventoryPacket(player).send(player);
new CloseInventoryPacket(SteamwarUser.get(player).getId()).send(player);
}
public void setClose(InvCallback close) {