Update to Minecraft 1.13-pre7

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot
2018-07-15 10:00:00 +10:00
parent debc7172fd
commit 767e4f6ccf
199 changed files with 8301 additions and 3637 deletions

View File

@@ -118,6 +118,10 @@ import com.google.common.collect.ImmutableSet;
* <td><code>awareness</code></td>
* <td>{@link #getAwareness()}</td>
* <td>The concepts that the plugin acknowledges</td>
* </tr><tr>
* <td><code>api-version</code></td>
* <td>{@link #getAPIVersion()}</td>
* <td>The API version which this plugin was programmed against</td>
* </tr>
* </table>
* <p>
@@ -134,6 +138,7 @@ import com.google.common.collect.ImmutableSet;
*
*main: com.captaininflamo.bukkit.inferno.Inferno
*depend: [NewFire, FlameWire]
*api-version: 1.13
*
*commands:
* flagrate:
@@ -223,6 +228,7 @@ public final class PluginDescriptionFile {
private Map<?, ?> lazyPermissions = null;
private PermissionDefault defaultPerm = PermissionDefault.OP;
private Set<PluginAwareness> awareness = ImmutableSet.of();
private String apiVersion = null;
public PluginDescriptionFile(final InputStream stream) throws InvalidDescriptionException {
loadMap(asMap(YAML.get().load(stream)));
@@ -846,6 +852,23 @@ public final class PluginDescriptionFile {
return name + " v" + version;
}
/**
* Gives the API version which this plugin is designed to support. No
* specific format is guaranteed.
* <ul>
* <li>Refer to release notes for supported API versions.
* </ul>
* <p>
* In the plugin.yml, this entry is named <code>api-version</code>.
* <p>
* Example:<blockquote><pre>api-version: 1.13</pre></blockquote>
*
* @return the version of the plugin
*/
public String getAPIVersion() {
return apiVersion;
}
/**
* @return unused
* @deprecated unused
@@ -995,6 +1018,14 @@ public final class PluginDescriptionFile {
this.awareness = ImmutableSet.copyOf(awareness);
}
if (map.get("api-version") != null) {
try {
apiVersion = map.get("api-version").toString();
} catch (ClassCastException ex) {
throw new InvalidDescriptionException(ex, "api-version is of wrong type");
}
}
try {
lazyPermissions = (Map<?, ?>) map.get("permissions");
} catch (ClassCastException ex) {
@@ -1056,6 +1087,10 @@ public final class PluginDescriptionFile {
map.put("authors", authors);
}
if (apiVersion != null) {
map.put("api-version", apiVersion);
}
if (classLoaderOf != null) {
map.put("class-loader-of", classLoaderOf);
}

View File

@@ -122,6 +122,8 @@ public final class JavaPluginLoader implements PluginLoader {
}
}
server.getUnsafe().checkSupported(description);
final PluginClassLoader loader;
try {
loader = new PluginClassLoader(this, getClass().getClassLoader(), description, dataFolder, file);

View File

@@ -100,6 +100,8 @@ final class PluginClassLoader extends URLClassLoader {
throw new ClassNotFoundException(name, ex);
}
classBytes = loader.server.getUnsafe().processClass(description, classBytes);
int dot = name.lastIndexOf('.');
if (dot != -1) {
String pkgName = name.substring(0, dot);

View File

@@ -1,12 +1,17 @@
package org.bukkit.plugin.messaging;
import java.util.Set;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
/**
* A class responsible for managing the registrations of plugin channels and
* their listeners.
*
* Channel names must contain a colon separator and consist of only [a-z0-9/._-]
* - i.e. they MUST be valid {@link NamespacedKey}. The "BungeeCord" channel is
* an exception and may only take this form.
*/
public interface Messenger {
@@ -18,7 +23,7 @@ public interface Messenger {
/**
* Represents the largest size that a Plugin Channel may be.
*/
public static final int MAX_CHANNEL_SIZE = 20;
public static final int MAX_CHANNEL_SIZE = 32;
/**
* Checks if the specified channel is a reserved name.

View File

@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
@@ -167,16 +168,16 @@ public class StandardMessenger implements Messenger {
}
public boolean isReservedChannel(String channel) {
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
return channel.equals("REGISTER") || channel.equals("UNREGISTER");
return channel.contains("minecraft");
}
public void registerOutgoingPluginChannel(Plugin plugin, String channel) {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
if (isReservedChannel(channel)) {
throw new ReservedChannelException(channel);
}
@@ -188,7 +189,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
removeFromOutgoing(plugin, channel);
}
@@ -205,7 +206,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
if (isReservedChannel(channel)) {
throw new ReservedChannelException(channel);
}
@@ -227,7 +228,7 @@ public class StandardMessenger implements Messenger {
if (listener == null) {
throw new IllegalArgumentException("Listener cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
removeFromIncoming(new PluginMessageListenerRegistration(this, plugin, channel, listener));
}
@@ -236,7 +237,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
removeFromIncoming(plugin, channel);
}
@@ -318,7 +319,7 @@ public class StandardMessenger implements Messenger {
}
public Set<PluginMessageListenerRegistration> getIncomingChannelRegistrations(String channel) {
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
synchronized (incomingLock) {
Set<PluginMessageListenerRegistration> registrations = incomingByChannel.get(channel);
@@ -335,7 +336,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
synchronized (incomingLock) {
Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);
@@ -376,7 +377,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
synchronized (incomingLock) {
Set<PluginMessageListenerRegistration> registrations = incomingByPlugin.get(plugin);
@@ -397,7 +398,7 @@ public class StandardMessenger implements Messenger {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
synchronized (outgoingLock) {
Set<String> channels = outgoingByPlugin.get(plugin);
@@ -417,7 +418,7 @@ public class StandardMessenger implements Messenger {
if (message == null) {
throw new IllegalArgumentException("Message cannot be null");
}
validateChannel(channel);
channel = validateAndCorrectChannel(channel);
Set<PluginMessageListenerRegistration> registrations = getIncomingChannelRegistrations(channel);
@@ -437,14 +438,46 @@ public class StandardMessenger implements Messenger {
* Validates a Plugin Channel name.
*
* @param channel Channel name to validate.
* @deprecated not an API method
*/
@Deprecated
public static void validateChannel(String channel) {
validateAndCorrectChannel(channel);
}
/**
* Validates and corrects a Plugin Channel name. Method is not reentrant / idempotent.
*
* @param channel Channel name to validate.
* @return corrected channel name
* @deprecated not an API method
*/
@Deprecated
public static String validateAndCorrectChannel(String channel) {
if (channel == null) {
throw new IllegalArgumentException("Channel cannot be null");
}
// This will correct registrations / outgoing messages
// It is not legal to send "BungeeCord" incoming anymore so we are fine there,
// but we must make sure that none of the API methods repeatedly call validate
if (channel.equals("BungeeCord")) {
return "bungeecord:main";
}
// And this will correct incoming messages.
if (channel.equals("bungeecord:main")) {
return "BungeeCord";
}
if (channel.length() > Messenger.MAX_CHANNEL_SIZE) {
throw new ChannelNameTooLongException(channel);
}
if (channel.indexOf(':') == -1) {
throw new IllegalArgumentException("Channel must contain : separator");
}
if (!channel.toLowerCase(Locale.ROOT).equals(channel)) {
// TODO: use NamespacedKey validation here
throw new IllegalArgumentException("Channel must be entirely lowercase");
}
return channel;
}
/**