Skip to content
Closed
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
264 changes: 264 additions & 0 deletions BungeeCord-Patches/0049-Add-some-things-to-the-API.patch
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);
Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Author

@MrIvanPlays MrIvanPlays Mar 12, 2019

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' ?!

Copy link
Copy Markdown

@mdcfe mdcfe Mar 12, 2019

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.

Copy link
Copy Markdown
Member

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.


/**
* 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @Deprecated to this method.

+
+ /**
+ * 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() ) )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
+ */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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