Compare commits
36 Commits
f03a80cf99
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1dbe281a6 | ||
|
|
8485e34756 | ||
|
|
7e6601d56d | ||
|
|
982190b730 | ||
|
|
4626646292 | ||
|
|
e82de277ef | ||
|
|
28658329a8 | ||
|
|
ac810349ac | ||
|
|
2a713d269e | ||
|
|
b20e0a03fd | ||
|
|
5a1c809d89 | ||
|
|
ef9643c2ae | ||
|
|
c732aa31b1 | ||
|
|
51c9ee0716 | ||
|
|
e10eaf9b66 | ||
|
|
686ad312c5 | ||
|
|
973897cc3e | ||
|
|
1eb472b576 | ||
|
|
c41ab95baf | ||
|
|
5e22456f61 | ||
|
|
2bda948c8f | ||
|
|
6c2e06afaf | ||
|
|
b54af93d4b | ||
|
|
1168b8859a | ||
|
|
b8ed619b1c | ||
|
|
1ab17c1ab6 | ||
|
|
fdc17aad0f | ||
|
|
bf18c82d6d | ||
|
|
2f64eb5ed0 | ||
|
|
cf061f9d75 | ||
|
|
b593a22568 | ||
|
|
884184006c | ||
|
|
41a15103b3 | ||
|
|
b010280111 | ||
|
|
63bab8ae2e | ||
|
|
3d602c526d |
@@ -7,10 +7,7 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.InvalidPropertiesFormatException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class Function {
|
public class Function {
|
||||||
public static String serialiseBlockLocation(Location loc){
|
public static String serialiseBlockLocation(Location loc){
|
||||||
@@ -129,6 +126,9 @@ public class Function {
|
|||||||
Material.STONE_SLAB,
|
Material.STONE_SLAB,
|
||||||
Material.WARPED_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){
|
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());
|
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)){
|
for(int i=0; loc.getBlockY()>=0 && loc.getBlockY()<=255; loc.add(searchDirection)){
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ public class Main extends JavaPlugin {
|
|||||||
|
|
||||||
public static Logger log;
|
public static Logger log;
|
||||||
|
|
||||||
public static LinkedBeaconTeleporterManager lbtManager;
|
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
log = getLogger();
|
log = getLogger();
|
||||||
|
|
||||||
@@ -37,17 +35,20 @@ public class Main extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new OnBlockPlace(), this);
|
pluginManager.registerEvents(new OnBlockPlace(), this);
|
||||||
pluginManager.registerEvents(new OnCraftItemEvent(), this);
|
pluginManager.registerEvents(new OnCraftItemEvent(), this);
|
||||||
|
|
||||||
CustomPlayerMoveEventHandler cpmHandler = new CustomPlayerMoveEventHandler(this, true);
|
|
||||||
cpmHandler.registerListener(new OnCustomPlayerMove());
|
|
||||||
|
|
||||||
loadConfigs();
|
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");
|
log.info("Plugin activated");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
saveData();
|
||||||
|
|
||||||
log.info("Plugin deactivated");
|
log.info("Plugin deactivated");
|
||||||
}
|
}
|
||||||
@@ -70,4 +71,31 @@ public class Main extends JavaPlugin {
|
|||||||
Bukkit.getPluginManager().disablePlugin(this);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.customPlayerMoveEvent;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.InvalidObjectException;
|
|
||||||
|
|
||||||
public class CustomPlayerMoveEvent {
|
public class CustomPlayerMoveEvent {
|
||||||
|
|
||||||
Player p;
|
Player p;
|
||||||
|
|||||||
@@ -17,16 +17,16 @@ public class CustomPlayerMoveEventHandler {
|
|||||||
HashMap<UUID, Location> oldPlayerLoc = new HashMap<>();
|
HashMap<UUID, Location> oldPlayerLoc = new HashMap<>();
|
||||||
|
|
||||||
boolean locationChangeOnBlockChange;
|
boolean locationChangeOnBlockChange;
|
||||||
public CustomPlayerMoveEventHandler(Plugin plugin, boolean locationChangeOnBlockChange){
|
public CustomPlayerMoveEventHandler(Plugin plugin, int interval, boolean locationChangeOnBlockChange){
|
||||||
this.locationChangeOnBlockChange = locationChangeOnBlockChange;
|
this.locationChangeOnBlockChange = locationChangeOnBlockChange;
|
||||||
|
|
||||||
startRunnable(plugin);
|
startRunnable(plugin, interval);
|
||||||
}
|
}
|
||||||
public CustomPlayerMoveEventHandler(Plugin plugin){
|
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, () -> {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
|
||||||
// Dont do anything without listeners
|
// Dont do anything without listeners
|
||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +64,7 @@ public class CustomPlayerMoveEventHandler {
|
|||||||
oldPlayerLoc.put(uuid, loc);
|
oldPlayerLoc.put(uuid, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, 20, 10);
|
}, interval, interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean blockLocationChanged(Location loc, Location oldLoc){
|
boolean blockLocationChanged(Location loc, Location oldLoc){
|
||||||
|
|||||||
@@ -1,24 +1,46 @@
|
|||||||
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
|
||||||
*/
|
*/
|
||||||
public abstract class LinkedBeaconTeleporter {
|
public abstract class LinkedBeaconTeleporter {
|
||||||
|
static String id_alphabet = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
static int id_length = 10;
|
||||||
|
|
||||||
// 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(id_alphabet, id_length);
|
||||||
|
|
||||||
|
linkedBeaconTeleporters = new ArrayList<>();
|
||||||
}
|
}
|
||||||
public LinkedBeaconTeleporter(String teleporterId){
|
public LinkedBeaconTeleporter(String teleporterId){
|
||||||
this.teleporterId = teleporterId;
|
this.teleporterId = teleporterId;
|
||||||
|
|
||||||
|
// Check if id exists
|
||||||
|
linkedBeaconTeleporters = LinkedBeaconTeleporterManager.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,56 @@ public class LinkedBeaconTeleporterBlock extends LinkedBeaconTeleporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LinkedBeaconTeleporterItem break_(BlockBreakEvent e){
|
||||||
|
Location loc = this.block().getLocation();
|
||||||
|
|
||||||
|
// Dont drop anything
|
||||||
|
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);
|
||||||
|
|
||||||
|
if(this.linkedBeaconTeleporters.size() == 0){
|
||||||
|
// List empty, delete from placedLBTsById
|
||||||
|
LinkedBeaconTeleporterManager.placedLBTsById.remove(
|
||||||
|
this.teleporterId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from loc
|
||||||
|
LinkedBeaconTeleporterManager.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()
|
||||||
|
);
|
||||||
|
|
||||||
|
return lbtItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Conversion methods
|
// Conversion methods
|
||||||
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
public static LinkedBeaconTeleporterBlock getFromLocation(Location loc){
|
||||||
return Main.lbtManager.getLbtBlockFromLocation(loc);
|
return LinkedBeaconTeleporterManager.getLbtBlockFromLocation(loc);
|
||||||
}
|
}
|
||||||
public static List<LinkedBeaconTeleporterBlock> getListFromTeleportId(String teleportId){
|
public static List<LinkedBeaconTeleporter> getListFromTeleportId(String teleportId){
|
||||||
return Main.lbtManager.getLbtBlocksFromTeleportId(teleportId);
|
return LinkedBeaconTeleporterManager.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;
|
||||||
@@ -17,7 +24,7 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
|||||||
// Create a new LinkedBeaconTeleporter
|
// Create a new LinkedBeaconTeleporter
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.item = Main.lbtManager.getItemStackFromData(this.teleporterId);
|
this.item = LinkedBeaconTeleporterManager.getItemStackFromData(this.teleporterId);
|
||||||
}
|
}
|
||||||
public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) {
|
public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) {
|
||||||
super(teleporterId);
|
super(teleporterId);
|
||||||
@@ -27,7 +34,7 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
|||||||
public LinkedBeaconTeleporterItem(String teleporterId){
|
public LinkedBeaconTeleporterItem(String teleporterId){
|
||||||
super(teleporterId);
|
super(teleporterId);
|
||||||
|
|
||||||
this.item = Main.lbtManager.getItemStackFromData(teleporterId);
|
this.item = LinkedBeaconTeleporterManager.getItemStackFromData(teleporterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack item(){
|
public ItemStack item(){
|
||||||
@@ -35,8 +42,56 @@ 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);
|
||||||
|
// 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(!LinkedBeaconTeleporterManager.placedLBTsById.containsKey(this.teleporterId))
|
||||||
|
LinkedBeaconTeleporterManager.placedLBTsById.put(this.teleporterId, this.linkedBeaconTeleporters);
|
||||||
|
|
||||||
|
// Add to location
|
||||||
|
LinkedBeaconTeleporterManager.placedLBTByLoc.put(
|
||||||
|
Function.serialiseBlockLocation(loc),
|
||||||
|
lbtBlock
|
||||||
|
);
|
||||||
|
|
||||||
|
// Notify Player when no other teleporter was found (yet?)
|
||||||
|
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
|
||||||
|
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 LinkedBeaconTeleporterManager.getLbtItemFromItemStack(itemStack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.block.Block;
|
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.ItemStack;
|
||||||
import org.bukkit.inventory.ShapelessRecipe;
|
import org.bukkit.inventory.ShapelessRecipe;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@@ -19,13 +19,13 @@ 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 static HashMap<String, List<LinkedBeaconTeleporter>> placedLBTsById = new HashMap();
|
||||||
HashMap<String, LinkedBeaconTeleporterBlock> linkedBeaconTeleporterByLoc = new HashMap();
|
public static 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;
|
static String regex;
|
||||||
|
|
||||||
public LinkedBeaconTeleporterManager(){
|
public static void init(){
|
||||||
Main.log.info("Loading LinkedBeaconTeleporter from config..");
|
Main.log.info("Loading LinkedBeaconTeleporter from config..");
|
||||||
|
|
||||||
// Construct search item-regex
|
// Construct search item-regex
|
||||||
@@ -34,26 +34,28 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
Main.config.getStringList("item.lore")
|
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
|
// Construct & add crafting-receipes
|
||||||
constructAndAddRecipes();
|
constructAndAddRecipes();
|
||||||
|
|
||||||
// Load teleporters
|
// Load teleporters
|
||||||
for(String teleporterId : Main.data.getKeys(false)){
|
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
|
// New list for this id
|
||||||
ArrayList<LinkedBeaconTeleporterBlock> lbtBlocks = new ArrayList();
|
List<LinkedBeaconTeleporter> linkedBeaconTeleporters = new ArrayList();
|
||||||
|
|
||||||
for(String blockId : teleportersData.getKeys(false)) {
|
for(String serializedLoc : serialisedLocs) {
|
||||||
ConfigurationSection teleporterData = teleportersData.getConfigurationSection(blockId);
|
|
||||||
|
|
||||||
// Load location
|
// Load location
|
||||||
String serializedLoc = teleporterData.getString("loc");
|
|
||||||
Location loc;
|
Location loc;
|
||||||
try {
|
try {
|
||||||
loc = Function.deserializeBlockLocation(teleporterData.getString("loc"));
|
loc = Function.deserializeBlockLocation(serializedLoc);
|
||||||
} catch (InvalidPropertiesFormatException e) {
|
} 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,68 +63,61 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
Block block = loc.getBlock();
|
Block block = loc.getBlock();
|
||||||
if(block.getType() != Material.BEACON){
|
if(block.getType() != Material.BEACON){
|
||||||
// Data out of sync! Skipping
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// Write block to list
|
||||||
lbtBlocks.add(lbtBlock);
|
linkedBeaconTeleporters.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.saveData();
|
||||||
|
|
||||||
Main.log.info("All done!");
|
Main.log.info("All done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedBeaconTeleporterBlock placeLbtItem(LinkedBeaconTeleporterItem lbtItem, Block block){
|
static int oldDataHashCode;
|
||||||
// Check if id already exists
|
public static boolean writeData(){
|
||||||
List<LinkedBeaconTeleporterBlock> lbtBlocks = linkedBeaconTeleporterById.get(lbtItem.teleporterId());
|
// Check if data changed
|
||||||
if(lbtBlocks == null){
|
int dataHashCode = placedLBTsById.hashCode();
|
||||||
// Create empty if not found
|
if(oldDataHashCode != dataHashCode){
|
||||||
lbtBlocks = new ArrayList<>();
|
// Changed
|
||||||
linkedBeaconTeleporterById.put(lbtItem.teleporterId(), lbtBlocks);
|
oldDataHashCode = dataHashCode;
|
||||||
}
|
}
|
||||||
|
else // Did not change
|
||||||
|
return false;
|
||||||
|
|
||||||
// Block from item
|
Main.data = new YamlConfiguration();
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = new LinkedBeaconTeleporterBlock(lbtItem.teleporterId(), block);
|
for(String teleporterId : placedLBTsById.keySet()){
|
||||||
|
List<LinkedBeaconTeleporter> LBTs = placedLBTsById.get(teleporterId);
|
||||||
|
|
||||||
// Add to list
|
// Generate clean array with data we want
|
||||||
lbtBlocks.add(lbtBlock);
|
List<String> dataList = new ArrayList<>();
|
||||||
// Add to location
|
for(LinkedBeaconTeleporter lbt : LBTs){
|
||||||
linkedBeaconTeleporterByLoc.put(
|
dataList.add(
|
||||||
Function.serialiseBlockLocation(block.getLocation()),
|
Function.serialiseBlockLocation(
|
||||||
lbtBlock
|
((LinkedBeaconTeleporterBlock)lbt).block().getLocation()
|
||||||
);
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return lbtBlock;
|
Main.data.set(teleporterId, dataList);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedBeaconTeleporterItem breakLbtBlock(LinkedBeaconTeleporterBlock lbtBlock){
|
static void constructAndAddRecipes(){
|
||||||
// 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(){
|
|
||||||
// Create result-item
|
// Create result-item
|
||||||
ItemStack item = getItemStackFromData("-");
|
ItemStack item = getItemStackFromData("-");
|
||||||
item.setAmount(2);
|
item.setAmount(2);
|
||||||
@@ -144,7 +139,7 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Conversion-methods
|
// Conversion-methods
|
||||||
public ItemStack getItemStackFromData(String teleporterId){
|
public static ItemStack getItemStackFromData(String teleporterId){
|
||||||
ItemStack item = new ItemStack(Material.BEACON);
|
ItemStack item = new ItemStack(Material.BEACON);
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
|
||||||
@@ -168,7 +163,7 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
public LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
|
public static LinkedBeaconTeleporterItem getLbtItemFromItemStack(ItemStack itemStack){
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
@@ -192,17 +187,17 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
return lbtItem;
|
return lbtItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
|
public static LinkedBeaconTeleporterBlock getLbtBlockFromLocation(Location loc){
|
||||||
// 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 static List<LinkedBeaconTeleporter> getLbtBlocksFromTeleportId(String teleportId){
|
||||||
return linkedBeaconTeleporterById.get(teleportId);
|
return placedLBTsById.get(teleportId);
|
||||||
}
|
}
|
||||||
|
|
||||||
String constructRegex(String name, List<String> lore){
|
static String constructRegex(String name, List<String> lore){
|
||||||
// Serialize
|
// Serialize
|
||||||
String regex = serialiseBeaconItem(name, lore);
|
String regex = serialiseBeaconItem(name, lore);
|
||||||
|
|
||||||
@@ -216,7 +211,7 @@ public class LinkedBeaconTeleporterManager {
|
|||||||
|
|
||||||
return regex;
|
return regex;
|
||||||
}
|
}
|
||||||
String serialiseBeaconItem(String name, List<String> lore){
|
static String serialiseBeaconItem(String name, List<String> lore){
|
||||||
// get name and remove control-chars
|
// get name and remove control-chars
|
||||||
String str = name.replace("\\", "\\\\");
|
String str = name.replace("\\", "\\\\");
|
||||||
if(lore != null){
|
if(lore != null){
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package eu.ruekov.ruakij.LinkedBeaconTeleporters.listener;
|
|||||||
|
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Main;
|
||||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem;
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterItem;
|
||||||
|
import eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -21,7 +22,7 @@ public class OnCraftItemEvent implements Listener {
|
|||||||
ItemStack itemResult = recipe.getResult();
|
ItemStack itemResult = recipe.getResult();
|
||||||
|
|
||||||
// Check if it has LinkedBeaconTeleporter-Data
|
// Check if it has LinkedBeaconTeleporter-Data
|
||||||
LinkedBeaconTeleporterItem lbtItem = Main.lbtManager.getLbtItemFromItemStack(itemResult);
|
LinkedBeaconTeleporterItem lbtItem = LinkedBeaconTeleporterManager.getLbtItemFromItemStack(itemResult);
|
||||||
|
|
||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtItem == null) return;
|
if(lbtItem == null) return;
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ 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 eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter.LinkedBeaconTeleporterManager;
|
||||||
|
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 +31,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(
|
||||||
@@ -46,7 +58,7 @@ public class OnCustomPlayerMove implements CustomPlayerMoveEventListener {
|
|||||||
// TODO: Check if beacon is active
|
// TODO: Check if beacon is active
|
||||||
|
|
||||||
// Check if beacon is a LinkedBeaconTeleporter
|
// Check if beacon is a LinkedBeaconTeleporter
|
||||||
LinkedBeaconTeleporterBlock lbtBlock = Main.lbtManager.getLbtBlockFromLocation(block.getLocation());
|
LinkedBeaconTeleporterBlock lbtBlock = LinkedBeaconTeleporterManager.getLbtBlockFromLocation(block.getLocation());
|
||||||
|
|
||||||
// Ignore if not found
|
// Ignore if not found
|
||||||
if(lbtBlock == null) return;
|
if(lbtBlock == null) return;
|
||||||
@@ -54,28 +66,53 @@ 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){
|
if(lbtBlockTmp != lbtBlock){
|
||||||
lbtBlockPartner = 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)
|
||||||
|
playerBeaconLocation.put(uuid, lbtBlock);
|
||||||
}
|
}
|
||||||
else{
|
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)
|
// Set player as ignored on target-LinkedBeaconTeleporter (so he wont trigger the teleport again)
|
||||||
playerBeaconLocation.put(uuid, lbtBlockPartner);
|
playerBeaconLocation.put(uuid, lbtBlockPartner);
|
||||||
|
|
||||||
// Teleport
|
// 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(
|
e.player().teleport(
|
||||||
lbtBlockPartner.block().getLocation().add(0, 1, 0)
|
loc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,28 @@
|
|||||||
|
|
||||||
item: # TODO
|
item:
|
||||||
# Name & Lore for linked-beacon-blocks
|
# Name & Lore for linked-beacon-blocks
|
||||||
# - Has to include %id% somewhere for identification!
|
# - Has to include %id% somewhere for identification!
|
||||||
name: '§9BeaconTeleporter'
|
name: '§9BeaconTeleporter'
|
||||||
lore:
|
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
|
||||||
Reference in New Issue
Block a user