use of com.google.api.ads.admanager.axis.v202111.User in project Village_Defense by Plajer.
the class QuitEvent method onQuitSaveStats.
@EventHandler
public void onQuitSaveStats(PlayerQuitEvent event) {
if (ArenaRegistry.getArena(event.getPlayer()) != null) {
ArenaRegistry.getArena(event.getPlayer()).leaveAttempt(event.getPlayer());
}
final User user = UserManager.getUser(event.getPlayer().getUniqueId());
final Player player = event.getPlayer();
if (plugin.isDatabaseActivated()) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
for (final String s : FileStats.STATISTICS) {
int i;
try {
i = plugin.getMySQLDatabase().getStat(player.getUniqueId().toString(), s);
} catch (NullPointerException npe) {
i = 0;
System.out.print("COULDN'T GET STATS FROM PLAYER: " + player.getName());
npe.printStackTrace();
BigTextUtils.errorOccured();
Bukkit.getConsoleSender().sendMessage("Cannot get stats from MySQL database!");
Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
}
if (i > user.getInt(s)) {
plugin.getMySQLDatabase().setStat(player.getUniqueId().toString(), s, user.getInt(s) + i);
} else {
plugin.getMySQLDatabase().setStat(player.getUniqueId().toString(), s, user.getInt(s));
}
}
});
} else {
for (String s : FileStats.STATISTICS) {
plugin.getFileStats().saveStat(player, s);
}
}
}
use of com.google.api.ads.admanager.axis.v202111.User in project Village_Defense by Plajer.
the class BlockerKit method onBarrierPlace.
@EventHandler(priority = EventPriority.HIGHEST)
public void onBarrierPlace(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Player player = event.getPlayer();
if (player.getItemInHand() == null)
return;
if (ArenaRegistry.getArena(player) == null)
return;
if (!player.getItemInHand().hasItemMeta())
return;
if (!player.getItemInHand().getItemMeta().hasDisplayName())
return;
if (!player.getItemInHand().getItemMeta().getDisplayName().equalsIgnoreCase(ChatManager.colorMessage("Kits.Blocker.Game-Item-Name")))
return;
Block block = null;
for (Block blocks : player.getLastTwoTargetBlocks(null, 5)) {
if (blocks.getType() == Material.AIR)
block = blocks;
}
if (block == null) {
event.getPlayer().sendMessage(ChatManager.colorMessage("Kits.Blocker.Game-Item-Place-Fail"));
return;
}
if (player.getItemInHand().getAmount() <= 1) {
player.setItemInHand(new ItemStack(Material.AIR));
} else {
player.getItemInHand().setAmount(player.getItemInHand().getAmount() - 1);
}
User user = UserManager.getUser(event.getPlayer().getUniqueId());
user.toPlayer().sendMessage(ChatManager.colorMessage("Kits.Blocker.Game-Item-Place-Message"));
ZombieBarrier zombieBarrier = new ZombieBarrier();
zombieBarrier.setLocation(block.getLocation());
zombieBarrier.getLocation().getWorld().playEffect(zombieBarrier.getLocation(), Effect.FIREWORKS_SPARK, 20);
new BukkitRunnable() {
@Override
public void run() {
zombieBarrier.decrementSeconds();
if (zombieBarrier.getSeconds() <= 0) {
zombieBarrier.getLocation().getBlock().setType(Material.AIR);
if (plugin.is1_8_R3()) {
zombieBarrier.getLocation().getWorld().playEffect(zombieBarrier.getLocation(), Effect.FIREWORKS_SPARK, 20);
} else {
zombieBarrier.getLocation().getWorld().spawnParticle(Particle.FIREWORKS_SPARK, zombieBarrier.getLocation(), 20);
}
this.cancel();
}
}
}.runTaskTimer(plugin, 20, 20);
block.setType(Material.FENCE);
}
use of com.google.api.ads.admanager.axis.v202111.User in project Village_Defense by Plajer.
the class Events method onItemPickup.
@EventHandler
public void onItemPickup(PlayerExpChangeEvent event) {
Arena arena = ArenaRegistry.getArena(event.getPlayer());
if (arena == null)
return;
int amount = (int) Math.ceil(event.getAmount() * 1.6);
User user = UserManager.getUser(event.getPlayer().getUniqueId());
event.setAmount(amount);
if (user.isFakeDead()) {
event.setAmount(0);
return;
}
// bonus orbs with custom permissions
for (String perm : plugin.getCustomPermissions().keySet()) {
if (event.getPlayer().hasPermission(perm)) {
amount = +(int) Math.ceil(event.getAmount() * (plugin.getCustomPermissions().get(perm) / 100));
user.addInt("orbs", (int) Math.ceil(event.getAmount() * (plugin.getCustomPermissions().get(perm) / 100)));
}
}
if (event.getPlayer().hasPermission(PermissionsManager.getElite())) {
amount = +(int) Math.ceil(event.getAmount() * 1.5);
user.addInt("orbs", (int) Math.ceil(event.getAmount() * 1.5));
} else if (event.getPlayer().hasPermission(PermissionsManager.getMvp())) {
amount = +(int) Math.ceil(event.getAmount() * 1.0);
user.addInt("orbs", (int) Math.ceil(event.getAmount() * 1.0));
} else if (event.getPlayer().hasPermission(PermissionsManager.getVip())) {
amount = +(int) Math.ceil(event.getAmount() * 0.5);
user.addInt("orbs", (int) Math.ceil(event.getAmount() * 0.5));
} else {
amount = +event.getAmount();
user.addInt("orbs", event.getAmount());
}
event.getPlayer().sendMessage(ChatManager.colorMessage("In-Game.Orbs-Pickup").replaceAll("%number%", String.valueOf(amount)));
}
use of com.google.api.ads.admanager.axis.v202111.User in project Village_Defense by Plajer.
the class Events method onSecond.
@EventHandler(priority = EventPriority.HIGHEST)
public void onSecond(EntityDamageByEntityEvent event) {
User user = UserManager.getUser((event.getDamager().getUniqueId()));
if (user.isFakeDead() || user.isSpectator()) {
event.setCancelled(true);
return;
}
if (!(event.getDamager() instanceof Arrow))
return;
Arrow arrow = (Arrow) event.getDamager();
if (arrow.getShooter() == null)
return;
if (!(arrow.getShooter() instanceof Player))
return;
Arena arena = ArenaRegistry.getArena((Player) arrow.getShooter());
if (arena == null)
return;
if (user.isFakeDead() || user.isSpectator()) {
event.setCancelled(true);
return;
}
if (!VILLAGE_ENTITIES.contains(event.getEntityType()))
return;
event.setCancelled(true);
}
use of com.google.api.ads.admanager.axis.v202111.User in project Village_Defense by Plajer.
the class AdminCommands method respawnOther.
public void respawnOther(CommandSender sender, String player) {
if (checkSenderIsConsole(sender))
return;
if (!checkIsInGameInstance((Player) sender))
return;
if (!hasPermission(sender, "villagedefense.admin.respawn.others"))
return;
Arena arena = ArenaRegistry.getArena((Player) sender);
for (Player loopPlayer : arena.getPlayers()) {
if (player.equalsIgnoreCase(loopPlayer.getName())) {
loopPlayer.setGameMode(GameMode.SURVIVAL);
User user = UserManager.getUser(loopPlayer.getUniqueId());
user.setFakeDead(false);
user.setSpectator(false);
sender.sendMessage(ChatColor.GREEN + "Player respawned!");
arena.teleportToStartLocation(loopPlayer);
loopPlayer.setFlying(false);
loopPlayer.setAllowFlight(false);
ArenaUtils.showPlayer(loopPlayer, arena);
loopPlayer.getInventory().clear();
user.getKit().giveKitItems(loopPlayer);
loopPlayer.sendMessage(ChatManager.colorMessage("In-Game.Back-In-Game"));
return;
}
}
sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Player-Not-Found"));
}
Aggregations