Skip to content

Commit 72f27a0

Browse files
#1001 Message if there are no weeping angel configured teleport worlds
1 parent d533702 commit 72f27a0

File tree

2 files changed

+16
-8
lines changed
  • src/main
    • java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels
    • resources

2 files changed

+16
-8
lines changed

src/main/java/me/eccentric_nz/tardisweepingangels/monsters/weeping_angels/Damage.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ public void onBeatUpAngel(EntityDamageByEntityEvent event) {
9797
} else {
9898
l = getRandomLocation(t.getWorld());
9999
}
100-
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> p.teleport(l), 1L);
100+
if (l != null) {
101+
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> p.teleport(l), 1L);
102+
} else {
103+
plugin.getMessenger().message(p, TardisModule.MONSTERS, "NO_CONFIGURED_WORLDS");
104+
}
101105
p.addPotionEffect(new PotionEffect(PotionEffectType.NAUSEA, 300, 5, true, false));
102106
if (TARDISWeepingAngels.angelsCanSteal()) {
103107
stealKey(p);
@@ -111,14 +115,17 @@ private Location getRandomLocation(World w) {
111115
// is this world an allowable world? - we don't want Nether or TARDIS worlds
112116
if (!angel_tp_worlds.contains(w)) {
113117
// get a random teleport world
114-
w = angel_tp_worlds.get(TARDISConstants.RANDOM.nextInt(angel_tp_worlds.size()));
118+
w = !angel_tp_worlds.isEmpty() ? angel_tp_worlds.get(TARDISConstants.RANDOM.nextInt(angel_tp_worlds.size())) : null;
119+
}
120+
if (w != null) {
121+
Chunk[] chunks = w.getLoadedChunks();
122+
Chunk c = chunks[TARDISConstants.RANDOM.nextInt(chunks.length)];
123+
int x = c.getX() * 16 + TARDISConstants.RANDOM.nextInt(16);
124+
int z = c.getZ() * 16 + TARDISConstants.RANDOM.nextInt(16);
125+
int y = w.getHighestBlockYAt(x, z);
126+
return new Location(w, x, y + 1, z).add(0.5d, 0, 0.5d);
115127
}
116-
Chunk[] chunks = w.getLoadedChunks();
117-
Chunk c = chunks[TARDISConstants.RANDOM.nextInt(chunks.length)];
118-
int x = c.getX() * 16 + TARDISConstants.RANDOM.nextInt(16);
119-
int z = c.getZ() * 16 + TARDISConstants.RANDOM.nextInt(16);
120-
int y = w.getHighestBlockYAt(x, z);
121-
return new Location(w, x, y + 1, z).add(0.5d, 0, 0.5d);
128+
return null;
122129
}
123130

124131
private Location getSpecificLocation() {

src/main/resources/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ NOT_WHILE_TRAVELLING: "You cannot do that while the TARDIS is travelling!"
733733
NO_ARS: "You don't have an Architectural Reconfiguration System GUI!"
734734
NO_CHUNKS: "No chunks in list!"
735735
NO_CONFIGURED_AREAS: "There are no areas to autonomously travel to!"
736+
NO_CONFIGURED_WORLDS: "There are no weeing angel teleport worlds configured!"
736737
NO_CONSTRUCT: "You haven't constructed a Chameleon preset yet!"
737738
NO_MAT_CIRCUIT: "The Materialisation Circuit is missing from the console!"
738739
NO_MEM_CIRCUIT: "The Memory Circuit is missing from the console!"

0 commit comments

Comments
 (0)