SteamWar/SpigotCore
Archiviert
13
0

SchematicRework

Dieser Commit ist enthalten in:
Lixfel 2019-09-24 18:57:05 +02:00
Ursprung 6585a33b1e
Commit 7d14bc6ead
5 geänderte Dateien mit 103 neuen und 35 gelöschten Zeilen

10
pom.xml
Datei anzeigen

@ -16,8 +16,8 @@
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
<id>steamwar</id>
<url>https://steamwar.de/maven/</url>
</repository>
</repositories>
@ -47,9 +47,9 @@
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

Datei anzeigen

@ -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){
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){

Datei anzeigen

@ -32,13 +32,17 @@ public class SWItem {
public SWItem(Material material, byte meta, String name, List<String> lore, boolean enchanted, InvCallback c){
itemStack = new ItemStack(material, 1, (short)0, meta);
itemMeta = itemStack.getItemMeta();
hideAttributes();
itemMeta.setDisplayName(name);
if(lore != null && !lore.isEmpty())
itemMeta.setLore(lore);
if(enchanted)
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
itemStack.setItemMeta(itemMeta);
if(itemMeta != null){
hideAttributes();
itemMeta.setDisplayName(name);
if(lore != null && !lore.isEmpty())
itemMeta.setLore(lore);
if(enchanted)
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
itemStack.setItemMeta(itemMeta);
}
callback = c;
}

Datei anzeigen

@ -15,6 +15,15 @@ public class Schematic {
private String Item;
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){
SchemName = schemName;
SchemOwner = schemOwner;
@ -36,7 +45,7 @@ public class Schematic {
sql.update("INSERT INTO Schematic" +
" (SchemName, SchemOwner, Item, SchemType)" +
" VALUES" +
" ('" + SchemName + "', '" + SchemOwner + "', '" + Item + "', '" + SchemType.name() + "')" +
" ('" + SchemName + "', '" + SchemOwner + "', '" + Item + "', '" + SchemType.toDB() + "')" +
" ON DUPLICATE KEY UPDATE" +
" Item = VALUES(Item), SchemType = VALUES(SchemType)");
}
@ -56,9 +65,7 @@ public class Schematic {
}
return getSchemFromDB(schemName, member.getSchemOwner());
}
String item = schematic.getString("Item");
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
return new Schematic(schemName, schemOwner, item, schemType, false);
return new Schematic(schematic);
} catch (SQLException e) {
e.printStackTrace();
}
@ -74,10 +81,7 @@ public class Schematic {
ResultSet schematic = sql.select("SELECT * FROM Schematic WHERE SchemOwner = '" + schemOwner + "'");
List<Schematic> schematics = new ArrayList<>();
while(schematic.next()){
String schemName = schematic.getString("SchemName");
String item = schematic.getString("Item");
SchematicType schemType = SchematicType.valueOf(schematic.getString("SchemType"));
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
schematics.add(new Schematic(schematic));
}
List<SchematicMember> addedSchems = SchematicMember.getAccessibleSchems(schemOwner);
for(SchematicMember schem : addedSchems){
@ -106,13 +110,10 @@ public class Schematic {
public static List<Schematic> getAllSchemsOfType(SchematicType schemType){
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<>();
while(schematic.next()){
int schemOwner = schematic.getInt("SchemOwner");
String schemName = schematic.getString("SchemName");
String item = schematic.getString("Item");
schematics.add(new Schematic(schemName, schemOwner, item, schemType, false));
schematics.add(new Schematic(schematic));
}
return schematics;
}catch(SQLException e){

Datei anzeigen

@ -1,13 +1,76 @@
package de.warking.hunjy.MySQL;
import java.util.HashMap;
import java.util.Map;
public enum SchematicType {
normal,
airship,
wargear,
warship,
miniwargear,
Cairship,
Cwargear,
Cwarship,
Cminiwargear
Normal("", Type.NORMAL),
CAirShip("", Type.CHECK_TYPE),
CWarGear("", Type.CHECK_TYPE),
CWarShip("", Type.CHECK_TYPE),
CMiniWarGear("", Type.CHECK_TYPE),
AirShip("", Type.FIGHT_TYPE, CAirShip),
WarGear("", Type.FIGHT_TYPE, CWarGear),
WarShip("", Type.FIGHT_TYPE, CWarShip),
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
}
}