Compare commits
8 Commits
f03a80cf99
...
2f64eb5ed0
Author | SHA1 | Date | |
---|---|---|---|
|
2f64eb5ed0 | ||
|
cf061f9d75 | ||
|
b593a22568 | ||
|
884184006c | ||
|
41a15103b3 | ||
|
b010280111 | ||
|
63bab8ae2e | ||
|
3d602c526d |
@ -1,8 +1,12 @@
|
|||||||
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
|
||||||
*/
|
*/
|
||||||
@ -11,14 +15,30 @@ 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,10 +1,11 @@
|
|||||||
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.block.BlockState;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -23,11 +24,50 @@ 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<LinkedBeaconTeleporterBlock> getListFromTeleportId(String teleportId){
|
public static List<LinkedBeaconTeleporter> getListFromTeleportId(String teleportId){
|
||||||
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
|
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
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;
|
||||||
@ -35,6 +42,50 @@ 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
|
||||||
HashMap<String, List<LinkedBeaconTeleporterBlock>> linkedBeaconTeleporterById = new HashMap();
|
public HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
||||||
HashMap<String, LinkedBeaconTeleporterBlock> linkedBeaconTeleporterByLoc = new HashMap();
|
public HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = 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
|
||||||
ArrayList<LinkedBeaconTeleporterBlock> lbtBlocks = new ArrayList();
|
List<LinkedBeaconTeleporter> linkedBeaconTeleporters = 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,61 +67,20 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
|
|
||||||
// Construct block
|
// Construct block
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(teleporterId, block);
|
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(teleporterId, block);
|
||||||
|
// Write reference of list
|
||||||
// Add block to id-list
|
lbtBlock.linkedBeaconTeleporters = linkedBeaconTeleporters;
|
||||||
lbtBlocks.add(lbtBlock);
|
|
||||||
|
|
||||||
// Save to loc-list
|
// Save to loc-list
|
||||||
linkedBeaconTeleporterByLoc.put(serializedLoc, lbtBlock);
|
placedLBTByLoc.put(serializedLoc, lbtBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save list to id-list
|
// Save list to id-list
|
||||||
linkedBeaconTeleporterById.put(teleporterId, lbtBlocks);
|
placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
|
||||||
}
|
}
|
||||||
|
|
||||||
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("-");
|
||||||
@ -196,10 +155,10 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
// Serialize
|
// Serialize
|
||||||
String serializedLoc = Function.serialiseBlockLocation(loc);
|
String serializedLoc = Function.serialiseBlockLocation(loc);
|
||||||
|
|
||||||
return linkedBeaconTeleporterByLoc.get(serializedLoc);
|
return placedLBTByLoc.get(serializedLoc);
|
||||||
}
|
}
|
||||||
public List<LinkedBeaconTeleporterBlock> getLbtBlocksFromTeleportId(String teleportId){
|
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
||||||
return linkedBeaconTeleporterById.get(teleportId);
|
return placedLBTsById.get(teleportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
String constructRegex(String name, List<String> lore){
|
String constructRegex(String name, List<String> lore){
|
||||||
|
@ -26,18 +26,7 @@ public class OnBlockBreak implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtBlock == null) return;
|
if(lbtBlock == null) return;
|
||||||
|
|
||||||
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.breakLbtBlock(lbtBlock);
|
LinkedBeaconTeleporterItem lbtItem = lbtBlock.break_(e);
|
||||||
|
|
||||||
// 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,8 +25,7 @@ public class OnBlockPlace implements Listener {
|
|||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtItem == null) return;
|
if(lbtItem == null) return;
|
||||||
|
|
||||||
Block block = e.getBlock();
|
LinkedBeaconTeleporterBlock lbtBlock = lbtItem.place(e);
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.placeLbtItem(lbtItem, block);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@ 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;
|
||||||
@ -28,9 +30,18 @@ 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, remove
|
// If player found in ignoreList, check if he stepped out of the Beacon-light
|
||||||
if(playerBeaconLocation.containsKey(uuid))
|
if(playerBeaconLocation.containsKey(uuid)) {
|
||||||
playerBeaconLocation.remove(uuid);
|
LinkedBeaconTeleporterBlock lbtBlock = playerBeaconLocation.get(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(
|
||||||
@ -54,20 +65,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(LinkedBeaconTeleporterBlock lbtBlockTmp: lbtBlocks){
|
for(LinkedBeaconTeleporter lbtBlockTmp: lbtBlock.linkedBeaconTeleporters()){
|
||||||
if(lbtBlockTmp != lbtBlocks){
|
// Upcast as linked-Teleporters are only blocks anyways
|
||||||
lbtBlockPartner = lbtBlockTmp;
|
if((LinkedBeaconTeleporterBlock)lbtBlockTmp != lbtBlock){
|
||||||
|
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)
|
||||||
@ -75,7 +86,7 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
|
|
||||||
// Teleport
|
// Teleport
|
||||||
e.player().teleport(
|
e.player().teleport(
|
||||||
lbtBlockPartner.block().getLocation().add(0, 1, 0)
|
lbtBlockPartner.block().getLocation().add(0.5, 1, 0.5)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user