use of com.google.api.ads.admanager.axis.v202205.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 com.google.api.ads.admanager.axis.v202205.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);
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class Arena method addExperience.
void addExperience(Player player, int i) {
User user = UserManager.getUser(player.getUniqueId());
user.addInt("xp", i);
if (player.hasPermission(PermissionsManager.getVip())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
if (player.hasPermission(PermissionsManager.getMvp())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
if (player.hasPermission(PermissionsManager.getElite())) {
user.addInt("xp", (int) Math.ceil(i / 2));
}
ArenaUtils.updateLevelStat(player, this);
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class FileStats method saveStat.
public void saveStat(Player player, String stat) {
User user = UserManager.getUser(player.getUniqueId());
config.set(player.getUniqueId().toString() + "." + stat, user.getInt(stat));
try {
config.save(ConfigurationManager.getFile("stats"));
} catch (IOException e) {
e.printStackTrace();
BigTextUtils.errorOccured();
Bukkit.getConsoleSender().sendMessage("Cannot save stats.yml file!");
Bukkit.getConsoleSender().sendMessage("Restart the server, file COULD BE OVERRIDDEN!");
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class Events method onShop.
@EventHandler
public void onShop(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player))
return;
Player player = (Player) event.getWhoClicked();
Inventory inv = event.getInventory();
Arena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
if (arena == null)
return;
User user = UserManager.getUser(player.getUniqueId());
if (user.isFakeDead()) {
event.setCancelled(true);
return;
}
if (inv.getName() == null || !inv.getName().equalsIgnoreCase(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Shop-GUI-Name")))
return;
event.setCancelled(true);
if (event.getCurrentItem() == null || !event.getCurrentItem().hasItemMeta() || !event.getCurrentItem().getItemMeta().hasLore())
return;
String string = event.getCurrentItem().getItemMeta().getLore().get(0);
string = ChatColor.stripColor(string);
if (!(string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs"))) {
boolean b = false;
for (String s : event.getCurrentItem().getItemMeta().getLore()) {
if (string.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop")) || string.contains("orbs")) {
string = s;
b = true;
}
}
if (!b)
return;
}
int price = Integer.parseInt(string.split(" ")[0]);
if (price > UserManager.getUser(player.getUniqueId()).getInt("orbs")) {
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Not-Enough-Orbs"));
return;
}
if (event.getCurrentItem().hasItemMeta() && event.getCurrentItem().getItemMeta().hasDisplayName()) {
if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Golem-Item-Name"))) {
arena.spawnGolem(arena.getStartLocation(), player);
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Golem-Spawned"));
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
return;
}
if (event.getCurrentItem().getItemMeta().getDisplayName().contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Wolf-Item-Name"))) {
arena.spawnWolf(arena.getStartLocation(), player);
player.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Wolf-Spawned"));
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
return;
}
}
ItemStack itemStack = event.getCurrentItem().clone();
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
for (String loopLore : lore) {
if (loopLore.contains(ChatManager.colorMessage("In-Game.Messages.Shop-Messages.Currency-In-Shop"))) {
lore.remove(loopLore);
}
}
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
player.getInventory().addItem(itemStack);
UserManager.getUser(player.getUniqueId()).setInt("orbs", UserManager.getUser(player.getUniqueId()).getInt("orbs") - price);
}
Aggregations