SteamWar/FightSystem
Archiviert
13
1
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Yaruma3341 2019-03-02 11:30:15 +01:00
Ursprung 30eace7a05
Commit 5fdfa6e598
3 geänderte Dateien mit 54 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -4,6 +4,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import de.diamant.hunjy.CoinSystem.CoinSystem;
import me.yaruma.fightsystem.commands.AkCommand;
import me.yaruma.fightsystem.fight.*;
import me.yaruma.fightsystem.kit.KitManager;
import me.yaruma.fightsystem.listener.*;
import me.yaruma.fightsystem.manager.FileManager;
import me.yaruma.fightsystem.utils.WorldEdit;
@ -15,6 +16,8 @@ import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.World;
@ -30,6 +33,7 @@ public class FightSystem extends JavaPlugin {
private FileManager fileManager;
private FightManager fightManager;
private Scoreboard scoreboard;
private KitManager kitManager;
private FightState fightState;
@ -67,6 +71,13 @@ public class FightSystem extends JavaPlugin {
public boolean entern = false;
public File kits = new File("plugins/" + this.getName(), "kits.data");
public FileConfiguration getKitData = YamlConfiguration.loadConfiguration(kits);
public void saveKitData() {
try { getKitData.save(kits); } catch (Exception ex) { }
}
public void onEnable() {
@ -74,6 +85,7 @@ public class FightSystem extends JavaPlugin {
this.fileManager = new FileManager(plugin);
this.fightManager = new FightManager();
this.scoreboard = new Scoreboard(plugin);
this.kitManager = new KitManager();
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
Fight.getRedTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamRedColor"));
@ -197,6 +209,10 @@ public class FightSystem extends JavaPlugin {
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
saveDefaultConfig();
System.out.println(PREFIX + "config.yml erstellt und geladen!");
}
if(!new File("plugins/" + this.getName() + "/kits.data").exists()) {
saveKitData();
System.out.println(PREFIX + "kits.data erstellt und geladen!");
Bukkit.shutdown();
}
}
@ -225,6 +241,10 @@ public class FightSystem extends JavaPlugin {
return scoreboard;
}
public KitManager getKitManager() {
return kitManager;
}
public void setSetupState() {
if(this.fightState == null) {
this.fightState = FightState.SETUP;

Datei anzeigen

@ -112,6 +112,10 @@ public class AkCommand implements CommandExecutor {
}
}
}
} else if(args[0].equalsIgnoreCase("kit")) {
if(FightSystem.getPlugin().getFightState() == FightState.SETUP) {
FightSystem.getPlugin().getKitManager().loadInventoryToPlayer("plugins/" + FightSystem.getPlugin().getName() + "/kits.data", player);
}
}
}else{
sendHelp(player);

Datei anzeigen

@ -0,0 +1,30 @@
package me.yaruma.fightsystem.kit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
public class KitManager {
public void loadInventoryToPlayer(String path, Player player) {
YamlConfiguration yamlConfiguration = YamlConfiguration.loadConfiguration(new File(path));
ItemStack[] content = ((List<ItemStack>) yamlConfiguration.get("inventory.armor")).toArray(new ItemStack[0]);
player.getInventory().setArmorContents(content);
content = ((List<ItemStack>) yamlConfiguration.get("inventory.content")).toArray(new ItemStack[0]);
player.getInventory().setContents(content);
}
public void saveInventory(String path, Player player) throws IOException {
YamlConfiguration yamlConfiguration = new YamlConfiguration();
yamlConfiguration.set("inventory.armor", player.getInventory().getArmorContents());
yamlConfiguration.set("inventory.contents", player.getInventory().getContents());
yamlConfiguration.save(new File(path));
}
}