Add Stuff for Bungee GUI
Dieser Commit ist enthalten in:
Ursprung
3fe222ae9b
Commit
4565f7da7e
@ -0,0 +1,16 @@
|
||||
package de.steamwar.bungeecore.coms.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import de.steamwar.bungeecore.coms.receiver.Handler;
|
||||
|
||||
public class InventoryCallbackHandler extends Handler {
|
||||
@Override
|
||||
protected String getName() {
|
||||
return "InventoryCallback";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(ByteArrayDataInput byteArrayDataInput) {
|
||||
|
||||
}
|
||||
}
|
55
src/de/steamwar/bungeecore/coms/packets/InventoryPacket.java
Normale Datei
55
src/de/steamwar/bungeecore/coms/packets/InventoryPacket.java
Normale Datei
@ -0,0 +1,55 @@
|
||||
package de.steamwar.bungeecore.coms.packets;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.bungeecore.coms.packets.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.coms.sender.Packet;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public class InventoryPacket extends Packet {
|
||||
|
||||
String title;
|
||||
String name;
|
||||
String player;
|
||||
int size;
|
||||
SWItem[] items;
|
||||
|
||||
public InventoryPacket(int size, String title, String name, ProxiedPlayer player) {
|
||||
items = new SWItem[size];
|
||||
this.title = title;
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.player = player.getUniqueId().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Inventory";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
||||
byteArrayDataOutput.writeUTF(name);
|
||||
byteArrayDataOutput.writeUTF(player);
|
||||
byteArrayDataOutput.writeUTF(title);
|
||||
byteArrayDataOutput.writeInt(size);
|
||||
byteArrayDataOutput.writeInt(items.length);
|
||||
for (SWItem item:
|
||||
items) {
|
||||
if(item == null)
|
||||
byteArrayDataOutput.writeUTF(item.writeToString());
|
||||
}
|
||||
}
|
||||
|
||||
public void addItem(SWItem item) {
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null) {
|
||||
items[i] = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setItem(int index, SWItem item) {
|
||||
items[index] = item;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package de.steamwar.bungeecore.coms.packets.inventory;
|
||||
|
||||
public class SWInventory {
|
||||
}
|
81
src/de/steamwar/bungeecore/coms/packets/inventory/SWItem.java
Normale Datei
81
src/de/steamwar/bungeecore/coms/packets/inventory/SWItem.java
Normale Datei
@ -0,0 +1,81 @@
|
||||
package de.steamwar.bungeecore.coms.packets.inventory;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SWItem {
|
||||
|
||||
String material, title, skullOwner;
|
||||
boolean enchanted, hideAttributes;
|
||||
int position;
|
||||
List<String> lore;
|
||||
|
||||
public SWItem(String material, int position, String title) {
|
||||
this.material = material;
|
||||
lore = new ArrayList<>();
|
||||
this.position = position;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public void setMaterial(String material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getSkullOwner() {
|
||||
return skullOwner;
|
||||
}
|
||||
|
||||
public void setSkullOwner(String skullOwner) {
|
||||
this.skullOwner = skullOwner;
|
||||
}
|
||||
|
||||
public boolean isEnchanted() {
|
||||
return enchanted;
|
||||
}
|
||||
|
||||
public void setEnchanted(boolean enchanted) {
|
||||
this.enchanted = enchanted;
|
||||
}
|
||||
|
||||
public boolean isHideAttributes() {
|
||||
return hideAttributes;
|
||||
}
|
||||
|
||||
public void setHideAttributes(boolean hideAttributes) {
|
||||
this.hideAttributes = hideAttributes;
|
||||
}
|
||||
|
||||
public void addLore(String lore) {
|
||||
this.lore.add(lore);
|
||||
}
|
||||
|
||||
public String writeToString() {
|
||||
JsonObject object = new JsonObject();
|
||||
object.addProperty("material", material);
|
||||
object.addProperty("position", position);
|
||||
object.addProperty("title", title);
|
||||
if(skullOwner != null)
|
||||
object.addProperty("skullOwner", skullOwner);
|
||||
if(enchanted)
|
||||
object.addProperty("enchanted", true);
|
||||
if(hideAttributes)
|
||||
object.addProperty("hideAttributes", true);
|
||||
if(!lore.isEmpty()) {
|
||||
JsonArray array = new JsonArray();
|
||||
for (String lores:
|
||||
lore) {
|
||||
array.add(lores);
|
||||
}
|
||||
object.add("lore", array);
|
||||
}
|
||||
|
||||
return object.getAsString();
|
||||
}
|
||||
}
|
@ -16,5 +16,6 @@ public abstract class Packet {
|
||||
|
||||
public abstract String getName();
|
||||
|
||||
//TODO Write Variables Automatic
|
||||
public abstract void writeVars(ByteArrayDataOutput byteArrayDataOutput);
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public class PacketSender {
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren