Implemented config-option locationCheck
This commit is contained in:
parent
4626646292
commit
982190b730
@ -35,11 +35,11 @@ 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();
|
||||||
|
|
||||||
|
CustomPlayerMoveEventHandler cpmHandler = new CustomPlayerMoveEventHandler(this, config.getInt("locationCheck.interval"), true);
|
||||||
|
cpmHandler.registerListener(new OnCustomPlayerMove());
|
||||||
|
|
||||||
LinkedBeaconTeleporterManager.init();
|
LinkedBeaconTeleporterManager.init();
|
||||||
|
|
||||||
initAutoSave();
|
initAutoSave();
|
||||||
|
@ -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
|
||||||
@ -64,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){
|
||||||
|
@ -14,7 +14,7 @@ id: # TODO
|
|||||||
# 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 :)
|
# 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
|
length: 10
|
||||||
|
|
||||||
locationCheck: # TODO
|
locationCheck:
|
||||||
# Interval [in ticks] to check if a player is on a beacon
|
# Interval [in ticks] to check if a player is on a beacon
|
||||||
# 5 (= 4 times/s) is usually responsive enough for most interactions
|
# 5 (= 4 times/s) is usually responsive enough for most interactions
|
||||||
interval: 5
|
interval: 5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user