Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added LazyWorldsProvider used for getting info about worlds without l…
…oading them
- Loading branch information
1 parent
0649d47
commit ebcc661
Showing
23 changed files
with
411 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
API/src/main/java/com/bgsoftware/superiorskyblock/api/hooks/LazyWorldsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.bgsoftware.superiorskyblock.api.hooks; | ||
|
||
import com.bgsoftware.superiorskyblock.api.island.Island; | ||
import com.bgsoftware.superiorskyblock.api.world.WorldInfo; | ||
import org.bukkit.World; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
public interface LazyWorldsProvider extends WorldsProvider { | ||
|
||
/** | ||
* Get the {@link WorldInfo} of the world of an island by the environment. | ||
* The world does not have to be loaded. | ||
* | ||
* @param island The island to check. | ||
* @param environment The world environment. | ||
* @return The world info for the given environment, or null if this environment is not enabled. | ||
*/ | ||
@Nullable | ||
WorldInfo getIslandsWorldInfo(Island island, World.Environment environment); | ||
|
||
/** | ||
* Get the {@link WorldInfo} of the world of an island by its name. | ||
* The world does not have to be loaded. | ||
* | ||
* @param island The island to check. | ||
* @param worldName The name of the world. | ||
* @return The world info for the given name, or null if this name is not an islands world. | ||
*/ | ||
@Nullable | ||
WorldInfo getIslandsWorldInfo(Island island, String worldName); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
API/src/main/java/com/bgsoftware/superiorskyblock/api/world/WorldInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bgsoftware.superiorskyblock.api.world; | ||
|
||
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI; | ||
import com.google.common.base.Preconditions; | ||
import org.bukkit.World; | ||
|
||
public interface WorldInfo { | ||
|
||
/** | ||
* Get the name of this world. | ||
*/ | ||
String getName(); | ||
|
||
/** | ||
* Get the environment of this world. | ||
*/ | ||
World.Environment getEnvironment(); | ||
|
||
/** | ||
* Create a new world info. | ||
* | ||
* @param world The world. | ||
*/ | ||
static WorldInfo of(World world) { | ||
Preconditions.checkNotNull(world, "world parameter cannot be null"); | ||
Preconditions.checkArgument(SuperiorSkyblockAPI.getGrid().isIslandsWorld(world), "World must be an islands world."); | ||
return of(world.getName(), world.getEnvironment()); | ||
} | ||
|
||
/** | ||
* Create a new world info. | ||
* | ||
* @param worldName The name of the world. | ||
* @param environment The environment of the world. | ||
*/ | ||
static WorldInfo of(String worldName, World.Environment environment) { | ||
Preconditions.checkNotNull(worldName, "worldName parameter cannot be null"); | ||
Preconditions.checkNotNull(environment, "environment parameter cannot be null"); | ||
return SuperiorSkyblockAPI.getFactory().createWorldInfo(worldName, environment); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/bgsoftware/superiorskyblock/core/DirtyChunk.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.bgsoftware.superiorskyblock.core; | ||
|
||
import java.util.Objects; | ||
|
||
public class DirtyChunk { | ||
|
||
private final String worldName; | ||
private final int x; | ||
private final int z; | ||
|
||
public DirtyChunk(String worldName, int x, int z) { | ||
this.worldName = worldName; | ||
this.x = x; | ||
this.z = z; | ||
} | ||
|
||
public String getWorldName() { | ||
return worldName; | ||
} | ||
|
||
public int getX() { | ||
return x; | ||
} | ||
|
||
public int getZ() { | ||
return z; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
DirtyChunk that = (DirtyChunk) o; | ||
return x == that.x && z == that.z && worldName.equals(that.worldName); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(worldName, x, z); | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/com/bgsoftware/superiorskyblock/core/WorldInfoImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.bgsoftware.superiorskyblock.core; | ||
|
||
import com.bgsoftware.superiorskyblock.api.world.WorldInfo; | ||
import org.bukkit.World; | ||
|
||
import java.util.Objects; | ||
|
||
public class WorldInfoImpl implements WorldInfo { | ||
|
||
private final String worldName; | ||
private final World.Environment environment; | ||
|
||
public WorldInfoImpl(String worldName, World.Environment environment) { | ||
this.worldName = worldName; | ||
this.environment = environment; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return this.worldName; | ||
} | ||
|
||
@Override | ||
public World.Environment getEnvironment() { | ||
return this.environment; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
WorldInfoImpl worldInfo = (WorldInfoImpl) o; | ||
return worldName.equals(worldInfo.worldName) && environment == worldInfo.environment; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(worldName, environment); | ||
} | ||
|
||
} |
Oops, something went wrong.