Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make NativeProxyCommandSender extend CraftBukkit class ProxiedNativeCommandSender #478

Open
wants to merge 6 commits into
base: dev/10.0.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,15 @@ This is the current roadmap for the CommandAPI (as of 30th April 2024):
</tr>
</thead>
<tbody>
<tr>
<td valign="top"><b>10.0.0</b></td>
<td valign="top">???</td>
<td valign="top">
<ul>
<li>https://github.com/JorelAli/CommandAPI/issues/477 Fixed <code>NativeProxyCommandSender</code> not being able to run Vanilla (and CommandAPI) commands</li>
</ul>
</td>
</tr>
<tr>
<td valign="top"><b>9.6.0</b></td>
<td valign="top">???</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,27 @@ void nativeSender() {
})
.register();
/* ANCHOR_END: native1 */

/* ANCHOR: native2 */
new CommandAPICommand("executeAs")
.withArguments(
new EntitySelectorArgument.OneEntity("target"),
new LocationArgument("location"),
new WorldArgument("world"),
new CommandArgument("command")
)
.executes((caller, args) -> {
CommandSender callee = args.getUnchecked("target");
Location location = args.getUnchecked("location");
World world = args.getUnchecked("world");
CommandResult command = args.getUnchecked("command");

assert callee != null && location != null && world != null && command != null;

command.execute(NativeProxyCommandSender.from(caller, callee, location, world));
})
.register();
/* ANCHOR_END: native2 */
}

void normalExecutors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1726,6 +1726,25 @@ CommandAPICommand("break")
})
.register()
/* ANCHOR_END: native1 */

/* ANCHOR: native2 */
CommandAPICommand("executeAs")
.withArguments(
EntitySelectorArgument.OneEntity("target"),
LocationArgument("location"),
WorldArgument("world"),
CommandArgument("command")
)
.executes(CommandExecutor { caller, args ->
val callee = args["target"] as CommandSender
val location = args["location"] as Location
val world = args["world"] as World
val command = args["command"] as CommandResult

command.execute(NativeProxyCommandSender.from(caller, callee, location, world))
})
.register();
/* ANCHOR_END: native2 */
}

fun normalExecutors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,23 @@ commandAPICommand("break") {
}
}
/* ANCHOR_END: native1 */

/* ANCHOR: native1 */
commandAPICommand("executeAs") {
entitySelectorArgumentOneEntity("target")
locationArgument("location")
worldArgument("world")
commandArgument("command")
anyExecutor { caller, args ->
val callee = args["target"] as CommandSender
val location = args["location"] as Location
val world = args["world"] as World
val command = args["command"] as CommandResult

command.execute(NativeProxyCommandSender.from(caller, callee, location, world))
}
}
/* ANCHOR_END: native1 */
}

fun optional_arguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.bukkit.advancement.Advancement;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
Expand All @@ -64,6 +65,7 @@
import dev.jorel.commandapi.wrappers.IntegerRange;
import dev.jorel.commandapi.wrappers.Location2D;
import dev.jorel.commandapi.wrappers.MathOperation;
import dev.jorel.commandapi.wrappers.NativeProxyCommandSender;
import dev.jorel.commandapi.wrappers.ParticleData;
import dev.jorel.commandapi.wrappers.Rotation;
import dev.jorel.commandapi.wrappers.ScoreboardSlot;
Expand Down Expand Up @@ -417,4 +419,6 @@ String getScoreHolderSingle(CommandContext<CommandListenerWrapper> cmdCtx, Strin
Message generateMessageFromJson(String json);

CommandRegistrationStrategy<CommandListenerWrapper> createCommandRegistrationStrategy();

NativeProxyCommandSender createNativeProxyCommandSender(CommandSender caller, CommandSender callee, Location location, World world);
}
Loading
Loading