This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9f0fc1
commit b052765
Showing
5 changed files
with
89 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
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
21 changes: 21 additions & 0 deletions
21
src/main/java/com/denizenscript/denizen2sponge/utilities/Utilities.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 |
---|---|---|
@@ -1,11 +1,32 @@ | ||
package com.denizenscript.denizen2sponge.utilities; | ||
|
||
import com.denizenscript.denizen2core.tags.objects.MapTag; | ||
import com.denizenscript.denizen2core.tags.objects.TimeTag; | ||
import com.denizenscript.denizen2core.utilities.Action; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.entity.living.player.gamemode.GameModes; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.ZoneId; | ||
|
||
public class Utilities { | ||
|
||
public static double getHandReach(Player player) { | ||
return player.gameMode().equals(GameModes.CREATIVE) ? 5.0 : 4.0; | ||
} | ||
|
||
public static boolean flagIsValidAndNotExpired(Action<String> error, MapTag flags, String flagName) { | ||
boolean b = false; | ||
if (flags.getInternal().containsKey(flagName)) { | ||
b = true; | ||
MapTag subMap = MapTag.getFor(error, flags.getInternal().get(flagName)); | ||
if (subMap.getInternal().containsKey("duration")) { | ||
TimeTag tt = TimeTag.getFor(error, subMap.getInternal().get("duration")); | ||
if (tt.getInternal().isBefore(LocalDateTime.now(ZoneId.of("UTC")))) { | ||
b = false; | ||
} | ||
} | ||
} | ||
return b; | ||
} | ||
} |