use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.
the class Kit method giveKit.
public void giveKit(Player player) {
if (getConfig().getList("KitContents") != null) {
List<ItemStack> kitContents = Arrays.asList(getConfig().getList("KitContents").toArray(new ItemStack[0]));
player.getInventory().setContents(kitContents.toArray(new ItemStack[0]));
for (ItemStack item : kitContents) {
if (item.getType().toString().contains("Helmet"))
player.getInventory().setHelmet(item);
if (item.getType().toString().contains("Chestplate"))
player.getInventory().setChestplate(item);
if (item.getType().toString().contains("Leggings"))
player.getInventory().setLeggings(item);
if (item.getType().toString().contains("Boots"))
player.getInventory().setBoots(item);
}
} else {
Knocker knocker = KnockbackFFA.getInstance().getKnocker(player);
knocker.getConfig().set("owned-kits", knocker.getConfig().getStringList("owned-kits").stream().filter(s -> s.contains(kitName)).collect(Collectors.toList()));
knocker.saveConfig();
}
}
use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.
the class ArenaSettings method onItemDrop.
@EventHandler
public void onItemDrop(PlayerDropItemEvent e) {
Player player = e.getPlayer();
Knocker knocker = KnockbackFFA.getInstance().getKnocker(player);
if (!knocker.isInGame())
return;
String[] arenaList = KnockbackFFA.getInstance().getArenaManager().getFolder().list();
assert arenaList != null;
for (String arenaName : arenaList) {
Arena arena = KnockbackFFA.getInstance().getArenaManager().load(arenaName.replace(".yml", ""));
e.setCancelled(knocker.isInArena() && !arena.getConfig().getBoolean("item-drop"));
}
}
use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.
the class ArenaSettings method onPlayerGoesToArena.
@EventHandler
public void onPlayerGoesToArena(PlayerMoveEvent e) {
Player player = e.getPlayer();
Knocker knocker = KnockbackFFA.getInstance().getKnocker(player);
if (KnockbackFFA.getInstance().getArenaManager().getEnabledArena() != null) {
Arena arena = KnockbackFFA.getInstance().getArenaManager().load(KnockbackFFA.getInstance().getArenaManager().getEnabledArena().getName());
if (!arena.contains(player.getLocation()))
return;
if (!knocker.isInArena())
knocker.setInArena(true);
if (knocker.getConfig().getString("selected-kit") == null)
knocker.getConfig().set("selected-kit", "Default");
List<String> ownedKits = knocker.getConfig().getStringList("owned-kits");
if (!ownedKits.contains("Default")) {
ownedKits.add("Default");
knocker.getConfig().set("owned-kits", ownedKits);
}
Kit kit = KnockbackFFA.getInstance().getKitManager().load(knocker.getConfig().getString("selected-kit"));
for (ItemStack item : player.getInventory().getContents()) {
if (item != null) {
if (Items.COSMETIC_ITEM.getItem().equals(item) || Items.SHOP_ITEM.getItem().equals(item) || Items.KIT_ITEM.getItem().equals(item)) {
player.getInventory().clear();
kit.giveKit(player);
break;
}
}
}
} else
knocker.setInArena(false);
if (!knocker.isInGame())
return;
if (knocker.getConfig().getString("selected-trails") == null)
return;
String selectedTrails = knocker.getConfig().getString("selected-trails");
Block block = player.getWorld().getBlockAt(e.getFrom().getBlockX(), e.getFrom().getBlockY() - 1, e.getFrom().getBlockZ());
DataBlock db = KnockbackFFA.getInstance().getBlockDataManager().getBlockData(block);
if (!db.getBlockType().equals("") || db.getBlockType() != null)
return;
if (KnockbackFFA.getInstance().getConfig().getStringList("no-trail-blocks").contains(block.getType().toString()))
return;
db.setPrevMaterial(block.getType());
List<String> materialString = KnockbackFFA.getInstance().getCosmeticConfiguration().getConfig.getStringList(selectedTrails + ".blocks");
List<Material> materialList = new ArrayList<>();
for (String material : materialString) materialList.add(Material.getMaterial(material));
if (materialList.size() == 1) {
block.setType(materialList.get(0));
db.setBlockType("trail");
new BukkitRunnable() {
@Override
public void run() {
block.setType(db.getPrevMaterial());
db.setBlockType("");
cancel();
}
}.runTaskTimer(KnockbackFFA.getInstance(), KnockbackFFA.getInstance().getCosmeticConfiguration().getConfig.getInt(selectedTrails + ".speed") * 20L, 1);
} else {
block.setType(materialList.get(0));
db.setBlockType("trail");
new BukkitRunnable() {
int i = 0;
@Override
public void run() {
if (i < materialList.size() - 1) {
i++;
String material = materialList.get(i).name();
block.setType(Material.getMaterial(material));
} else {
block.setType(db.getPrevMaterial());
db.setBlockType("");
cancel();
}
}
}.runTaskTimer(KnockbackFFA.getInstance(), KnockbackFFA.getInstance().getCosmeticConfiguration().getConfig.getInt(selectedTrails + ".speed") * 20, KnockbackFFA.getInstance().getCosmeticConfiguration().getConfig.getInt(selectedTrails + ".speed") * 20);
}
}
use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.
the class DeathListener method playerDeathByVoid.
@EventHandler
public void playerDeathByVoid(PlayerDeathEvent e) {
Player player = e.getEntity();
Entity damager = killer.get(player);
if (KnockbackFFA.getInstance().getArenaManager() == null)
return;
Knocker knocker = KnockbackFFA.getInstance().getKnocker(player);
Arena arena = KnockbackFFA.getInstance().getArenaManager().getEnabledArena();
killer.remove(player);
knocker.setInArena(false);
if (!KnockbackFFA.getInstance().BungeeMode() && !knocker.isInGame())
return;
new BukkitRunnable() {
@Override
public void run() {
player.spigot().respawn();
knocker.giveLobbyItems();
arena.teleportPlayer(player);
cancel();
}
}.runTaskTimer(KnockbackFFA.getInstance(), 0, 1);
World world = player.getWorld();
List<Entity> entList = world.getEntities();
for (Entity current : entList) if ((current instanceof Item))
current.remove();
knocker.setKillStreak(0);
knocker.getConfig().set("deaths", knocker.getConfig().getInt("deaths") + 1);
knocker.saveConfig();
if (damager == null) {
player.sendMessage(Message.DEATH_VOID.toString());
e.setDeathMessage(Message.DEATH_VOID_GLOBAL.toString().replace("%player_name%", player.getName()));
} else {
if (damager != player && damager instanceof Player) {
knocker.loadCosmetic(knocker.selectedCosmetic());
Knocker damageKnocker = KnockbackFFA.getInstance().getKnocker((Player) damager);
float prize = KnockbackFFA.getInstance().getConfig().getInt("kill-prize");
damageKnocker.sendMessage(Message.PRIZE.toString().replace("%prize%", prize + "").replace("&", "ยง"));
damageKnocker.addBalance(prize);
damageKnocker.getConfig().set("kills", damageKnocker.getConfig().getInt("kills") + 1);
damageKnocker.setKillStreak(damageKnocker.getKillStreak() + 1);
if (damageKnocker.getKillStreak() > damageKnocker.getConfig().getInt("best-ks")) {
String msg = Message.KILLSTREAK_RECORD.toString().replace("%killstreak%", damageKnocker.getConfig().getInt("best-ks") + "");
damageKnocker.sendActionBar(msg);
damageKnocker.getConfig().set("best-ks", damageKnocker.getKillStreak());
}
damageKnocker.saveConfig();
e.setDeathMessage(PlaceholderAPI.setPlaceholders(e.getEntity(), Message.DEATH_KNOCKED_GOBAL.toString().replace("%killer%", damager.getName())));
} else if (damager.hasMetadata("bot"))
e.setDeathMessage(PlaceholderAPI.setPlaceholders(e.getEntity(), Message.DEATH_KNOCKED_GOBAL.toString().replace("%killer%", damager.getName())));
}
}
use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.
the class ArenaManager method changeArena.
/**
* Changes the arena to another arena
*/
public void changeArena(Arena arena) {
String arenaName = arena.getName();
setEnabledArena(arenaName);
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
Knocker knocker = KnockbackFFA.getInstance().getKnocker(p);
if (!knocker.isInGame())
return;
p.getInventory().clear();
knocker.giveLobbyItems();
teleportPlayerToArena(p);
p.playSound(p.getLocation(), Sounds.ARENA_CHANGE.toSound(), 1, 1);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', Message.ARENA_CHANGE.toString()).replace("%arena%", arenaName));
}
if (arena.getConfig().getBoolean("auto-reset"))
arena.resetArena();
}
Aggregations