SteamWar/FightSystem
Archiviert
13
1

personalKit #106

Zusammengeführt
Lixfel hat 5 Commits von personalKit nach master 2020-01-27 06:33:09 +01:00 zusammengeführt
6 geänderte Dateien mit 55 neuen und 8 gelöschten Zeilen
Nur Änderungen aus Commit c5c6e8c32b werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -98,6 +98,7 @@ public class Config {
public static final String MemberDefault;
public static final String LeaderDefault;
public static final boolean PersonalKits;
public static final List<String> ForbiddenItems;
//tech hider parameter
public static final Set<Integer> HiddenBlocks;
@ -179,6 +180,7 @@ public class Config {
MemberDefault = config.getString("Kits.MemberDefault");
LeaderDefault = config.getString("Kits.LeaderDefault");
PersonalKits = config.getBoolean("Kits.PersonalKits");
ForbiddenItems = config.getStringList("Kits.ForbiddenItems");
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
Set<Integer> blocks = new HashSet<>();

Datei anzeigen

@ -41,6 +41,8 @@ WinConditionParams:
Kits:
MemberDefault: default
LeaderDefault: default
PersonalKits: false
ForbiddenItems: []
Techhider:
ObfuscateWith: 121
ObfuscateWithTag: ENDER_STONE

Datei anzeigen

@ -10,6 +10,7 @@ import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.FightScoreboard;
import de.steamwar.fightsystem.utils.PersonalKitCreator;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.fightsystem.utils.WaterRemover;
import de.steamwar.fightsystem.winconditions.*;
@ -136,6 +137,7 @@ public class FightSystem extends JavaPlugin {
throw new SecurityException(fightState.name());
setFightState(FightState.PRE_RUNNING);
PersonalKitCreator.closeAll();
loadKits(Fight.getBlueTeam());
loadKits(Fight.getRedTeam());
setAllPlayersGM(GameMode.SURVIVAL);

Datei anzeigen

@ -8,6 +8,7 @@ import de.steamwar.fightsystem.kit.Kit;
import de.steamwar.fightsystem.kit.KitManager;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.PersonalKitCreator;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
@ -77,6 +78,11 @@ public class GUI {
if(fightPlayer == null)
return;
if(Config.PersonalKits){
new PersonalKitCreator(p);
return;
}
List<Pair<SWItem, Kit>> iconList = new ArrayList<>();
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());

Datei anzeigen

@ -149,7 +149,7 @@ public class FightTeam implements IFightTeam{
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
player.teleport(spawn);
if(KitManager.getKits(false).size() > 1)
if(KitManager.getKits(false).size() > 1 || Config.PersonalKits)
player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
TechHider.reloadChunks(player, chunksToReload);

Datei anzeigen

@ -1,18 +1,30 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
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.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class PersonalKitCreator implements Listener {
private static final Set<PersonalKitCreator> openKitCreators = new HashSet<>();
private final Player player;
private final SteamwarUser user;
private final ItemStack[] contents;
private final ItemStack[] armor;
@ -20,15 +32,33 @@ public class PersonalKitCreator implements Listener {
this.player = player;
contents = player.getInventory().getContents();
armor = player.getInventory().getArmorContents();
user = SteamwarUser.get(player.getUniqueId());
//TODO Get Current Kit inventory
//TODO Prevent unwanted items
player.getInventory().setContents();
player.getInventory().setArmorContents();
PersonalKit kit = PersonalKit.get(user.getId(), Config.SchematicType.toDB());
if(kit == null){
FightPlayer fightPlayer = Fight.getFightPlayer(player);
assert fightPlayer != null;
fightPlayer.getKit().loadToPlayer(player);
}else{
player.getInventory().setContents(kit.getInventory());
player.getInventory().setArmorContents(kit.getArmor());
}
player.setGameMode(GameMode.CREATIVE);
player.openInventory(this.inventory);
player.openInventory(player.getInventory());
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
openKitCreators.add(this);
}
public static void closeAll(){
for(PersonalKitCreator creator : openKitCreators)
creator.close();
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e){
if(e.getCursor() != null && Config.ForbiddenItems.contains(e.getCursor().getType().name()))
e.setCancelled(true);
}
@EventHandler
@ -36,11 +66,16 @@ public class PersonalKitCreator implements Listener {
if(!player.equals(e.getPlayer()))
return;
//TODO Autoclose inventory on PreFightStart
close();
}
private void close(){
PersonalKit.save(user.getId(), Config.SchematicType.toDB(), player.getInventory().getContents(), player.getInventory().getArmorContents());
player.closeInventory();
player.getInventory().setContents(contents);
player.getInventory().setArmorContents(contents);
player.getInventory().setArmorContents(armor);
player.setGameMode(GameMode.SURVIVAL);
HandlerList.unregisterAll(this);
openKitCreators.remove(this);
}
}