mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-18 05:21:57 +01:00
Change in SafeTTeleporter: We can SET the BlockSafety!
This commit is contained in:
parent
59f2c8b62e
commit
b4ea5e9299
@ -33,11 +33,9 @@ import java.util.logging.Level;
|
|||||||
public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
||||||
|
|
||||||
private MultiverseCore plugin;
|
private MultiverseCore plugin;
|
||||||
private BlockSafety bs;
|
|
||||||
|
|
||||||
public SimpleSafeTTeleporter(MultiverseCore plugin) {
|
public SimpleSafeTTeleporter(MultiverseCore plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.bs = plugin.getBlockSafety();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int DEFAULT_TOLERANCE = 6;
|
private static final int DEFAULT_TOLERANCE = 6;
|
||||||
@ -144,13 +142,13 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
// ...
|
// ...
|
||||||
int adjustedCircle = ((circle - 1) / 2);
|
int adjustedCircle = ((circle - 1) / 2);
|
||||||
checkLoc.add(adjustedCircle, 0, 0);
|
checkLoc.add(adjustedCircle, 0, 0);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Now we go to the right that adjustedCircle many
|
// Now we go to the right that adjustedCircle many
|
||||||
for (int i = 0; i < adjustedCircle; i++) {
|
for (int i = 0; i < adjustedCircle; i++) {
|
||||||
checkLoc.add(0, 0, 1);
|
checkLoc.add(0, 0, 1);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,7 +156,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
// Then down adjustedCircle *2
|
// Then down adjustedCircle *2
|
||||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||||
checkLoc.add(-1, 0, 0);
|
checkLoc.add(-1, 0, 0);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -166,7 +164,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
// Then left adjustedCircle *2
|
// Then left adjustedCircle *2
|
||||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||||
checkLoc.add(0, 0, -1);
|
checkLoc.add(0, 0, -1);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +172,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
// Then up Then left adjustedCircle *2
|
// Then up Then left adjustedCircle *2
|
||||||
for (int i = 0; i < adjustedCircle * 2; i++) {
|
for (int i = 0; i < adjustedCircle * 2; i++) {
|
||||||
checkLoc.add(1, 0, 0);
|
checkLoc.add(1, 0, 0);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,7 +180,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
// Then finish up by doing adjustedCircle - 1
|
// Then finish up by doing adjustedCircle - 1
|
||||||
for (int i = 0; i < adjustedCircle - 1; i++) {
|
for (int i = 0; i < adjustedCircle - 1; i++) {
|
||||||
checkLoc.add(0, 0, 1);
|
checkLoc.add(0, 0, 1);
|
||||||
if (this.bs.playerCanSpawnHereSafely(checkLoc)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(checkLoc)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,25 +249,25 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
|
|||||||
@Override
|
@Override
|
||||||
public Location getSafeLocation(Entity e, MVDestination d) {
|
public Location getSafeLocation(Entity e, MVDestination d) {
|
||||||
Location l = d.getLocation(e);
|
Location l = d.getLocation(e);
|
||||||
if (this.bs.playerCanSpawnHereSafely(l)) {
|
if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) {
|
||||||
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
plugin.log(Level.FINE, "The first location you gave me was safe.");
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
if (e instanceof Minecart) {
|
if (e instanceof Minecart) {
|
||||||
Minecart m = (Minecart) e;
|
Minecart m = (Minecart) e;
|
||||||
if (!this.bs.canSpawnCartSafely(m)) {
|
if (!plugin.getBlockSafety().canSpawnCartSafely(m)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else if (e instanceof Vehicle) {
|
} else if (e instanceof Vehicle) {
|
||||||
Vehicle v = (Vehicle) e;
|
Vehicle v = (Vehicle) e;
|
||||||
if (!this.bs.canSpawnVehicleSafely(v)) {
|
if (!plugin.getBlockSafety().canSpawnVehicleSafely(v)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Location safeLocation = this.getSafeLocation(l);
|
Location safeLocation = this.getSafeLocation(l);
|
||||||
if (safeLocation != null) {
|
if (safeLocation != null) {
|
||||||
// Add offset to account for a vehicle on dry land!
|
// Add offset to account for a vehicle on dry land!
|
||||||
if (e instanceof Minecart && !this.bs.isEntitiyOnTrack(safeLocation)) {
|
if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) {
|
||||||
safeLocation.setY(safeLocation.getBlockY() + .5);
|
safeLocation.setY(safeLocation.getBlockY() + .5);
|
||||||
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user