Compare commits
8 Commits
6c2e06afaf
...
51c9ee0716
Author | SHA1 | Date | |
---|---|---|---|
|
51c9ee0716 | ||
|
e10eaf9b66 | ||
|
686ad312c5 | ||
|
973897cc3e | ||
|
1eb472b576 | ||
|
c41ab95baf | ||
|
5e22456f61 | ||
|
2bda948c8f |
@ -52,7 +52,9 @@ public class CustomPlayerMoveEventHandler {
|
|||||||
if(distance > 0)
|
if(distance > 0)
|
||||||
locationChangeListeners(e);
|
locationChangeListeners(e);
|
||||||
}
|
}
|
||||||
else
|
else if(loc.getBlockX() != oldLoc.getBlockX() ||
|
||||||
|
loc.getBlockY() != oldLoc.getBlockY() ||
|
||||||
|
loc.getBlockZ() != oldLoc.getBlockZ())
|
||||||
locationChangeListeners(e);
|
locationChangeListeners(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
|
|||||||
e.setExpToDrop(0);
|
e.setExpToDrop(0);
|
||||||
|
|
||||||
// Notify Player when link was destroyed
|
// Notify Player when link was destroyed
|
||||||
if(this.linkedBeaconTeleporters.size()-1 != 2){
|
if(this.linkedBeaconTeleporters.size() == 2){
|
||||||
e.getPlayer().sendMessage("§cConnection to Teleporter with id §7"+ this.teleporterId +" §e("+
|
e.getPlayer().sendMessage("§cConnection to Teleporter with id §7"+ this.teleporterId +" §e("+
|
||||||
(int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance(
|
(int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance(
|
||||||
((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation()
|
((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation()
|
||||||
|
@ -56,6 +56,10 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
|||||||
|
|
||||||
// Block from item
|
// Block from item
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(this.teleporterId(), block);
|
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(this.teleporterId(), block);
|
||||||
|
// Both objects have different lists (as both are new), overwrite block-list with item-list
|
||||||
|
// FIXME: This seems like a bad design.. maybe only create the list when necessary? (e.g. keep null if no linked objects found)
|
||||||
|
lbtBlock.linkedBeaconTeleporters = this.linkedBeaconTeleporters;
|
||||||
|
|
||||||
// Add to list
|
// Add to list
|
||||||
this.linkedBeaconTeleporters.add(lbtBlock);
|
this.linkedBeaconTeleporters.add(lbtBlock);
|
||||||
|
|
||||||
|
@ -69,29 +69,39 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
// Get first partner thats not our current-block
|
// Get first partner thats not our current-block
|
||||||
LinkedBeaconTeleporterBlock lbtBlockPartner = null;
|
LinkedBeaconTeleporterBlock lbtBlockPartner = null;
|
||||||
for(LinkedBeaconTeleporter lbtBlockTmp: lbtBlock.linkedBeaconTeleporters()){
|
for(LinkedBeaconTeleporter lbtBlockTmp: lbtBlock.linkedBeaconTeleporters()){
|
||||||
// Upcast as linked-Teleporters are only blocks anyways
|
if(lbtBlockTmp != lbtBlock){
|
||||||
if((LinkedBeaconTeleporterBlock)lbtBlockTmp != lbtBlock){
|
|
||||||
lbtBlockPartner = (LinkedBeaconTeleporterBlock)lbtBlockTmp;
|
lbtBlockPartner = (LinkedBeaconTeleporterBlock)lbtBlockTmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(lbtBlockPartner == null){
|
if(lbtBlockPartner == null){
|
||||||
// No other partner
|
// No other partner
|
||||||
|
p.sendMessage("§cNo linked beacon found with id §7"+ lbtBlock.teleporterId());
|
||||||
|
|
||||||
// Set player as ignored on this LinkedBeaconTeleporter (so he wont trigger the checks again)
|
// Set player as ignored on this LinkedBeaconTeleporter (so he wont trigger the checks again)
|
||||||
playerBeaconLocation.put(uuid, lbtBlock);
|
playerBeaconLocation.put(uuid, lbtBlock);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
|
// TODO: Check if beacon is active
|
||||||
playerBeaconLocation.put(uuid, lbtBlockPartner);
|
|
||||||
|
|
||||||
// Get safe-location on top of other beacon
|
// Get safe-location on top of other beacon
|
||||||
Block safeBlock = Function.searchForMaterial(
|
Block safeBlock = Function.searchForMaterial(
|
||||||
lbtBlockPartner.block().getLocation().add(0, 1, 0),
|
lbtBlockPartner.block().getLocation().add(0, 1, 0),
|
||||||
new Vector(0, 1, 0),
|
new Vector(0, 1, 0),
|
||||||
Material.AIR
|
Material.AIR,
|
||||||
|
Function.transparentMaterials
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(safeBlock == null){
|
||||||
|
// No safe location found
|
||||||
|
p.sendMessage("§cNo safe-location found at target teleporter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Check if there is enough space for a player
|
||||||
|
|
||||||
|
// Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
|
||||||
|
playerBeaconLocation.put(uuid, lbtBlockPartner);
|
||||||
|
|
||||||
// Teleport
|
// Teleport
|
||||||
e.player().teleport(
|
e.player().teleport(
|
||||||
safeBlock.getLocation().add(0.5, 0, 0.5)
|
safeBlock.getLocation().add(0.5, 0, 0.5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user