SteamWar/FightSystem
Archiviert
13
1
Dieser Commit ist enthalten in:
lixfel 2019-04-13 15:17:58 +02:00
Ursprung efb1821f38
Commit 1aed04917d
3 geänderte Dateien mit 29 neuen und 58 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,5 @@
package me.yaruma.fightsystem; package me.yaruma.fightsystem;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.warking.hunjy.CoinSystem.CoinSystem; import de.warking.hunjy.CoinSystem.CoinSystem;
import me.yaruma.fightsystem.commands.AkCommand; import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.*; import me.yaruma.fightsystem.fight.*;
@ -31,7 +30,6 @@ public class FightSystem extends JavaPlugin {
private static FightSystem plugin; private static FightSystem plugin;
private Scoreboard scoreboard; private Scoreboard scoreboard;
private KitManager kitManager;
private WaterRemover waterRemover; private WaterRemover waterRemover;
private FightState fightState; private FightState fightState;
@ -57,12 +55,11 @@ public class FightSystem extends JavaPlugin {
Config.load(); Config.load();
this.scoreboard = new Scoreboard(plugin); this.scoreboard = new Scoreboard(plugin);
this.kitManager = new KitManager();
this.waterRemover = new WaterRemover(); this.waterRemover = new WaterRemover();
loadConfig(); loadConfig();
getKitManager().loadAllKits(); KitManager.loadAllKits();
init(); init();
@ -123,10 +120,6 @@ public class FightSystem extends JavaPlugin {
return scoreboard; return scoreboard;
} }
public KitManager getKitManager() {
return kitManager;
}
public WaterRemover getWaterRemover() { public WaterRemover getWaterRemover() {
return waterRemover; return waterRemover;
} }
@ -141,9 +134,11 @@ public class FightSystem extends JavaPlugin {
countdown.startTimer(this); countdown.startTimer(this);
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) { for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear(); allFightPlayers.getPlayer().getInventory().clear();
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
} }
for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) { for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) {
allFightPlayers.getPlayer().getInventory().clear(); allFightPlayers.getPlayer().getInventory().clear();
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
} }
teleportAllToFightSpawn(); teleportAllToFightSpawn();
@ -221,10 +216,6 @@ public class FightSystem extends JavaPlugin {
countdown.startTimer(FightSystem.getPlugin()); countdown.startTimer(FightSystem.getPlugin());
} }
public static WorldEditPlugin getWorldEditPlugin() {
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
}
public int getFightTime() { public int getFightTime() {
return fightTime; return fightTime;
} }

Datei anzeigen

@ -1,8 +1,7 @@
package me.yaruma.fightsystem.kit; package me.yaruma.fightsystem.kit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
public class Kit { public class Kit {
@ -10,58 +9,44 @@ public class Kit {
private int price; private int price;
private boolean leaderAllowed; private boolean leaderAllowed;
private boolean memberAllowed; private boolean memberAllowed;
private PlayerInventory playerInventory; private ItemStack[] inventory;
private ItemStack[] armor;
public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, PlayerInventory playerInventory) { public Kit(String name, int price, boolean leaderAllowed, boolean memberAllowed, ItemStack[] Armor, ItemStack[] Inventory) {
this.name = name; this.name = name;
this.price = price; this.price = price;
this.leaderAllowed = leaderAllowed; this.leaderAllowed = leaderAllowed;
this.memberAllowed = memberAllowed; this.memberAllowed = memberAllowed;
this.playerInventory = playerInventory; inventory = Inventory;
armor = Armor;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) {
this.name = name;
}
public int getPrice() { public int getPrice() {
return price; return price;
} }
public void setPrice(int price) {
this.price = price;
}
public boolean isLeaderAllowed() { public boolean isLeaderAllowed() {
return leaderAllowed; return leaderAllowed;
} }
public void setLeaderAllowed(boolean leaderAllowed) {
this.leaderAllowed = leaderAllowed;
}
public boolean isMemberAllowed() { public boolean isMemberAllowed() {
return memberAllowed; return memberAllowed;
} }
public void setMemberAllowed(boolean memberAllowed) { public ItemStack[] getInventory() {
this.memberAllowed = memberAllowed; return inventory;
} }
public PlayerInventory getInventory() { public ItemStack[] getArmor() {
return playerInventory; return armor;
}
public void setPlayerInventory(Inventory inventory) {
this.playerInventory = playerInventory;
} }
public void loadToPlayer(Player player) { public void loadToPlayer(Player player) {
player.getInventory().setContents(playerInventory.getContents()); player.getInventory().setContents(inventory);
player.getInventory().setArmorContents(playerInventory.getArmorContents()); player.getInventory().setArmorContents(armor);
} }
} }

Datei anzeigen

@ -4,12 +4,10 @@ import de.warking.hunjy.CoinSystem.CoinSystem;
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;
import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -32,7 +30,7 @@ public class KitManager {
} }
public static void saveInventory(String kitName, Player player){ public static void saveInventory(String kitName, Player player){
loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory())); loadedKits.add(new Kit(kitName, 0, true, true, player.getInventory().getArmorContents(), player.getInventory().getContents()));
saveAllKits(); saveAllKits();
} }
@ -74,22 +72,19 @@ public class KitManager {
} }
public static Kit loadKitFromConfig(String name) { public static Kit loadKitFromConfig(String name) {
if(instance.getKitData().contains("Kits." + name)) { FileConfiguration data = instance.getKitData();
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Armor"); name = "Kits." + name;
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Items"); if(data.contains(name)) {
List<ItemStack> armor = (List<ItemStack>) data.getList(name + ".Armor");
List<ItemStack> items = (List<ItemStack>) data.getList(name + ".Items");
PlayerInventory playerInventory = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER); int price = data.getInt(name + ".Price");
playerInventory.setArmorContents(armor); boolean leaderAllowed = data.getBoolean(name + ".LeaderAllowed");
playerInventory.setContents(items); boolean memberAllowed = data.getBoolean(name + ".MemberAllowed");
int price = instance.getKitData().getInt("Kits." + name + ".Price"); Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, armor.toArray(new ItemStack[1]), items.toArray(new ItemStack[1]));
boolean leaderAllowed = instance.getKitData().getBoolean("Kits." + name + ".LeaderAllowed");
boolean memberAllowed = instance.getKitData().getBoolean("Kits." + name + ".MemberAllowed");
Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, playerInventory);
return kit; return kit;
} else }
System.out.println("§4Warning: ES WURDE VERSUCHT EIN KIT ZU LADEN DAS NICHT EXISTIERT!");
return null; return null;
} }
@ -105,8 +100,8 @@ public class KitManager {
YamlConfiguration yamlConfiguration = new YamlConfiguration(); YamlConfiguration yamlConfiguration = new YamlConfiguration();
for(Kit k : loadedKits){ for(Kit k : loadedKits){
String path = "Kits." + k.getName(); String path = "Kits." + k.getName();
yamlConfiguration.set(path + ".Armor", k.getInventory().getArmorContents()); yamlConfiguration.set(path + ".Armor", k.getArmor());
yamlConfiguration.set(path + ".Items", k.getInventory().getContents()); yamlConfiguration.set(path + ".Items", k.getInventory());
yamlConfiguration.set(path + ".Price", k.getPrice()); yamlConfiguration.set(path + ".Price", k.getPrice());
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed()); yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());
yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed()); yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed());