-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
#492 runnable_in_console option #493
Conversation
This PR #493 may also have some effects from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looking good
Perhaps it's better to push it to next version instead though
public abstract Object createEmptyPlayerEvent(ICommandSender sender); | ||
|
||
public abstract Object createPlayerCommandEvent(ICommandSender sender, String label, String[] args); | ||
public abstract Object createCommandEvent(ICommandSender sender, String label, String[] args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest creating a separate method and leave the previous method for now. Maybe also mark as deprecated if it will be removed.
You may rename it in the next version
@@ -592,6 +591,19 @@ public void onSave(String script) { | |||
trigger.getInfo().setSync(!trigger.getInfo().isSync()); | |||
|
|||
sender.sendMessage("&7Sync mode: " + (trigger.getInfo().isSync() ? "&a" : "&c") + trigger.getInfo().isSync()); | |||
saveAsynchronously(getCmdManager()); | |||
} else if (args.length == 3 && getCmdManager().has(args[1]) && args[2].equalsIgnoreCase("console")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe getCmdManager().has(args[1])
can be checked inside the block and give the feedback as necessary?
@@ -28,6 +26,8 @@ public IEntity wrap(Entity entity) { | |||
|
|||
public abstract IPlayer wrap(Player player); | |||
|
|||
public abstract IConsoleCommandSender wrap(ConsoleCommandSender sender); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is implementation for BukkitConsoleCommandSender differ between latest and legacy versions? Or we could just make it a concrete method
@@ -455,8 +458,9 @@ public IPlayer getPlayer(String string) { | |||
return null; | |||
} | |||
|
|||
public ICommandSender getConsoleSender() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: leave it and change in next version
@@ -476,7 +480,7 @@ public HandlerList getHandlers() { | |||
} | |||
} | |||
|
|||
public Object createPlayerCommandEvent(ICommandSender sender, String label, String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: leave it and change in next version
@Override | ||
public Object createEmptyPlayerEvent(ICommandSender sender) { | ||
return bukkit.createEmptyPlayerEvent(sender); | ||
} | ||
|
||
@Override | ||
public Object createPlayerCommandEvent(ICommandSender sender, String label, String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: leave it and change in next version
@@ -11,4 +13,7 @@ public IPlayer wrap(Player player) { | |||
return new BukkitPlayer(player); | |||
} | |||
|
|||
@Override | |||
public IConsoleCommandSender wrap(ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public IConsoleCommandSender wrap(ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} | |
public IConsoleCommandSender wrap(final ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} |
@@ -11,4 +13,6 @@ public IPlayer wrap(Player player) { | |||
return new BukkitPlayer(player); | |||
} | |||
|
|||
@Override | |||
public IConsoleCommandSender wrap(ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public IConsoleCommandSender wrap(ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} | |
public IConsoleCommandSender wrap(final ConsoleCommandSender sender) {return new BukkitConsoleCommandSender(sender);} |
|
||
public class BukkitConsoleCommandSender implements IConsoleCommandSender { | ||
private final ConsoleCommandSender sender; | ||
public BukkitConsoleCommandSender(ConsoleCommandSender sender){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public BukkitConsoleCommandSender(ConsoleCommandSender sender){ | |
public BukkitConsoleCommandSender(final ConsoleCommandSender sender){ |
this.sender = sender; | ||
} | ||
@Override | ||
public void sendMessage(String message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void sendMessage(String message) { | |
public void sendMessage(final String message) { |
} | ||
|
||
@Override | ||
public boolean hasPermission(String permission) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public boolean hasPermission(String permission) { | |
public boolean hasPermission(final String permission) { |
@@ -476,7 +480,7 @@ public HandlerList getHandlers() { | |||
} | |||
} | |||
|
|||
public Object createPlayerCommandEvent(ICommandSender sender, String label, String[] args) { | |||
public Object createCommandEvent(ICommandSender sender, String label, String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Object createCommandEvent(ICommandSender sender, String label, String[] args) { | |
public Object createCommandEvent(final ICommandSender sender, final String label, final String[] args) { |
public IConsoleCommandSender getConsoleCommandSender() { | ||
return bukkit.getConsoleSender(); | ||
} | ||
|
||
@Override | ||
public Object createEmptyPlayerEvent(ICommandSender sender) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Object createEmptyPlayerEvent(ICommandSender sender) { | |
public Object createEmptyPlayerEvent(final ICommandSender sender) { |
@Override | ||
public Object createEmptyPlayerEvent(ICommandSender sender) { | ||
return bukkit.createEmptyPlayerEvent(sender); | ||
} | ||
|
||
@Override | ||
public Object createPlayerCommandEvent(ICommandSender sender, String label, String[] args) { | ||
return bukkit.createPlayerCommandEvent(sender, label, args); | ||
public Object createCommandEvent(ICommandSender sender, String label, String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Object createCommandEvent(ICommandSender sender, String label, String[] args) { | |
public Object createCommandEvent(final ICommandSender sender, final String label, final String[] args) { |
Map<String, Object> varMap = new HashMap<>(); | ||
varMap.put("isByPlayer", false); | ||
varMap.put("sender", sender); | ||
varMap.put("command", cmd); | ||
varMap.put("args", args); | ||
varMap.put("argslength", args.length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map<String, Object> varMap = new HashMap<>(); | |
varMap.put("isByPlayer", false); | |
varMap.put("sender", sender); | |
varMap.put("command", cmd); | |
varMap.put("args", args); | |
varMap.put("argslength", args.length); | |
Map<String, Object> varMap = Map.of("isByPlayer", true, "sender", sender, "command", cmd, "args", args, "argslength", args.length); |
return console_available; | ||
} | ||
|
||
public void setConsoleAvailable(boolean bool){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void setConsoleAvailable(boolean bool){ | |
public void setConsoleAvailable(final boolean bool){ |
this branch is stale for long time and is unlikely cleanly merged Suggested to create a new branch and replicate the changes there |
Please Check This Comment