Compare commits

..

28 Commits

Author SHA1 Message Date
Ruakij
c1dbe281a6 Preserve pitch and yaw from player 2021-05-11 12:55:01 +02:00
Ruakij
8485e34756 Added config-option beacon 2021-05-11 12:50:16 +02:00
Ruakij
7e6601d56d Implemented config-option id 2021-05-11 12:46:03 +02:00
Ruakij
982190b730 Implemented config-option locationCheck 2021-05-11 12:42:42 +02:00
Ruakij
4626646292 Implemented config-option autosave 2021-05-11 12:41:09 +02:00
Ruakij
e82de277ef Added config-options 2021-05-11 12:39:34 +02:00
Ruakij
28658329a8 Save on shutdown added 2021-05-11 12:08:00 +02:00
Ruakij
ac810349ac Fixed saving not working 2021-05-11 11:48:39 +02:00
Ruakij
2a713d269e Delete list when empty 2021-05-11 11:45:06 +02:00
Ruakij
b20e0a03fd Added Autosave 2021-05-11 11:42:46 +02:00
Ruakij
5a1c809d89 Changed save-system 2021-05-11 11:42:05 +02:00
Ruakij
ef9643c2ae Fixed loading not writing blocks to list 2021-05-11 11:30:01 +02:00
Ruakij
c732aa31b1 Set player to ignore-list if teleport didnt succeed 2021-05-11 11:10:24 +02:00
Ruakij
51c9ee0716 Fix first placed block having a different list leading to new linked-blocks being out-of-sync
(teleport not working and breaking leading to unexpected and undesired states)
2021-05-11 11:03:44 +02:00
Ruakij
e10eaf9b66 Fix system trying to gather non-existent data to display message 2021-05-11 11:02:30 +02:00
Ruakij
686ad312c5 Removed upcasting, check is done on reference-layer anyways 2021-05-11 09:53:57 +02:00
Ruakij
973897cc3e Notify player when teleport could not succeed 2021-05-11 09:53:30 +02:00
Ruakij
1eb472b576 Added check when no safe-location could be found 2021-05-11 09:52:22 +02:00
Ruakij
c41ab95baf Added comments 2021-05-11 09:45:50 +02:00
Ruakij
5e22456f61 Fixed empty-space search not working, because of missing ignore 2021-05-11 09:45:25 +02:00
Ruakij
2bda948c8f Fixed CustomMoveEvent firing all the time instead of only on Block-change 2021-05-11 09:37:10 +02:00
Ruakij
6c2e06afaf Changed data.yml format and added save-method 2021-05-10 16:15:56 +02:00
Ruakij
b54af93d4b Made Manager static 2021-05-10 16:15:07 +02:00
Ruakij
1168b8859a Changed data-yml format 2021-05-10 15:45:48 +02:00
Ruakij
b8ed619b1c Implemented search for safe-location on target-beacon 2021-05-10 15:42:44 +02:00
Ruakij
1ab17c1ab6 Added overloaded-alternative-method searchForMaterial 2021-05-10 15:42:22 +02:00
Ruakij
fdc17aad0f Fixed logic 2021-05-10 15:29:37 +02:00
Ruakij
bf18c82d6d Fixed broken if-statements 2021-05-10 15:27:29 +02:00
11 changed files with 190 additions and 66 deletions

View File

