forked from PseudoKnight/Stargate-Bukkit
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Seems like it loads a chunk whenever it's called. Seems unnecessary
- Loading branch information
1 parent
7a10e26
commit af2be3f
Showing
4 changed files
with
73 additions
and
16 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
55 changes: 55 additions & 0 deletions
55
src/main/java/org/sgrewritten/stargate/api/network/portal/StargateChunk.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,55 @@ | ||
package org.sgrewritten.stargate.api.network.portal; | ||
|
||
import com.bergerkiller.bukkit.common.bases.IntVector2; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.World; | ||
|
||
public class StargateChunk { | ||
|
||
private final int x; | ||
private final int z; | ||
private final String worldName; | ||
|
||
public StargateChunk(Chunk chunk){ | ||
this(chunk.getX(),chunk.getZ(), chunk.getWorld()); | ||
} | ||
|
||
public StargateChunk(int x, int z, World world){ | ||
this(x,z,world.getName()); | ||
} | ||
|
||
public StargateChunk(int x, int z, String worldName){ | ||
this.x = x; | ||
this.z = z; | ||
this.worldName = worldName; | ||
} | ||
|
||
public StargateChunk(IntVector2 coordinate, World world){ | ||
this(coordinate.x, coordinate.z, world); | ||
} | ||
|
||
public Chunk getChunk(){ | ||
return Bukkit.getWorld(worldName).getChunkAt(x,z); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other){ | ||
if(other == this){ | ||
return true; | ||
} | ||
if(!(other instanceof StargateChunk otherChunk)){ | ||
return false; | ||
} | ||
return otherChunk.x == this.x && otherChunk.z == this.z && otherChunk.worldName.equals(this.worldName); | ||
} | ||
|
||
@Override | ||
public int hashCode(){ | ||
int result = 18; | ||
result = result * 27 + x; | ||
result = result * 27 + z; | ||
result = result * 27 + worldName.hashCode(); | ||
return result; | ||
} | ||
} |
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