-
-
Notifications
You must be signed in to change notification settings - Fork 306
Things to the API patch #359
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,264 @@ | ||
| From fa435a332e99ec02e25ffb65d90c78aa10bbd172 Mon Sep 17 00:00:00 2001 | ||
| From: MrIvanPlays <pekov.ivan@abv.bg> | ||
| Date: Mon, 11 Mar 2019 16:00:17 +0200 | ||
| Subject: [PATCH] Add some things to the API | ||
|
|
||
|
|
||
| diff --git a/api/src/main/java/net/md_5/bungee/api/Callback.java b/api/src/main/java/net/md_5/bungee/api/Callback.java | ||
| index 0cccc175..f383279b 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/Callback.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/Callback.java | ||
| @@ -6,6 +6,7 @@ package net.md_5.bungee.api; | ||
| * | ||
| * @param <V> the type of result | ||
| */ | ||
| +@FunctionalInterface // Waterfall | ||
| public interface Callback<V> | ||
| { | ||
|
|
||
| diff --git a/api/src/main/java/net/md_5/bungee/api/CommandSender.java b/api/src/main/java/net/md_5/bungee/api/CommandSender.java | ||
| index a35b3fd0..f83fc023 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/CommandSender.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/CommandSender.java | ||
| @@ -16,19 +16,19 @@ public interface CommandSender | ||
|
|
||
| /** | ||
| * Send a message to this sender. | ||
| + * Waterfall - Deprecation removal. No reason deprecating | ||
| * | ||
| * @param message the message to send | ||
| */ | ||
| - @Deprecated | ||
| public void sendMessage(String message); | ||
|
|
||
| /** | ||
| * Send several messages to this sender. Each message will be sent | ||
| * separately. | ||
| + * Waterfall - Deprecation removal. No reason deprecating | ||
| * | ||
| * @param messages the messages to send | ||
| */ | ||
| - @Deprecated | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here |
||
| public void sendMessages(String... messages); | ||
|
|
||
| /** | ||
| diff --git a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java | ||
| index f7459860..9946c310 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/connection/ProxiedPlayer.java | ||
| @@ -69,7 +69,9 @@ public interface ProxiedPlayer extends Connection, CommandSender | ||
| * | ||
| * @param position the screen position | ||
| * @param message the message to send | ||
| + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} or {@link #sendActionBar(BaseComponent)}, {@link #sendActionBar(BaseComponent...)} for a more proper ActionBar API. | ||
| */ | ||
| + @Deprecated // Waterfall | ||
| public void sendMessage(ChatMessageType position, BaseComponent... message); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is perfectly valid, why would we deprecate it? |
||
|
|
||
| /** | ||
| @@ -77,7 +79,9 @@ public interface ProxiedPlayer extends Connection, CommandSender | ||
| * | ||
| * @param position the screen position | ||
| * @param message the message to send | ||
| + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} or {@link #sendActionBar(BaseComponent)}, {@link #sendActionBar(BaseComponent...)} for a more proper ActionBar API. | ||
| */ | ||
| + @Deprecated // Waterfall | ||
| public void sendMessage(ChatMessageType position, BaseComponent message); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing as above. |
||
|
|
||
| /** | ||
| @@ -372,4 +376,37 @@ public interface ProxiedPlayer extends Connection, CommandSender | ||
| * @return this player's {@link Scoreboard} | ||
| */ | ||
| Scoreboard getScoreboard(); | ||
| + | ||
| + // Waterfall start | ||
| + | ||
| + /** | ||
| + * Sends ActionBar message to the client. | ||
| + * | ||
| + * @param message the message you wish to send | ||
| + */ | ||
| + public void sendActionBar(String message); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add |
||
| + | ||
| + /** | ||
| + * Sends ActionBar message to the client. | ||
| + * | ||
| + * @param message the message you wish to send | ||
| + */ | ||
| + public void sendActionBar(BaseComponent message); | ||
| + | ||
| + /** | ||
| + * Sends ActionBar message to the client. | ||
| + * | ||
| + * @param message the message you wish to send | ||
| + */ | ||
| + public void sendActionBar(BaseComponent... message); | ||
| + | ||
| + /** | ||
| + * Gets the current player title. The method can return null if the current | ||
| + * title is null. | ||
| + * | ||
| + * @return title if not null | ||
| + */ | ||
| + public Title getCurrentTitle(); | ||
| + | ||
| + // Waterfall end | ||
| } | ||
| diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java | ||
| index 2e5ae4fb..981dd8ef 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/plugin/Plugin.java | ||
| @@ -67,6 +67,13 @@ public class Plugin | ||
| return new File( getProxy().getPluginsFolder(), getDescription().getName() ); | ||
| } | ||
|
|
||
| + // Waterfall start - allow plugins to get plugin names directly | ||
| + public String getName() | ||
| + { | ||
| + return description.getName(); | ||
| + } | ||
| + // Waterfall end | ||
| + | ||
| /** | ||
| * Get a resource from within this plugins jar or container. Care must be | ||
| * taken to close the returned stream. | ||
| diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java | ||
| index 81bd18f0..44ff7cd9 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java | ||
| @@ -181,10 +181,14 @@ public class PluginManager | ||
| { | ||
| if ( proxy.getConfig().isLogCommands() ) | ||
| { | ||
| - proxy.getLogger().log( Level.INFO, "{0} executed command: /{1}", new Object[] | ||
| + // Waterfall - check if the command sender is not the console | ||
| + if ( !sender.getName().equalsIgnoreCase( proxy.getConsole().getName() ) ) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Logging console commands might be useful for web terminals/screen/tmux... where multiple people might be watching the same console output
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And generally useful when checking the log file? |
||
| { | ||
| - sender.getName(), commandLine | ||
| - } ); | ||
| + proxy.getLogger().log( Level.INFO, "{0} executed command: /{1}", new Object[] | ||
| + { | ||
| + sender.getName(), commandLine | ||
| + } ); | ||
| + } | ||
| } | ||
| command.execute( sender, args ); | ||
| } else if ( commandLine.contains( " " ) && command instanceof TabExecutor ) | ||
| diff --git a/api/src/main/java/net/md_5/bungee/api/scheduler/TaskScheduler.java b/api/src/main/java/net/md_5/bungee/api/scheduler/TaskScheduler.java | ||
| index 5d2b088c..4fa6ec45 100644 | ||
| --- a/api/src/main/java/net/md_5/bungee/api/scheduler/TaskScheduler.java | ||
| +++ b/api/src/main/java/net/md_5/bungee/api/scheduler/TaskScheduler.java | ||
| @@ -58,6 +58,35 @@ public interface TaskScheduler | ||
| */ | ||
| ScheduledTask schedule(Plugin owner, Runnable task, long delay, TimeUnit unit); | ||
|
|
||
| + // Waterfall start - allow scheduling tasks with ticks | ||
| + | ||
| + /** | ||
| + * Schedules a task to be executed asynchronously after the specified delay | ||
| + * is up. | ||
| + * | ||
| + * @param owner the plugin owning this task | ||
| + * @param task the task to run | ||
| + * @param delay the delay before this task will be executed, specified in ticks | ||
| + * @return the scheduled task | ||
| + */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bungee (and by extension, Waterfall) doesn't have a concept of ticks. This is only used in NMS based servers. You can pass 50 millis if you want to run a task every tick. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In addition, you should specify either in Javadocs or the method name (or both) that this method accepts ticks. It isn't obvious what unit the delay is in unless you read the implementation code. |
||
| + ScheduledTask schedule(Plugin owner, Runnable task, long delay); | ||
| + | ||
| + /** | ||
| + * Schedules a task to be executed asynchronously after the specified delay | ||
| + * is up. The scheduled task will continue running at the specified | ||
| + * interval. The interval will not begin to count down until the last task | ||
| + * invocation is complete. | ||
| + * | ||
| + * @param owner the plugin owning this task | ||
| + * @param task the task to run | ||
| + * @param delay the delay before this task will be executed, specified in ticks | ||
| + * @param period the interval before subsequent executions of this task, specified in ticks | ||
| + * @return the scheduled task | ||
| + */ | ||
| + ScheduledTask schedule(Plugin owner, Runnable task, long delay, long period); | ||
| + | ||
| + // Waterfall end | ||
| + | ||
| /** | ||
| * Schedules a task to be executed asynchronously after the specified delay | ||
| * is up. The scheduled task will continue running at the specified | ||
| diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java | ||
| index e649678e..24e84846 100644 | ||
| --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java | ||
| +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java | ||
| @@ -130,6 +130,8 @@ public final class UserConnection implements ProxiedPlayer | ||
| // Waterfall start | ||
| @Getter | ||
| private final Multimap<Integer, Integer> potions = HashMultimap.create(); | ||
| + @Getter | ||
| + private Title currentTitle; | ||
| // Waterfall end | ||
| /*========================================================================*/ | ||
| @Getter | ||
| @@ -709,6 +711,7 @@ public final class UserConnection implements ProxiedPlayer | ||
| @Override | ||
| public void sendTitle(Title title) | ||
| { | ||
| + this.currentTitle = title; // Waterfall | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see any current title expiration code |
||
| title.send( this ); | ||
| } | ||
|
|
||
| @@ -740,6 +743,26 @@ public final class UserConnection implements ProxiedPlayer | ||
| } | ||
|
|
||
| // Waterfall start | ||
| + | ||
| + @Override | ||
| + public void sendActionBar(String message) | ||
| + { | ||
| + sendActionBar( TextComponent.fromLegacyText( message ) ); | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void sendActionBar(BaseComponent message) | ||
| + { | ||
| + BaseComponent[] sent = ChatComponentTransformer.getInstance().transform( this, message ); | ||
| + sendActionBar( sent ); | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void sendActionBar(BaseComponent... message) | ||
| + { | ||
| + sendMessage( ChatMessageType.ACTION_BAR, message ); | ||
| + } | ||
| + | ||
| public boolean isDisableEntityMetadataRewrite() { | ||
| return disableEntityMetadaRewrite; | ||
| } | ||
| diff --git a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java | ||
| index fd0dabcf..ff080581 100644 | ||
| --- a/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java | ||
| +++ b/proxy/src/main/java/net/md_5/bungee/scheduler/BungeeScheduler.java | ||
| @@ -88,6 +88,22 @@ public class BungeeScheduler implements TaskScheduler | ||
| return schedule( owner, task, delay, 0, unit ); | ||
| } | ||
|
|
||
| + // Waterfall start | ||
| + | ||
| + @Override | ||
| + public ScheduledTask schedule(Plugin owner, Runnable task, long delay) | ||
| + { | ||
| + return schedule( owner, task, delay * 50, TimeUnit.MILLISECONDS ); | ||
| + } | ||
| + | ||
| + @Override | ||
| + public ScheduledTask schedule(Plugin owner, Runnable task, long delay, long period) | ||
| + { | ||
| + return schedule( owner, task, delay * 50, period * 50, TimeUnit.MILLISECONDS ); | ||
| + } | ||
| + | ||
| + //Waterfall end | ||
| + | ||
| @Override | ||
| public ScheduledTask schedule(Plugin owner, Runnable task, long delay, long period, TimeUnit unit) | ||
| { | ||
| -- | ||
| 2.20.1.windows.1 | ||
|
|
||
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.
This method is deprecated for valid reasons. Legacy texts are converted to text components, but you should always use the latter.
Uh oh!
There was an error while loading. Please reload this page.
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.
Then why md_5 doesn't specify it in javadocs as '@ deprecated' ?!
Uh oh!
There was an error while loading. Please reload this page.
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.
You can already see it's deprecated from the annotation on the method; he probably felt it wasn't necessary to duplicate that line.
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.
Honestly, Deprecating string methods is stupid, as it serves a purpose to send a simple message.
One could argue the legacy codes support of this message are 'deprecated' and that the method isn't, but it's also possible to permanently support that system on the API, which I'm supportive of, as components are stupid for simple messaging.
I'm in favor of permanently keeping legacy codes around for simple messaging, and if mojang adds more advanced capabilities than current with components, then the legacy system just wouldn't expose it and people can move to comps then.
But even a sendMessage(ChatColor color, String msg); that doesn't use legacy codes would be useful to declare simple messages, but I see no harm in keeping legacy codes on sendMessage.
If md5 removed it from Bukkit API, I would add it back. It costs nothing to maintain.