@@ -7,10 +7,7 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.util.Vector;
import java.util.Arrays;
import java.util.InvalidPropertiesFormatException;
import java.util.List;
import java.util.Random;
import java.util.*;
public class Function {
public static String serialiseBlockLocation(Location loc){
@@ -129,6 +126,9 @@ public class Function {
Material.STONE_SLAB,
Material.WARPED_SLAB
);
public static Block searchForMaterial(Location startLoc, Vector searchDirection, Material searchMaterial){
return searchForMaterial(startLoc, searchDirection, searchMaterial, new ArrayList<>());
}
public static Block searchForMaterial(Location startLoc, Vector searchDirection, Material searchMaterial, List<Material> ignoreMaterials){
Location loc = new Location(startLoc.getWorld(), startLoc.getBlockX(), startLoc.getBlockY(), startLoc.getBlockZ());
for(int i=0; loc.getBlockY()>=0 && loc.getBlockY()<=255; loc.add(searchDirection)){

View File

@@ -25,8 +25,6 @@ public class Main extends JavaPlugin {
public static Logger log;
public static LinkedBeaconTeleporterManager lbtManager;
public void onEnable() {
log = getLogger();
@@ -37,17 +35,20 @@ public class Main extends JavaPlugin {
pluginManager.registerEvents(new OnBlockPlace(), this);
pluginManager.registerEvents(new OnCraftItemEvent(), this);
CustomPlayerMoveEventHandler cpmHandler = new CustomPlayerMoveEventHandler(this, true);
cpmHandler.registerListener(new OnCustomPlayerMove());
loadConfigs();
lbtManager = new LinkedBeaconTeleporterManager();
CustomPlayerMoveEventHandler cpmHandler = new CustomPlayerMoveEventHandler(this, config.getInt("locationCheck.interval"), true);
cpmHandler.registerListener(new OnCustomPlayerMove());
LinkedBeaconTeleporterManager.init();
initAutoSave();
log.info("Plugin activated");
}
public void onDisable() {
saveData();
log.info("Plugin deactivated");
}
@@ -70,4 +71,31 @@ public class Main extends JavaPlugin {
Bukkit.getPluginManager().disablePlugin(this);
}
}
public static void saveData(){
boolean lbtDataChanged = LinkedBeaconTeleporterManager.writeData();
// Only run save, when data changed
if(lbtDataChanged)
saveFiles();
}
public static void saveFiles() {
// data.yml
try{
File dataFile = new File("plugins/"+ plugin.getName() +"/data.yml");
data.save(dataFile);
}catch (Exception ex){
log.severe("Could not save data.yml!");
ex.printStackTrace();
}
}
static void initAutoSave(){
int autosaveInterval = config.getInt("config.interval")*20;
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
saveData();
}, autosaveInterval, autosaveInterval);
}
}

View File

@@ -3,8 +3,6 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.io.InvalidObjectException;
public class CustomPlayerMoveEvent {
Player p;

View File

@@ -17,16 +17,16 @@ public class CustomPlayerMoveEventHandler {
HashMap<UUID, Location> oldPlayerLoc = new HashMap<>();
boolean locationChangeOnBlockChange;
public CustomPlayerMoveEventHandler(Plugin plugin, boolean locationChangeOnBlockChange){
public CustomPlayerMoveEventHandler(Plugin plugin, int interval, boolean locationChangeOnBlockChange){
this.locationChangeOnBlockChange = locationChangeOnBlockChange;
startRunnable(plugin);
startRunnable(plugin, interval);
}
public CustomPlayerMoveEventHandler(Plugin plugin){
this(plugin, false);
this(plugin, 5, false);
}
void startRunnable(Plugin plugin){
void startRunnable(Plugin plugin, int interval){
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
// Dont do anything without listeners
@@ -52,7 +52,9 @@ public class CustomPlayerMoveEventHandler {
if(distance > 0)
locationChangeListeners(e);
}
else
else if(loc.getBlockX() != oldLoc.getBlockX() ||
loc.getBlockY() != oldLoc.getBlockY() ||
loc.getBlockZ() != oldLoc.getBlockZ())
locationChangeListeners(e);
}
@@ -62,7 +64,7 @@ public class CustomPlayerMoveEventHandler {
oldPlayerLoc.put(uuid, loc);
}
}, 20, 10);
}, interval, interval);
}
boolean blockLocationChanged(Location loc, Location oldLoc){

View File

@@ -11,6 +11,8 @@ import java.util.List;
* Describes a placed-beacon-teleporter in the world
*/
public abstract class LinkedBeaconTeleporter {
static String id_alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
static int id_length = 10;
// Persistent id for linked-beacons
public String teleporterId;
@@ -19,7 +21,7 @@ public abstract class LinkedBeaconTeleporter {
protected List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList<>();
LinkedBeaconTeleporter(){
this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10);
this.teleporterId = Function.randomString(id_alphabet, id_length);
linkedBeaconTeleporters = new ArrayList<>();
}
@@ -27,7 +29,7 @@ public abstract class LinkedBeaconTeleporter {
this.teleporterId = teleporterId;
// Check if id exists
linkedBeaconTeleporters = Main.lbtManager.placedLBTsById.get(this.teleporterId());
linkedBeaconTeleporters = LinkedBeaconTeleporterManager.placedLBTsById.get(this.teleporterId());
if(linkedBeaconTeleporters == null){
// Create empty if not found
linkedBeaconTeleporters = new ArrayList<>();

View File

@@ -31,12 +31,27 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
e.setDropItems(false);
e.setExpToDrop(0);
// 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");
}
// Remove from list
this.linkedBeaconTeleporters.remove(this);
// TODO: Remove from placedLBTsById when empty?
if(this.linkedBeaconTeleporters.size() == 0){
// List empty, delete from placedLBTsById
LinkedBeaconTeleporterManager.placedLBTsById.remove(
this.teleporterId
);
}
// Remove from loc
Main.lbtManager.placedLBTByLoc.remove(
LinkedBeaconTeleporterManager.placedLBTByLoc.remove(
Function.serialiseBlockLocation(loc)
);
@@ -50,24 +65,15 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
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
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
return Main.lbtManager.getLbtBlockFromLocation(loc);
return LinkedBeaconTeleporterManager.getLbtBlockFromLocation(loc);
}
public static List<LinkedBeaconTeleporter> getListFromTeleportId(String teleportId){
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
return LinkedBeaconTeleporterManager.getLbtBlocksFromTeleportId(teleportId);
}
}

View File

@@ -24,7 +24,7 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
// Create a new LinkedBeaconTeleporter
super();
this.item = Main.lbtManager.getItemStackFromData(this.teleporterId);
this.item = LinkedBeaconTeleporterManager.getItemStackFromData(this.teleporterId);
}
public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) {
super(teleporterId);
@@ -34,7 +34,7 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
public LinkedBeaconTeleporterItem(String teleporterId){
super(teleporterId);
this.item = Main.lbtManager.getItemStackFromData(teleporterId);
this.item = LinkedBeaconTeleporterManager.getItemStackFromData(teleporterId);
}
public ItemStack item(){
@@ -56,21 +56,25 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
// Block from item
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
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);
if(!LinkedBeaconTeleporterManager.placedLBTsById.containsKey(this.teleporterId))
LinkedBeaconTeleporterManager.placedLBTsById.put(this.teleporterId, this.linkedBeaconTeleporters);
// Add to location
Main.lbtManager.placedLBTByLoc.put(
LinkedBeaconTeleporterManager.placedLBTByLoc.put(
Function.serialiseBlockLocation(loc),
lbtBlock
);
// Notify Player when no other teleporter was found (yet?)
if(this.linkedBeaconTeleporters.size() == 2){
if(this.linkedBeaconTeleporters.size() == 1){
e.getPlayer().sendMessage("§6No other Teleporter found with with id §7"+ this.teleporterId);
}
// Notify Player when we have a full link
@@ -88,6 +92,6 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
// Conversion methods
public static LinkedBeaconTeleporterItem getFromItemStack(ItemStack itemStack){
return Main.lbtManager.getLbtItemFromItemStack(itemStack);
return LinkedBeaconTeleporterManager.getLbtItemFromItemStack(itemStack);
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
@@ -19,13 +19,13 @@ import java.util.regex.Pattern;
public class LinkedBeaconTeleporterManager {
// Stores all placed Beacon-Teleporters for fast access
// TODO: Evaluate necessity of 2 HashMaps with main reason of performance
public HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
public HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = new HashMap();
public static HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
public static HashMap<String, LinkedBeaconTeleporterBlock> placedLBTByLoc = new HashMap();
// Regex to match item-name&lore and extract id (group 1)
String regex;
static String regex;
public LinkedBeaconTeleporterManager(){
public static void init(){
Main.log.info("Loading LinkedBeaconTeleporter from config..");
// Construct search item-regex
@@ -34,26 +34,28 @@ public class LinkedBeaconTeleporterManager {
Main.config.getStringList("item.lore")
);
// Load settings
LinkedBeaconTeleporter.id_alphabet = Main.config.getString("id.alphabet");
LinkedBeaconTeleporter.id_length = Main.config.getInt("id.length");
// Construct & add crafting-receipes
constructAndAddRecipes();
// Load teleporters
for(String teleporterId : Main.data.getKeys(false)){
ConfigurationSection teleportersData = Main.data.getConfigurationSection(teleporterId);
List<String> serialisedLocs = Main.data.getStringList(teleporterId);
// New list for this id
List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList();
for(String blockId : teleportersData.getKeys(false)) {
ConfigurationSection teleporterData = teleportersData.getConfigurationSection(blockId);
for(String serializedLoc : serialisedLocs) {
// Load location
String serializedLoc = teleporterData.getString("loc");
Location loc;
try {
loc = Function.deserializeBlockLocation(teleporterData.getString("loc"));
loc = Function.deserializeBlockLocation(serializedLoc);
} catch (InvalidPropertiesFormatException e) {
Main.log.severe("Could not load location='"+ serializedLoc +"' from "+ teleporterId +" > "+ blockId);
Main.log.severe("Could not load location='"+ serializedLoc +"' from "+ teleporterId);
continue;
}
@@ -61,7 +63,7 @@ public class LinkedBeaconTeleporterManager {
Block block = loc.getBlock();
if(block.getType() != Material.BEACON){
// Data out of sync! Skipping
Main.log.warning(teleporterId +" > "+ blockId +" at location "+ serializedLoc +" changed and is no longer LinkedBlockTeleporter! (Changed without the plugin running?)");
Main.log.warning(teleporterId +" at location "+ serializedLoc +" changed and is no longer LinkedBlockTeleporter! (Changed without the plugin running?)");
continue;
}
@@ -70,6 +72,8 @@ public class LinkedBeaconTeleporterManager {
// Write reference of list
lbtBlock.linkedBeaconTeleporters = linkedBeaconTeleporters;
// Write block to list
linkedBeaconTeleporters.add(lbtBlock);
// Save to loc-list
placedLBTByLoc.put(serializedLoc, lbtBlock);
}
@@ -78,10 +82,42 @@ public class LinkedBeaconTeleporterManager {
placedLBTsById.put(teleporterId, linkedBeaconTeleporters);
}
Main.saveData();
Main.log.info("All done!");
}
void constructAndAddRecipes(){
static int oldDataHashCode;
public static boolean writeData(){
// Check if data changed
int dataHashCode = placedLBTsById.hashCode();
if(oldDataHashCode != dataHashCode){
// Changed
oldDataHashCode = dataHashCode;
}
else // Did not change
return false;
Main.data = new YamlConfiguration();
for(String teleporterId : placedLBTsById.keySet()){
List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
// Generate clean array with data we want
List<String> dataList = new ArrayList<>();
for(LinkedBeaconTeleporter lbt : LBTs){
dataList.add(
Function.serialiseBlockLocation(
((LinkedBeaconTeleporterBlock)lbt).block().getLocation()
)
);
}
Main.data.set(teleporterId, dataList);
}
return true;
}
static void constructAndAddRecipes(){
// Create result-item
ItemStack item = getItemStackFromData("-");
item.setAmount(2);
@@ -103,7 +139,7 @@ public class LinkedBeaconTeleporterManager {
}
// Conversion-methods
public ItemStack getItemStackFromData(String teleporterId){
public static ItemStack getItemStackFromData(String teleporterId){
ItemStack item = new ItemStack(Material.BEACON);
ItemMeta itemMeta = item.getItemMeta();
@@ -127,7 +163,7 @@ public class LinkedBeaconTeleporterManager {
return item;
}
public LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
public static LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
ItemMeta itemMeta = itemStack.getItemMeta();
// Serialize
@@ -151,17 +187,17 @@ public class LinkedBeaconTeleporterManager {
return lbtItem;
}
public LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
public static LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
// Serialize
String serializedLoc = Function.serialiseBlockLocation(loc);
return placedLBTByLoc.get(serializedLoc);
}
public List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
public static List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
return placedLBTsById.get(teleportId);
}
String constructRegex(String name, List<String> lore){
static String constructRegex(String name, List<String> lore){
// Serialize
String regex = serialiseBeaconItem(name, lore);
@@ -175,7 +211,7 @@ public class LinkedBeaconTeleporterManager {
return regex;
}
String serialiseBeaconItem(String name, List<String> lore){
static String serialiseBeaconItem(String name, List<String> lore){
// get name and remove control-chars
String str = name.replace("\\", "\\\\");
if(lore != null){

View File

@@ -2,6 +2,7 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.listener;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
@@ -21,7 +22,7 @@ public class OnCraftItemEvent implements Listener {
ItemStack itemResult = recipe.getResult();
// Check if it has LinkedBeaconTeleporter-Data
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.getLbtItemFromItemStack(itemResult);
LinkedBeaconTeleporterItem lbtItem = LinkedBeaconTeleporterManager.getLbtItemFromItemStack(itemResult);
// Ignore if not found
if(lbtItem == null) return;

View File

@@ -6,6 +6,7 @@ import eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent.CustomPlay
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.LinkedBeaconTeleporterManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@@ -57,7 +58,7 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
// TODO: Check if beacon is active
// Check if beacon is a LinkedBeaconTeleporter
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.getLbtBlockFromLocation(block.getLocation());
LinkedBeaconTeleporterBlock lbtBlock = LinkedBeaconTeleporterManager.getLbtBlockFromLocation(block.getLocation());
// Ignore if not found
if(lbtBlock == null) return;
@@ -68,25 +69,50 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
// Get first partner thats not our current-block
LinkedBeaconTeleporterBlock lbtBlockPartner = null;
for(LinkedBeaconTeleporter lbtBlockTmp: lbtBlock.linkedBeaconTeleporters()){
// Upcast as linked-Teleporters are only blocks anyways
if((LinkedBeaconTeleporterBlock)lbtBlockTmp != lbtBlock){
if(lbtBlockTmp != lbtBlock){
lbtBlockPartner = (LinkedBeaconTeleporterBlock)lbtBlockTmp;
break;
}
}
if(lbtBlockPartner == null){
// 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)
playerBeaconLocation.put(uuid, lbtBlock);
}
else{
// TODO: Check if beacon is active
// Get safe-location on top of other beacon
Block safeBlock = Function.searchForMaterial(
lbtBlockPartner.block().getLocation().add(0, 1, 0),
new Vector(0, 1, 0),
Material.AIR,
Function.transparentMaterials
);
if(safeBlock == null){
// No safe location found
p.sendMessage("§cNo safe-location found at target teleporter");
playerBeaconLocation.put(uuid, lbtBlock);
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
Location loc = safeBlock.getLocation();
// Middle of block
loc.add(0.5, 0, 0.5);
// Preserve pitch and yaw from player
loc.setPitch(p.getLocation().getPitch());
loc.setYaw(p.getLocation().getYaw());
e.player().teleport(
lbtBlockPartner.block().getLocation().add(0.5, 1, 0.5)
loc
);
}
}

View File

@@ -1,7 +1,28 @@
item: # TODO
item:
# Name & Lore for linked-beacon-blocks
# - Has to include %id% somewhere for identification!
name: '§9BeaconTeleporter'
lore:
- '§8§o%id%'
- '§8§o%id%'
beacon:
# Checks that have to succeed for a teleporter to be active (source and target)
checks: # TODO
active: true
id:
# Alphabet to use for random-generation
alphabet: 'abcdefghijklmnopqrstuvwxyz0123456789'
# Length of id
# If its too short, ids will "collide" more often (e.g. 2 players generating same linked-teleporters independently), but maybe thats a gameplay-feature for you :)
length: 10
locationCheck:
# Interval [in ticks] to check if a player is on a beacon
# 5 (= 4 times/s) is usually responsive enough for most interactions
interval: 5
autosave:
# Interval [in seconds] for autosave
interval: 600