mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 17:21:37 +01:00
SPIGOT-6789: Improve resource pack related API
By: Patrick Choe <mailpatrickkr@gmail.com>
This commit is contained in:
parent
3736fd83de
commit
edea21b253
@ -36,6 +36,7 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -670,6 +671,26 @@ public final class CraftServer implements Server {
|
|||||||
return this.configuration.getBoolean("settings.query-plugins");
|
return this.configuration.getBoolean("settings.query-plugins");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourcePack() {
|
||||||
|
return this.getServer().getResourcePack();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourcePackHash() {
|
||||||
|
return this.getServer().getResourcePackHash().toUpperCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResourcePackPrompt() {
|
||||||
|
return CraftChatMessage.fromComponent(this.getServer().getResourcePackPrompt());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isResourcePackRequired() {
|
||||||
|
return this.getServer().isResourcePackRequired();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasWhitelist() {
|
public boolean hasWhitelist() {
|
||||||
return this.getProperties().whiteList.get();
|
return this.getProperties().whiteList.get();
|
||||||
|
@ -1306,18 +1306,35 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResourcePack(String url) {
|
public void setResourcePack(String url) {
|
||||||
Validate.notNull(url, "Resource pack URL cannot be null");
|
setResourcePack(url, null);
|
||||||
|
|
||||||
getHandle().sendTexturePack(url, "null", false, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setResourcePack(String url, byte[] hash) {
|
public void setResourcePack(String url, byte[] hash) {
|
||||||
|
setResourcePack(url, hash, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourcePack(String url, byte[] hash, String prompt) {
|
||||||
|
setResourcePack(url, hash, prompt, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourcePack(String url, byte[] hash, boolean force) {
|
||||||
|
setResourcePack(url, hash, null, force);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setResourcePack(String url, byte[] hash, String prompt, boolean force) {
|
||||||
Validate.notNull(url, "Resource pack URL cannot be null");
|
Validate.notNull(url, "Resource pack URL cannot be null");
|
||||||
Validate.notNull(hash, "Resource pack hash cannot be null");
|
|
||||||
|
if (hash != null) {
|
||||||
Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length);
|
Validate.isTrue(hash.length == 20, "Resource pack hash should be 20 bytes long but was " + hash.length);
|
||||||
|
|
||||||
getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), false, null);
|
getHandle().sendTexturePack(url, BaseEncoding.base16().lowerCase().encode(hash), force, CraftChatMessage.fromStringOrNull(prompt, true));
|
||||||
|
} else {
|
||||||
|
getHandle().sendTexturePack(url, "", force, CraftChatMessage.fromStringOrNull(prompt, true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChannel(String channel) {
|
public void addChannel(String channel) {
|
||||||
|
Loading…
Reference in New Issue
Block a user