Skip to content

Commit

Permalink
fix: getTime
Browse files Browse the repository at this point in the history
- исправлен null в getTime
  • Loading branch information
Reider745 committed Dec 16, 2023
1 parent ca15087 commit 9f3759d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/main/java/com/reider745/world/WorldMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
import com.reider745.InnerCoreServer;

public class WorldMethod {

private static Level getLevel(){
return InnerCoreServer.server.getDefaultLevel();
}

public static long getTime() {
return InnerCoreServer.server.getLevel(0).getTime() % Level.TIME_FULL;
final Level level = getLevel();
if(level != null)
return level.getTime() % Level.TIME_FULL;
return 0;
}

public static void setTime(int time) {
InnerCoreServer.server.getLevel(0).setTime(time);
final Level level = getLevel();
if(level != null)
level.setTime(time);
}

public static int getGameMode() {
Expand All @@ -28,7 +38,7 @@ public static void setDifficulty(int difficulty) {
}

public static double getRainLevel() {
return 0;

}

public static void setRainLevel(float v) {
Expand All @@ -42,6 +52,9 @@ public static void setLightningLevel(float v) {
}

public static long getSeed() {
return InnerCoreServer.server.getLevelByName("world").getSeed();
final Level level = getLevel();
if(level != null)
return level.getSeed();
return 0;
}
}

0 comments on commit 9f3759d

Please sign in to comment.