Dieser Commit ist enthalten in:
Ursprung
8a1076b30d
Commit
af1b06b9ed
@ -21,7 +21,6 @@ package de.steamwar.comms.packets;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import de.steamwar.comms.PacketIdManager;
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
@ -38,13 +37,6 @@ public class PrepareSchemPacket extends SpigotPacket{
|
||||
this.schematicType = schematicType;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PrepareSchemPacket(SteamwarUser user, Schematic schematic, SchematicType schematicType) {
|
||||
this.user = user;
|
||||
this.schematic = schematic.getNode();
|
||||
this.schematicType = schematicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getName() {
|
||||
return PacketIdManager.PREPARE_SCHEM;
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package de.steamwar.inventory;
|
||||
|
||||
import de.steamwar.sql.Schematic;
|
||||
import de.steamwar.sql.SchematicNode;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -28,7 +27,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SWListInv<T> extends SWInventory {
|
||||
|
||||
@ -138,11 +136,6 @@ public class SWListInv<T> extends SWInventory {
|
||||
}
|
||||
return schemList;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static List<SWListEntry<Schematic>> getSchemList(SchematicType type, int steamwarUserId){
|
||||
return getSchemnodeList(type, steamwarUserId).stream().map(schematicNodeSWListEntry -> new SWListEntry<Schematic>(schematicNodeSWListEntry.getItem(), Schematic.wrap(schematicNodeSWListEntry.getObject()))).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean sizeBiggerMax(){
|
||||
return dynamicSize ? elements.size() > 54 : elements.size() > 45;
|
||||
|
@ -1,29 +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.sql;
|
||||
|
||||
public class DownloadSchematic {
|
||||
private DownloadSchematic(){}
|
||||
|
||||
@Deprecated
|
||||
public static String getLink(Schematic schem){
|
||||
return NodeDownload.getLink(schem.getNode());
|
||||
}
|
||||
}
|
@ -31,8 +31,8 @@ import java.util.function.Consumer;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
private static final SQL.Statement getPunishment = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1");
|
||||
private static final SQL.Statement getPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
|
||||
private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1");
|
||||
private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)");
|
||||
|
||||
public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) {
|
||||
return getPunishment.select(rs -> {
|
||||
|
@ -1,204 +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.sql;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.WorldEditWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Deprecated
|
||||
public class Schematic {
|
||||
|
||||
private static final Statement getSchemsOfType = new Statement("SELECT DISTINCT s.SchemID, s.SchemName, s.SchemOwner, s.Item, s.SchemType, s.Rank, s.SchemFormat FROM Schematic s LEFT JOIN SchemMember sm ON sm.SchemName = s.SchemName AND sm.SchemOwner = s.SchemOwner WHERE s.SchemType = ? AND (s.SchemOwner = ? OR sm.Member = ?) ORDER BY s.SchemName");
|
||||
|
||||
private final SchematicNode node;
|
||||
|
||||
private Schematic(SchematicNode node) {
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public static Schematic wrap(SchematicNode node) {
|
||||
return new Schematic(node);
|
||||
}
|
||||
|
||||
public static void createSchem(String schemName, UUID schemOwner, String item, SchematicType schemType){
|
||||
createSchem(schemName, SteamwarUser.get(schemOwner).getId(), item, schemType);
|
||||
}
|
||||
|
||||
public static void createSchem(String schemName, int schemOwner, String item, SchematicType schemType){
|
||||
SchematicNode.createSchematicNode(schemOwner, schemName, null, schemType.toDB(), item);
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(String schemName, UUID schemOwner){
|
||||
return getSchemFromDB(schemName, SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(String schemName, int schemOwner){
|
||||
SchematicNode node = SchematicNode.getSchematicNode(schemOwner, schemName, 0);
|
||||
if(node != null) {
|
||||
return new Schematic(node);
|
||||
} else {
|
||||
Optional<SchematicNode> n = SchematicNode.getSchematicsAccessibleByUser(schemOwner, 0).stream().filter(node1 -> node1.getName().equals(schemName)).findAny();
|
||||
if(n.isPresent()) {
|
||||
return new Schematic(n.get());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Schematic getSchemFromDB(int schemID){
|
||||
SchematicNode node = SchematicNode.getSchematicNode(schemID);
|
||||
if(node != null) {
|
||||
return new Schematic(node);
|
||||
} else {
|
||||
throw new SecurityException("Failed to load Schematics");
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsAccessibleByUser(UUID schemOwner){
|
||||
return getSchemsAccessibleByUser(SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsAccessibleByUser(int schemOwner){
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
SchematicNode.getSchematicsAccessibleByUser(schemOwner, null)
|
||||
.forEach(node1 -> {
|
||||
if (!node1.isDir()) schematics.add(new Schematic(node1));
|
||||
});
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsOfType(UUID schemOwner, SchematicType schemType){
|
||||
return getSchemsOfType(SteamwarUser.get(schemOwner).getId(), schemType);
|
||||
}
|
||||
|
||||
public static List<Schematic> getSchemsOfType(int schemOwner, SchematicType schemType){
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
SchematicNode.getAllAccessibleSchematicsOfType(schemOwner, schemType.toDB())
|
||||
.forEach(node1 -> {
|
||||
if (!node1.isDir()) schematics.add(new Schematic(node1));
|
||||
});
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
||||
List<Schematic> schematics = new ArrayList<>();
|
||||
SchematicNode.getAllSchematicsOfType(schemType.toDB())
|
||||
.forEach(node1 -> schematics.add(new Schematic(node1)));
|
||||
return schematics;
|
||||
}
|
||||
|
||||
public int getSchemID() {
|
||||
return node.getId();
|
||||
}
|
||||
|
||||
public String getSchemName() {
|
||||
return node.getName();
|
||||
}
|
||||
|
||||
public int getSchemOwner() {
|
||||
return node.getOwner();
|
||||
}
|
||||
|
||||
public int getRank(){
|
||||
return node.getRank();
|
||||
}
|
||||
|
||||
public String getItem() {
|
||||
return node.getItem();
|
||||
}
|
||||
|
||||
public void setItem(String item) {
|
||||
node.setItem(item);
|
||||
}
|
||||
|
||||
public void setRank(int rank){
|
||||
node.setRank(rank);
|
||||
}
|
||||
|
||||
public SchematicType getSchemType() {
|
||||
return node.getSchemtype();
|
||||
}
|
||||
|
||||
public void setSchemType(SchematicType schemType) {
|
||||
node.setType(schemType.toDB());
|
||||
}
|
||||
|
||||
public boolean availible(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public InputStream schemData() throws IOException {
|
||||
return node.schemData();
|
||||
}
|
||||
|
||||
public static Clipboard clipboardFromStream(InputStream is, boolean schemFormat) {
|
||||
try {
|
||||
return WorldEditWrapper.impl.getClipboard(is, schemFormat);
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not read schem", e);
|
||||
}
|
||||
}
|
||||
|
||||
public Clipboard load() throws IOException, NoClipboardException {
|
||||
return clipboardFromStream(schemData(), node.getSchemFormat());
|
||||
}
|
||||
|
||||
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
||||
InputStream is = schemData();
|
||||
WorldEditWrapper.impl.setPlayerClipboard(player, is, node.getSchemFormat());
|
||||
}
|
||||
|
||||
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||
saveFromPlayer(player, false);
|
||||
}
|
||||
|
||||
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||
saveFromPlayer(player, Core.getVersion() > 12);
|
||||
}
|
||||
|
||||
public void saveFromBytes(byte[] bytes, boolean newFormat) {
|
||||
node.saveFromBytes(bytes, newFormat);
|
||||
}
|
||||
|
||||
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
|
||||
node.saveFromPlayer(player, newFormat);
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
node.delete();
|
||||
}
|
||||
|
||||
public SchematicNode getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static class WrongVersionException extends Exception{}
|
||||
}
|
@ -1,96 +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.sql;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Deprecated
|
||||
public class SchematicMember {
|
||||
|
||||
private final NodeMember member;
|
||||
|
||||
private SchematicMember(NodeMember member){
|
||||
this.member = member;
|
||||
}
|
||||
|
||||
public SchematicMember(String schemName, int schemOwner, int schemMember){
|
||||
this(NodeMember.createNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), schemMember));
|
||||
}
|
||||
|
||||
public SchematicMember(String schemName, UUID schemOwner, UUID schemMember){
|
||||
this(NodeMember.createNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), SteamwarUser.get(schemMember).getId()));
|
||||
}
|
||||
|
||||
public static SchematicMember getSchemMemberFromDB(String schemName, UUID schemOwner, UUID schemMember){
|
||||
return getSchemMemberFromDB(schemName, SteamwarUser.get(schemOwner).getId(), SteamwarUser.get(schemMember).getId());
|
||||
}
|
||||
|
||||
public static SchematicMember getSchemMemberFromDB(String schemName, int schemOwner, int schemMember){
|
||||
NodeMember member = NodeMember.getNodeMember(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID(), schemMember);
|
||||
if(member == null) {
|
||||
return null;
|
||||
}
|
||||
return new SchematicMember(member);
|
||||
}
|
||||
|
||||
public static SchematicMember getMemberBySchematic(String schemName, int schemMember){
|
||||
Optional<NodeMember> nodeMember = NodeMember.getSchematics(schemMember)
|
||||
.stream().filter(member1 -> SchematicNode.getSchematicNode(member1.getNode()).getName().equalsIgnoreCase(schemName)).findFirst();
|
||||
return nodeMember.map(SchematicMember::new).orElse(null);
|
||||
}
|
||||
|
||||
public static List<SchematicMember> getSchemMembers(String schemName, UUID schemOwner){
|
||||
return getSchemMembers(schemName, SteamwarUser.get(schemOwner).getId());
|
||||
}
|
||||
|
||||
public static List<SchematicMember> getSchemMembers(String schemName, int schemOwner){
|
||||
List<SchematicMember> members = new ArrayList<>();
|
||||
NodeMember.getNodeMembers(Schematic.getSchemFromDB(schemName, schemOwner).getSchemID())
|
||||
.forEach(member1 -> members.add(new SchematicMember(member1)));
|
||||
return members;
|
||||
}
|
||||
|
||||
public static List<SchematicMember> getAccessibleSchems(UUID schemMember){
|
||||
return getAccessibleSchems(SteamwarUser.get(schemMember).getId());
|
||||
}
|
||||
|
||||
public static List<SchematicMember> getAccessibleSchems(int schemMember){
|
||||
List<SchematicMember> members = new ArrayList<>();
|
||||
NodeMember.getSchematics(schemMember)
|
||||
.forEach(member1 -> members.add(new SchematicMember(member1)));
|
||||
return members;
|
||||
}
|
||||
|
||||
public int getSchemOwner() {
|
||||
return SchematicNode.getSchematicNode(member.getNode()).getOwner();
|
||||
}
|
||||
|
||||
public String getSchemName() {
|
||||
return SchematicNode.getSchematicNode(member.getNode()).getName();
|
||||
}
|
||||
|
||||
public int getMember() {
|
||||
return member.getMember();
|
||||
}
|
||||
|
||||
public void remove(){
|
||||
member.delete();
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren