Fix Shield and Mine destructing Portal #9
@ -31,6 +31,7 @@ import com.sk89q.worldedit.world.World;
|
||||
import de.steamwar.misslewars.Config;
|
||||
import de.steamwar.misslewars.FightState;
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import de.steamwar.misslewars.items.Missile;
|
||||
import de.steamwar.misslewars.items.SpecialItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -101,6 +102,7 @@ public class ItemListener extends BasicListener {
|
||||
if (e.getEntity() instanceof Snowball) {
|
||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
||||
Location l = e.getEntity().getLocation();
|
||||
if (!validSpawn(l)) return;
|
||||
BlockVector3 paste = BlockVector3.at(l.getX(), l.getY(), l.getZ()).subtract(offsetShield);
|
||||
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
|
||||
@ -111,6 +113,7 @@ public class ItemListener extends BasicListener {
|
||||
if (e.getEntity() instanceof Egg) {
|
||||
Bukkit.getScheduler().runTaskLater(MissileWars.getPlugin(), () -> {
|
||||
Location l = e.getEntity().getLocation();
|
||||
if (!validSpawn(l)) return;
|
||||
BlockVector3 paste = BlockVector3.at(l.getX(), l.getY(), l.getZ()).subtract(offsetMine);
|
||||
|
||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
|
||||
@ -119,4 +122,27 @@ public class ItemListener extends BasicListener {
|
||||
}, Config.ShieldFlyTime);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean validSpawn(Location location) {
|
||||
int bz = MissileWars.getBlueTeam().getPortalZ();
|
||||
int rz = MissileWars.getRedTeam().getPortalZ();
|
||||
|
||||
int offset = sign(bz - rz) * 5;
|
||||
|
||||
int blockZ = location.getBlockZ();
|
||||
if (offset > 0) {
|
||||
if (blockZ > bz - offset) return false;
|
||||
if (blockZ < rz + offset) return false;
|
||||
} else {
|
||||
if (blockZ < bz - offset) return false;
|
||||
if (blockZ > rz + offset) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int sign(int i) {
|
||||
if (i < 0) return -1;
|
||||
return i > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren