Fixing Bugs
Dieser Commit ist enthalten in:
Ursprung
43eb2c3293
Commit
3472f71102
@ -23,12 +23,9 @@ import com.google.common.io.ByteArrayDataInput;
|
|||||||
import com.google.common.io.ByteStreams;
|
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.comms.packets.MaterialsReturnPacket;
|
|
||||||
import de.steamwar.comms.packets.PluginCallbackPacket;
|
import de.steamwar.comms.packets.PluginCallbackPacket;
|
||||||
import de.steamwar.core.Core;
|
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.sql.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.SoundCategory;
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -61,11 +58,6 @@ public class BungeeReceiver implements PluginMessageListener {
|
|||||||
Player player = Bukkit.getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUUID());
|
Player player = Bukkit.getPlayer(SteamwarUser.get(byteArrayDataInput.readInt()).getUUID());
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
});
|
});
|
||||||
registerHandler(PacketIdManager.MATERIALS_GET_PACKET, byteArrayDataInput -> {
|
|
||||||
UUID id = UUID.fromString(byteArrayDataInput.readUTF());
|
|
||||||
MaterialsReturnPacket packet = new MaterialsReturnPacket(id, Material.values());
|
|
||||||
packet.send(Bukkit.getOnlinePlayers().stream().limit(1).collect(Collectors.toList()).get(0));
|
|
||||||
});
|
|
||||||
registerHandler(PacketIdManager.CHECK_PLUGIN, byteArrayDataInput -> {
|
registerHandler(PacketIdManager.CHECK_PLUGIN, byteArrayDataInput -> {
|
||||||
String id = byteArrayDataInput.readUTF();
|
String id = byteArrayDataInput.readUTF();
|
||||||
String plugin = byteArrayDataInput.readUTF();
|
String plugin = byteArrayDataInput.readUTF();
|
||||||
|
@ -28,6 +28,7 @@ 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 +46,17 @@ 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 -> {
|
||||||
|
if(Bukkit.getPlayer(player).getOpenInventory().getType() == InventoryType.CRAFTING)
|
||||||
|
new InventoryCallbackPacket(player).send(Bukkit.getPlayer(player));
|
||||||
|
});
|
||||||
inventory.open();
|
inventory.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.comms.packets;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import de.steamwar.comms.PacketIdManager;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class MaterialsReturnPacket extends SpigotPacket{
|
|
||||||
|
|
||||||
final UUID id;
|
|
||||||
final Material[] array;
|
|
||||||
|
|
||||||
public MaterialsReturnPacket(UUID id, Material[] array) {
|
|
||||||
this.id = id;
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getName() {
|
|
||||||
return PacketIdManager.MATERIALS_RETURN_PACKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeVars(ByteArrayDataOutput byteArrayDataOutput) {
|
|
||||||
byteArrayDataOutput.writeUTF(id.toString());
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
for (int i = 0; i < this.array.length; i++) {
|
|
||||||
if(new ItemStack(this.array[i]).getItemMeta() != null && this.array[i].isItem())
|
|
||||||
array.add(this.array[i].name());
|
|
||||||
}
|
|
||||||
byteArrayDataOutput.writeUTF(array.toString());
|
|
||||||
}
|
|
||||||
}
|
|
@ -61,8 +61,8 @@ public class Schematic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createSchem(String schemName, int schemOwner, String item, SchematicType schemType){
|
public static void createSchem(String schemName, int schemOwner, String item, SchematicType schemType){
|
||||||
SQL.update("INSERT INTO Schematic (SchemName, SchemOwner, Item, SchemType) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), SchemType = VALUES(SchemType)",
|
SQL.update("INSERT INTO Schematic (SchemName, SchemOwner, Item, SchemType, Rank) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE Item = VALUES(Item), SchemType = VALUES(SchemType)",
|
||||||
schemName, schemOwner, item, schemType.toDB());
|
schemName, schemOwner, item, schemType.toDB(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
|
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren