Change where Lib's premim does its check. Fix backwards compatibility a little
This commit is contained in:
parent
f239dcc1fe
commit
bd93f1dbd7
@ -17,6 +17,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion());
|
getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion());
|
||||||
@ -35,6 +37,8 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
saveResource("disguises.yml", false);
|
saveResource("disguises.yml", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LibsPremium.check(instance);
|
||||||
|
|
||||||
PacketsManager.init(this);
|
PacketsManager.init(this);
|
||||||
DisguiseUtilities.init(this);
|
DisguiseUtilities.init(this);
|
||||||
|
|
||||||
@ -200,6 +204,27 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
return updates ? "Enabled" : "Disabled";
|
return updates ? "Enabled" : "Disabled";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("targeted_disguises") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
Collection<HashSet<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
||||||
|
|
||||||
|
if (list.isEmpty())
|
||||||
|
return "Unknown";
|
||||||
|
|
||||||
|
for (HashSet<TargetedDisguise> dList : list) {
|
||||||
|
for (TargetedDisguise disg : dList) {
|
||||||
|
if (disg.getObservers().isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return "Yes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "No";
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -423,13 +448,18 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
indexes.remove(flagType);
|
indexes.remove(flagType);
|
||||||
|
|
||||||
if (ReflectionManager.convertInvalidItem(flagType.getDefault()).getClass() != ReflectionManager
|
Object obj1 = ReflectionManager.convertInvalidItem(flagType.getDefault());
|
||||||
.convertInvalidItem(watch.getValue()).getClass()) {
|
Object obj2 = ReflectionManager.convertInvalidItem(watch.getValue());
|
||||||
System.err.println("Mismatch of FlagType's for " + disguiseType.name() + "! Index " + watch
|
|
||||||
|
if (obj1 != obj2 && ((obj1 == null || obj2 == null) || obj1.getClass() != obj2.getClass())) {
|
||||||
|
System.err.println("Mismatch of " + "FlagType's for " + disguiseType.name() + "! Index " + watch
|
||||||
.getIndex() + " has the wrong classtype!");
|
.getIndex() + " has the wrong classtype!");
|
||||||
System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue()
|
System.err.println(
|
||||||
.getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass
|
"MetaIndex has the " + "default of " + flagType.getDefault() + " (" + flagType
|
||||||
.getSimpleName() + " which doesn't match up with " + flagType.getDefault().getClass());
|
.getDefault().getClass() + ") (" + nmsEntity.getClass() + ") & " + watcherClass
|
||||||
|
.getSimpleName());
|
||||||
|
System.err.println("Where the internals is " + watch.getRawValue() + " (" + watch.getRawValue()
|
||||||
|
.getClass());
|
||||||
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,12 +410,19 @@ public class MetaIndex<Y> {
|
|||||||
ArrayList<MetaIndex> list = new ArrayList<>();
|
ArrayList<MetaIndex> list = new ArrayList<>();
|
||||||
|
|
||||||
for (MetaIndex type : values()) {
|
for (MetaIndex type : values()) {
|
||||||
if (!type.getFlagWatcher().isAssignableFrom(watcherClass))
|
if (type == null || !type.getFlagWatcher().isAssignableFrom(watcherClass))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
list.add(type);
|
list.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.sort(list, new Comparator<MetaIndex>() {
|
||||||
|
@Override
|
||||||
|
public int compare(MetaIndex o1, MetaIndex o2) {
|
||||||
|
return Integer.compare(o1.getIndex(), o2.getIndex());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,8 +453,15 @@ public class MetaIndex<Y> {
|
|||||||
for (int i = values().length - metaIndexes.length, a = 0; i < values().length; i++, a++) {
|
for (int i = values().length - metaIndexes.length, a = 0; i < values().length; i++, a++) {
|
||||||
MetaIndex index = metaIndexes[a];
|
MetaIndex index = metaIndexes[a];
|
||||||
|
|
||||||
|
ArrayList<MetaIndex> list = getFlags(index.getFlagWatcher());
|
||||||
|
|
||||||
|
for (int b = index.getIndex(); b < list.size(); b++) {
|
||||||
|
list.get(b)._index++;
|
||||||
|
}
|
||||||
|
|
||||||
for (MetaIndex metaIndex : values()) {
|
for (MetaIndex metaIndex : values()) {
|
||||||
if (metaIndex.getFlagWatcher() != index.getFlagWatcher() || metaIndex.getIndex() != index.getIndex()) {
|
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() || metaIndex
|
||||||
|
.getIndex() != index.getIndex()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -507,7 +521,7 @@ public class MetaIndex<Y> {
|
|||||||
private int _index;
|
private int _index;
|
||||||
private Class<? extends FlagWatcher> _watcher;
|
private Class<? extends FlagWatcher> _watcher;
|
||||||
|
|
||||||
private MetaIndex(Class<? extends FlagWatcher> watcher, int index, Y defaultValue) {
|
public MetaIndex(Class<? extends FlagWatcher> watcher, int index, Y defaultValue) {
|
||||||
_index = index;
|
_index = index;
|
||||||
_watcher = watcher;
|
_watcher = watcher;
|
||||||
_defaultValue = defaultValue;
|
_defaultValue = defaultValue;
|
||||||
|
@ -9,6 +9,8 @@ import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_9;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 8/06/2017.
|
* Created by libraryaddict on 8/06/2017.
|
||||||
@ -48,16 +50,22 @@ public class BackwardsSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void getIndexes(Class backwardsClass, BackwardMethods backwards,
|
private static void getIndexes(Class backwardsClass, BackwardMethods backwards,
|
||||||
ArrayList<MetaIndex> newIndexes) throws IllegalAccessException {
|
HashMap<String, MetaIndex> newIndexes) throws IllegalAccessException {
|
||||||
for (Field field : backwardsClass.getFields()) {
|
for (Field field : backwardsClass.getDeclaredFields()) {
|
||||||
if (field.getType() != MetaIndex.class)
|
if (field.getType() != MetaIndex.class)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
field.setAccessible(true);
|
||||||
|
|
||||||
|
if (newIndexes.containsKey(field.getName()))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (MetaIndex.setMetaIndex(field.getName(), (MetaIndex) field.get(backwards))) {
|
if (MetaIndex.setMetaIndex(field.getName(), (MetaIndex) field.get(backwards))) {
|
||||||
|
newIndexes.put(field.getName(), MetaIndex.ENTITY_META);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
newIndexes.add((MetaIndex) field.get(backwards));
|
newIndexes.put(field.getName(), (MetaIndex) field.get(backwards));
|
||||||
}
|
}
|
||||||
|
|
||||||
backwardsClass = backwardsClass.getSuperclass();
|
backwardsClass = backwardsClass.getSuperclass();
|
||||||
@ -70,13 +78,17 @@ public class BackwardsSupport {
|
|||||||
try {
|
try {
|
||||||
BackwardMethods backwards = backwardsClass.newInstance();
|
BackwardMethods backwards = backwardsClass.newInstance();
|
||||||
|
|
||||||
ArrayList<MetaIndex> newIndexes = new ArrayList<>();
|
HashMap<String, MetaIndex> newIndexes = new HashMap<>();
|
||||||
|
|
||||||
getIndexes(backwardsClass, backwards, newIndexes);
|
getIndexes(backwardsClass, backwards, newIndexes);
|
||||||
|
|
||||||
MetaIndex.setValues();
|
MetaIndex.setValues();
|
||||||
|
|
||||||
MetaIndex.addMetaIndexes(newIndexes.toArray(new MetaIndex[0]));
|
HashSet<MetaIndex> indexes = new HashSet<>(newIndexes.values());
|
||||||
|
indexes.remove(MetaIndex.ENTITY_META); // We do the hashmap stuff to prevent multiple versions
|
||||||
|
// registering the same meta index
|
||||||
|
|
||||||
|
MetaIndex.addMetaIndexes(indexes.toArray(new MetaIndex[0]));
|
||||||
|
|
||||||
if (backwards.isOrderedIndexes()) {
|
if (backwards.isOrderedIndexes()) {
|
||||||
MetaIndex.eliminateBlankIndexes();
|
MetaIndex.eliminateBlankIndexes();
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 9/06/2017.
|
* Created by libraryaddict on 9/06/2017.
|
||||||
@ -10,4 +15,8 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|||||||
public class Version_1_10 extends Version_1_11 {
|
public class Version_1_10 extends Version_1_11 {
|
||||||
private MetaIndex ILLAGER_META;
|
private MetaIndex ILLAGER_META;
|
||||||
private MetaIndex ILLAGER_SPELL_TICKS;
|
private MetaIndex ILLAGER_SPELL_TICKS;
|
||||||
|
private MetaIndex<Integer> HORSE_VARIANT = new MetaIndex<>(HorseWatcher.class, 1, 0);
|
||||||
|
private MetaIndex<Byte> SHULKER_COLOR;
|
||||||
|
private MetaIndex<Optional<ItemStack>> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0,
|
||||||
|
Optional.of(new ItemStack(Material.STONE)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user