use of org.bukkit.Location in project Minigames by AddstarMC.
the class MinigameData method minigameLocations.
public Location minigameLocations(String minigame, String type, Configuration save) {
Double locx = (Double) save.get(minigame + "." + type + ".x");
Double locy = (Double) save.get(minigame + "." + type + ".y");
Double locz = (Double) save.get(minigame + "." + type + ".z");
Float yaw = new Float(save.get(minigame + "." + type + ".yaw").toString());
Float pitch = new Float(save.get(minigame + "." + type + ".pitch").toString());
String world = (String) save.get(minigame + "." + type + ".world");
Location loc = new Location(plugin.getServer().getWorld(world), locx, locy, locz, yaw, pitch);
return loc;
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class Events method onTeleportAway.
@EventHandler
public void onTeleportAway(PlayerTeleportEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame() && (event.getCause() == TeleportCause.COMMAND || event.getCause() == TeleportCause.PLUGIN || (!ply.getMinigame().isAllowedEnderpearls() && event.getCause() == TeleportCause.ENDER_PEARL))) {
if (!ply.getAllowTeleport()) {
Location from = event.getFrom();
Location to = event.getTo();
if (from.getWorld() != to.getWorld() || from.distance(to) > 2) {
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "[Minigames] " + ChatColor.WHITE + MinigameUtils.getLang("minigame.error.noTeleport"));
}
}
}
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class FloorDegenerator method degenerateRandom.
private void degenerateRandom(Location lowest, Location highest, int chance) {
Location curblock = lowest.clone();
int x = curblock.getBlockX();
int z = curblock.getBlockZ();
int y = curblock.getBlockY();
Random random = new Random();
do {
curblock.setZ(z);
curblock.setX(x);
curblock.setY(y);
for (int i = lowest.getBlockX(); i <= highest.getBlockX() + 1; i++) {
for (int k = lowest.getBlockZ(); k <= highest.getBlockZ() + 1; k++) {
if (curblock.getBlock().getType() != Material.AIR && random.nextInt(100) < chance) {
mgm.getBlockRecorder().addBlock(curblock.getBlock(), null);
curblock.getBlock().setType(Material.AIR);
}
curblock.setZ(k);
}
curblock.setX(i);
curblock.setZ(z);
}
y++;
} while (y <= highest.getBlockY());
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class FloorDegenerator method degenerateCircle.
private void degenerateCircle(Location lowest, Location highest) {
int middledist = (int) Math.abs(Math.floor((highest.getBlockX() - lowest.getBlockX()) / 2));
int radius = middledist - radiusModifier;
Location centerBlock = lowest.clone();
centerBlock.setX(centerBlock.getX() + middledist);
centerBlock.setZ(centerBlock.getZ() + middledist);
Location curBlock = centerBlock.clone();
int size = (int) Math.pow(radius, 3) + 8;
for (int i = 0; i < size; i++) {
double cirPoint = 2 * Math.PI * i / size;
double cx = centerBlock.getX() - 0.5 + Math.round(radius * Math.cos(cirPoint));
double cz = centerBlock.getZ() - 0.5 + Math.round(radius * Math.sin(cirPoint));
curBlock.setX(cx);
curBlock.setZ(cz);
for (int k = lowest.getBlockY(); k <= highest.getBlockY(); k++) {
curBlock.setY(k);
mgm.getBlockRecorder().addBlock(curBlock.getBlock(), null);
curBlock.getBlock().setType(Material.AIR);
}
}
radiusModifier++;
if (middledist == radiusModifier) {
stopDegenerator();
}
}
use of org.bukkit.Location in project Minigames by AddstarMC.
the class TreasureHuntMechanic method timerExpire.
@EventHandler
private void timerExpire(TimerExpireEvent event) {
if (event.getMinigame().getType() != MinigameType.GLOBAL && !event.getMinigame().getMechanicName().equals(getMechanic()))
return;
Minigame mgm = event.getMinigame();
TreasureHuntModule thm = TreasureHuntModule.getMinigameModule(mgm);
if (thm.hasTreasureLocation()) {
mgm.setMinigameTimer(new MinigameTimer(mgm, thm.getTreasureWaitTime()));
Location old = thm.getTreasureLocation();
removeTreasure(mgm);
if (!thm.isTreasureFound()) {
MinigameUtils.broadcast(MinigameUtils.formStr("minigame.treasurehunt.plyDespawn", mgm.getName(true)) + "\n" + ChatColor.GRAY + MinigameUtils.formStr("minigame.treasurehunt.plyDespawnCoords", old.getBlockX(), old.getBlockY(), old.getBlockZ()), mgm, "minigame.treasure.announce");
}
thm.setTreasureFound(false);
} else {
spawnTreasure(mgm);
}
}
Aggregations