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;
}
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();
}
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;
}
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;
}
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;
}
Aggregations