use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class Events method onFriendHurt.
@EventHandler(priority = EventPriority.HIGHEST)
public void onFriendHurt(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player))
return;
Arena arena = ArenaRegistry.getArena((Player) event.getDamager());
if (arena == null)
return;
User user = UserManager.getUser(event.getDamager().getUniqueId());
if (user.isFakeDead()) {
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 Events method onEntityInteractEntity.
@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
Arena arena = ArenaRegistry.getArena(event.getPlayer());
if (arena == null)
return;
User user = UserManager.getUser(event.getPlayer().getUniqueId());
if (user.isFakeDead()) {
event.setCancelled(true);
return;
}
if (event.getPlayer().getItemInHand().getType() == Material.SADDLE) {
if (event.getRightClicked().getType() == EntityType.IRON_GOLEM || event.getRightClicked().getType() == EntityType.VILLAGER) {
event.getRightClicked().setPassenger(event.getPlayer());
event.setCancelled(true);
return;
}
}
if (event.getRightClicked().getType() == EntityType.VILLAGER) {
event.setCancelled(true);
ShopManager.openShop(event.getPlayer());
} else if (event.getRightClicked().getType() == EntityType.IRON_GOLEM) {
IronGolem ironGolem = (IronGolem) event.getRightClicked();
if (ironGolem.getCustomName() != null && ironGolem.getCustomName().contains(event.getPlayer().getName())) {
event.getRightClicked().setPassenger(event.getPlayer());
} else {
event.getPlayer().sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Cant-Ride-Others-Golem"));
}
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class LooterKit method onDeath.
@EventHandler
public void onDeath(EntityDeathEvent event) {
if (event.getEntity().getType() != EntityType.ZOMBIE)
return;
if (event.getEntity().getKiller() == null)
return;
Player player = event.getEntity().getKiller();
if (ArenaRegistry.getArena(player) == null)
return;
User user = UserManager.getUser(player.getUniqueId());
if (user.getKit() instanceof LooterKit) {
player.getInventory().addItem(new ItemStack(Material.ROTTEN_FLESH, 1));
}
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class WorkerKit method onDoorPlace.
@EventHandler(priority = EventPriority.HIGHEST)
public void onDoorPlace(BlockPlaceEvent event) {
Arena arena = ArenaRegistry.getArena(event.getPlayer());
if (arena == null)
return;
User user = UserManager.getUser(event.getPlayer().getUniqueId());
if (user.isSpectator()) {
event.setCancelled(true);
return;
}
if (event.getPlayer().getItemInHand() == null) {
event.setCancelled(true);
return;
}
if (!(event.getPlayer().getItemInHand().getType() == Material.WOOD_DOOR || event.getPlayer().getItemInHand().getType() == Material.WOODEN_DOOR)) {
event.setCancelled(true);
return;
}
if (!arena.getDoorLocations().containsKey(event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
event.setCancelled(false);
event.getPlayer().sendMessage(ChatManager.colorMessage("Kits.Worker.Game-Item-Place-Message"));
}
use of com.google.api.ads.admanager.axis.v202205.User in project Village_Defense by Plajer.
the class AdminCommands method addOrbsOther.
public void addOrbsOther(CommandSender sender, String p, String number) {
// check only target player, maybe sender would do this from console.
if (Bukkit.getPlayerExact(p) == null) {
sender.sendMessage(ChatColor.RED + "Target player doesn't exist!");
}
Player player = Bukkit.getPlayer(p);
if (!checkIsInGameInstance(player))
return;
if (!hasPermission(sender, "villagedefense.admin.addorbs.others"))
return;
if (NumberUtils.isNumber(number)) {
User user = UserManager.getUser(player.getUniqueId());
user.setInt("orbs", user.getInt("orbs") + Integer.parseInt(number));
sender.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("Commands.Admin-Commands.Added-Orbs"));
} else {
sender.sendMessage(ChatColor.RED + "Wrong usage. Do /villagedefense addorbs <player> <amount>");
}
}
Aggregations