Search in sources :

Example 1 with PlayerSettings

use of com.ebicep.warlords.player.PlayerSettings in project Warlords by ebicep.

the class ClassCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    if (!sender.hasPermission("warlords.game.changeclass")) {
        return true;
    }
    Player player = BaseCommand.requirePlayerOutsideGame(sender);
    if (player != null) {
        PlayerSettings settings = Warlords.getPlayerSettings(player.getUniqueId());
        if (args.length != 0) {
            try {
                Classes selectedClass = Classes.valueOf(args[0].toUpperCase(Locale.ROOT));
                settings.setSelectedClass(selectedClass);
            } catch (IllegalArgumentException e) {
                sender.sendMessage(ChatColor.RED + args[0] + " was not found, valid classes: " + Arrays.toString(Classes.values()));
                return true;
            }
        }
        Classes selected = settings.getSelectedClass();
        player.sendMessage(ChatColor.BLUE + "Your selected spec: §7" + selected);
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) Classes(com.ebicep.warlords.player.Classes)

Example 2 with PlayerSettings

use of com.ebicep.warlords.player.PlayerSettings in project Warlords by ebicep.

the class PlayingState method begin.

@Override
@SuppressWarnings("null")
public void begin() {
    this.game.setAcceptsSpectators(true);
    this.game.setAcceptsPlayers(false);
    this.resetTimer();
    RemoveEntities.doRemove(this.game);
    for (Option option : game.getOptions()) {
        option.start(game);
    }
    this.game.forEachOfflinePlayer((player, team) -> {
        if (team != null) {
            PlayerSettings playerSettings = Warlords.getPlayerSettings(player.getUniqueId());
            Warlords.addPlayer(new WarlordsPlayer(player, this, team, playerSettings));
        }
    });
    this.game.forEachOfflineWarlordsPlayer(wp -> {
        CustomScoreboard customScoreboard = Warlords.playerScoreboards.get(wp.getUuid());
        updateBasedOnGameState(customScoreboard, wp);
        if (wp.getEntity() instanceof Player) {
            wp.applySkillBoost((Player) wp.getEntity());
        }
    });
    if (DatabaseManager.playerService != null) {
        Warlords.newChain().async(() -> game.forEachOfflinePlayer((player, team) -> {
            DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
            DatabaseManager.updatePlayerAsync(databasePlayer);
            DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.SEASON_5, () -> {
            });
            DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.WEEKLY, () -> {
            });
            DatabaseManager.loadPlayer(player.getUniqueId(), PlayersCollections.DAILY, () -> {
            });
        })).execute();
    } else {
        System.out.println("ATTENTION - playerService is null");
    }
    game.registerEvents(new Listener() {

        @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
        public void onWin(WarlordsGameTriggerWinEvent event) {
            game.setNextState(new EndState(game, event));
            winEvent = event;
        }
    });
    GameRunnable.create(game, this::updateScoreboard).runTaskTimer(0, 10);
    new GameRunnable(game) {

        @Override
        public void run() {
            counter++;
            timer += GameRunnable.SECOND;
            if (counter >= 60) {
                counter -= 60;
                PlayerFilter.playingGame(game).forEach(wp -> wp.getMinuteStats().advanceMinute());
            }
            PlayerFilter.playingGame(game).forEach(wp -> wp.getSecondStats().advanceSecond());
        }
    }.runTaskTimer(0, GameRunnable.SECOND);
    game.registerGameMarker(TimerSkipAbleMarker.class, (delay) -> {
        counter += delay / GameRunnable.SECOND;
        timer += delay;
    });
    Warlords.getInstance().hideAndUnhidePeople();
}
Also used : DisplaySlot(org.bukkit.scoreboard.DisplaySlot) Utils(com.ebicep.warlords.util.warlords.Utils) GameAddon(com.ebicep.warlords.game.GameAddon) DatabaseManager(com.ebicep.warlords.database.DatabaseManager) CustomScoreboard(com.ebicep.warlords.player.CustomScoreboard) Player(org.bukkit.entity.Player) DatabaseGameBase(com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Objective(org.bukkit.scoreboard.Objective) Scoreboard(org.bukkit.scoreboard.Scoreboard) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler) GameMode(org.bukkit.GameMode) Location(org.bukkit.Location) SpawnLocationMarker(com.ebicep.warlords.game.option.marker.SpawnLocationMarker) RecordGamesCommand(com.ebicep.warlords.commands.debugcommands.RecordGamesCommand) ScoreboardHandler(com.ebicep.warlords.game.option.marker.scoreboard.ScoreboardHandler) LobbyLocationMarker(com.ebicep.warlords.game.option.marker.LobbyLocationMarker) TimerSkipAbleMarker(com.ebicep.warlords.game.option.marker.TimerSkipAbleMarker) RemoveEntities(com.ebicep.warlords.util.bukkit.RemoveEntities) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) LocationMarker(com.ebicep.warlords.game.option.marker.LocationMarker) Listener(org.bukkit.event.Listener) BotManager(com.ebicep.jda.BotManager) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) Team(com.ebicep.warlords.game.Team) Warlords(com.ebicep.warlords.Warlords) SRCalculator(com.ebicep.warlords.sr.SRCalculator) PlayersCollections(com.ebicep.warlords.database.repositories.player.PlayersCollections) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) PlayerFilter(com.ebicep.warlords.util.warlords.PlayerFilter) WarlordsGameTriggerWinEvent(com.ebicep.warlords.events.WarlordsGameTriggerWinEvent) List(java.util.List) Stream(java.util.stream.Stream) Game(com.ebicep.warlords.game.Game) ExperienceManager(com.ebicep.warlords.player.ExperienceManager) EventPriority(org.bukkit.event.EventPriority) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) ChatColor(org.bukkit.ChatColor) Option(com.ebicep.warlords.game.option.Option) Comparator(java.util.Comparator) Player(org.bukkit.entity.Player) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Listener(org.bukkit.event.Listener) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) EventHandler(org.bukkit.event.EventHandler) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) GameRunnable(com.ebicep.warlords.util.warlords.GameRunnable) CustomScoreboard(com.ebicep.warlords.player.CustomScoreboard) WarlordsGameTriggerWinEvent(com.ebicep.warlords.events.WarlordsGameTriggerWinEvent) Option(com.ebicep.warlords.game.option.Option) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 3 with PlayerSettings

