Search in sources :

Example 16 with Knocker

use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.

the class Expansion method onRequest.

@Override
public String onRequest(OfflinePlayer player, @NotNull String placeholder) {
    Player player1 = player.getPlayer();
    Knocker knocker = KnockbackFFA.getInstance().getKnocker(player1);
    if (placeholder.equalsIgnoreCase("player_kills"))
        return knocker.getConfig().getInt("kills") + "";
    if (placeholder.equalsIgnoreCase("player_deaths"))
        return knocker.getConfig().getInt("deaths") + "";
    if (placeholder.equalsIgnoreCase("player_balance"))
        return knocker.getBalance() + "";
    if (placeholder.equalsIgnoreCase("current_map")) {
        String arenaName = KnockbackFFA.getInstance().getArenaManager().getEnabledArena().getName();
        if (arenaName == null)
            return "No Arena";
        else
            return arenaName;
    }
    if (placeholder.equalsIgnoreCase("timer_nextmap")) {
        int timer = KnockbackFFA.getInstance().getTimer();
        int seconds = timer % 60;
        int minutes = timer / 60;
        return minutes + ":" + seconds;
    }
    if (placeholder.equalsIgnoreCase("next_map")) {
        if (KnockbackFFA.getInstance().getArenaManager().getFolder().list() == null || KnockbackFFA.getInstance().getArenaManager().getFolder().list().length <= 1)
            return "No Arena";
        String currentArenaName = KnockbackFFA.getInstance().getArenaManager().getEnabledArena().getName();
        List<String> arenaList = Arrays.asList(KnockbackFFA.getInstance().getArenaManager().getFolder().list());
        int index = arenaList.indexOf(currentArenaName);
        if (index == arenaList.size() - 1)
            return arenaList.get(0).replace(".yml", "");
        else
            return arenaList.get(index + 2).replace(".yml", "");
    }
    return "Invalid Placeholder";
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) Knocker(me.gameisntover.kbffa.api.Knocker)

Example 17 with Knocker

use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.

the class ArenaSettings method onBlockBreak.

@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
    Player player = e.getPlayer();
    Knocker knocker = KnockbackFFA.getInstance().getKnocker(player);
    if (knocker.isInArena())
        return;
    String[] arenaList = KnockbackFFA.getInstance().getArenaManager().getFolder().list();
    if (arenaList == null)
        return;
    for (String arenaName : arenaList) {
        Arena arena = KnockbackFFA.getInstance().getArenaManager().load(arenaName.replace(".yml", ""));
        e.setCancelled(!arena.getConfig().getBoolean("block-break"));
    }
}
Also used : Player(org.bukkit.entity.Player) Knocker(me.gameisntover.kbffa.api.Knocker) Arena(me.gameisntover.kbffa.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 18 with Knocker

use of me.gameisntover.kbffa.api.Knocker in project KnockbackFFA by GaMeIsNtOvEr.

the class GameEventsListener method playerChatFormat.

@EventHandler
public void playerChatFormat(AsyncPlayerChatEvent e) {
    Player player = e.getPlayer();
    Knocker knocker = KnockbackFFA.getInstance().getKnocker(e.getPlayer());
    if (KnockbackFFA.getInstance().BungeeMode() || knocker.isInGame())
        e.setFormat(Message.CHATFORMAT.toString().replace("%player%", player.getName()).replace("%message%", e.getMessage()));
}
Also used : Player(org.bukkit.entity.Player) Knocker(me.gameisntover.kbffa.api.Knocker) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Knocker (me.gameisntover.kbffa.api.Knocker)18 Player (org.bukkit.entity.Player)14 EventHandler (org.bukkit.event.EventHandler)12 Arena (me.gameisntover.kbffa.arena.Arena)5 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)5 DataBlock (me.gameisntover.kbffa.arena.regions.DataBlock)3 Block (org.bukkit.block.Block)3 ItemStack (org.bukkit.inventory.ItemStack)3 Kit (me.gameisntover.kbffa.kit.Kit)2 Material (org.bukkit.Material)2 World (org.bukkit.World)2 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 SneakyThrows (lombok.SneakyThrows)1 KnockbackFFA (me.gameisntover.kbffa.KnockbackFFA)1 ArenaManager (me.gameisntover.kbffa.arena.ArenaManager)1