SteamWar/FightSystem
Archiviert
13
1

Schematic Pasting + Kit Management

Dieser Commit ist enthalten in:
lixfel 2019-04-13 14:25:25 +02:00
Ursprung eab9235eef
Commit 32028a27de
5 geänderte Dateien mit 39 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -47,3 +47,6 @@ Money:
Win: 0 Win: 0
Lose: 0 Lose: 0
Draw: 0 Draw: 0
Kits:
MemberDefault: default
LeaderDefault: default

Datei anzeigen

@ -1,6 +1,8 @@
package me.yaruma.fightsystem.commands; package me.yaruma.fightsystem.commands;
import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.Schematic;
import de.warking.hunjy.MySQL.UserGroup;
import de.warking.hunjy.MySQL.WarkingUser;
import me.yaruma.fightsystem.FightSystem; import me.yaruma.fightsystem.FightSystem;
import me.yaruma.fightsystem.fight.Fight; import me.yaruma.fightsystem.fight.Fight;
import me.yaruma.fightsystem.fight.FightPlayer; import me.yaruma.fightsystem.fight.FightPlayer;
@ -159,6 +161,12 @@ public class AkCommand implements CommandExecutor {
fightTeam.setSchematic(schem); fightTeam.setSchematic(schem);
Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!"); Fight.getPlayerTeam(player).broadcast(FightSystem.PREFIX + "Schematic §6" + args[1] + " §8wird für den Kampf verwendet!");
} else if(args[0].equalsIgnoreCase("addkit")){
if(WarkingUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer){
sendHelp(player);
return false;
}
KitManager.saveInventory(args[2], player);
} }
}else{ }else{
sendHelp(player); sendHelp(player);
@ -175,5 +183,6 @@ public class AkCommand implements CommandExecutor {
p.sendMessage("§8/§6ak accept §8- §7Einladung annehmen"); p.sendMessage("§8/§6ak accept §8- §7Einladung annehmen");
p.sendMessage("§8/§6ak decline §8- §7Einladung ablehnen"); p.sendMessage("§8/§6ak decline §8- §7Einladung ablehnen");
p.sendMessage("§8/§6ak kit <Kit> §8- §7Wähle ein Kit"); p.sendMessage("§8/§6ak kit <Kit> §8- §7Wähle ein Kit");
p.sendMessage("§8/§6ak schem <Schematic> §8- §7Setze deine Schematic");
} }
} }

Datei anzeigen

@ -52,10 +52,6 @@ public class FightTeam {
return null; return null;
} }
public void setPlayerOut(Player player) {
getFightPlayer(player).setOut(true);
}
public boolean allPlayersOut() { public boolean allPlayersOut() {
for(FightPlayer fightPlayer : this.players) { for(FightPlayer fightPlayer : this.players) {
if(!fightPlayer.isOut()) if(!fightPlayer.isOut())

Datei anzeigen

@ -31,11 +31,9 @@ public class KitManager {
player.getInventory().setContents(content); player.getInventory().setContents(content);
} }
private static void saveInventory(String kitName, Player player) throws IOException { public static void saveInventory(String kitName, Player player){
YamlConfiguration yamlConfiguration = new YamlConfiguration(); loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory()));
yamlConfiguration.set("Kits." + kitName + ".Armor", player.getInventory().getArmorContents()); saveAllKits();
yamlConfiguration.set("Kits." + kitName + ".Items", player.getInventory().getContents());
yamlConfiguration.save(new File(kitsPath));
} }
public static boolean canBuy(Player player, String kitName) { public static boolean canBuy(Player player, String kitName) {
@ -76,9 +74,9 @@ public class KitManager {
} }
public static Kit loadKitFromConfig(String name) { public static Kit loadKitFromConfig(String name) {
if(instance.getKitData().contains("Kit." + name)) { if(instance.getKitData().contains("Kits." + name)) {
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Armor"); ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Armor");
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kit." + name + ".Items"); ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Items");
PlayerInventory playerInventory = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER); PlayerInventory playerInventory = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER);
playerInventory.setArmorContents(armor); playerInventory.setArmorContents(armor);
@ -103,6 +101,21 @@ public class KitManager {
} }
} }
private static void saveAllKits(){
YamlConfiguration yamlConfiguration = new YamlConfiguration();
for(Kit k : loadedKits){
String path = "Kits." + k.getName();
yamlConfiguration.set(path + ".Armor", k.getInventory().getArmorContents());
yamlConfiguration.set(path + ".Items", k.getInventory().getContents());
yamlConfiguration.set(path + ".Price", k.getPrice());
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());
yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed());
}
try {
yamlConfiguration.save(new File(kitsPath));
}catch(IOException ignored){}
}
public static Kit getKitByName(String kitName) { public static Kit getKitByName(String kitName) {
for(Kit kit : loadedKits) { for(Kit kit : loadedKits) {
if(kit.getName().equalsIgnoreCase(kitName)) if(kit.getName().equalsIgnoreCase(kitName))
@ -110,12 +123,4 @@ public class KitManager {
} }
return null; return null;
} }
public static String getKitsPath() {
return kitsPath;
}
public static ArrayList<Kit> getLoadedKits() {
return loadedKits;
}
} }

Datei anzeigen

@ -58,6 +58,9 @@ public class Config {
public static int MoneyLose; public static int MoneyLose;
public static int MoneyDraw; public static int MoneyDraw;
public static String MemberDefault;
public static String LeaderDefault;
public static int TeamRedCornerX; public static int TeamRedCornerX;
public static int TeamRedCornerY; public static int TeamRedCornerY;
public static int TeamRedCornerZ; public static int TeamRedCornerZ;
@ -133,6 +136,9 @@ public class Config {
MoneyLose = config.getInt("Money.Lose"); MoneyLose = config.getInt("Money.Lose");
MoneyDraw = config.getInt("Money.Draw"); MoneyDraw = config.getInt("Money.Draw");
MemberDefault = config.getString("Kits.MemberDefault");
LeaderDefault = config.getString("Kits.LeaderDefault");
if(SchemsizeX < 0){ if(SchemsizeX < 0){
SchemsizeX = -SchemsizeX; SchemsizeX = -SchemsizeX;
TeamBlueCornerX -= SchemsizeX; TeamBlueCornerX -= SchemsizeX;