Kitanpassungen
Dieser Commit ist enthalten in:
Ursprung
efb1821f38
Commit
1aed04917d
@ -1,6 +1,5 @@
|
||||
package me.yaruma.fightsystem;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import de.warking.hunjy.CoinSystem.CoinSystem;
|
||||
import me.yaruma.fightsystem.commands.AkCommand;
|
||||
import me.yaruma.fightsystem.fight.*;
|
||||
@ -31,7 +30,6 @@ public class FightSystem extends JavaPlugin {
|
||||
|
||||
private static FightSystem plugin;
|
||||
private Scoreboard scoreboard;
|
||||
private KitManager kitManager;
|
||||
private WaterRemover waterRemover;
|
||||
|
||||
private FightState fightState;
|
||||
@ -57,12 +55,11 @@ public class FightSystem extends JavaPlugin {
|
||||
Config.load();
|
||||
|
||||
this.scoreboard = new Scoreboard(plugin);
|
||||
this.kitManager = new KitManager();
|
||||
this.waterRemover = new WaterRemover();
|
||||
|
||||
loadConfig();
|
||||
|
||||
getKitManager().loadAllKits();
|
||||
KitManager.loadAllKits();
|
||||
|
||||
init();
|
||||
|
||||
@ -123,10 +120,6 @@ public class FightSystem extends JavaPlugin {
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
public KitManager getKitManager() {
|
||||
return kitManager;
|
||||
}
|
||||
|
||||
public WaterRemover getWaterRemover() {
|
||||
return waterRemover;
|
||||
}
|
||||
@ -141,9 +134,11 @@ public class FightSystem extends JavaPlugin {
|
||||
countdown.startTimer(this);
|
||||
for(FightPlayer allFightPlayers : Fight.getBlueTeam().getPlayers()) {
|
||||
allFightPlayers.getPlayer().getInventory().clear();
|
||||
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
|
||||
}
|
||||
for(FightPlayer allFightPlayers : Fight.getRedTeam().getPlayers()) {
|
||||
allFightPlayers.getPlayer().getInventory().clear();
|
||||
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
|
||||
}
|
||||
|
||||
teleportAllToFightSpawn();
|
||||
@ -221,10 +216,6 @@ public class FightSystem extends JavaPlugin {
|
||||
countdown.startTimer(FightSystem.getPlugin());
|
||||
}
|
||||
|
||||
public static WorldEditPlugin getWorldEditPlugin() {
|
||||
return (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
|
||||
}
|
||||
|
||||
public int getFightTime() {
|
||||
return fightTime;
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package me.yaruma.fightsystem.kit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Kit {
|
||||
|
||||
@ -10,58 +9,44 @@ public class Kit {
|
||||
private int price;
|
||||
private boolean leaderAllowed;
|
||||
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.price = price;
|
||||
this.leaderAllowed = leaderAllowed;
|
||||
this.memberAllowed = memberAllowed;
|
||||
this.playerInventory = playerInventory;
|
||||
inventory = Inventory;
|
||||
armor = Armor;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(int price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public boolean isLeaderAllowed() {
|
||||
return leaderAllowed;
|
||||
}
|
||||
|
||||
public void setLeaderAllowed(boolean leaderAllowed) {
|
||||
this.leaderAllowed = leaderAllowed;
|
||||
}
|
||||
|
||||
public boolean isMemberAllowed() {
|
||||
return memberAllowed;
|
||||
}
|
||||
|
||||
public void setMemberAllowed(boolean memberAllowed) {
|
||||
this.memberAllowed = memberAllowed;
|
||||
public ItemStack[] getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public PlayerInventory getInventory() {
|
||||
return playerInventory;
|
||||
}
|
||||
|
||||
public void setPlayerInventory(Inventory inventory) {
|
||||
this.playerInventory = playerInventory;
|
||||
public ItemStack[] getArmor() {
|
||||
return armor;
|
||||
}
|
||||
|
||||
public void loadToPlayer(Player player) {
|
||||
player.getInventory().setContents(playerInventory.getContents());
|
||||
player.getInventory().setArmorContents(playerInventory.getArmorContents());
|
||||
player.getInventory().setContents(inventory);
|
||||
player.getInventory().setArmorContents(armor);
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,10 @@ import de.warking.hunjy.CoinSystem.CoinSystem;
|
||||
import me.yaruma.fightsystem.FightSystem;
|
||||
import me.yaruma.fightsystem.fight.Fight;
|
||||
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.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -32,7 +30,7 @@ public class KitManager {
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
@ -74,22 +72,19 @@ public class KitManager {
|
||||
}
|
||||
|
||||
public static Kit loadKitFromConfig(String name) {
|
||||
if(instance.getKitData().contains("Kits." + name)) {
|
||||
ItemStack[] armor = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Armor");
|
||||
ItemStack[] items = (ItemStack[]) instance.getKitData().get("Kits." + name + ".Items");
|
||||
FileConfiguration data = instance.getKitData();
|
||||
name = "Kits." + name;
|
||||
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);
|
||||
playerInventory.setArmorContents(armor);
|
||||
playerInventory.setContents(items);
|
||||
int price = data.getInt(name + ".Price");
|
||||
boolean leaderAllowed = data.getBoolean(name + ".LeaderAllowed");
|
||||
boolean memberAllowed = data.getBoolean(name + ".MemberAllowed");
|
||||
|
||||
int price = instance.getKitData().getInt("Kits." + name + ".Price");
|
||||
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);
|
||||
Kit kit = new Kit(name, price, leaderAllowed, memberAllowed, armor.toArray(new ItemStack[1]), items.toArray(new ItemStack[1]));
|
||||
return kit;
|
||||
} else
|
||||
System.out.println("§4Warning: ES WURDE VERSUCHT EIN KIT ZU LADEN DAS NICHT EXISTIERT!");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -105,8 +100,8 @@ public class KitManager {
|
||||
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 + ".Armor", k.getArmor());
|
||||
yamlConfiguration.set(path + ".Items", k.getInventory());
|
||||
yamlConfiguration.set(path + ".Price", k.getPrice());
|
||||
yamlConfiguration.set(path + ".LeaderAllowed", k.isLeaderAllowed());
|
||||
yamlConfiguration.set(path + ".MemberAllowed", k.isMemberAllowed());
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren