diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java
index 98aad17..043ddfb 100644
--- a/src/de/steamwar/bungeecore/commands/BauCommand.java
+++ b/src/de/steamwar/bungeecore/commands/BauCommand.java
@@ -228,41 +228,33 @@ public class BauCommand {
}
private static void delete(ProxiedPlayer p, String[] command){
- SWInventory inventory = new SWInventory(p, 9, "§e/Bau delete Bestätigen");
- inventory.addItem(0, new SWItem(0, "§cAbbrechen", 1), click -> {
- inventory.close();
- });
- inventory.addItem(8, new SWItem(8, "§aLöchen", 10), click -> {
+ 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 -> {
if(bau15(p, command, 2)){
- BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§aDeine Welt wird zurückgesetzt.");
- ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
- for (Subserver subserver : Subserver.getServerList()) {
- if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) {
- subserver.stop();
- break;
- }
- }
- SteamwarUser user = SteamwarUser.get(p.getUniqueId());
- File directory = new File(BungeeCore.USERWORLDS15 + user.getId());
- del(directory);
- });
+ SteamwarUser user = SteamwarUser.get(p.getUniqueId());
+ deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());
}else{
- BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§aDeine Welt wird zurückgesetzt.");
- ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
- for (Subserver subserver : Subserver.getServerList()) {
- if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId())) {
- subserver.stop();
- break;
- }
- }
- File directory = new File(BungeeCore.WORLD_FOLDER + p.getUniqueId().toString());
- del(directory);
- });
+ deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString());
}
});
inventory.open();
}
+ private static void deleteWorld(ProxiedPlayer player, String world) {
+ BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDeine Welt wird zurückgesetzt.");
+ ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
+ for (Subserver subserver : Subserver.getServerList()) {
+ if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(player.getUniqueId())) {
+ subserver.stop();
+ break;
+ }
+ }
+ File directory = new File(world);
+ del(directory);
+ });
+ }
+
private static void testarena(ProxiedPlayer p, String[] command){
FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
for (Subserver subserver : Subserver.getServerList()) {
diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java
index 13f951a..32d25e3 100644
--- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java
+++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java
@@ -1,3 +1,22 @@
+/*
+ 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 .
+*/
+
package de.steamwar.bungeecore.comms;
public class PacketIdManager {
diff --git a/src/de/steamwar/bungeecore/comms/packets/InventoryPacket.java b/src/de/steamwar/bungeecore/comms/packets/InventoryPacket.java
index db5282a..4a37d1c 100644
--- a/src/de/steamwar/bungeecore/comms/packets/InventoryPacket.java
+++ b/src/de/steamwar/bungeecore/comms/packets/InventoryPacket.java
@@ -23,19 +23,21 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.steamwar.bungeecore.comms.PacketIdManager;
+import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.comms.BungeePacket;
import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.HashMap;
+import java.util.Map;
public class InventoryPacket extends BungeePacket {
final String title;
final int player;
final int size;
- final HashMap items;
+ final Map items;
public InventoryPacket(int size, String title, ProxiedPlayer player) {
items = new HashMap<>();
@@ -44,6 +46,13 @@ public class InventoryPacket extends BungeePacket {
this.player = SteamwarUser.get(player).getId();
}
+ public InventoryPacket(SWInventory inventory) {
+ items = inventory.getItems();
+ this.title = inventory.getTitle();
+ this.size = inventory.getSize();
+ this.player = SteamwarUser.get(inventory.getPlayer()).getId();
+ }
+
@Override
public int getId() {
return PacketIdManager.INVENTORY_PACKET;
diff --git a/src/de/steamwar/bungeecore/inventory/SWInventory.java b/src/de/steamwar/bungeecore/inventory/SWInventory.java
index c76b6a4..6a308cf 100644
--- a/src/de/steamwar/bungeecore/inventory/SWInventory.java
+++ b/src/de/steamwar/bungeecore/inventory/SWInventory.java
@@ -96,6 +96,10 @@ public class SWInventory {
return next;
}
+ public Map getItems() {
+ return itemMap;
+ }
+
public void handleCallback(InvCallback.ClickType type, int pos) {
itemMap.get(pos).getCallback().clicked(type);
}
@@ -107,14 +111,27 @@ public class SWInventory {
}
public void open() {
- InventoryPacket inv = new InventoryPacket(size, title, player);
- for (Map.Entry entry : itemMap.entrySet()) {
- inv.setItem(entry.getKey(), entry.getValue());
- }
+ InventoryPacket inv = new InventoryPacket(this);
inv.send(player);
}
public void close() {
new CloseInventoryPacket(player).send(player);
}
+
+ public void setClose(InvCallback close) {
+ this.close = close;
+ }
+
+ public ProxiedPlayer getPlayer() {
+ return player;
+ }
+
+ public void setPlayer(ProxiedPlayer player) {
+ this.player = player;
+ }
+
+ public String getTitle() {
+ return title;
+ }
}
diff --git a/src/de/steamwar/bungeecore/sql/Schematic.java b/src/de/steamwar/bungeecore/sql/Schematic.java
index 37243da..9d25a38 100644
--- a/src/de/steamwar/bungeecore/sql/Schematic.java
+++ b/src/de/steamwar/bungeecore/sql/Schematic.java
@@ -30,12 +30,14 @@ public class Schematic {
private final String schemName;
private final int schemOwner;
private SchematicType schemType;
+ private String schemItem;
private Schematic(ResultSet rs) throws SQLException {
this.schemID = rs.getInt("SchemID");
this.schemName = rs.getString("SchemName");
this.schemOwner = rs.getInt("SchemOwner");
this.schemType = SchematicType.fromDB(rs.getString("SchemType"));
+ this.schemItem = rs.getString("Item");
}
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
@@ -43,7 +45,7 @@ public class Schematic {
}
public static Schematic getSchemFromDB(String schemName, int schemOwner){
- ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemName = ? AND SchemOwner = ?", schemName, schemOwner);
+ ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType, Item FROM Schematic WHERE SchemName = ? AND SchemOwner = ?", schemName, schemOwner);
try {
if(schematic == null || !schematic.next()){
return null;
@@ -55,7 +57,7 @@ public class Schematic {
}
public static Schematic getSchemFromDB(int schemID){
- ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemID = ?", schemID);
+ ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType, Item FROM Schematic WHERE SchemID = ?", schemID);
try {
if(!schematic.next())
throw new SecurityException("Failed loading schematic " + schemID);
@@ -67,7 +69,7 @@ public class Schematic {
public static List getAllSchemsOfType(SchematicType schemType){
try{
- ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ?", schemType.toDB());
+ ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType, Item FROM Schematic WHERE SchemType = ?", schemType.toDB());
List schematics = new ArrayList<>();
while(schematic.next()){
schematics.add(new Schematic(schematic));
@@ -80,7 +82,7 @@ public class Schematic {
public static List getSchemsOfType(int userId, SchematicType schemType){
try{
- ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType FROM Schematic WHERE SchemType = ? AND SchemOwner = ?", schemType.toDB(), userId);
+ ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, SchemType, Item FROM Schematic WHERE SchemType = ? AND SchemOwner = ?", schemType.toDB(), userId);
List schematics = new ArrayList<>();
while(schematic.next()){
schematics.add(new Schematic(schematic));
@@ -93,7 +95,7 @@ public class Schematic {
public static List getSchemsAccessibleByUser(int schemOwner){
try{
- ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, Rank, SchemFormat FROM Schematic WHERE SchemOwner = ? ORDER BY SchemName", schemOwner);
+ ResultSet schematic = SQL.select("SELECT SchemID, SchemName, SchemOwner, Item, SchemType, Rank, SchemFormat, Item FROM Schematic WHERE SchemOwner = ? ORDER BY SchemName", schemOwner);
List schematics = new ArrayList<>();
while(schematic.next()){
schematics.add(new Schematic(schematic));
@@ -120,17 +122,12 @@ public class Schematic {
return schemOwner;
}
- public SchematicType getSchemType() {
- return schemType;
+ public String getSchemItem() {
+ return schemItem;
}
- public String getSchemItem() {
- try {
- ResultSet set = SQL.select("SELECT Item WHERE SchemID = ?", schemID);
- return set.getString("Item");
- } catch (SQLException throwables) {
- throw new SecurityException("Could not load Item");
- }
+ public SchematicType getSchemType() {
+ return schemType;
}
public void setSchemType(SchematicType schemType) {