use of com.ebicep.warlords.player.PlayerSettings in project Warlords by ebicep.

the class SpawnTestDummyCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    WarlordsPlayer player = BaseCommand.requireWarlordsPlayer(sender);
    if (!sender.hasPermission("warlords.game.spawndummy")) {
        sender.sendMessage("§cYou do not have permission to do that.");
        return true;
    }
    if (player == null) {
        return true;
    }
    if (!player.getGame().getAddons().contains(GameAddon.PRIVATE_GAME)) {
        sender.sendMessage("§cDebug commands are disabled in public games!");
        return true;
    }
    if (args.length >= 1) {
        String teamString = args[0];
        Optional<Team> teamOpt = TeamMarker.getTeams(player.getGame()).stream().filter(e -> e.name().equalsIgnoreCase(teamString)).findAny();
        if (teamOpt.isPresent()) {
            Team team = teamOpt.get();
            OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer("testdummy");
            WarlordsPlayer testDummy = new WarlordsPlayer(offlinePlayer, player.getGameState(), team, new PlayerSettings());
            Warlords.addPlayer(testDummy);
            if (args.length >= 2 && args[1].equalsIgnoreCase("false")) {
                testDummy.setTakeDamage(false);
            } else if (args.length >= 2 && args[1].equalsIgnoreCase("true")) {
                testDummy.setTakeDamage(true);
            } else {
                sender.sendMessage("§cInvalid arguments! Valid arguments: [true, false]");
            }
            testDummy.teleport(player.getLocation());
            // SKULL
            ItemStack playerSkull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
            SkullMeta skullMeta = (SkullMeta) playerSkull.getItemMeta();
            skullMeta.setOwner(offlinePlayer.getName());
            playerSkull.setItemMeta(skullMeta);
            Warlords.getPlayerHeads().put(offlinePlayer.getUniqueId(), CraftItemStack.asNMSCopy(playerSkull));
        } else {
            sender.sendMessage("§cUnable to find team named " + teamString + ", valid options: " + TeamMarker.getTeams(player.getGame()));
            return true;
        }
    }
    return true;
}
Also used : GameAddon(com.ebicep.warlords.game.GameAddon) CommandSender(org.bukkit.command.CommandSender) SkullType(org.bukkit.SkullType) BaseCommand(com.ebicep.warlords.commands.BaseCommand) Team(com.ebicep.warlords.game.Team) Warlords(com.ebicep.warlords.Warlords) CommandExecutor(org.bukkit.command.CommandExecutor) SkullMeta(org.bukkit.inventory.meta.SkullMeta) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) OfflinePlayer(org.bukkit.OfflinePlayer) ItemStack(org.bukkit.inventory.ItemStack) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) Optional(java.util.Optional) Command(org.bukkit.command.Command) TeamMarker(com.ebicep.warlords.game.option.marker.TeamMarker) Material(org.bukkit.Material) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack) Bukkit(org.bukkit.Bukkit) WarlordsPlayer(com.ebicep.warlords.player.WarlordsPlayer) OfflinePlayer(org.bukkit.OfflinePlayer) Team(com.ebicep.warlords.game.Team) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)

