use of com.google.api.ads.admanager.axis.v202205.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.v202205.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.v202205.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.v202205.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"));
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class MySQLConnectionUtils method loadPlayerStats.
public static void loadPlayerStats(Player player, Main plugin) {
boolean b = false;
MySQLDatabase database = plugin.getMySQLDatabase();
ResultSet resultSet = database.executeQuery("SELECT UUID from playerstats WHERE UUID='" + player.getUniqueId().toString() + "'");
try {
if (!resultSet.next()) {
database.insertPlayer(player.getUniqueId().toString());
b = true;
}
int gamesplayed;
int zombiekills;
int highestwave;
int deaths;
int xp;
int level;
int orbs;
gamesplayed = database.getStat(player.getUniqueId().toString(), "gamesplayed");
zombiekills = database.getStat(player.getUniqueId().toString(), "kills");
highestwave = database.getStat(player.getUniqueId().toString(), "highestwave");
deaths = database.getStat(player.getUniqueId().toString(), "deaths");
xp = database.getStat(player.getUniqueId().toString(), "xp");
level = database.getStat(player.getUniqueId().toString(), "level");
orbs = database.getStat(player.getUniqueId().toString(), "orbs");
User user = UserManager.getUser(player.getUniqueId());
user.setInt("gamesplayed", gamesplayed);
user.setInt("kills", zombiekills);
user.setInt("highestwave", highestwave);
user.setInt("deaths", deaths);
user.setInt("xp", xp);
user.setInt("level", level);
user.setInt("orbs", orbs);
b = true;
} catch (SQLException e1) {
System.out.print("CONNECTION FAILED FOR PLAYER " + player.getName());
e1.printStackTrace();
BigTextUtils.errorOccured();
Bukkit.getConsoleSender().sendMessage("Cannot save contents to MySQL database!");
Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
}
if (!b) {
try {
if (!resultSet.next()) {
database.insertPlayer(player.getUniqueId().toString());
}
int gamesplayed;
int zombiekills;
int highestwave;
int deaths;
int xp;
int level;
int orbs;
gamesplayed = database.getStat(player.getUniqueId().toString(), "gamesplayed");
zombiekills = database.getStat(player.getUniqueId().toString(), "kills");
highestwave = database.getStat(player.getUniqueId().toString(), "highestwave");
deaths = database.getStat(player.getUniqueId().toString(), "deaths");
xp = database.getStat(player.getUniqueId().toString(), "xp");
level = database.getStat(player.getUniqueId().toString(), "level");
orbs = database.getStat(player.getUniqueId().toString(), "orbs");
User user = UserManager.getUser(player.getUniqueId());
user.setInt("gamesplayed", gamesplayed);
user.setInt("kills", zombiekills);
user.setInt("highestwave", highestwave);
user.setInt("deaths", deaths);
user.setInt("xp", xp);
user.setInt("level", level);
user.setInt("orbs", orbs);
} catch (SQLException e1) {
System.out.print("CONNECTION FAILED TWICE FOR PLAYER " + player.getName());
e1.printStackTrace();
BigTextUtils.errorOccured();
Bukkit.getConsoleSender().sendMessage("Cannot save contents to MySQL database!");
Bukkit.getConsoleSender().sendMessage("Check configuration of mysql.yml file or disable mysql option in config.yml");
}
}
}
Aggregations