1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
|
package org.bukkit;
import java.io.File;
import org.bukkit.generator.ChunkGenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.entity.*;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.util.Vector;
/**
* Represents a world, which may contain entities, chunks and blocks
*/
public interface World extends PluginMessageRecipient {
/**
* Gets the {@link Block} at the given coordinates
*
* @param x X-coordinate of the block
* @param y Y-coordinate of the block
* @param z Z-coordinate of the block
* @return Block at the given coordinates
* @see #getBlockTypeIdAt(int, int, int) Returns the current type ID of the block
*/
public Block getBlockAt(int x, int y, int z);
/**
* Gets the {@link Block} at the given {@link Location}
*
* @param location Location of the block
* @return Block at the given location
* @see #getBlockTypeIdAt(org.bukkit.Location) Returns the current type ID of the block
*/
public Block getBlockAt(Location location);
/**
* Gets the block type ID at the given coordinates
*
* @param x X-coordinate of the block
* @param y Y-coordinate of the block
* @param z Z-coordinate of the block
* @return Type ID of the block at the given coordinates
* @see #getBlockAt(int, int, int) Returns a live Block object at the given location
*/
public int getBlockTypeIdAt(int x, int y, int z);
/**
* Gets the block type ID at the given {@link Location}
*
* @param location Location of the block
* @return Type ID of the block at the given location
* @see #getBlockAt(org.bukkit.Location) Returns a live Block object at the given location
*/
public int getBlockTypeIdAt(Location location);
/**
* Gets the highest non-air coordinate at the given coordinates
*
* @param x X-coordinate of the blocks
* @param z Z-coordinate of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(int x, int z);
/**
* Gets the highest non-air coordinate at the given {@link Location}
*
* @param location Location of the blocks
* @return Y-coordinate of the highest non-air block
*/
public int getHighestBlockYAt(Location location);
/**
* Gets the highest non-empty block at the given coordinates
*
* @param x X-coordinate of the block
* @param z Z-coordinate of the block
* @return Highest non-empty block
*/
public Block getHighestBlockAt(int x, int z);
/**
* Gets the highest non-empty block at the given coordinates
*
* @param location Coordinates to get the highest block
* @return Highest non-empty block
*/
public Block getHighestBlockAt(Location location);
/**
* Gets the {@link Chunk} at the given coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Chunk at the given coordinates
*/
public Chunk getChunkAt(int x, int z);
/**
* Gets the {@link Chunk} at the given {@link Location}
*
* @param location Location of the chunk
* @return Chunk at the given location
*/
public Chunk getChunkAt(Location location);
/**
* Gets the {@link Chunk} that contains the given {@link Block}
*
* @param block Block to get the containing chunk from
* @return The chunk that contains the given block
*/
public Chunk getChunkAt(Block block);
/**
* Checks if the specified {@link Chunk} is loaded
*
* @param chunk The chunk to check
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(Chunk chunk);
/**
* Gets an array of all loaded {@link Chunk}s
*
* @return Chunk[] containing all loaded chunks
*/
public Chunk[] getLoadedChunks();
/**
* Loads the specified {@link Chunk}
*
* @param chunk The chunk to load
*/
public void loadChunk(Chunk chunk);
/**
* Checks if the {@link Chunk} at the specified coordinates is loaded
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true if the chunk is loaded, otherwise false
*/
public boolean isChunkLoaded(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
* <p />
* If the chunk does not exist, it will be generated.
* This method is analogous to {@link #loadChunk(int, int, boolean)} where generate is true.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
*/
public void loadChunk(int x, int z);
/**
* Loads the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param generate Whether or not to generate a chunk if it doesn't already exist
* @return true if the chunk has loaded successfully, otherwise false
*/
public boolean loadChunk(int x, int z, boolean generate);
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p />
* This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where safe and saveis true
*
* @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(Chunk chunk);
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p />
* This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where safe and saveis true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z);
/**
* Safely unloads and optionally saves the {@link Chunk} at the specified coordinates
* <p />
* This method is analogous to {@link #unloadChunk(int, int, boolean, boolean)} where save is true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param save Whether or not to save the chunk
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save);
/**
* Unloads and optionally saves the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are nearby
* @return true if the chunk has unloaded successfully, otherwise false
*/
public boolean unloadChunk(int x, int z, boolean save, boolean safe);
/**
* Safely queues the {@link Chunk} at the specified coordinates for unloading
* <p />
* This method is analogous to {@link #unloadChunkRequest(int, int, boolean)} where safe is true
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return true is the queue attempt was successful, otherwise false
*/
public boolean unloadChunkRequest(int x, int z);
/**
* Queues the {@link Chunk} at the specified coordinates for unloading
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
*/
public boolean unloadChunkRequest(int x, int z, boolean safe);
/**
* Regenerates the {@link Chunk} at the specified coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually regenerated
*/
public boolean regenerateChunk(int x, int z);
/**
* Resends the {@link Chunk} to all clients
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @return Whether the chunk was actually refreshed
*/
public boolean refreshChunk(int x, int z);
/**
* Drops an item at the specified {@link Location}
*
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItem(Location location, ItemStack item);
/**
* Drops an item at the specified {@link Location} with a random offset
*
* @param location Location to drop the item
* @param item ItemStack to drop
* @return ItemDrop entity created as a result of this method
*/
public Item dropItemNaturally(Location location, ItemStack item);
/**
* Creates an {@link Arrow} entity at the given {@link Location}
*
* @param location Location to spawn the arrow
* @param velocity Velocity to shoot the arrow in
* @param speed Speed of the arrow. A recommend speed is 0.6
* @param spread Spread of the arrow. A recommend spread is 12
* @return Arrow entity spawned as a result of this method
*/
public Arrow spawnArrow(Location location, Vector velocity, float speed, float spread);
/**
* Creates a tree at the given {@link Location}
*
* @param location Location to spawn the tree
* @param type Type of the tree to create
* @return true if the tree was created successfully, otherwise false
*/
public boolean generateTree(Location location, TreeType type);
/**
* Creates a tree at the given {@link Location}
*
* @param loc Location to spawn the tree
* @param type Type of the tree to create
* @param delegate A class to call for each block changed as a result of this method
* @return true if the tree was created successfully, otherwise false
*/
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate);
/**
* Creates a creature at the given {@link Location}
*
* @param loc The location to spawn the creature
* @param type The creature to spawn
* @return Resulting LivingEntity of this method, or null if it was unsuccessful
*/
public LivingEntity spawnCreature(Location loc, CreatureType type);
/**
* Strikes lightning at the given {@link Location}
*
* @param loc The location to strike lightning
* @return The lightning entity.
*/
public LightningStrike strikeLightning(Location loc);
/**
* Strikes lightning at the given {@link Location} without doing damage
*
* @param loc The location to strike lightning
* @return The lightning entity.
*/
public LightningStrike strikeLightningEffect(Location loc);
/**
* Get a list of all entities in this World
*
* @return A List of all Entities currently residing in this world
*/
public List<Entity> getEntities();
/**
* Get a list of all living entities in this World
*
* @return A List of all LivingEntities currently residing in this world
*/
public List<LivingEntity> getLivingEntities();
/**
* Get a list of all players in this World
*
* @return A list of all Players currently residing in this world
*/
public List<Player> getPlayers();
/**
* Gets the unique name of this world
*
* @return Name of this world
*/
public String getName();
/**
* Gets the Unique ID of this world
*
* @return Unique ID of this world.
*/
public UUID getUID();
/**
* Gets a semi-unique identifier for this world.
* <p />
* While it is highly unlikely that this may be shared with another World,
* it is not guaranteed to be unique
*
* @deprecated Replaced with {@link #getUID()}
* @return Id of this world
*/
@Deprecated
public long getId();
/**
* Gets the default spawn {@link Location} of this world
*
* @return The spawn location of this world
*/
public Location getSpawnLocation();
/**
* Sets the spawn location of the world
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(int x, int y, int z);
/**
* Gets the relative in-game time of this world.
* <p />
* The relative time is analogous to hours * 1000
*
* @return The current relative time
* @see #getFullTime() Returns an absolute time of this world
*/
public long getTime();
/**
* Sets the relative in-game time on the server.
* <p />
* The relative time is analogous to hours * 1000
* <br /><br />
* Note that setting the relative time below the current relative time will
* actually move the clock forward a day. If you require to rewind time, please
* see setFullTime
*
* @param time The new relative time to set the in-game time to (in hours*1000)
* @see #setFullTime(long) Sets the absolute time of this world
*/
public void setTime(long time);
/**
* Gets the full in-game time on this world
*
* @return The current absolute time
* @see #getTime() Returns a relative time of this world
*/
public long getFullTime();
/**
* Sets the in-game time on the server
* <br /><br />
* Note that this sets the full time of the world, which may cause adverse
* effects such as breaking redstone clocks and any scheduled events
*
* @param time The new absolute time to set this world to
* @see #setTime(long) Sets the relative time of this world
*/
public void setFullTime(long time);
/**
* Returns whether the world has an ongoing storm.
*
* @return Whether there is an ongoing storm
*/
public boolean hasStorm();
/**
* Set whether there is a storm. A duration will be set for the new
* current conditions.
*
* @param hasStorm Whether there is rain and snow
*/
public void setStorm(boolean hasStorm);
/**
* Get the remaining time in ticks of the current conditions.
*
* @return Time in ticks
*/
public int getWeatherDuration();
/**
* Set the remaining time in ticks of the current conditions.
*
* @param duration Time in ticks
*/
public void setWeatherDuration(int duration);
/**
* Returns whether there is thunder.
*
* @return Whether there is thunder
*/
public boolean isThundering();
/**
* Set whether it is thundering.
*
* @param thundering Whether it is thundering
*/
public void setThundering(boolean thundering);
/**
* Get the thundering duration.
*
* @return Duration in ticks
*/
public int getThunderDuration();
/**
* Set the thundering duration.
*
* @param duration Duration in ticks
*/
public void setThunderDuration(int duration);
/**
* Creates explosion at given coordinates with given power
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power);
/**
* Creates explosion at given coordinates with given power and optionally setting
* blocks on fire.
*
* @param x X coordinate
* @param y Y coordinate
* @param z Z coordinate
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(double x, double y, double z, float power, boolean setFire);
/**
* Creates explosion at given coordinates with given power
*
* @param loc Location to blow up
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power);
/**
* Creates explosion at given coordinates with given power and optionally setting
* blocks on fire.
*
* @param loc Location to blow up
* @param power The power of explosion, where 4F is TNT
* @param setFire Whether or not to set blocks on fire
* @return false if explosion was canceled, otherwise true
*/
public boolean createExplosion(Location loc, float power, boolean setFire);
/**
* Gets the {@link Environment} type of this world
*
* @return This worlds Environment type
*/
public Environment getEnvironment();
/**
* Gets the Seed for this world.
*
* @return This worlds Seed
*/
public long getSeed();
/**
* Gets the current PVP setting for this world.
*
* @return True if PVP is enabled
*/
public boolean getPVP();
/**
* Sets the PVP setting for this world.
*
* @param pvp True/False whether PVP should be Enabled.
*/
public void setPVP(boolean pvp);
/**
* Gets the chunk generator for this world
*
* @return ChunkGenerator associated with this world
*/
public ChunkGenerator getGenerator();
/**
* Saves world to disk
*/
public void save();
/**
* Gets a list of all applied {@link BlockPopulator}s for this World
*
* @return List containing any or none BlockPopulators
*/
public List<BlockPopulator> getPopulators();
/**
* Spawn an entity of a specific class at the given {@link Location}
*
* @param location the {@link Location} to spawn the entity at
* @param clazz the class of the {@link Entity} to spawn
* @param <T> the class of the {@link Entity} to spawn
* @return an instance of the spawned {@link Entity}
* @throws IllegalArgumentException if either parameter is null or the {@link Entity} requested cannot be spawned
*/
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException;
/**
* Plays an effect to all players within a default radius around a given location.
*
* @param location the {@link Location} around which players must be to hear the sound
* @param effect the {@link Effect}
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
*/
public void playEffect(Location location, Effect effect, int data);
/**
* Plays an effect to all players within a given radius around a location.
*
* @param location the {@link Location} around which players must be to hear the effect
* @param effect the {@link Effect}
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP effects
* @param radius the radius around the location
*/
public void playEffect(Location location, Effect effect, int data, int radius);
/**
* Get empty chunk snapshot (equivalent to all air blocks), optionally including valid biome
* data. Used for representing an ungenerated chunk, or for fetching only biome data without loading a chunk.
*
* @param x - chunk x coordinate
* @param z - chunk z coordinate
* @param includeBiome - if true, snapshot includes per-coordinate biome type
* @param includeBiomeTempRain - if true, snapshot includes per-coordinate raw biome temperature and rainfall
* @return The empty snapshot.
*/
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTempRain);
/**
* Sets the spawn flags for this.
*
* @param allowMonsters - if true, monsters are allowed to spawn in this world.
* @param allowAnimals - if true, animals are allowed to spawn in this world.
*/
public void setSpawnFlags(boolean allowMonsters, boolean allowAnimals);
/**
* Gets whether animals can spawn in this world.
*
* @return whether animals can spawn in this world.
*/
public boolean getAllowAnimals();
/**
* Gets whether monsters can spawn in this world.
*
* @return whether monsters can spawn in this world.
*/
public boolean getAllowMonsters();
/**
* Gets the biome for the given block coordinates.
* <p />
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
* @return Biome of the requested block
*/
public Biome getBiome(int x, int z);
/**
* Gets the temperature for the given block coordinates.
* <p />
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
* @return Temperature of the requested block
*/
public double getTemperature(int x, int z);
/**
* Gets the humidity for the given block coordinates.
* <p />
* It is safe to run this method when the block does not exist, it will not create the block.
*
* @param x X coordinate of the block
* @param z Z coordinate of the block
* @return Humidity of the requested block
*/
public double getHumidity(int x, int z);
/**
* Gets the maximum height of this world.
* <p />
* If the max height is 100, there are only blocks from y=0 to y=99.
*
* @return Maximum height of the world
*/
public int getMaxHeight();
/**
* Gets the sea level for this world.
* <p />
* This is often half of {@link #getMaxHeight()}
*
* @return Sea level
*/
public int getSeaLevel();
/**
* Gets whether the world's spawn area should be kept loaded into memory or not.
*
* @return true if the world's spawn area will be kept loaded into memory.
*/
public boolean getKeepSpawnInMemory();
/**
* Sets whether the world's spawn area should be kept loaded into memory or not.
*
* @param keepLoaded if true then the world's spawn area will be kept loaded into memory.
*/
public void setKeepSpawnInMemory(boolean keepLoaded);
/**
* Gets whether or not the world will automatically save
*
* @return true if the world will automatically save, otherwise false
*/
public boolean isAutoSave();
/**
* Sets whether or not the world will automatically save
*
* @param value true if the world should automatically save, otherwise false
*/
public void setAutoSave(boolean value);
/**
* Sets the Difficulty of the world.
*
* @param difficulty the new difficulty you want to set the world to
*/
public void setDifficulty(Difficulty difficulty);
/**
* Gets the Difficulty of the world.
*
* @return The difficulty of the world.
*/
public Difficulty getDifficulty();
/**
* Gets the folder of this world on disk.
*
* @return The folder of this world.
*/
public File getWorldFolder();
/**
* Gets the type of this world.
*
* @return Type of this world.
*/
public WorldType getWorldType();
/**
* Represents various map environment types that a world may be
*/
public enum Environment {
/**
* Represents the "normal"/"surface world" map
*/
NORMAL(0),
/**
* Represents a nether based map ("hell")
*/
NETHER(-1),
/**
* Represents the "end" map
*/
THE_END(1);
private final int id;
private static final Map<Integer, Environment> lookup = new HashMap<Integer, Environment>();
private Environment(int id) {
this.id = id;
}
/**
* Gets the dimension ID of this environment
*
* @return dimension ID
*/
public int getId() {
return id;
}
public static Environment getEnvironment(int id) {
return lookup.get(id);
}
static {
for (Environment env : values()) {
lookup.put(env.getId(), env);
}
}
}
}
|