mirror of
https://github.com/songoda/EpicHeads.git
synced 2024-11-29 14:06:29 +01:00
Updated to 2.1.3 (not too much manual changes).
This commit is contained in:
parent
299aa989cc
commit
00f0e36c53
@ -5,22 +5,24 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import nl.marido.deluxeheads.api.DeluxeHeadsAPI.Head;
|
||||
|
||||
public class LiveHead {
|
||||
|
||||
private int frames;
|
||||
private List<DeluxeHeads> texures;
|
||||
private List<Head> texures;
|
||||
private Location location;
|
||||
|
||||
// Do not pay attention to this class, this is just a sort of sketch which is not ready.
|
||||
|
||||
public LiveHead(int frames, List<DeluxeHeads> texures, Location location /*.more.*/) {
|
||||
public LiveHead(int frames, List<Head> texures, Location location /*.more.*/) {
|
||||
// Safety first, experimental features should not crash servers.
|
||||
if (frames > 60)
|
||||
frames = 60;
|
||||
this.frames = frames;
|
||||
if (texures.size() > frames)
|
||||
while (texures.size() != frames) {
|
||||
texures.remove(0);
|
||||
texures.remove(texures.size()); // logic - the last ones will be removed
|
||||
}
|
||||
this.texures = texures;
|
||||
this.location = location;
|
||||
|
@ -20,7 +20,6 @@ public class LangConfig {
|
||||
|
||||
public LangConfig() {
|
||||
this.configFile = new FileConfigFile("lang.yml");
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
|
@ -3,66 +3,73 @@ package nl.marido.deluxeheads.config.lang;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import nl.marido.deluxeheads.util.ArrayUtils;
|
||||
|
||||
public final class LangMessage {
|
||||
|
||||
private final String[] messages;
|
||||
private final Placeholder[] placeholders;
|
||||
|
||||
public LangMessage(String... messages) {
|
||||
this(messages, new Placeholder[0]);
|
||||
}
|
||||
private final String[] messages;
|
||||
private final Placeholder[] placeholders;
|
||||
|
||||
private LangMessage(String[] messages, Placeholder[] placeholders) {
|
||||
this.messages = messages;
|
||||
this.placeholders = placeholders;
|
||||
}
|
||||
public LangMessage(String... messages) {
|
||||
this(messages, new Placeholder[0]);
|
||||
}
|
||||
|
||||
public LangMessage with(Placeholder... placeholders) {
|
||||
return new LangMessage(messages, ArrayUtils.append(this.placeholders, placeholders));
|
||||
}
|
||||
private LangMessage(String[] messages, Placeholder[] placeholders) {
|
||||
this.messages = messages;
|
||||
this.placeholders = placeholders;
|
||||
}
|
||||
|
||||
public LangMessage with(String key, Object value) {
|
||||
return with(new Placeholder(key, value));
|
||||
}
|
||||
public LangMessage with(Placeholder... placeholders) {
|
||||
return new LangMessage(messages, ArrayUtils.append(this.placeholders, placeholders));
|
||||
}
|
||||
|
||||
public int getLineCount() {
|
||||
return messages.length;
|
||||
}
|
||||
public LangMessage with(String key, Object value) {
|
||||
return with(new Placeholder(key, value));
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getLineCount() == 0;
|
||||
}
|
||||
public int getLineCount() {
|
||||
return messages.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getSingle();
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return getLineCount() == 0;
|
||||
}
|
||||
|
||||
public String getSingle() {
|
||||
return (isEmpty() ? "" : get()[0]);
|
||||
}
|
||||
|
||||
public String[] get() {
|
||||
return Placeholder.applyAll(Placeholder.colourAll(messages), placeholders);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return getSingle();
|
||||
}
|
||||
|
||||
public void send(CommandSender sender) {
|
||||
for (String message : get()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
public String getSingle() {
|
||||
return (isEmpty() ? "" : get()[0]);
|
||||
}
|
||||
|
||||
public Object getConfigSaveValue() {
|
||||
if(isEmpty())
|
||||
return "";
|
||||
public String[] get() {
|
||||
return Placeholder.applyAll(Placeholder.colourAll(messages), placeholders);
|
||||
}
|
||||
|
||||
if(getLineCount() == 1)
|
||||
return messages[0];
|
||||
public void send(CommandSender sender) {
|
||||
for (String message : get()) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void send(Player player) {
|
||||
for (String message : get()) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public Object getConfigSaveValue() {
|
||||
if (isEmpty())
|
||||
return "";
|
||||
|
||||
if (getLineCount() == 1)
|
||||
return messages[0];
|
||||
|
||||
return Arrays.asList(messages);
|
||||
}
|
||||
|
||||
return Arrays.asList(messages);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,9 +5,7 @@ import java.util.function.Function;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import nl.marido.deluxeheads.DeluxeHeads;
|
||||
import nl.marido.deluxeheads.cache.CacheFile;
|
||||
import nl.marido.deluxeheads.cache.CacheHead;
|
||||
import nl.marido.deluxeheads.menu.ui.Bounds;
|
||||
@ -175,19 +173,4 @@ public class CacheHeadsMenu extends Element {
|
||||
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void openHeadsMenu(Player player) {
|
||||
InventoryMenu inventory = new InventoryMenu(player, "Heads", 6);
|
||||
|
||||
CacheHeadsMenu menu = new CacheHeadsMenu(DeluxeHeads.getCache(), inventory, inventory.bounds, head -> {
|
||||
player.sendMessage(head.getName());
|
||||
return MenuResponse.NONE;
|
||||
});
|
||||
|
||||
menu.setTemplate(DeluxeHeads.getMenus().getBrowseTemplate());
|
||||
|
||||
inventory.addElement(menu);
|
||||
inventory.open();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -206,7 +206,6 @@ public final class Item {
|
||||
return new Item(type, 1, data, null, null, false);
|
||||
}
|
||||
return new Item(type, 1, (short) 0, null, null, false);
|
||||
// TODO: Needs manual testing on 1.13.
|
||||
}
|
||||
|
||||
public static Item create(ItemStack itemStack) {
|
||||
@ -261,7 +260,7 @@ public final class Item {
|
||||
int typeId = section.getInt("type");
|
||||
String convertedType = DeluxeHeads.getLegacyIDs().fromId(typeId);
|
||||
|
||||
if (convertedType == null) {
|
||||
if (convertedType == null || convertedType.isEmpty()) {
|
||||
DeluxeHeads.warning("Invalid type of item " + section.getCurrentPath() + ", " + "unknown type id " + typeId);
|
||||
return;
|
||||
}
|
||||
|
@ -1,84 +1,83 @@
|
||||
package nl.marido.deluxeheads.volatilecode.reflection;
|
||||
|
||||
|
||||
public class Version {
|
||||
|
||||
private static final char[] allowed = "0123456789_".toCharArray();
|
||||
public static final Version v1_8 = Version.getVersion("v1_8");
|
||||
public static final Version v1_10 = Version.getVersion("v1_10");
|
||||
public static final Version v1_13 = Version.getVersion("v1_13");
|
||||
|
||||
private int major;
|
||||
private int minor;
|
||||
private int revision;
|
||||
|
||||
public Version(int major, int minor, int revision) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
public int getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
public boolean higherThan(Version other) {
|
||||
return other.getMajor() < getMajor() || other.getMinor() < getMinor() || other.getRevision() < getRevision();
|
||||
}
|
||||
|
||||
public static Version getVersion() {
|
||||
return getVersion(ReflectionUtils.getServerVersion());
|
||||
}
|
||||
|
||||
public static Version getVersion(String version) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (char c : version.toCharArray()) {
|
||||
if (isAllowed(c)) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
String[] split = builder.toString().split("_");
|
||||
|
||||
if (split.length != 2 && split.length != 3) {
|
||||
throw new IllegalArgumentException("version is not of the valid type v?_?_R?");
|
||||
}
|
||||
|
||||
int major = Integer.valueOf(split[0]);
|
||||
int minor = Integer.valueOf(split[1]);
|
||||
int revision = 0;
|
||||
|
||||
if (split.length == 3) {
|
||||
revision = Integer.valueOf(split[2]);
|
||||
}
|
||||
|
||||
return new Version(major, minor, revision);
|
||||
}
|
||||
|
||||
public static boolean isAbove(Version version) {
|
||||
return getVersion().higherThan(version);
|
||||
}
|
||||
private static final char[] allowed = "0123456789_".toCharArray();
|
||||
public static final Version v1_8 = Version.getVersion("v1_8");
|
||||
public static final Version v1_10 = Version.getVersion("v1_10");
|
||||
public static final Version v1_13 = Version.getVersion("v1_13");
|
||||
|
||||
public static boolean isBelow(Version version) {
|
||||
return version.higherThan(getVersion());
|
||||
}
|
||||
private int major;
|
||||
private int minor;
|
||||
private int revision;
|
||||
|
||||
public Version(int major, int minor, int revision) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.revision = revision;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
public int getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
public boolean higherThan(Version other) {
|
||||
return other.getMajor() < getMajor() || other.getMinor() < getMinor() || other.getRevision() < getRevision();
|
||||
}
|
||||
|
||||
public static Version getVersion() {
|
||||
return getVersion(ReflectionUtils.getServerVersion());
|
||||
}
|
||||
|
||||
public static Version getVersion(String version) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (char c : version.toCharArray()) {
|
||||
if (isAllowed(c)) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
String[] split = builder.toString().split("_");
|
||||
|
||||
if (split.length != 2 && split.length != 3) {
|
||||
throw new IllegalArgumentException("version is not of the valid type v?_?_R?");
|
||||
}
|
||||
|
||||
int major = Integer.valueOf(split[0]);
|
||||
int minor = Integer.valueOf(split[1]);
|
||||
int revision = 0;
|
||||
|
||||
if (split.length == 3) {
|
||||
revision = Integer.valueOf(split[2]);
|
||||
}
|
||||
|
||||
return new Version(major, minor, revision);
|
||||
}
|
||||
|
||||
public static boolean isAbove(Version version) {
|
||||
return getVersion().higherThan(version);
|
||||
}
|
||||
|
||||
public static boolean isBelow(Version version) {
|
||||
return version.higherThan(getVersion());
|
||||
}
|
||||
|
||||
private static boolean isAllowed(char c) {
|
||||
for (char ch : allowed) {
|
||||
if (ch == c) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isAllowed(char c) {
|
||||
for (char ch : allowed) {
|
||||
if (ch == c) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ main: nl.marido.deluxeheads.DeluxeHeads
|
||||
author: Marido
|
||||
name: DeluxeHeads
|
||||
description: Enhance your server with over 17,000 awesome unique heads with amazing features.
|
||||
version: 2.1.2
|
||||
version: 2.1.3
|
||||
api-version: 1.13
|
||||
softdepend: [Vault, PlayerPoints, BlockStore]
|
||||
loadbefore: [DeluxeMenus]
|
||||
|
Loading…
Reference in New Issue
Block a user