-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce action use result with customizable message
- Loading branch information
1 parent
efec77a
commit 3ee3f44
Showing
27 changed files
with
230 additions
and
123 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
40 changes: 40 additions & 0 deletions
40
src/api/java/de/teamlapen/vampirism/api/entity/player/actions/IActionResult.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,40 @@ | ||
package de.teamlapen.vampirism.api.entity.player.actions; | ||
|
||
import de.teamlapen.vampirism.api.entity.player.ISkillPlayer; | ||
import net.minecraft.Util; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceKey; | ||
|
||
public interface IActionResult { | ||
|
||
IActionResult SUCCESS = new Custom(true, Component.empty()); | ||
IActionResult ON_COOLDOWN = new Custom(false, Component.translatable("text.vampirism.action.cooldown_not_over")); | ||
IActionResult RESTRICTED = new Custom(false, Component.translatable("text.vampirism.action.restricted")); | ||
IActionResult NOT_UNLOCKED = new Custom(false, Component.translatable("text.vampirism.action.not_unlocked")); | ||
IActionResult DISALLOWED_PERMISSION = new Custom(false, Component.translatable("text.vampirism.action.permission_disallowed"), false); | ||
IActionResult DISABLED_CONFIG = new Custom(false, Component.translatable("text.vampirism.action.deactivated_by_serveradmin"), false); | ||
IActionResult DISALLOWED_FACTION = new Custom(false, Component.translatable("text.vampirism.action.invalid_faction"), false); | ||
|
||
|
||
boolean successful(); | ||
|
||
Component message(); | ||
|
||
boolean sendToStatusBar(); | ||
|
||
record Custom(boolean successful, Component message, boolean sendToStatusBar) implements IActionResult { | ||
|
||
Custom(boolean successful, Component message) { | ||
this(successful, message, true); | ||
} | ||
} | ||
|
||
static IActionResult disallowed(Component message) { | ||
return new Custom(false, message); | ||
} | ||
|
||
static <T extends ISkillPlayer<T>> IActionResult otherAction(IActionHandler<T> handler, Holder<? extends ILastingAction<T>> otherAction) { | ||
return handler.isActionActive(otherAction) ? new Custom(false, Component.translatable("text.vampirism.action.other_action", Component.translatable(Util.makeDescriptionId("action", otherAction.unwrapKey().map(ResourceKey::location).orElseThrow())))) : SUCCESS; | ||
} | ||
} |
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
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
Oops, something went wrong.