Compare commits

..

No commits in common. "51c9ee0716877d95d730e0ce29b8d450202618fb" and "6c2e06afaf58ad4801d3c10aaf00f30000d88e24" have entirely different histories.

4 changed files with 7 additions and 23 deletions

View File

@ -52,9 +52,7 @@ public class CustomPlayerMoveEventHandler {
if(distance > 0) if(distance > 0)
locationChangeListeners(e); locationChangeListeners(e);
} }
else if(loc.getBlockX() != oldLoc.getBlockX() || else
loc.getBlockY() != oldLoc.getBlockY() ||
loc.getBlockZ() != oldLoc.getBlockZ())
locationChangeListeners(e); locationChangeListeners(e);
} }

View File

@ -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() == 2){ if(this.linkedBeaconTeleporters.size()-1 != 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()

View File

@ -56,10 +56,6 @@ 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);

View File

@ -69,39 +69,29 @@ 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()){
if(lbtBlockTmp != lbtBlock){ // Upcast as linked-Teleporters are only blocks anyways
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{
// TODO: Check if beacon is active // Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
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)