Updated to 2.0.2 (some manual changes).

This commit is contained in:
CoderMarido 2018-08-22 17:12:55 +02:00
parent 002a5e9b68
commit 1caf138d56
11 changed files with 724 additions and 697 deletions

View File

@ -1,15 +1,14 @@
package net.sothatsit.heads;
import com.mojang.authlib.GameProfile;
import net.sothatsit.blockstore.BlockStoreApi;
import net.sothatsit.heads.cache.CacheHead;
import net.sothatsit.heads.volatilecode.ItemNBT;
import net.sothatsit.heads.volatilecode.Items;
import net.sothatsit.heads.volatilecode.TextureGetter;
import net.sothatsit.heads.volatilecode.reflection.nms.BlockPosition;
import net.sothatsit.heads.volatilecode.reflection.nms.TileEntitySkull;
import net.sothatsit.heads.volatilecode.reflection.nms.World;
import org.bukkit.*;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Skull;
@ -25,9 +24,16 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.RegisteredListener;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import com.mojang.authlib.GameProfile;
import net.sothatsit.blockstore.BlockStoreApi;
import net.sothatsit.heads.cache.CacheHead;
import net.sothatsit.heads.volatilecode.ItemNBT;
import net.sothatsit.heads.volatilecode.Items;
import net.sothatsit.heads.volatilecode.TextureGetter;
import net.sothatsit.heads.volatilecode.reflection.nms.BlockPosition;
import net.sothatsit.heads.volatilecode.reflection.nms.TileEntitySkull;
import net.sothatsit.heads.volatilecode.reflection.nms.World;
public class HeadNamer implements Listener {

View File

@ -1,13 +1,21 @@
package net.sothatsit.heads;
import net.sothatsit.heads.util.Checks;
import org.bukkit.Material;
import java.io.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Material;
import net.sothatsit.heads.util.Checks;
public class LegacyIDs {
public static final LegacyIDs EMPTY = new LegacyIDs(Collections.emptyMap());
@ -25,9 +33,7 @@ public class LegacyIDs {
}
public void write(File file) throws IOException {
try (FileOutputStream fos = new FileOutputStream(file);
OutputStreamWriter osr = new OutputStreamWriter(fos);
BufferedWriter writer = new BufferedWriter(osr)) {
try (FileOutputStream fos = new FileOutputStream(file); OutputStreamWriter osr = new OutputStreamWriter(fos); BufferedWriter writer = new BufferedWriter(osr)) {
write(writer);
}
@ -50,9 +56,7 @@ public class LegacyIDs {
}
public static LegacyIDs readResource(String resource) throws IOException {
try (InputStream is = Heads.getInstance().getResource(resource);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr)) {
try (InputStream is = Heads.getInstance().getResource(resource); InputStreamReader isr = new InputStreamReader(is); BufferedReader reader = new BufferedReader(isr)) {
return read(reader);
}

View File

@ -0,0 +1,7 @@
package net.sothatsit.heads;
public class LiveHead {
// TODO: Add animation heads with live (cached) texures in the next updates.
}

View File

@ -0,0 +1,7 @@
package net.sothatsit.heads.animation;
public class Animations {
// TODO: Add animation heads with live (cached) texures in the next updates.
}

View File

@ -0,0 +1,7 @@
package net.sothatsit.heads.animation;
public class LiveData {
// TODO: Add animation heads with live (cached) texures in the next updates.
}

View File

@ -0,0 +1,7 @@
package net.sothatsit.heads.animation;
public class Monitor {
// TODO: Add animation heads with live (cached) texures in the next updates.
}

View File

@ -1,5 +1,20 @@
package net.sothatsit.heads.menu.ui.item;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import net.sothatsit.heads.Heads;
import net.sothatsit.heads.config.lang.Placeholder;
import net.sothatsit.heads.menu.ui.MenuResponse;
@ -7,21 +22,6 @@ import net.sothatsit.heads.util.Checks;
import net.sothatsit.heads.util.Stringify;
import net.sothatsit.heads.volatilecode.ItemNBT;
import net.sothatsit.heads.volatilecode.reflection.Version;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;
public final class Item {
@ -158,11 +158,7 @@ public final class Item {
Item other = (Item) obj;
return other.type == type
&& other.amount == amount
&& Objects.equals(other.name, name)
&& (other.lore == null ? lore == null : Arrays.equals(other.lore, lore))
&& other.enchanted == enchanted;
return other.type == type && other.amount == amount && Objects.equals(other.name, name) && (other.lore == null ? lore == null : Arrays.equals(other.lore, lore)) && other.enchanted == enchanted;
}
@Override
@ -204,18 +200,15 @@ public final class Item {
return new Item(type);
}
/**
* @deprecated data is only supported pre-1.13
*/
@Deprecated
public static Item create(Material type, byte data) {
if (Version.isBelow(Version.v1_13)) {
return new Item(type, 1, data, null, null, false);
}
return new Item(type, 1, (short) 0, null, null, false);
}
public static Item create(ItemStack itemStack) {
Item item = create(itemStack.getType())
.amount(itemStack.getAmount())
.damage(itemStack.getDurability());
Item item = create(itemStack.getType()).amount(itemStack.getAmount()).damage(itemStack.getDurability());
ItemMeta meta = itemStack.getItemMeta();
@ -267,8 +260,7 @@ public final class Item {
String convertedType = Heads.getLegacyIDs().fromId(typeId);
if (convertedType == null) {
Heads.warning("Invalid type of item " + section.getCurrentPath() + ", " +
"unknown type id " + typeId);
Heads.warning("Invalid type of item " + section.getCurrentPath() + ", " + "unknown type id " + typeId);
return;
}
@ -301,8 +293,7 @@ public final class Item {
Material withoutData = fromLegacyType(legacyType, (byte) 0);
type = fromLegacyType(legacyType, byteData);
if (type == null) {
Heads.warning("Invalid legacy type of item " + section.getCurrentPath() + ": " +
"Could not convert " + legacyType + ":" + data + " to non-legacy format");
Heads.warning("Invalid legacy type of item " + section.getCurrentPath() + ": " + "Could not convert " + legacyType + ":" + data + " to non-legacy format");
return;
}
@ -315,8 +306,7 @@ public final class Item {
String from = typeName + (typeData != null ? ":" + typeData : "");
String to = type.name().toLowerCase() + (section.isSet("damage") ? ":" + section.get("damage") : "");
Heads.info("1.13 Update - " + from + " converted to " + to +
" for " + filename + " -> " + section.getCurrentPath());
Heads.info("1.13 Update - " + from + " converted to " + to + " for " + filename + " -> " + section.getCurrentPath());
shouldSave.set(true);
}
@ -326,8 +316,7 @@ public final class Item {
updateLegacyTypes(filename, section, shouldSave);
if (!section.isSet("type") || !section.isString("type")) {
Heads.warning("Invalid type of item " + section.getCurrentPath() + " in " + filename + ", " +
"expected a type name");
Heads.warning("Invalid type of item " + section.getCurrentPath() + " in " + filename + ", " + "expected a type name");
return null;
}
@ -335,24 +324,21 @@ public final class Item {
Material type = Material.matchMaterial(typeName);
if (type == null) {
Heads.warning("Invalid type of item " + section.getCurrentPath() + ", " +
"unknown material for type name " + typeName);
Heads.warning("Invalid type of item " + section.getCurrentPath() + ", " + "unknown material for type name " + typeName);
return null;
}
short damage = (short) section.getInt("damage", 0);
if (damage < 0) {
Heads.warning("Invalid damage of item " + section.getCurrentPath() + ", " +
"damage must be at least 0");
Heads.warning("Invalid damage of item " + section.getCurrentPath() + ", " + "damage must be at least 0");
return null;
}
int amount = section.getInt("amount", 1);
if (amount < 1) {
Heads.warning("Invalid amount of item " + section.getCurrentPath() + ", " +
"amount must be at least 1");
Heads.warning("Invalid amount of item " + section.getCurrentPath() + ", " + "amount must be at least 1");
return null;
}

View File

@ -3,6 +3,9 @@ package net.sothatsit.heads.util;
public abstract class ExceptionDetailer {
private static class DetailException extends Exception {
private static final long serialVersionUID = 7714839411923164464L;
public DetailException(String detail) {
super(detail);
}

View File

@ -1,9 +1,10 @@
package net.sothatsit.heads.volatilecode;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import net.sothatsit.heads.menu.ui.item.Item;
import net.sothatsit.heads.volatilecode.reflection.Version;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
* Methods to deal with items on different Spigot versions.

View File

@ -1,7 +1,6 @@
package net.sothatsit.heads.volatilecode.reflection;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

View File

@ -1,7 +1,7 @@
main: net.sothatsit.heads.Heads
author: Marido
name: Heads
version: 2.0.1
version: 2.0.2
api-version: 1.13
softdepend: [Vault, PlayerPoints, BlockStore]
loadbefore: [DeluxeMenus]