Read desc

Renamed the package utils to utilities
Moved Values and DisguiseSounds into it.
Renamed Values to DisguiseValues
Renamed another method in DisguiseValues
This commit is contained in:
libraryaddict 2013-11-23 09:10:20 +13:00
parent a502792df2
commit 0a98e90afc
20 changed files with 53 additions and 54 deletions

View File

@ -4,9 +4,9 @@ import java.lang.reflect.Field;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.events.DisguiseEvent; import me.libraryaddict.disguise.events.DisguiseEvent;
import me.libraryaddict.disguise.events.UndisguiseEvent; import me.libraryaddict.disguise.events.UndisguiseEvent;
import me.libraryaddict.disguise.utils.PacketsManager; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utils.DisguiseUtilities; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;

View File

@ -3,8 +3,8 @@ package me.libraryaddict.disguise;
import java.util.HashMap; import java.util.HashMap;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utils.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utils.UpdateChecker; import me.libraryaddict.disguise.utilities.UpdateChecker;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -7,19 +7,19 @@ import java.util.List;
import me.libraryaddict.disguise.commands.*; import me.libraryaddict.disguise.commands.*;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseSound;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.Values;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
import me.libraryaddict.disguise.utils.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseSound;
import me.libraryaddict.disguise.utils.PacketsManager; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utilities.ReflectionManager;
import me.libraryaddict.disguise.utilities.DisguiseValues;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -192,7 +192,7 @@ public class LibsDisguises extends JavaPlugin {
break; break;
} }
} }
Values disguiseValues = new Values(disguiseType, nmsEntity.getClass(), entitySize); DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), entitySize);
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity); WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity);
List<WrappedWatchableObject> watchers = dataWatcher.getWatchableObjects(); List<WrappedWatchableObject> watchers = dataWatcher.getWatchableObjects();
for (WrappedWatchableObject watch : watchers) for (WrappedWatchableObject watch : watchers)

View File

@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList; import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utils.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList; import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseListener; import me.libraryaddict.disguise.DisguiseListener;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utils.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.utils.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList; import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utils.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList; import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.utils.BaseDisguiseCommand; import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -11,9 +11,10 @@ import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher; import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
import me.libraryaddict.disguise.utils.PacketsManager; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utils.DisguiseUtilities; import me.libraryaddict.disguise.utilities.ReflectionManager;
import me.libraryaddict.disguise.utilities.DisguiseValues;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Horse.Variant; import org.bukkit.entity.Horse.Variant;
@ -429,9 +430,8 @@ public abstract class Disguise {
* datawatcher. * datawatcher.
*/ */
private void setupWatcher() { private void setupWatcher() {
Class disguiseClass = Values.getEntityClass(getType()); HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
HashMap<Integer, Object> disguiseValues = Values.getMetaValues(getType()); HashMap<Integer, Object> entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(entity.getType()));
HashMap<Integer, Object> entityValues = Values.getMetaValues(DisguiseType.getType(entity.getType()));
// Start from 2 as they ALL share 0 and 1 // Start from 2 as they ALL share 0 and 1
for (int dataNo = 2; dataNo <= 31; dataNo++) { for (int dataNo = 2; dataNo <= 31; dataNo++) {
// STEP 1. Find out if the watcher has set data on it. // STEP 1. Find out if the watcher has set data on it.
@ -509,16 +509,17 @@ public abstract class Disguise {
default: default:
break; break;
} }
Class entityClass = ReflectionManager.getNmsEntity(getEntity()).getClass(); Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass();
Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType());
// If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..? // If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..?
if (baseClass != null && baseClass.isAssignableFrom(disguiseClass) && baseClass.isAssignableFrom(entityClass)) if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass) && baseClass.isAssignableFrom(nmsEntityClass))
continue; continue;
// So they don't extend a basic class. // So they don't extend a basic class.
// Maybe if I check that they extend each other.. // Maybe if I check that they extend each other..
// Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared // Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared
// datawatchers. // datawatchers.
if (entityClass.isAssignableFrom(disguiseClass) || disguiseClass.isAssignableFrom(entityClass)) if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass))
continue; continue;
// Well I can't find a reason I should leave it alone. They will probably conflict. // Well I can't find a reason I should leave it alone. They will probably conflict.
// Time to set the value to the disguises value so no conflicts! // Time to set the value to the disguises value so no conflicts!

