Add Fix
Dieser Commit ist enthalten in:
Ursprung
4b4d5f92bf
Commit
3efe00c16f
@ -20,15 +20,9 @@
|
|||||||
package de.steamwar.sql;
|
package de.steamwar.sql;
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import de.steamwar.core.VersionedCallable;
|
|
||||||
import de.steamwar.core.VersionedRunnable;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.sql.Blob;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -33,15 +33,12 @@ import java.util.*;
|
|||||||
|
|
||||||
public class SchematicNode {
|
public class SchematicNode {
|
||||||
|
|
||||||
private static final String DIR_TYPE = "directory";
|
|
||||||
public static final int ROOT_DIR = 0;
|
|
||||||
|
|
||||||
public static SchematicNode createSchematic(int owner, String name, int parent) {
|
public static SchematicNode createSchematic(int owner, String name, int parent) {
|
||||||
return createSchematicNode(owner, name, parent, SchematicType.Normal.toDB(), "");
|
return createSchematicNode(owner, name, parent, SchematicType.Normal.toDB(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode createSchematicDirectory(int owner, String name, int parent) {
|
public static SchematicNode createSchematicDirectory(int owner, String name, int parent) {
|
||||||
return createSchematicNode(owner, name, parent, DIR_TYPE, "");
|
return createSchematicNode(owner, name, parent, null, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode createSchematicNode(int owner, String name, int parent, String type, String item) {
|
public static SchematicNode createSchematicNode(int owner, String name, int parent, String type, String item) {
|
||||||
@ -222,6 +219,7 @@ public class SchematicNode {
|
|||||||
private String type;
|
private String type;
|
||||||
private boolean schemFormat;
|
private boolean schemFormat;
|
||||||
private int rank;
|
private int rank;
|
||||||
|
private boolean isDir;
|
||||||
|
|
||||||
private SchematicNode(ResultSet set) throws SQLException {
|
private SchematicNode(ResultSet set) throws SQLException {
|
||||||
id = set.getInt("NodeId");
|
id = set.getInt("NodeId");
|
||||||
@ -230,8 +228,13 @@ public class SchematicNode {
|
|||||||
parent = set.getInt("ParentNode");
|
parent = set.getInt("ParentNode");
|
||||||
item = set.getString("NodeItem");
|
item = set.getString("NodeItem");
|
||||||
type = set.getString("NodeType");
|
type = set.getString("NodeType");
|
||||||
|
if(type != null) {
|
||||||
|
isDir = false;
|
||||||
rank = set.getInt("NodeRank");
|
rank = set.getInt("NodeRank");
|
||||||
schemFormat = set.getBoolean("SchemFormat");
|
schemFormat = set.getBoolean("SchemFormat");
|
||||||
|
}else {
|
||||||
|
isDir = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -270,27 +273,37 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
this.type = type;
|
this.type = type;
|
||||||
updateDB();
|
updateDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDir() {
|
public boolean isDir() {
|
||||||
return type.equals(DIR_TYPE);
|
return isDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getSchemFormat() {
|
public boolean getSchemFormat() {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
return schemFormat;
|
return schemFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRank() {
|
public int getRank() {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
return rank;
|
return rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRank(int rank) {
|
public void setRank(int rank) {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
this.rank = rank;
|
this.rank = rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +338,8 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Clipboard load() throws IOException, NoClipboardException {
|
public Clipboard load() throws IOException, NoClipboardException {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
ResultSet rs = SQL.select("SELECT NodeData FROM SchematicNode WHERE NodeId = ?", id);
|
ResultSet rs = SQL.select("SELECT NodeData FROM SchematicNode WHERE NodeId = ?", id);
|
||||||
try {
|
try {
|
||||||
rs.next();
|
rs.next();
|
||||||
@ -340,6 +355,8 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
public void loadToPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
ResultSet rs = SQL.select("SELECT NodeData FROM SchematicNode WHERE NodeId = ?", id);
|
ResultSet rs = SQL.select("SELECT NodeData FROM SchematicNode WHERE NodeId = ?", id);
|
||||||
try {
|
try {
|
||||||
rs.next();
|
rs.next();
|
||||||
@ -355,14 +372,20 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
|
public void saveOldFormatFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
saveFromPlayer(player, false);
|
saveFromPlayer(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
|
public void saveFromPlayer(Player player) throws IOException, NoClipboardException {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
saveFromPlayer(player, true);
|
saveFromPlayer(player, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFromBytes(byte[] bytes, boolean newFormat) {
|
public void saveFromBytes(byte[] bytes, boolean newFormat) {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
Blob blob = SQL.blob();
|
Blob blob = SQL.blob();
|
||||||
try {
|
try {
|
||||||
blob.setBytes(1, bytes);
|
blob.setBytes(1, bytes);
|
||||||
@ -373,6 +396,8 @@ public class SchematicNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
|
private void saveFromPlayer(Player player, boolean newFormat) throws IOException, NoClipboardException {
|
||||||
|
if(isDir)
|
||||||
|
throw new SecurityException("Node is Directory");
|
||||||
Blob blob = SQL.blob();
|
Blob blob = SQL.blob();
|
||||||
VersionedRunnable.call(new VersionedRunnable(() -> {
|
VersionedRunnable.call(new VersionedRunnable(() -> {
|
||||||
try {
|
try {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren