use of com.wasteofplastic.askyblock.Island in project askyblock by tastybento.
the class IslandCmd method addPlayertoTeam.
/**
* Adds a player to a team. The player and the teamleader MAY be the same
*
* @param playerUUID - the player's UUID
* @param teamLeader
* @return true if the player is successfully added
*/
public boolean addPlayertoTeam(final UUID playerUUID, final UUID teamLeader) {
// location
if (!plugin.getPlayers().setJoinTeam(playerUUID, teamLeader, plugin.getPlayers().getIslandLocation(teamLeader))) {
return false;
}
// if it exists, and if not set to the island location
if (!playerUUID.equals(teamLeader)) {
// Clear any old home locations
plugin.getPlayers().clearHomeLocations(playerUUID);
// Set homes and spawn point home locations if they exist
for (Entry<Integer, Location> homes : plugin.getPlayers().getHomeLocations(teamLeader).entrySet()) {
if (homes.getKey() < 2) {
plugin.getPlayers().setHomeLocation(playerUUID, homes.getValue(), homes.getKey());
}
}
if (plugin.getPlayers().getHomeLocation(teamLeader, 1) == null) {
plugin.getPlayers().setHomeLocation(playerUUID, plugin.getPlayers().getIslandLocation(teamLeader));
// plugin.getLogger().info("DEBUG: Setting player's home to the team island location");
}
// If the leader's member list does not contain player then add it
if (!plugin.getPlayers().getMembers(teamLeader).contains(playerUUID)) {
plugin.getPlayers().addTeamMember(teamLeader, playerUUID);
}
// add it
if (!plugin.getPlayers().getMembers(teamLeader).contains(teamLeader)) {
plugin.getPlayers().addTeamMember(teamLeader, teamLeader);
}
// Fire event
final Island island = plugin.getGrid().getIsland(teamLeader);
final IslandJoinEvent event = new IslandJoinEvent(playerUUID, island);
plugin.getServer().getPluginManager().callEvent(event);
}
return true;
}
use of com.wasteofplastic.askyblock.Island in project askyblock by tastybento.
the class PlayerEvents3 method onVisitorPickup.
/*
* Prevent item pickup by visitors for 1.12+.
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorPickup(final EntityPickupItemEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (e.getEntity() instanceof Player) {
Player player = (Player) e.getEntity();
if (!IslandGuard.inWorld(player)) {
return;
}
Island island = plugin.getGrid().getIslandAt(e.getItem().getLocation());
if ((island != null && island.getIgsFlag(SettingsFlag.VISITOR_ITEM_PICKUP)) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().locationIsOnIsland(player, e.getItem().getLocation())) {
return;
}
e.setCancelled(true);
}
}
use of com.wasteofplastic.askyblock.Island in project askyblock by tastybento.
the class BiomesPanel method onInventoryClick.
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryClick(InventoryClickEvent event) {
// The player that
Player player = (Player) event.getWhoClicked();
// clicked the item
UUID playerUUID = player.getUniqueId();
// The inventory that was
Inventory inventory = event.getInventory();
// clicked in
int slot = event.getRawSlot();
// Check this is the right panel
if (inventory.getName() == null || !inventory.getName().equals(plugin.myLocale().biomePanelTitle)) {
return;
}
if (slot == -999) {
inventory.clear();
player.closeInventory();
event.setCancelled(true);
return;
}
if (event.getClick().equals(ClickType.SHIFT_RIGHT)) {
event.setCancelled(true);
inventory.clear();
player.closeInventory();
player.updateInventory();
return;
}
// Get the list of items for this player
List<BiomeItem> thisPanel = biomeItems.get(player.getUniqueId());
if (thisPanel == null) {
inventory.clear();
player.closeInventory();
event.setCancelled(true);
return;
}
if (slot >= 0 && slot < thisPanel.size()) {
event.setCancelled(true);
// plugin.getLogger().info("DEBUG: slot is " + slot);
// Do something
// Check this player has an island
Island island = plugin.getGrid().getIsland(playerUUID);
if (island == null) {
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoIsland);
return;
}
// Check ownership
if (!island.getOwner().equals(playerUUID)) {
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).levelerrornotYourIsland);
return;
}
if (!plugin.getGrid().playerIsOnIsland(player)) {
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).challengeserrorNotOnIsland);
return;
}
Biome biome = thisPanel.get(slot).getBiome();
if (biome != null) {
event.setCancelled(true);
if (Settings.useEconomy) {
// Check cost
double cost = thisPanel.get(slot).getPrice();
if (cost > 0D) {
if (!VaultHelper.econ.has(player, Settings.worldName, cost)) {
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).minishopYouCannotAfford.replace("[description]", VaultHelper.econ.format(cost)));
return;
} else {
VaultHelper.econ.withdrawPlayer(player, Settings.worldName, cost);
Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).biomeYouBought.replace("[cost]", VaultHelper.econ.format(cost)));
}
}
}
}
inventory.clear();
// Closes the inventory
player.closeInventory();
// Actually set the biome
Util.sendMessage(player, ChatColor.GREEN + plugin.myLocale(player.getUniqueId()).biomePleaseWait);
new SetBiome(plugin, island, biome, player);
}
return;
}
use of com.wasteofplastic.askyblock.Island in project askyblock by tastybento.
the class IslandGuard method onEggThrow.
/**
* Handle visitor chicken egg throwing
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEggThrow(PlayerEggThrowEvent e) {
if (DEBUG) {
plugin.getLogger().info("egg throwing = " + e.getEventName());
}
if (!inWorld(e.getPlayer()) || e.getPlayer().isOp() || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().playerIsOnIsland(e.getPlayer()) || plugin.getGrid().isAtSpawn(e.getPlayer().getLocation())) {
return;
}
// Check island
Island island = plugin.getGrid().getProtectedIslandAt(e.getPlayer().getLocation());
if (island == null) {
return;
}
if (!island.getIgsFlag(SettingsFlag.EGGS)) {
e.setHatching(false);
Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
// e.getPlayer().updateInventory();
}
return;
}
use of com.wasteofplastic.askyblock.Island in project askyblock by tastybento.
the class IslandGuard method onProjectileHit.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onProjectileHit(EntityInteractEvent e) {
if (e.getEntity() == null || !(e.getEntity() instanceof Projectile)) {
return;
}
Projectile p = (Projectile) e.getEntity();
if (p.getShooter() != null && p.getShooter() instanceof Player && e.getBlock() != null) {
Player player = (Player) p.getShooter();
if (!inWorld(player) || player.isOp() || VaultHelper.checkPerm(player, Settings.PERMPREFIX + "mod.bypassprotect") || plugin.getGrid().playerIsOnIsland(player)) {
return;
}
Island island = plugin.getGrid().getProtectedIslandAt(e.getBlock().getLocation());
switch(e.getBlock().getType()) {
case WOOD_BUTTON:
case STONE_BUTTON:
if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.LEVER_BUTTON))) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.LEVER_BUTTON)) {
return;
}
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected);
e.setCancelled(true);
break;
case WOOD_PLATE:
case STONE_PLATE:
case GOLD_PLATE:
case IRON_PLATE:
// Pressure plates
if ((island == null && Settings.defaultWorldSettings.get(SettingsFlag.PRESSURE_PLATE))) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.PRESSURE_PLATE)) {
return;
}
Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).islandProtected);
e.setCancelled(true);
break;
default:
break;
}
}
}
Aggregations