use of org.bukkit.Location in project Minigames by AddstarMC.
the class CheckpointSign method signUse.
@Override
public boolean signUse(Sign sign, MinigamePlayer player) {
if ((player.isInMinigame() || (!player.isInMinigame() && sign.getLine(2).equals(ChatColor.BLUE + "Global"))) && player.getPlayer().getInventory().getItemInMainHand().getType() == Material.AIR) {
if (player.isInMinigame() && player.getMinigame().isSpectator(player)) {
return false;
}
if (player.getPlayer().isOnGround()) {
Location newloc = player.getPlayer().getLocation();
if (!sign.getLine(2).equals(ChatColor.BLUE + "Global")) {
player.setCheckpoint(newloc);
} else {
player.getStoredPlayerCheckpoints().setGlobalCheckpoint(newloc);
}
player.sendMessage(ChatColor.AQUA + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.checkpoint.set"));
return true;
} else {
player.sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.checkpoint.fail"));
}
} else
player.sendMessage(ChatColor.AQUA + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("sign.emptyHand"));
return false;
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class StartPositionMode method onLeftClick.
@Override
public void onLeftClick(MinigamePlayer player, Minigame minigame, Team team, PlayerInteractEvent event) {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
int x = event.getClickedBlock().getLocation().getBlockX();
int y = event.getClickedBlock().getLocation().getBlockY();
int z = event.getClickedBlock().getLocation().getBlockZ();
String world = event.getClickedBlock().getLocation().getWorld().getName();
int nx;
int ny;
int nz;
String nworld;
Location delLoc = null;
if (team != null) {
if (team.hasStartLocations()) {
for (Location loc : team.getStartLocations()) {
nx = loc.getBlockX();
ny = loc.getBlockY();
nz = loc.getBlockZ();
nworld = loc.getWorld().getName();
if (x == nx && y == ny && z == nz && world.equals(nworld)) {
delLoc = loc;
break;
}
}
}
if (delLoc != null) {
team.getStartLocations().remove(delLoc);
player.sendMessage("Removed selected " + team.getChatColor() + team.getDisplayName() + ChatColor.WHITE + " start location.", null);
} else {
player.sendMessage("Could not find a " + team.getChatColor() + team.getDisplayName() + ChatColor.WHITE + " start location at that point.", "error");
}
} else {
for (Location loc : minigame.getStartLocations()) {
nx = loc.getBlockX();
ny = loc.getBlockY();
nz = loc.getBlockZ();
nworld = loc.getWorld().getName();
if (x == nx && y == ny && z == nz && world.equals(nworld)) {
delLoc = loc;
break;
}
}
if (delLoc != null) {
minigame.getStartLocations().remove(delLoc);
player.sendMessage("Removed selected start location.", null);
} else
player.sendMessage("Could not find a start location at that point.", "error");
}
}
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class MinigameUtils method loadShortLocation.
/**
* Loads a short location (x, y, z, world) from a configuration section
* @param section The section that contains the fields
* @return A location with the the contents of that section, or null if the world is invalid
*/
public static Location loadShortLocation(ConfigurationSection section) {
double x = section.getDouble("x");
double y = section.getDouble("y");
double z = section.getDouble("z");
String worldName = section.getString("world");
World world = Bukkit.getWorld(worldName);
if (world != null) {
return new Location(world, x, y, z);
} else {
return null;
}
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class RecorderData method cartkMoveItem.
@EventHandler(ignoreCancelled = true)
private void cartkMoveItem(InventoryMoveItemEvent event) {
if (!hasRegenArea() || !minigame.hasPlayers())
return;
Location loc = null;
if (event.getInitiator().getHolder() instanceof HopperMinecart) {
loc = ((HopperMinecart) event.getInitiator().getHolder()).getLocation().clone();
if (blockInRegenArea(loc))
addEntity((Entity) event.getInitiator().getHolder(), null, false);
}
loc = null;
if (event.getDestination().getHolder() instanceof HopperMinecart) {
loc = ((HopperMinecart) event.getDestination().getHolder()).getLocation().clone();
if (blockInRegenArea(loc))
addEntity((Entity) event.getInitiator().getHolder(), null, false);
}
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class BasicRecorder method bucketEmpty.
@EventHandler(ignoreCancelled = true)
private void bucketEmpty(PlayerBucketEmptyEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
Minigame mgm = ply.getMinigame();
RecorderData d = mgm.getBlockRecorder();
if (((d.getWhitelistMode() && d.getWBBlocks().contains(event.getBlockClicked().getType())) || (!d.getWhitelistMode() && !d.getWBBlocks().contains(event.getBlockClicked().getType()))) && mgm.canBlockPlace()) {
Location loc = new Location(event.getBlockClicked().getWorld(), event.getBlockFace().getModX() + event.getBlockClicked().getX(), event.getBlockFace().getModY() + event.getBlockClicked().getY(), event.getBlockFace().getModZ() + event.getBlockClicked().getZ());
d.addBlock(loc.getBlock(), pdata.getMinigamePlayer(event.getPlayer()));
} else {
event.setCancelled(true);
}
}
}
Aggregations