View File

@ -19,8 +19,8 @@ import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedWatchableObject; import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.utils.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
public class FlagWatcher { public class FlagWatcher {
public enum SlotType { public enum SlotType {

View File

@ -2,7 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -2,7 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -4,7 +4,7 @@ import java.lang.reflect.Method;
import java.util.HashSet; import java.util.HashSet;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utils.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;

View File

@ -1,4 +1,4 @@
package me.libraryaddict.disguise.utils; package me.libraryaddict.disguise.utilities;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -1,9 +1,8 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.utilities;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import me.libraryaddict.disguise.utils.ReflectionManager;
import org.bukkit.Sound; import org.bukkit.Sound;

View File

@ -1,4 +1,4 @@
package me.libraryaddict.disguise.utils; package me.libraryaddict.disguise.utilities;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;

View File

@ -1,20 +1,22 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.utilities;
import java.util.HashMap; import java.util.HashMap;
public class Values { import me.libraryaddict.disguise.disguisetypes.DisguiseType;
private static HashMap<DisguiseType, Values> values = new HashMap<DisguiseType, Values>(); public class DisguiseValues {
public static Class getEntityClass(DisguiseType type) { private static HashMap<DisguiseType, DisguiseValues> values = new HashMap<DisguiseType, DisguiseValues>();
return getValues(type).getEntityClass();
public static Class getNmsEntityClass(DisguiseType type) {
return getDisguiseValues(type).getNmsEntityClass();
} }
public static HashMap<Integer, Object> getMetaValues(DisguiseType type) { public static HashMap<Integer, Object> getMetaValues(DisguiseType type) {
return getValues(type).getMetaValues(); return getDisguiseValues(type).getMetaValues();
} }
public static Values getValues(DisguiseType type) { public static DisguiseValues getDisguiseValues(DisguiseType type) {
switch (type) { switch (type) {
case DONKEY: case DONKEY:
case MULE: case MULE:
@ -41,19 +43,18 @@ public class Values {
return values.get(type); return values.get(type);
} }
private Class declared; private Class nmsEntityClass;
private int enumEntitySize; private int enumEntitySize;
private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>(); private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>();
public Values(DisguiseType type, Class classType, int entitySize) { public DisguiseValues(DisguiseType type, Class classType, int entitySize) {
values.put(type, this); values.put(type, this);
enumEntitySize = entitySize; enumEntitySize = entitySize;
declared = classType; nmsEntityClass = classType;
} }
public Class getEntityClass() { public Class getNmsEntityClass() {
return declared; return nmsEntityClass;
} }
public int getEntitySize(double paramDouble) { public int getEntitySize(double paramDouble) {

View File

@ -1,4 +1,4 @@
package me.libraryaddict.disguise.utils; package me.libraryaddict.disguise.utilities;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
@ -9,14 +9,12 @@ import java.util.Random;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseSound;
import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.MiscDisguise; import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
import me.libraryaddict.disguise.disguisetypes.MobDisguise; import me.libraryaddict.disguise.disguisetypes.MobDisguise;
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise; import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
import me.libraryaddict.disguise.disguisetypes.Values; import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
import me.libraryaddict.disguise.disguisetypes.DisguiseSound.SoundType;
import org.bukkit.Art; import org.bukkit.Art;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -217,7 +215,7 @@ public class PacketsManager {
} else if (disguise.getType().isMob()) { } else if (disguise.getType().isMob()) {
Values values = Values.getValues(disguise.getType()); DisguiseValues values = DisguiseValues.getDisguiseValues(disguise.getType());
Vector vec = disguisedEntity.getVelocity(); Vector vec = disguisedEntity.getVelocity();
spawnPackets[0] = new PacketContainer(Packets.Server.MOB_SPAWN); spawnPackets[0] = new PacketContainer(Packets.Server.MOB_SPAWN);
StructureModifier<Object> mods = spawnPackets[0].getModifier(); StructureModifier<Object> mods = spawnPackets[0].getModifier();

View File

@ -1,4 +1,4 @@
package me.libraryaddict.disguise.utils; package me.libraryaddict.disguise.utilities;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;

View File

@ -1,4 +1,4 @@
package me.libraryaddict.disguise.utils; package me.libraryaddict.disguise.utilities;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;