Added Kits
Signed-off-by: Yaruma3341 <yaruma3341@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
30eace7a05
Commit
5fdfa6e598
@ -4,6 +4,7 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|||||||
import de.diamant.hunjy.CoinSystem.CoinSystem;
|
import de.diamant.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.*;
|
||||||
|
import me.yaruma.fightsystem.kit.KitManager;
|
||||||
import me.yaruma.fightsystem.listener.*;
|
import me.yaruma.fightsystem.listener.*;
|
||||||
import me.yaruma.fightsystem.manager.FileManager;
|
import me.yaruma.fightsystem.manager.FileManager;
|
||||||
import me.yaruma.fightsystem.utils.WorldEdit;
|
import me.yaruma.fightsystem.utils.WorldEdit;
|
||||||
@ -15,6 +16,8 @@ import me.yaruma.fightsystem.winconditions.WinconditionPercentSystem;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
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.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -30,6 +33,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
private FileManager fileManager;
|
private FileManager fileManager;
|
||||||
private FightManager fightManager;
|
private FightManager fightManager;
|
||||||
private Scoreboard scoreboard;
|
private Scoreboard scoreboard;
|
||||||
|
private KitManager kitManager;
|
||||||
|
|
||||||
private FightState fightState;
|
private FightState fightState;
|
||||||
|
|
||||||
@ -67,6 +71,13 @@ public class FightSystem extends JavaPlugin {
|
|||||||
|
|
||||||
public boolean entern = false;
|
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() {
|
public void onEnable() {
|
||||||
|
|
||||||
@ -74,6 +85,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
this.fileManager = new FileManager(plugin);
|
this.fileManager = new FileManager(plugin);
|
||||||
this.fightManager = new FightManager();
|
this.fightManager = new FightManager();
|
||||||
this.scoreboard = new Scoreboard(plugin);
|
this.scoreboard = new Scoreboard(plugin);
|
||||||
|
this.kitManager = new KitManager();
|
||||||
|
|
||||||
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
|
Fight.getRedTeam().setName(fileManager.getStringFromConfig("Output.TeamRedName"));
|
||||||
Fight.getRedTeam().setPrefix(fileManager.getStringFromConfig("Output.TeamRedColor"));
|
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()) {
|
if(!new File("plugins/" + this.getName() + "/config.yml").exists()) {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
System.out.println(PREFIX + "config.yml erstellt und geladen!");
|
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();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,6 +241,10 @@ public class FightSystem extends JavaPlugin {
|
|||||||
return scoreboard;
|
return scoreboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KitManager getKitManager() {
|
||||||
|
return kitManager;
|
||||||
|
}
|
||||||
|
|
||||||
public void setSetupState() {
|
public void setSetupState() {
|
||||||
if(this.fightState == null) {
|
if(this.fightState == null) {
|
||||||
this.fightState = FightState.SETUP;
|
this.fightState = FightState.SETUP;
|
||||||
|
@ -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{
|
}else{
|
||||||
sendHelp(player);
|
sendHelp(player);
|
||||||
|
30
src/me/yaruma/fightsystem/kit/KitManager.java
Normale Datei
30
src/me/yaruma/fightsystem/kit/KitManager.java
Normale Datei
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren