Compare commits
No commits in common. "2f64eb5ed0e8dda9c86845a1c03860c837778a74" and "f03a80cf99a22eb9f4bdf1ef799bb5be0d05319f" have entirely different histories.
2f64eb5ed0
...
f03a80cf99
@ -1,12 +1,8 @@
|
|||||||
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes a placed-beacon-teleporter in the world
|
* Describes a placed-beacon-teleporter in the world
|
||||||
*/
|
*/
|
||||||
@ -15,30 +11,14 @@ public abstract class LinkedBeaconTeleporter {
|
|||||||
// Persistent id for linked-beacons
|
// Persistent id for linked-beacons
|
||||||
public String teleporterId;
|
public String teleporterId;
|
||||||
|
|
||||||
// List of all linkedBeaconTeleporters with same teleporterId (real Type is usually ..Block, because linked Items are temporary constructs are useless)
|
|
||||||
protected List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList<>();
|
|
||||||
|
|
||||||
LinkedBeaconTeleporter(){
|
LinkedBeaconTeleporter(){
|
||||||
this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10);
|
this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10);
|
||||||
|
|
||||||
linkedBeaconTeleporters = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
public LinkedBeaconTeleporter(String teleporterId){
|
public LinkedBeaconTeleporter(String teleporterId){
|
||||||
this.teleporterId = teleporterId;
|
this.teleporterId = teleporterId;
|
||||||
|
|
||||||
// Check if id exists
|
|
||||||
linkedBeaconTeleporters = Main.lbtManager.placedLBTsById.get(this.teleporterId());
|
|
||||||
if(linkedBeaconTeleporters == null){
|
|
||||||
// Create empty if not found
|
|
||||||
linkedBeaconTeleporters = new ArrayList<>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String teleporterId(){
|
public String teleporterId(){
|
||||||
return teleporterId;
|
return teleporterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LinkedBeaconTeleporter> linkedBeaconTeleporters(){
|
|
||||||
return linkedBeaconTeleporters;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -24,50 +23,11 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LinkedBeaconTeleporterItem break_(BlockBreakEvent e){
|
|
||||||
Location loc = this.block().getLocation();
|
|
||||||
|
|
||||||
// Dont drop anything
|
|
||||||
e.setDropItems(false);
|
|
||||||
e.setExpToDrop(0);
|
|
||||||
|
|
||||||
// Remove from list
|
|
||||||
this.linkedBeaconTeleporters.remove(this);
|
|
||||||
// TODO: Remove from placedLBTsById when empty?
|
|
||||||
|
|
||||||
// Remove from loc
|
|
||||||
Main.lbtManager.placedLBTByLoc.remove(
|
|
||||||
Function.serialiseBlockLocation(loc)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Item from block
|
|
||||||
LinkedBeaconTeleporterItem lbtItem = new LinkedBeaconTeleporterItem(this.teleporterId());
|
|
||||||
|
|
||||||
// Drop custom-item
|
|
||||||
if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
|
|
||||||
loc.getWorld().dropItemNaturally(
|
|
||||||
loc.add(0.5, 0, 0.5),
|
|
||||||
lbtItem.item()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Notify Player when link was destroyed
|
|
||||||
if(this.linkedBeaconTeleporters.size() < 2){
|
|
||||||
e.getPlayer().sendMessage("§cConnection to Teleporter with id §7"+ this.teleporterId +" §e("+
|
|
||||||
(int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance(
|
|
||||||
((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation()
|
|
||||||
)
|
|
||||||
+" Blocks away) §cdestroyed");
|
|
||||||
}
|
|
||||||
|
|
||||||
return lbtItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Conversion methods
|
// Conversion methods
|
||||||
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
||||||
return Main.lbtManager.getLbtBlockFromLocation(loc);
|
return Main.lbtManager.getLbtBlockFromLocation(loc);
|
||||||
}
|
}
|
||||||
public static List<LinkedBeaconTeleporter> getListFromTeleportId(String teleportId){
|
public static List<LinkedBeaconTeleporterBlock> getListFromTeleportId(String teleportId){
|
||||||
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
|
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
|
||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -42,50 +35,6 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LinkedBeaconTeleporterBlock place(BlockPlaceEvent e){
|
|
||||||
// Deny placing when 2 LinkedBeaconTeleporter's are already placed
|
|
||||||
if(this.linkedBeaconTeleporters.size() == 2){
|
|
||||||
e.getPlayer().sendMessage("§cMaximum-Amount §7(2) §cof §6LinkedBeaconTeleporters §cwith id §7"+ this.teleporterId +" §care already placed");
|
|
||||||
|
|
||||||
e.setCancelled(true);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Block block = e.getBlock();
|
|
||||||
Location loc = block.getLocation();
|
|
||||||
|
|
||||||
// Block from item
|
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(this.teleporterId(), block);
|
|
||||||
// Add to list
|
|
||||||
this.linkedBeaconTeleporters.add(lbtBlock);
|
|
||||||
|
|
||||||
// Add to id if not exists
|
|
||||||
if(!Main.lbtManager.placedLBTsById.containsKey(this.teleporterId))
|
|
||||||
Main.lbtManager.placedLBTsById.put(this.teleporterId, this.linkedBeaconTeleporters);
|
|
||||||
|
|
||||||
// Add to location
|
|
||||||
Main.lbtManager.placedLBTByLoc.put(
|
|
||||||
Function.serialiseBlockLocation(loc),
|
|
||||||
lbtBlock
|
|
||||||
);
|
|
||||||
|
|
||||||
// Notify Player when no other teleporter was found (yet?)
|
|
||||||
if(this.linkedBeaconTeleporters.size() == 2){
|
|
||||||
e.getPlayer().sendMessage("§6No other Teleporter found with with id §7"+ this.teleporterId);
|
|
||||||
}
|
|
||||||
// Notify Player when we have a full link
|
|
||||||
else if(this.linkedBeaconTeleporters.size() == 2){
|
|
||||||
e.getPlayer().sendMessage("§aConnected to Teleporter with id §7"+ this.teleporterId +" §e("+
|
|
||||||
(int)((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(0)).block.getLocation().distance(
|
|
||||||
((LinkedBeaconTeleporterBlock)this.linkedBeaconTeleporters.get(1)).block().getLocation()
|
|
||||||
)
|
|
||||||
+" Blocks away)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return lbtBlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Conversion methods
|
// Conversion methods
|
||||||
public static LinkedBeaconTeleporterItem getFromItemStack(ItemStack itemStack){
|
public static LinkedBeaconTeleporterItem getFromItemStack(ItemStack itemStack){
|
||||||
return Main.lbtManager.getLbtItemFromItemStack(itemStack);
|
return Main.lbtManager.getLbtItemFromItemStack(itemStack);
|
||||||
|
@ -19,8 +19,8 @@ import java.util.regex.Pattern;
|
|||||||
public class LinkedBeaconTeleporterManager {
|
public class LinkedBeaconTeleporterManager {
|
||||||
// Stores all placed Beacon-Teleporters for fast access
|
// Stores all placed Beacon-Teleporters for fast access
|
||||||
// TODO: Evaluate necessity of 2 HashMaps with main reason of performance
|
// TODO: Evaluate necessity of 2 HashMaps with main reason of performance
|
||||||
public HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
HashMap<String, List<LinkedBeaconTeleporterBlock>> linkedBeaconTeleporterById = new HashMap();
|
||||||
public HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = new HashMap();
|
HashMap<String, LinkedBeaconTeleporterBlock> linkedBeaconTeleporterByLoc = new HashMap();
|
||||||
|
|
||||||
// Regex to match item-name&lore and extract id (group 1)
|
// Regex to match item-name&lore and extract id (group 1)
|
||||||
String regex;
|
String regex;
|
||||||
@ -42,7 +42,7 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
ConfigurationSection teleportersData = Main.data.getConfigurationSection(teleporterId);
|
ConfigurationSection teleportersData = Main.data.getConfigurationSection(teleporterId);
|
||||||
|
|
||||||
// New list for this id
|
// New list for this id
|
||||||
List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList();
|
ArrayList<LinkedBeaconTeleporterBlock> lbtBlocks = new ArrayList();
|
||||||
|
|
||||||
for(String blockId : teleportersData.getKeys(false)) {
|
for(String blockId : teleportersData.getKeys(false)) {
|
||||||
ConfigurationSection teleporterData = teleportersData.getConfigurationSection(blockId);
|
ConfigurationSection teleporterData = teleportersData.getConfigurationSection(blockId);
|
||||||
@ -67,20 +67,61 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
|
|
||||||
// Construct block
|
// Construct block
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(teleporterId, block);
|
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(teleporterId, block);
|
||||||
// Write reference of list
|
|
||||||
lbtBlock.linkedBeaconTeleporters = linkedBeaconTeleporters;
|
// Add block to id-list
|
||||||
|
lbtBlocks.add(lbtBlock);
|
||||||
|
|
||||||
// Save to loc-list
|
// Save to loc-list
|
||||||
placedLBTByLoc.put(serializedLoc, lbtBlock);
|
linkedBeaconTeleporterByLoc.put(serializedLoc, lbtBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save list to id-list
|
// Save list to id-list
|
||||||
placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
|
linkedBeaconTeleporterById.put(teleporterId, lbtBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
Main.log.info("All done!");
|
Main.log.info("All done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedBeaconTeleporterBlock placeLbtItem(LinkedBeaconTeleporterItem lbtItem, Block block){
|
||||||
|
// Check if id already exists
|
||||||
|
List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtItem.teleporterId());
|
||||||
|
if(lbtBlocks == null){
|
||||||
|
// Create empty if not found
|
||||||
|
lbtBlocks = new ArrayList<>();
|
||||||
|
linkedBeaconTeleporterById.put(lbtItem.teleporterId(), lbtBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Block from item
|
||||||
|
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(lbtItem.teleporterId(), block);
|
||||||
|
|
||||||
|
// Add to list
|
||||||
|
lbtBlocks.add(lbtBlock);
|
||||||
|
// Add to location
|
||||||
|
linkedBeaconTeleporterByLoc.put(
|
||||||
|
Function.serialiseBlockLocation(block.getLocation()),
|
||||||
|
lbtBlock
|
||||||
|
);
|
||||||
|
|
||||||
|
return lbtBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedBeaconTeleporterItem breakLbtBlock(LinkedBeaconTeleporterBlock lbtBlock){
|
||||||
|
// Get list by id
|
||||||
|
List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtBlock.teleporterId());
|
||||||
|
|
||||||
|
// Remove from list
|
||||||
|
lbtBlocks.remove(lbtBlock);
|
||||||
|
// Remove from location
|
||||||
|
linkedBeaconTeleporterByLoc.remove(
|
||||||
|
Function.serialiseBlockLocation(lbtBlock.block().getLocation())
|
||||||
|
);
|
||||||
|
|
||||||
|
// Item from block
|
||||||
|
LinkedBeaconTeleporterItem lbtItem = new LinkedBeaconTeleporterItem(lbtBlock.teleporterId());
|
||||||
|
|
||||||
|
return lbtItem;
|
||||||
|
}
|
||||||
|
|
||||||
void constructAndAddRecipes(){
|
void constructAndAddRecipes(){
|
||||||
// Create result-item
|
// Create result-item
|
||||||
ItemStack item = getItemStackFromData("-");
|
ItemStack item = getItemStackFromData("-");
|
||||||
@ -155,10 +196,10 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
// Serialize
|
// Serialize
|
||||||
String serializedLoc = Function.serialiseBlockLocation(loc);
|
String serializedLoc = Function.serialiseBlockLocation(loc);
|
||||||
|
|
||||||
return placedLBTByLoc.get(serializedLoc);
|
return linkedBeaconTeleporterByLoc.get(serializedLoc);
|
||||||
}
|
}
|
||||||
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
public List<LinkedBeaconTeleporterBlock> getLbtBlocksFromTeleportId(String teleportId){
|
||||||
return placedLBTsById.get(teleportId);
|
return linkedBeaconTeleporterById.get(teleportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
String constructRegex(String name, List<String> lore){
|
String constructRegex(String name, List<String> lore){
|
||||||
|
@ -26,7 +26,18 @@ public class OnBlockBreak implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtBlock == null) return;
|
if(lbtBlock == null) return;
|
||||||
|
|
||||||
LinkedBeaconTeleporterItem lbtItem = lbtBlock.break_(e);
|
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock);
|
||||||
|
|
||||||
|
// Dont drop anything
|
||||||
|
e.setDropItems(false);
|
||||||
|
e.setExpToDrop(0);
|
||||||
|
|
||||||
|
// Drop custom-item
|
||||||
|
if(e.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
|
lbtBlock.block().getLocation().getWorld().dropItemNaturally(
|
||||||
|
lbtBlock.block().getLocation(),
|
||||||
|
lbtItem.item()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ public class OnBlockPlace implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtItem == null) return;
|
if(lbtItem == null) return;
|
||||||
|
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = lbtItem.place(e);
|
Block block = e.getBlock();
|
||||||
|
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,7 @@ import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
|||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlayerMoveEvent;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlayerMoveEvent;
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlayerMoveEventListener;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlayerMoveEventListener;
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporter;
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterBlock;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,18 +28,9 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
Player p = e.player();
|
Player p = e.player();
|
||||||
UUID uuid = p.getUniqueId();
|
UUID uuid = p.getUniqueId();
|
||||||
|
|
||||||
// If player found in ignoreList, check if he stepped out of the Beacon-light
|
// If player found in ignoreList, remove
|
||||||
if(playerBeaconLocation.containsKey(uuid)) {
|
if(playerBeaconLocation.containsKey(uuid))
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = playerBeaconLocation.get(uuid);
|
playerBeaconLocation.remove(uuid);
|
||||||
Location lbtBlockLoc = lbtBlock.block().getLocation();
|
|
||||||
Location pLoc = p.getLocation();
|
|
||||||
if(lbtBlockLoc.getBlockX() != pLoc.getBlockX() || lbtBlockLoc.getBlockZ() != pLoc.getBlockZ()){
|
|
||||||
playerBeaconLocation.remove(uuid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
// Player still on beacon, ignore
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if player is on-top of a beacon
|
// Check if player is on-top of a beacon
|
||||||
Block block = Function.searchForMaterial(
|
Block block = Function.searchForMaterial(
|
||||||
@ -65,20 +54,20 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
// Check if player should be ignored on this LinkedBeaconTeleporter
|
// Check if player should be ignored on this LinkedBeaconTeleporter
|
||||||
if(playerBeaconLocation.get(uuid) != null && playerBeaconLocation.get(uuid) == lbtBlock) return;
|
if(playerBeaconLocation.get(uuid) != null && playerBeaconLocation.get(uuid) == lbtBlock) return;
|
||||||
|
|
||||||
|
// Find partnering Beacon
|
||||||
|
List<LinkedBeaconTeleporterBlock> lbtBlocks = Main.lbtManager.getLbtBlocksFromTeleportId(lbtBlock.teleporterId());
|
||||||
|
if(lbtBlocks == null) return;
|
||||||
|
|
||||||
// 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(LinkedBeaconTeleporterBlock lbtBlockTmp: lbtBlocks){
|
||||||
// Upcast as linked-Teleporters are only blocks anyways
|
if(lbtBlockTmp != lbtBlocks){
|
||||||
if((LinkedBeaconTeleporterBlock)lbtBlockTmp != lbtBlock){
|
lbtBlockPartner = lbtBlockTmp;
|
||||||
lbtBlockPartner = (LinkedBeaconTeleporterBlock)lbtBlockTmp;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(lbtBlockPartner == null){
|
if(lbtBlockPartner == null){
|
||||||
// No other partner
|
// No other partner
|
||||||
|
|
||||||
// Set player as ignored on this LinkedBeaconTeleporter (so he wont trigger the checks again)
|
|
||||||
playerBeaconLocation.put(uuid, lbtBlock);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
|
// Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
|
||||||
@ -86,7 +75,7 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
|
|
||||||
// Teleport
|
// Teleport
|
||||||
e.player().teleport(
|
e.player().teleport(
|
||||||
lbtBlockPartner.block().getLocation().add(0.5, 1, 0.5)
|
lbtBlockPartner.block().getLocation().add(0, 1, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user