Class WorldUtils
java.lang.Object
ua.mcchickenstudio.opencreative.utils.world.WorldUtils
WorldUtils
This class contains methods for changing or manipulating worlds, like checking if world is a planet.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromLocationToMap(@NotNull org.bukkit.Location location) Converts location to map with x, y, z, yaw, pitch values.static doublefromTextToCoordinate(@NotNull String text, double defaultValue) Converts text coordinate to numeric double.static intReturns a unique numeric ID for new planet.static org.bukkit.NamespacedKeyReturns key, that will be used in entities, that mustn't damage any entity.static @NotNull StringgetPlanetIdFromName(@NotNull org.bukkit.World world) Returns planet id from world's name by splitting it and removing path to planets folder.static booleanisDevPlanet(@NotNull String worldName) Checks if the world is a dev planet by checking whether it's name ends with "dev" word.static booleanisDevPlanet(@NotNull org.bukkit.World world) Checks if the world is a dev planet by checking whether it's name ends with "dev" word.static booleanisEntityHostile(@Nullable org.bukkit.entity.Entity entity) Checks if entity is a hostile one, that can attack player.static booleanisLobbyWorld(@NotNull org.bukkit.World world) Checks if the world is a lobby world, where players will be teleported on server connection or by /spawn command.static booleanisOpenCreativeWorld(@NotNull org.bukkit.World world) Checks if the world is a planet, or dev planet, or lobby world.static booleanChecks if the world is a planet by checking whether it's name contains a typical planets folder path.static booleanisPlanet(@NotNull org.bukkit.World world) Checks if the world is a planet by checking whether it's name contains a typical planets folder path.static @NotNull org.bukkit.LocationroundLocation(@NotNull org.bukkit.Location location) Rounds location numbers: x, y, z, yaw, pitch.static voidsummonFireworks(int times, int period) Summons fireworks around players in world.static voidsummonFireworks(@NotNull org.bukkit.World world, int amount) Summons fireworks around players in world.
-
Constructor Details
-
WorldUtils
public WorldUtils()
-
-
Method Details
-
getDoNotHurtAnyoneKey
public static org.bukkit.NamespacedKey getDoNotHurtAnyoneKey()Returns key, that will be used in entities, that mustn't damage any entity.- Returns:
- namespaced key of not hurting anyone.
-
summonFireworks
public static void summonFireworks(@NotNull @NotNull org.bukkit.World world, int amount) Summons fireworks around players in world. They won't damage players or entities.- Parameters:
world- world to summon.amount- amount of fireworks.
-
summonFireworks
public static void summonFireworks(int times, int period) Summons fireworks around players in world. They won't damage players or entities.- Parameters:
times- how many times summon fireworks.period- period of time, that should pass before every time.
-
getPlanetIdFromName
@NotNull public static @NotNull String getPlanetIdFromName(@NotNull @NotNull org.bukkit.World world) Returns planet id from world's name by splitting it and removing path to planets folder.- Parameters:
world- world to get id.- Returns:
- planet id.
-
roundLocation
@NotNull public static @NotNull org.bukkit.Location roundLocation(@NotNull @NotNull org.bukkit.Location location) Rounds location numbers: x, y, z, yaw, pitch.- Parameters:
location- location to round.- Returns:
- location with rounded coordinates.
-
fromTextToCoordinate
Converts text coordinate to numeric double.If it starts with ~ symbol, it will add specified value to default value.
If it fails to get number from text, it will return default value.
- Parameters:
text- text with number to convert.defaultValue- default value.- Returns:
- coordinate double value.
-
fromLocationToMap
-
isPlanet
public static boolean isPlanet(@NotNull @NotNull org.bukkit.World world) Checks if the world is a planet by checking whether it's name contains a typical planets folder path.- Parameters:
world- world to check.- Returns:
- true - should be a planet, false - not a planet.
-
isPlanet
Checks if the world is a planet by checking whether it's name contains a typical planets folder path.- Parameters:
worldName- name of world to check.- Returns:
- true - should be a planet, false - not a planet.
-
isDevPlanet
Checks if the world is a dev planet by checking whether it's name ends with "dev" word.- Parameters:
worldName- world to check.- Returns:
- true - should be a dev planet, false - not a dev planet.
-
isOpenCreativeWorld
public static boolean isOpenCreativeWorld(@NotNull @NotNull org.bukkit.World world) Checks if the world is a planet, or dev planet, or lobby world.- Parameters:
world- world to check.- Returns:
- true - it's spawn, planet, dev planet world, false - not plugin's world.
-
isEntityHostile
public static boolean isEntityHostile(@Nullable @Nullable org.bukkit.entity.Entity entity) Checks if entity is a hostile one, that can attack player.- Parameters:
entity- entity to check.- Returns:
- true - entity is angry, false - entity is friendly or null.
-
isDevPlanet
public static boolean isDevPlanet(@NotNull @NotNull org.bukkit.World world) Checks if the world is a dev planet by checking whether it's name ends with "dev" word.- Parameters:
world- world to check.- Returns:
- true - should be a dev planet, false - not a dev planet.
-
isLobbyWorld
public static boolean isLobbyWorld(@NotNull @NotNull org.bukkit.World world) Checks if the world is a lobby world, where players will be teleported on server connection or by /spawn command.- Parameters:
world- world to check.- Returns:
- true - it's lobby world, false - not lobby world.
-
generateWorldID
public static int generateWorldID()Returns a unique numeric ID for new planet. It gets a last numeric ID from config and increases it while checking is number free. Immediately will replace last numeric ID with result.- Returns:
- unique numeric ID.
-