Archiviert
1
0
Dieser Commit ist enthalten in:
Chaoscaot 2020-09-24 14:10:15 +02:00
Ursprung 0da5db17fb
Commit 30290b33b6
5 geänderte Dateien mit 81 neuen und 47 gelöschten Zeilen

Datei anzeigen

@ -228,41 +228,33 @@ public class BauCommand {
} }
private static void delete(ProxiedPlayer p, String[] command){ private static void delete(ProxiedPlayer p, String[] command){
SWInventory inventory = new SWInventory(p, 9, "§e/Bau delete Bestätigen"); SWInventory inventory = new SWInventory(p, 9, "§eWirklich Welt löschen?");
inventory.addItem(0, new SWItem(0, "§cAbbrechen", 1), click -> { inventory.addItem(8, new SWItem(8, "§cAbbrechen", 1), click -> inventory.close());
inventory.close(); inventory.addItem(1, new SWItem(1, "§aLöchen", 10), click -> {
});
inventory.addItem(8, new SWItem(8, "§aLöchen", 10), click -> {
if(bau15(p, command, 2)){ if(bau15(p, command, 2)){
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§aDeine Welt wird zurückgesetzt."); SteamwarUser user = SteamwarUser.get(p.getUniqueId());
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());
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);
});
}else{ }else{
BungeeCore.send(p, BungeeCore.CHAT_PREFIX + "§aDeine Welt wird zurückgesetzt."); deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString());
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);
});
} }
}); });
inventory.open(); 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){ 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(), () -> { FightCommand.createArena(p, "/bau testarena ", command, 2, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
for (Subserver subserver : Subserver.getServerList()) { for (Subserver subserver : Subserver.getServerList()) {

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bungeecore.comms; package de.steamwar.bungeecore.comms;
public class PacketIdManager { public class PacketIdManager {

Datei anzeigen

@ -23,19 +23,21 @@ import com.google.common.io.ByteArrayDataOutput;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.steamwar.bungeecore.comms.PacketIdManager; import de.steamwar.bungeecore.comms.PacketIdManager;
import de.steamwar.bungeecore.inventory.SWInventory;
import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWItem;
import de.steamwar.bungeecore.comms.BungeePacket; import de.steamwar.bungeecore.comms.BungeePacket;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class InventoryPacket extends BungeePacket { public class InventoryPacket extends BungeePacket {
final String title; final String title;
final int player; final int player;
final int size; final int size;
final HashMap<Integer, SWItem> items; final Map<Integer, SWItem> items;
public InventoryPacket(int size, String title, ProxiedPlayer player) { public InventoryPacket(int size, String title, ProxiedPlayer player) {
items = new HashMap<>(); items = new HashMap<>();
@ -44,6 +46,13 @@ public class InventoryPacket extends BungeePacket {
this.player = SteamwarUser.get(player).getId(); 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 @Override
public int getId() { public int getId() {
return PacketIdManager.INVENTORY_PACKET; return PacketIdManager.INVENTORY_PACKET;

Datei anzeigen

@ -96,6 +96,10 @@ public class SWInventory {
return next; return next;
} }
public Map<Integer, SWItem> getItems() {
return itemMap;
}
public void handleCallback(InvCallback.ClickType type, int pos) { public void handleCallback(InvCallback.ClickType type, int pos) {
itemMap.get(pos).getCallback().clicked(type); itemMap.get(pos).getCallback().clicked(type);
} }
@ -107,14 +111,27 @@ public class SWInventory {
} }
public void open() { public void open() {
InventoryPacket inv = new InventoryPacket(size, title, player); InventoryPacket inv = new InventoryPacket(this);
for (Map.Entry<Integer, SWItem> entry : itemMap.entrySet()) {
inv.setItem(entry.getKey(), entry.getValue());
}
inv.send(player); inv.send(player);
} }
public void close() { public void close() {
new CloseInventoryPacket(player).send(player); 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;
}
} }

Datei anzeigen

@ -30,12 +30,14 @@ public class Schematic {
private final String schemName; private final String schemName;
private final int schemOwner; private final int schemOwner;
private SchematicType schemType; private SchematicType schemType;
private String schemItem;
private Schematic(ResultSet rs) throws SQLException { private Schematic(ResultSet rs) throws SQLException {
this.schemID = rs.getInt("SchemID"); this.schemID = rs.getInt("SchemID");
this.schemName = rs.getString("SchemName"); this.schemName = rs.getString("SchemName");
this.schemOwner = rs.getInt("SchemOwner"); this.schemOwner = rs.getInt("SchemOwner");
this.schemType = SchematicType.fromDB(rs.getString("SchemType")); this.schemType = SchematicType.fromDB(rs.getString("SchemType"));
this.schemItem = rs.getString("Item");
} }
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){ public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
@ -43,7 +45,7 @@ public class Schematic {
} }
public static Schematic getSchemFromDB(String schemName, int schemOwner){ 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 { try {
if(schematic == null || !schematic.next()){ if(schematic == null || !schematic.next()){
return null; return null;
@ -55,7 +57,7 @@ public class Schematic {
} }
public static Schematic getSchemFromDB(int schemID){ 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 { try {
if(!schematic.next()) if(!schematic.next())
throw new SecurityException("Failed loading schematic " + schemID); throw new SecurityException("Failed loading schematic " + schemID);
@ -67,7 +69,7 @@ public class Schematic {
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){ public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
try{ 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<Schematic> schematics = new ArrayList<>(); List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){ while(schematic.next()){
schematics.add(new Schematic(schematic)); schematics.add(new Schematic(schematic));
@ -80,7 +82,7 @@ public class Schematic {
public static List<Schematic> getSchemsOfType(int userId, SchematicType schemType){ public static List<Schematic> getSchemsOfType(int userId, SchematicType schemType){
try{ 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<Schematic> schematics = new ArrayList<>(); List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){ while(schematic.next()){
schematics.add(new Schematic(schematic)); schematics.add(new Schematic(schematic));
@ -93,7 +95,7 @@ public class Schematic {
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){ public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
try{ 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<Schematic> schematics = new ArrayList<>(); List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){ while(schematic.next()){
schematics.add(new Schematic(schematic)); schematics.add(new Schematic(schematic));
@ -120,17 +122,12 @@ public class Schematic {
return schemOwner; return schemOwner;
} }
public SchematicType getSchemType() { public String getSchemItem() {
return schemType; return schemItem;
} }
public String getSchemItem() { public SchematicType getSchemType() {
try { return schemType;
ResultSet set = SQL.select("SELECT Item WHERE SchemID = ?", schemID);
return set.getString("Item");
} catch (SQLException throwables) {
throw new SecurityException("Could not load Item");
}
} }
public void setSchemType(SchematicType schemType) { public void setSchemType(SchematicType schemType) {