Merge branch 'personalKit' of SteamWar/FightSystem into master
Dieser Commit ist enthalten in:
Commit
86c3855cd5
@ -98,6 +98,8 @@ public class Config {
|
|||||||
//default kits
|
//default kits
|
||||||
public static final String MemberDefault;
|
public static final String MemberDefault;
|
||||||
public static final String LeaderDefault;
|
public static final String LeaderDefault;
|
||||||
|
public static final boolean PersonalKits;
|
||||||
|
public static final List<String> ForbiddenItems;
|
||||||
|
|
||||||
//tech hider parameter
|
//tech hider parameter
|
||||||
public static final Set<Integer> HiddenBlocks;
|
public static final Set<Integer> HiddenBlocks;
|
||||||
@ -179,6 +181,8 @@ public class Config {
|
|||||||
|
|
||||||
MemberDefault = config.getString("Kits.MemberDefault");
|
MemberDefault = config.getString("Kits.MemberDefault");
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
LeaderDefault = config.getString("Kits.LeaderDefault");
|
||||||
|
PersonalKits = config.getBoolean("Kits.PersonalKits");
|
||||||
|
ForbiddenItems = config.getStringList("Kits.ForbiddenItems");
|
||||||
|
|
||||||
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
|
ConfigurationSection techhiderConfig = config.getConfigurationSection("Techhider.HiddenBlocks");
|
||||||
Set<Integer> blocks = new HashSet<>();
|
Set<Integer> blocks = new HashSet<>();
|
||||||
|
@ -41,6 +41,8 @@ WinConditionParams:
|
|||||||
Kits:
|
Kits:
|
||||||
MemberDefault: default
|
MemberDefault: default
|
||||||
LeaderDefault: default
|
LeaderDefault: default
|
||||||
|
PersonalKits: false
|
||||||
|
ForbiddenItems: []
|
||||||
Techhider:
|
Techhider:
|
||||||
ObfuscateWith: 121
|
ObfuscateWith: 121
|
||||||
ObfuscateWithTag: ENDER_STONE
|
ObfuscateWithTag: ENDER_STONE
|
||||||
|
@ -133,12 +133,14 @@ public class FightSystem extends JavaPlugin {
|
|||||||
throw new SecurityException(fightState.name());
|
throw new SecurityException(fightState.name());
|
||||||
setFightState(FightState.PRE_RUNNING);
|
setFightState(FightState.PRE_RUNNING);
|
||||||
|
|
||||||
loadKits(Fight.getBlueTeam());
|
PersonalKitCreator.closeAll();
|
||||||
loadKits(Fight.getRedTeam());
|
Fight.getBlueTeam().loadKits();
|
||||||
|
Fight.getRedTeam().loadKits();
|
||||||
setAllPlayersGM(GameMode.SURVIVAL);
|
setAllPlayersGM(GameMode.SURVIVAL);
|
||||||
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
Bukkit.broadcastMessage(PREFIX + "§aDer Kampf beginnt!");
|
||||||
|
|
||||||
mainCountdown = new PreRunningCountdown();
|
mainCountdown = new PreRunningCountdown();
|
||||||
|
|
||||||
Fight.replaceSync();
|
Fight.replaceSync();
|
||||||
|
|
||||||
if(Config.event())
|
if(Config.event())
|
||||||
@ -253,17 +255,6 @@ public class FightSystem extends JavaPlugin {
|
|||||||
stateDependent.enable();
|
stateDependent.enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void loadKits(FightTeam team){
|
|
||||||
for(FightPlayer allFightPlayers : team.getPlayers()) {
|
|
||||||
if(allFightPlayers.getPlayer() == null)
|
|
||||||
continue;
|
|
||||||
allFightPlayers.getPlayer().getInventory().clear();
|
|
||||||
if(allFightPlayers.getKit() == null)
|
|
||||||
continue;
|
|
||||||
allFightPlayers.getKit().loadToPlayer(allFightPlayers.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setAllPlayersGM(GameMode gm) {
|
private static void setAllPlayersGM(GameMode gm) {
|
||||||
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
|
for(FightPlayer fightPlayer: Fight.getBlueTeam().getPlayers()){
|
||||||
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
Fight.setPlayerGamemode(fightPlayer.getPlayer(), gm);
|
||||||
|
@ -8,6 +8,7 @@ import de.steamwar.fightsystem.kit.Kit;
|
|||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.utils.PersonalKitCreator;
|
||||||
import de.steamwar.inventory.SWInventory;
|
import de.steamwar.inventory.SWInventory;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.inventory.SWListInv;
|
import de.steamwar.inventory.SWListInv;
|
||||||
@ -76,6 +77,11 @@ public class GUI {
|
|||||||
if(fightPlayer == null)
|
if(fightPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(Config.PersonalKits){
|
||||||
|
new PersonalKitCreator(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
List<SWListInv.SWListEntry<Kit>> iconList = new ArrayList<>();
|
List<SWListInv.SWListEntry<Kit>> iconList = new ArrayList<>();
|
||||||
|
|
||||||
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
|
List<Kit> kitList = KitManager.getKits(fightPlayer.isLeader());
|
||||||
|
@ -10,7 +10,9 @@ import de.steamwar.fightsystem.states.FightState;
|
|||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.*;
|
||||||
import de.steamwar.inventory.SWItem;
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
|
import de.steamwar.sql.PersonalKit;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -20,6 +22,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
@ -145,7 +148,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
|
||||||
player.teleport(spawn);
|
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(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());
|
player.getInventory().setItem(7, new ItemBuilder(Material.BEACON).removeAllAttributs().setDisplayName("§eRespawn").build());
|
||||||
TechHider.reloadChunks(player, chunksToReload);
|
TechHider.reloadChunks(player, chunksToReload);
|
||||||
@ -195,7 +198,7 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
leader.setKit(KitManager.getKitByName(Config.LeaderDefault));
|
||||||
Inventory inventory = leader.getPlayer().getInventory();
|
Inventory inventory = leader.getPlayer().getInventory();
|
||||||
if (KitManager.getKits(true).size() > 1)
|
if (KitManager.getKits(true).size() > 1 || Config.PersonalKits)
|
||||||
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
inventory.setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build());
|
||||||
else
|
else
|
||||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||||
@ -349,6 +352,25 @@ public class FightTeam implements IFightTeam{
|
|||||||
return currentHearts / maximumHearts;
|
return currentHearts / maximumHearts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadKits(){
|
||||||
|
for(FightPlayer fightPlayer : players) {
|
||||||
|
if(fightPlayer.getPlayer() == null)
|
||||||
|
continue;
|
||||||
|
fightPlayer.getPlayer().getInventory().clear();
|
||||||
|
|
||||||
|
PersonalKit personalKit = null;
|
||||||
|
if(Config.PersonalKits)
|
||||||
|
personalKit = PersonalKit.get(SteamwarUser.get(fightPlayer.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB());
|
||||||
|
|
||||||
|
if(personalKit != null){
|
||||||
|
PlayerInventory inventory = fightPlayer.getPlayer().getInventory();
|
||||||
|
inventory.setContents(personalKit.getInventory());
|
||||||
|
inventory.setArmorContents(personalKit.getArmor());
|
||||||
|
}else if(fightPlayer.getKit() != null)
|
||||||
|
fightPlayer.getKit().loadToPlayer(fightPlayer.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void replaceSync(boolean replace, Material target, Material replacement) {
|
void replaceSync(boolean replace, Material target, Material replacement) {
|
||||||
if(!replace)
|
if(!replace)
|
||||||
return;
|
return;
|
||||||
|
@ -2,6 +2,7 @@ package de.steamwar.fightsystem.listener;
|
|||||||
|
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
|
import de.steamwar.fightsystem.utils.PersonalKitCreator;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -42,12 +43,14 @@ public class FreezeWorldStateListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
event.setCancelled(true);
|
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryDrag(InventoryDragEvent event) {
|
public void onInventoryDrag(InventoryDragEvent event) {
|
||||||
event.setCancelled(true);
|
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
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.HumanEntity;
|
||||||
|
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.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PersonalKitCreator implements Listener {
|
||||||
|
|
||||||
|
private static final Map<Player, PersonalKitCreator> openKitCreators = new HashMap<>();
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private final SteamwarUser user;
|
||||||
|
private final ItemStack[] contents;
|
||||||
|
private final ItemStack[] armor;
|
||||||
|
|
||||||
|
public PersonalKitCreator(Player player){
|
||||||
|
this.player = player;
|
||||||
|
contents = player.getInventory().getContents();
|
||||||
|
armor = player.getInventory().getArmorContents();
|
||||||
|
user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
|
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);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin());
|
||||||
|
openKitCreators.put(player, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void closeAll(){
|
||||||
|
for(PersonalKitCreator creator : openKitCreators.values()){
|
||||||
|
creator.player.closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean inKitCreator(HumanEntity player){
|
||||||
|
return openKitCreators.containsKey(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent e){
|
||||||
|
if(e.getCursor() != null && Config.ForbiddenItems.contains(e.getCursor().getType().name()))
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMoveEvent(PlayerMoveEvent e){
|
||||||
|
if(!player.equals(e.getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClose(InventoryCloseEvent e) {
|
||||||
|
if(!player.equals(e.getPlayer()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void close(){
|
||||||
|
PersonalKit.save(user.getId(), Config.SchematicType.toDB(), player.getInventory().getContents(), player.getInventory().getArmorContents());
|
||||||
|
player.getInventory().setContents(contents);
|
||||||
|
player.getInventory().setArmorContents(armor);
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
openKitCreators.remove(player);
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren