-
Notifications
You must be signed in to change notification settings - Fork 17
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
Showing
10 changed files
with
50 additions
and
79 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
6 changes: 0 additions & 6 deletions
6
src/main/java/dev/gegy/roles/command/ExtendedEntitySelectorReader.java
This file was deleted.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
src/main/java/dev/gegy/roles/command/PlayerRolesEntitySelectorOptions.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,35 @@ | ||
package dev.gegy.roles.command; | ||
|
||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import dev.gegy.roles.PlayerRoles; | ||
import dev.gegy.roles.api.PlayerRolesApi; | ||
import net.fabricmc.fabric.api.command.v2.EntitySelectorOptionRegistry; | ||
import net.minecraft.command.EntitySelectorReader; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
|
||
public final class PlayerRolesEntitySelectorOptions { | ||
private static final Identifier ID = PlayerRoles.identifier("role"); | ||
private static final Text DESCRIPTION = Text.literal("Player Role"); | ||
|
||
public static void register() { | ||
EntitySelectorOptionRegistry.register(ID, DESCRIPTION, PlayerRolesEntitySelectorOptions::handle, PlayerRolesEntitySelectorOptions::canUse); | ||
} | ||
|
||
private static void handle(EntitySelectorReader reader) throws CommandSyntaxException { | ||
boolean isNegated = reader.readNegationCharacter(); | ||
String roleName = reader.getReader().readUnquotedString(); | ||
reader.addPredicate(entity -> { | ||
var role = PlayerRolesApi.provider().get(roleName); | ||
return (role != null && PlayerRolesApi.lookup().byEntity(entity).has(role)) != isNegated; | ||
}); | ||
if (!isNegated) { | ||
reader.setCustomFlag(ID, true); | ||
} | ||
} | ||
|
||
private static boolean canUse(EntitySelectorReader reader) { | ||
return !reader.getCustomFlag(ID); | ||
} | ||
} |
39 changes: 0 additions & 39 deletions
39
src/main/java/dev/gegy/roles/mixin/EntitySelectorOptionsMixin.java
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
src/main/java/dev/gegy/roles/mixin/EntitySelectorReaderMixin.java
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
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