SPIGOT-2152: Method to set resource pack + hash.

By: Max Lee <mail@moep.tv>
This commit is contained in:
CraftBukkit/Spigot 2017-02-14 14:00:30 +01:00
parent 4b11aba0f7
commit 0a74e4d700

View file

@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.io.BaseEncoding;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
@ -14,6 +15,7 @@ import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -1094,6 +1096,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
getHandle().setResourcePack(url, "null"); getHandle().setResourcePack(url, "null");
} }
@Override
public void setResourcePack(String url, byte[] hash) {
Validate.notNull(url, "Resource pack URL cannot be null");
Validate.notNull(hash, "Resource pack hash cannot be null");
Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length);
getHandle().setResourcePack(url, BaseEncoding.base16().lowerCase().encode(hash));
}
public void addChannel(String channel) { public void addChannel(String channel) {
if (channels.add(channel)) { if (channels.add(channel)) {
server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel)); server.getPluginManager().callEvent(new PlayerRegisterChannelEvent(this, channel));