Example 4 with PlayerSettings

use of com.ebicep.warlords.player.PlayerSettings in project Warlords by ebicep.

the class HotkeyModeCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    Player player = BaseCommand.requirePlayer(sender);
    if (player != null) {
        PlayerSettings settings = Warlords.getPlayerSettings(player.getUniqueId());
        if (settings.getHotKeyMode()) {
            sender.sendMessage(ChatColor.GREEN + "Hotkey Mode " + ChatColor.AQUA + "Classic " + ChatColor.GREEN + "enabled.");
        } else {
            sender.sendMessage(ChatColor.GREEN + "Hotkey Mode " + ChatColor.YELLOW + "NEW " + ChatColor.GREEN + "enabled.");
        }
        settings.setHotKeyMode(!settings.getHotKeyMode());
        DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
        databasePlayer.setHotkeyMode(settings.getHotKeyMode() ? Settings.HotkeyMode.NEW_MODE : Settings.HotkeyMode.CLASSIC_MODE);
        DatabaseManager.updatePlayerAsync(databasePlayer);
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)

Example 5 with PlayerSettings

use of com.ebicep.warlords.player.PlayerSettings in project Warlords by ebicep.

the class ParticleQualityCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
    Player player = BaseCommand.requirePlayer(sender);
    if (player != null) {
        if (args.length == 0) {
            player.sendMessage(ChatColor.GREEN + "Possible Values: LOW, MEDIUM, HIGH");
            return true;
        }
        if (args[0] != null) {
            if (Arrays.stream(Settings.ParticleQuality.values()).anyMatch((t) -> t.name().equals(args[0].toUpperCase()))) {
                Settings.ParticleQuality newParticleQuality = Settings.ParticleQuality.valueOf(args[0].toUpperCase());
                PlayerSettings settings = Warlords.getPlayerSettings(player.getUniqueId());
                settings.setParticleQuality(newParticleQuality);
                DatabasePlayer databasePlayer = DatabaseManager.playerService.findByUUID(player.getUniqueId());
                databasePlayer.setParticleQuality(newParticleQuality);
                DatabaseManager.updatePlayerAsync(databasePlayer);
                sender.sendMessage(ChatColor.GREEN + "Particle Quality set to " + args[0].toUpperCase());
                return true;
            }
        }
        sender.sendMessage(ChatColor.RED + "Not found. Possible Values: LOW, MEDIUM, HIGH");
        return true;
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) PlayerSettings(com.ebicep.warlords.player.PlayerSettings) DatabasePlayer(com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer) Settings(com.ebicep.warlords.player.Settings) PlayerSettings(com.ebicep.warlords.player.PlayerSettings)

Aggregations

PlayerSettings (com.ebicep.warlords.player.PlayerSettings)5 Player (org.bukkit.entity.Player)4 DatabasePlayer (com.ebicep.warlords.database.repositories.player.pojos.general.DatabasePlayer)3 Warlords (com.ebicep.warlords.Warlords)2 GameAddon (com.ebicep.warlords.game.GameAddon)2 Team (com.ebicep.warlords.game.Team)2 WarlordsPlayer (com.ebicep.warlords.player.WarlordsPlayer)2 BotManager (com.ebicep.jda.BotManager)1 BaseCommand (com.ebicep.warlords.commands.BaseCommand)1 RecordGamesCommand (com.ebicep.warlords.commands.debugcommands.RecordGamesCommand)1 DatabaseManager (com.ebicep.warlords.database.DatabaseManager)1 DatabaseGameBase (com.ebicep.warlords.database.repositories.games.pojos.DatabaseGameBase)1 PlayersCollections (com.ebicep.warlords.database.repositories.player.PlayersCollections)1 WarlordsGameTriggerWinEvent (com.ebicep.warlords.events.WarlordsGameTriggerWinEvent)1 Game (com.ebicep.warlords.game.Game)1 Option (com.ebicep.warlords.game.option.Option)1 LobbyLocationMarker (com.ebicep.warlords.game.option.marker.LobbyLocationMarker)1 LocationMarker (com.ebicep.warlords.game.option.marker.LocationMarker)1 SpawnLocationMarker (com.ebicep.warlords.game.option.marker.SpawnLocationMarker)1 TeamMarker (com.ebicep.warlords.game.option.marker.TeamMarker)1