use of com.leomelonseeds.missilewars.arenas.Arena in project MissileWars by Leomelonseeds.
the class ArenaGameruleListener method onPortalCreate.
/**
* Make sure players can't create portals
*/
@EventHandler
public void onPortalCreate(PortalCreateEvent event) {
// Ensure it was in an arena world
String possibleArenaName = event.getWorld().getName().replace("mwarena_", "");
Arena possibleArena = MissileWarsPlugin.getPlugin().getArenaManager().getArena(possibleArenaName);
if (possibleArena == null) {
return;
}
event.setCancelled(true);
}
use of com.leomelonseeds.missilewars.arenas.Arena in project MissileWars by Leomelonseeds.
the class ArenaGameruleListener method onBreak.
/**
* Handle shield block breaks breaks.
*/
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
// Ensure it was in an arena world
String possibleArenaName = block.getWorld().getName().replace("mwarena_", "");
Arena possibleArena = MissileWarsPlugin.getPlugin().getArenaManager().getArena(possibleArenaName);
if (possibleArena == null) {
return;
}
// Fix dumb bug. No break obsidian
if (block.getType().toString().contains("OBSIDIAN")) {
event.setCancelled(true);
return;
}
// Register block break
possibleArena.registerShieldBlockEdit(block.getLocation(), false);
}
use of com.leomelonseeds.missilewars.arenas.Arena in project MissileWars by Leomelonseeds.
the class ArenaInventoryListener method onMapVote.
/**
* Handle map voting
*/
@EventHandler
public void onMapVote(InventoryClickEvent event) {
// Check if player is in an Arena
if (!(event.getWhoClicked() instanceof Player)) {
return;
}
Player player = (Player) event.getWhoClicked();
ArenaManager manager = MissileWarsPlugin.getPlugin().getArenaManager();
Arena arena = manager.getArena(player.getUniqueId());
// Ensure map vote inventory is open
if ((arena == null) || !event.getView().getTitle().equals(ConfigUtils.getConfigText("inventories.map-voting.title", player, null, null))) {
return;
}
// Cancel click and try to register vote
event.setCancelled(true);
ItemStack clicked = event.getCurrentItem();
if (clicked == null || !clicked.hasItemMeta() || !clicked.getItemMeta().hasDisplayName()) {
return;
}
String mapVotedFor = arena.registerVote(player.getUniqueId(), clicked.getItemMeta().getDisplayName());
player.sendMessage(ChatColor.GREEN + "Voted for " + mapVotedFor);
arena.openMapVote(player);
}
use of com.leomelonseeds.missilewars.arenas.Arena in project MissileWars by Leomelonseeds.
the class ArenaInventoryListener method stopItemMoving.
/**
* Stop players from changing their armor/bow items.
*/
@EventHandler
public void stopItemMoving(InventoryClickEvent event) {
// Obtain player
if (!(event.getClickedInventory() instanceof PlayerInventory)) {
return;
}
Player player = (Player) event.getWhoClicked();
// Check if player is in an active arena
ArenaManager manager = MissileWarsPlugin.getPlugin().getArenaManager();
Arena arena = manager.getArena(player.getUniqueId());
if (arena == null || !arena.isRunning()) {
return;
}
// Stop armor removals and first slot changes
if (event.getSlotType() == InventoryType.SlotType.ARMOR) {
event.setCancelled(true);
return;
}
}
use of com.leomelonseeds.missilewars.arenas.Arena in project MissileWars by Leomelonseeds.
the class ArenaInventoryListener method onItemPickup.
/**
* Manage item pickups.
*/
@EventHandler
public void onItemPickup(EntityPickupItemEvent event) {
// Check if player is in Arena
if (!(event.getEntity() instanceof Player)) {
return;
}
Player player = (Player) event.getEntity();
ArenaManager manager = MissileWarsPlugin.getPlugin().getArenaManager();
Arena arena = manager.getArena(player.getUniqueId());
if (arena == null) {
return;
}
MissileWarsPlayer mwPlayer = arena.getPlayerInArena(player.getUniqueId());
// Cancel event if player cannot pick up item based on their given deck
if (mwPlayer.getDeck() != null && !mwPlayer.getDeck().hasInventorySpace(mwPlayer.getMCPlayer())) {
event.setCancelled(true);
}
}
Aggregations