SteamWar/FightSystem
Archiviert
13
1

WIP Adding personal kits

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-01-19 17:25:11 +01:00
Ursprung d02ede97e0
Commit 00967a2d3e
2 geänderte Dateien mit 48 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -97,6 +97,7 @@ public class Config {
//default kits
public static final String MemberDefault;
public static final String LeaderDefault;
public static final boolean PersonalKits;
//tech hider parameter
public static final Set<Integer> HiddenBlocks;
@ -177,6 +178,7 @@ public class Config {
MemberDefault = config.getString("Kits.MemberDefault");
LeaderDefault = config.getString("Kits.LeaderDefault");
PersonalKits = config.getBoolean("Kits.PersonalKits");
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
Set<Integer> blocks = new HashSet<>();

Datei anzeigen

@ -0,0 +1,46 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
public class PersonalKitCreator implements Listener {
private final Player player;
private final ItemStack[] contents;
private final ItemStack[] armor;
public PersonalKitCreator(Player player){
this.player = player;
contents = player.getInventory().getContents();
armor = player.getInventory().getArmorContents();
//TODO Get Current Kit inventory
//TODO Prevent unwanted items
player.getInventory().setContents();
player.getInventory().setArmorContents();
player.setGameMode(GameMode.CREATIVE);
player.openInventory(this.inventory);
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
}
@EventHandler
public void onInventoryClose(InventoryCloseEvent e) {
if(!player.equals(e.getPlayer()))
return;
//TODO Autoclose inventory on PreFightStart
player.closeInventory();
player.getInventory().setContents(contents);
player.getInventory().setArmorContents(contents);
player.setGameMode(GameMode.SURVIVAL);
HandlerList.unregisterAll(this);
}
}