-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving dimension logic to specific class, checks
- Loading branch information
Showing
10 changed files
with
112 additions
and
152 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
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,44 @@ | ||
package com.cooptweaks; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public final class Dimension { | ||
/** Maps player names to their current dimension. */ | ||
private static final ConcurrentHashMap<String, String> PLAYER_CURRENT_DIMENSION_ID = new ConcurrentHashMap<>(); | ||
|
||
/** Maps dimension IDs to their names. */ | ||
private static final HashMap<String, String> DIMENSIONS = new HashMap<>(Map.of( | ||
"minecraft:overworld", "Overworld", | ||
"minecraft:the_nether", "Nether", | ||
"minecraft:the_end", "End" | ||
)); | ||
|
||
/** | ||
Gets the dimension name of a player. | ||
@param player The player's name. | ||
@return The dimension name of the player. Example: "Overworld". | ||
*/ | ||
public static String getPlayerDimension(String player) { | ||
String dimensionId = getPlayerCurrentDimension(player); | ||
String dimension = DIMENSIONS.get(dimensionId); | ||
|
||
if (dimension == null) { | ||
return dimensionId; | ||
} | ||
|
||
return dimension; | ||
} | ||
|
||
/** Gets the current dimension ID of a player. */ | ||
public static String getPlayerCurrentDimension(String name) { | ||
return PLAYER_CURRENT_DIMENSION_ID.get(name); | ||
} | ||
|
||
/** Updates the current dimension ID of a player. */ | ||
public static void updatePlayerCurrentDimension(String name, String dimensionId) { | ||
PLAYER_CURRENT_DIMENSION_ID.put(name, dimensionId); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.