- Joined
- Dec 20, 2016
- Messages
- 37
- Thread Author
- #1
Hello there, just wondering if anyone knows any methods to accomplish the following tasks:
Currently searching through the docs now.
Detect if there are nearby players (not counting ourselves!): Players.newQuery().filter(player -> !Objects.equals(player, Players.getLocal())).results().isEmpty();
Return current world: Worlds.getCurrent();
Hop to specific world: WorldHop.hopTo('int world#');
Edit: updated hop method below, allows for 7.5 second checking before hopping.
I've stored all hoppable worlds in a freeWorld and membersWorld int[] array.
This script just hops to the next world.
Currently searching through the docs now.
Detect if there are nearby players (not counting ourselves!): Players.newQuery().filter(player -> !Objects.equals(player, Players.getLocal())).results().isEmpty();
Return current world: Worlds.getCurrent();
Hop to specific world: WorldHop.hopTo('int world#');
Edit: updated hop method below, allows for 7.5 second checking before hopping.
I've stored all hoppable worlds in a freeWorld and membersWorld int[] array.
This script just hops to the next world.
Code:
public class HopLeaf extends LeafTask {
private int[] freeWorlds = new int[] { 3, 7, 8, 11, 17, 19, 20, 29, 34, 38, 41, 43, 61, 80, 81, 108 ,135, 141};
private int[] membersWorlds = new int[] { 1, 2, 4, 5, 6, 9, 10, 12, 14, 15, 16, 21, 22, 23, 24, 25, 26, 27 ,28, 31, 32, 35, 36, 37, 40, 42, 44, 45, 46, 49, 50, 51, 53, 54, 56, 58, 59, 60, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 82, 83, 84, 85, 87, 89, 91, 92, 96, 98, 99, 100, 103, 104, 105, 116, 117, 119, 123, 124, 134, 138, 139, 140};
@Override
public void execute() {
int currentWorld = Worlds.getCurrent();
int selectedWorld = 0;
System.out.println("Current World: " + currentWorld);
for (int i = 0; i <= membersWorlds.length - 1; i++){
if (currentWorld < membersWorlds[i]){
selectedWorld = membersWorlds[i];
i = membersWorlds.length;
} else if (membersWorlds[membersWorlds.length - 1] == currentWorld){
selectedWorld = membersWorlds[0];
}
}
if (ChatDialog.getContinue() != null) {
System.out.println("Detected continue dialogue.");
// PRESSES SPACE
Keyboard.typeKey(32);
}
if (!WorldHop.isOpen()){
System.out.println("Opening world switcher.");
// PRESSES KEY: ESC
Keyboard.typeKey(27);
System.out.println("Pressed Escape");
WorldHop.open();
System.out.println("World Hopper should be open.");
}
if (selectedWorld != 0){
System.out.println("Detected nearby players, preparing to hop worlds.");
Execution.delayUntil(() -> Players.newQuery().filter(player -> !Objects.equals(player, Players.getLocal())).results().isEmpty(), 7500);
if (WorldHop.isOpen() && Players.newQuery().filter(player -> !Objects.equals(player, Players.getLocal())).results().isEmpty()){
System.out.println("Cancelling world hop.");
// PRESSES KEY: ESC
Keyboard.typeKey(27);
} else {
System.out.println("Hopping.");
WorldHop.hopTo(selectedWorld);
}
}
}
}
Last edited: