SchematicRework
Dieser Commit ist enthalten in:
Ursprung
6585a33b1e
Commit
7d14bc6ead
10
pom.xml
10
pom.xml
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigotmc-repo</id>
|
<id>steamwar</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://steamwar.de/maven/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
@ -47,9 +47,9 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -57,7 +57,7 @@ public class SWInventory implements Listener, Inventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, Material m, String name, List<String> lore, boolean e, InvCallback c){
|
public void setItem(int pos, Material m, String name, List<String> lore, boolean e, InvCallback c){
|
||||||
setItem(pos, m, (byte)0, name, new ArrayList<>(), false, c);
|
setItem(pos, m, (byte)0, name, lore, e, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int pos, Material m, byte meta, String name, List<String> lore, boolean e, InvCallback c){
|
public void setItem(int pos, Material m, byte meta, String name, List<String> lore, boolean e, InvCallback c){
|
||||||
|
@ -32,13 +32,17 @@ public class SWItem {
|
|||||||
public SWItem(Material material, byte meta, String name, List<String> lore, boolean enchanted, InvCallback c){
|
public SWItem(Material material, byte meta, String name, List<String> lore, boolean enchanted, InvCallback c){
|
||||||
itemStack = new ItemStack(material, 1, (short)0, meta);
|
itemStack = new ItemStack(material, 1, (short)0, meta);
|
||||||
itemMeta = itemStack.getItemMeta();
|
itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
|
if(itemMeta != null){
|
||||||
hideAttributes();
|
hideAttributes();
|
||||||
|
|
||||||
itemMeta.setDisplayName(name);
|
itemMeta.setDisplayName(name);
|
||||||
if(lore != null && !lore.isEmpty())
|
if(lore != null && !lore.isEmpty())
|
||||||
itemMeta.setLore(lore);
|
itemMeta.setLore(lore);
|
||||||
if(enchanted)
|
if(enchanted)
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
|
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
|
||||||
itemStack.setItemMeta(itemMeta);
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
}
|
||||||
callback = c;
|
callback = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,15 @@ public class Schematic {
|
|||||||
private String Item;
|
private String Item;
|
||||||
private SchematicType SchemType;
|
private SchematicType SchemType;
|
||||||
|
|
||||||
|
private Schematic(ResultSet rs) throws SQLException {
|
||||||
|
this(
|
||||||
|
rs.getString("SchemName"),
|
||||||
|
rs.getInt("SchemOwner"),
|
||||||
|
rs.getString("Item"),
|
||||||
|
SchematicType.fromDB(rs.getString("SchemType")),
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
private Schematic(String schemName, int schemOwner, String item, SchematicType schemType, boolean updateDB){
|
private Schematic(String schemName, int schemOwner, String item, SchematicType schemType, boolean updateDB){
|
||||||
SchemName = schemName;
|
SchemName = schemName;
|
||||||
SchemOwner = schemOwner;
|
SchemOwner = schemOwner;
|
||||||
@ -36,7 +45,7 @@ public class Schematic {
|
|||||||
sql.update("INSERT INTO Schematic" +
|
sql.update("INSERT INTO Schematic" +
|
||||||
" (SchemName, SchemOwner, Item, SchemType)" +
|
" (SchemName, SchemOwner, Item, SchemType)" +
|
||||||
" VALUES" +
|
" VALUES" +
|
||||||
" ('" + SchemName + "', '" + SchemOwner + "', '" + Item + "', '" + SchemType.name() + "')" +
|
" ('" + SchemName + "', '" + SchemOwner + "', '" + Item + "', '" + SchemType.toDB() + "')" +
|
||||||
" ON DUPLICATE KEY UPDATE" +
|
" ON DUPLICATE KEY UPDATE" +
|
||||||
" Item = VALUES(Item), SchemType = VALUES(SchemType)");
|
" Item = VALUES(Item), SchemType = VALUES(SchemType)");
|
||||||
}
|
}
|
||||||
@ -56,9 +65,7 @@ public class Schematic {
|
|||||||
}
|
}
|
||||||
return getSchemFromDB(schemName, member.getSchemOwner());
|
return getSchemFromDB(schemName, member.getSchemOwner());
|
||||||
}
|
}
|
||||||
String item = schematic.getString("Item");
|
return new Schematic(schematic);
|
||||||
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
|
|
||||||
return new Schematic(schemName, schemOwner, item, schemType, false);
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -74,10 +81,7 @@ public class Schematic {
|
|||||||
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
|
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
|
||||||
List<Schematic> schematics = new ArrayList<>();
|
List<Schematic> schematics = new ArrayList<>();
|
||||||
while(schematic.next()){
|
while(schematic.next()){
|
||||||
String schemName = schematic.getString("SchemName");
|
schematics.add(new Schematic(schematic));
|
||||||
String item = schematic.getString("Item");
|
|
||||||
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
|
|
||||||
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
|
|
||||||
}
|
}
|
||||||
List<SchematicMember> addedSchems = SchematicMember.getAccessibleSchems(schemOwner);
|
List<SchematicMember> addedSchems = SchematicMember.getAccessibleSchems(schemOwner);
|
||||||
for(SchematicMember schem : addedSchems){
|
for(SchematicMember schem : addedSchems){
|
||||||
@ -106,13 +110,10 @@ public class Schematic {
|
|||||||
|
|
||||||
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
|
||||||
try{
|
try{
|
||||||
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemType = '" + schemType.name() + "'");
|
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemType = '" + schemType.toDB() + "'");
|
||||||
List<Schematic> schematics = new ArrayList<>();
|
List<Schematic> schematics = new ArrayList<>();
|
||||||
while(schematic.next()){
|
while(schematic.next()){
|
||||||
int schemOwner = schematic.getInt("SchemOwner");
|
schematics.add(new Schematic(schematic));
|
||||||
String schemName = schematic.getString("SchemName");
|
|
||||||
String item = schematic.getString("Item");
|
|
||||||
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
|
|
||||||
}
|
}
|
||||||
return schematics;
|
return schematics;
|
||||||
}catch(SQLException e){
|
}catch(SQLException e){
|
||||||
|
@ -1,13 +1,76 @@
|
|||||||
package de.warking.hunjy.MySQL;
|
package de.warking.hunjy.MySQL;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum SchematicType {
|
public enum SchematicType {
|
||||||
normal,
|
Normal("", Type.NORMAL),
|
||||||
airship,
|
CAirShip("", Type.CHECK_TYPE),
|
||||||
wargear,
|
CWarGear("", Type.CHECK_TYPE),
|
||||||
warship,
|
CWarShip("", Type.CHECK_TYPE),
|
||||||
miniwargear,
|
CMiniWarGear("", Type.CHECK_TYPE),
|
||||||
Cairship,
|
AirShip("", Type.FIGHT_TYPE, CAirShip),
|
||||||
Cwargear,
|
WarGear("", Type.FIGHT_TYPE, CWarGear),
|
||||||
Cwarship,
|
WarShip("", Type.FIGHT_TYPE, CWarShip),
|
||||||
Cminiwargear
|
MiniWarGear("", Type.FIGHT_TYPE, CMiniWarGear);
|
||||||
|
|
||||||
|
private static Map<String, SchematicType> fromDB = new HashMap<>();
|
||||||
|
|
||||||
|
static{
|
||||||
|
for(SchematicType type : values()){
|
||||||
|
fromDB.put(type.toDB(), type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String kuerzel;
|
||||||
|
private final Type type;
|
||||||
|
private SchematicType checkType;
|
||||||
|
|
||||||
|
SchematicType(String kuerzel, Type type){
|
||||||
|
this(kuerzel, type, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
SchematicType(String kuerzel, Type type, SchematicType checkType){
|
||||||
|
this.kuerzel = kuerzel;
|
||||||
|
this.type = type;
|
||||||
|
this.checkType = checkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAssignable(){
|
||||||
|
return type == Type.NORMAL || type == Type.FIGHT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SchematicType checkType(){
|
||||||
|
return checkType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean check(){
|
||||||
|
return type == Type.CHECK_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean fightType(){
|
||||||
|
return type == Type.FIGHT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean writeable(){
|
||||||
|
return type == Type.NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKuerzel() {
|
||||||
|
return kuerzel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toDB(){
|
||||||
|
return name().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SchematicType fromDB(String input){
|
||||||
|
return fromDB.get(input.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Type{
|
||||||
|
NORMAL,
|
||||||
|
CHECK_TYPE,
|
||||||
|
FIGHT_TYPE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren