use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class ArenaUtils method updateScoreboard.
public static void updateScoreboard(Arena arena) {
if (arena.getPlayers().size() == 0)
return;
for (Player p : arena.getPlayers()) {
User user = UserManager.getUser(p.getUniqueId());
if (user.getScoreboard().getObjective("vd_state_0") == null) {
for (ArenaState state : ArenaState.values()) {
user.getScoreboard().registerNewObjective("vd_state_" + state.ordinal(), "dummy");
}
// fighting stage of IN_GAME state
user.getScoreboard().registerNewObjective("vd_state_2F", "dummy");
}
if (arena.getArenaState() == ArenaState.ENDING) {
user.removeScoreboard();
return;
}
Objective gameObjective;
if (arena.getArenaState() == ArenaState.IN_GAME) {
gameObjective = user.getScoreboard().getObjective("vd_state_" + arena.getArenaState().ordinal() + (arena.isFighting() ? "F" : ""));
} else {
gameObjective = user.getScoreboard().getObjective("vd_state_" + arena.getArenaState().ordinal());
}
if (gameObjective == null)
return;
gameObjective.setDisplayName(ChatManager.colorMessage("Scoreboard.Header"));
gameObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
switch(arena.getArenaState()) {
case WAITING_FOR_PLAYERS:
Score playersTotal1 = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players")));
playersTotal1.setScore(arena.getPlayers().size());
Score neededPlayers2 = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Minimum-Players")));
neededPlayers2.setScore(arena.getMinimumPlayers());
break;
case STARTING:
Score timer = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Starting-In")));
timer.setScore(arena.getTimer());
Score playersTotal = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players")));
playersTotal.setScore(arena.getPlayers().size());
Score neededPlayers = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Minimum-Players")));
neededPlayers.setScore(arena.getMinimumPlayers());
break;
case IN_GAME:
Score playersLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Players-Left")));
playersLeft.setScore(arena.getPlayersLeft().size());
Score villagersLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Villagers-Left")));
villagersLeft.setScore(arena.getVillagers().size());
Score orbs = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Orbs")));
orbs.setScore(user.getInt("orbs"));
if (arena.isFighting()) {
Score zombiesLeft = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Zombies-Left")));
zombiesLeft.setScore(arena.getZombiesLeft());
} else {
Score nextWaveIn = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Next-Wave-In")));
nextWaveIn.setScore(arena.getTimer());
}
Score rottenFlesh = gameObjective.getScore(ChatManager.formatMessage(arena, ChatManager.colorMessage("Scoreboard.Rotten-Flesh")));
rottenFlesh.setScore(arena.getRottenFlesh());
break;
case RESTARTING:
break;
default:
arena.setArenaState(ArenaState.WAITING_FOR_PLAYERS);
break;
}
Score empty = gameObjective.getScore("");
empty.setScore(-1);
Score footer = gameObjective.getScore(ChatManager.colorMessage("Scoreboard.Footer"));
footer.setScore(-2);
user.setScoreboard(user.getScoreboard());
}
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class GameCommands method sendStatsOther.
public void sendStatsOther(CommandSender sender, String p) {
Player player = Bukkit.getPlayerExact(p);
if (player == null || UserManager.getUser(player.getUniqueId()) == null) {
sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Player-Not-Found"));
return;
}
User user = UserManager.getUser(player.getUniqueId());
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Header-Other").replaceAll("%player%", player.getName()));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Kills") + user.getInt("kills"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Deaths") + user.getInt("deaths"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Games-Played") + user.getInt("gamesplayed"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Highest-Wave") + user.getInt("highestwave"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Level") + user.getInt("level"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Exp") + user.getInt("xp"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Next-Level-Exp") + Math.ceil(Math.pow(50 * user.getInt("level"), 1.5)));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Footer"));
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class GameCommands method sendStats.
public void sendStats(CommandSender sender) {
if (checkSenderIsConsole(sender))
return;
User user = UserManager.getUser(((Player) sender).getUniqueId());
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Header"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Kills") + user.getInt("kills"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Deaths") + user.getInt("deaths"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Games-Played") + user.getInt("gamesplayed"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Highest-Wave") + user.getInt("highestwave"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Level") + user.getInt("level"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Exp") + user.getInt("xp"));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Next-Level-Exp") + Math.ceil(Math.pow(50 * user.getInt("level"), 1.5)));
sender.sendMessage(ChatManager.colorMessage("Commands.Stats-Command.Footer"));
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Arena method leaveAttempt.
/**
* Attempts player to leave arena.
* Calls VillageGameLeaveAttemptEvent event.
*
* @param p player to join
* @see VillageGameLeaveAttemptEvent
*/
public void leaveAttempt(Player p) {
VillageGameLeaveAttemptEvent villageGameLeaveAttemptEvent = new VillageGameLeaveAttemptEvent(p, this);
Bukkit.getPluginManager().callEvent(villageGameLeaveAttemptEvent);
if (Main.isDebugged()) {
System.out.println("[Village Debugger] Player " + p.getName() + " is attemping to leave arena!");
}
User user = UserManager.getUser(p.getUniqueId());
user.setInt("orbs", 0);
p.getInventory().clear();
ArmorHelper.clearArmor(p);
this.removePlayer(p);
if (!user.isSpectator()) {
ChatManager.broadcastLeaveMessage(this, p);
}
user.setFakeDead(false);
user.setSpectator(false);
user.removeScoreboard();
if (user.getKit() instanceof GolemFriendKit) {
for (IronGolem ironGolem : getIronGolems()) {
if (ironGolem.getCustomName().contains(user.toPlayer().getName()))
ironGolem.remove();
}
}
if (plugin.isBossbarEnabled()) {
gameBar.removePlayer(p);
}
p.setMaxHealth(20.0);
p.setHealth(p.getMaxHealth());
p.setFoodLevel(20);
p.setFlying(false);
p.setAllowFlight(false);
for (PotionEffect effect : p.getActivePotionEffects()) {
p.removePotionEffect(effect.getType());
}
p.setFireTicks(0);
if (getPlayers().size() == 0) {
this.setArenaState(ArenaState.RESTARTING);
}
p.setGameMode(GameMode.SURVIVAL);
for (Player players : plugin.getServer().getOnlinePlayers()) {
if (ArenaRegistry.getArena(players) != null)
players.showPlayer(p);
p.showPlayer(players);
}
this.teleportToEndLocation(p);
if (!plugin.isBungeeActivated() && plugin.isInventoryManagerEnabled()) {
plugin.getInventoryManager().loadInventory(p);
}
}
use of sqlite.kripton209.model1.User in project Village_Defense by Plajer.
the class Arena method startWave.
private void startWave() {
VillageWaveStartEvent villageWaveStartEvent = new VillageWaveStartEvent(this, wave);
Bukkit.getPluginManager().callEvent(villageWaveStartEvent);
setZombieAmount();
if (plugin.getConfig().getBoolean("Respawn-After-Wave"))
ArenaUtils.bringDeathPlayersBack(this);
for (User user : UserManager.getUsers(this)) {
user.getKit().reStock(user.toPlayer());
}
String message = ChatManager.formatMessage(this, ChatManager.colorMessage("In-Game.Messages.Wave-Started"), wave);
for (Player player1 : getPlayers()) {
player1.sendMessage(ChatManager.PLUGIN_PREFIX + message);
}
}
Aggregations