Rename from CustomDisguise to ModdedDisguise

This commit is contained in:
libraryaddict
2020-04-19 08:19:03 +12:00
parent 2ce9b38c74
commit f10870b727
12 changed files with 188 additions and 189 deletions

View File

@@ -55,7 +55,7 @@ public class SerializerDisguise implements JsonDeserializer<Disguise>, JsonSeria
@Override
public JsonElement serialize(Disguise src, Type typeOfSrc, JsonSerializationContext context) {
if (src.isCustomDisguise()) {
return context.serialize(src, CustomDisguise.class);
return context.serialize(src, ModdedDisguise.class);
} else if (src.isPlayerDisguise())
return context.serialize(src, PlayerDisguise.class);
else if (src.isMobDisguise())

View File

@@ -9,7 +9,7 @@ import lombok.Setter;
*/
@AllArgsConstructor
@Getter
public class CustomEntity {
public class ModdedEntity {
@Setter
private Object entityType;
private final String name;

View File

@@ -22,7 +22,7 @@ import java.util.Map;
*/
public class ModdedManager implements PluginMessageListener {
@Getter
private static final HashMap<NamespacedKey, CustomEntity> entities = new HashMap<>();
private static final HashMap<NamespacedKey, ModdedEntity> entities = new HashMap<>();
@Getter
private static byte[] fmlHandshake;
@@ -67,7 +67,7 @@ public class ModdedManager implements PluginMessageListener {
fmlHandshake = stream.toByteArray();
}
public static void registerCustomEntity(NamespacedKey name, CustomEntity entity, boolean register) {
public static void registerCustomEntity(NamespacedKey name, ModdedEntity entity, boolean register) {
if (entities.keySet().stream().anyMatch(n -> n.toString().equalsIgnoreCase(name.toString()))) {
throw new IllegalArgumentException(name + " has already been registered");
}
@@ -93,12 +93,12 @@ public class ModdedManager implements PluginMessageListener {
entities.put(name, entity);
}
public static CustomEntity getCustomEntity(NamespacedKey name) {
public static ModdedEntity getCustomEntity(NamespacedKey name) {
return entities.get(name);
}
public static CustomEntity getCustomEntity(String name) {
for (CustomEntity entity : entities.values()) {
public static ModdedEntity getCustomEntity(String name) {
for (ModdedEntity entity : entities.values()) {
if (!entity.getName().equalsIgnoreCase(name)) {
continue;
}
@@ -112,9 +112,9 @@ public class ModdedManager implements PluginMessageListener {
public static ArrayList<DisguisePerm> getDisguiseTypes() {
ArrayList<DisguisePerm> perms = new ArrayList<>();
for (Map.Entry<NamespacedKey, CustomEntity> entry : entities.entrySet()) {
for (Map.Entry<NamespacedKey, ModdedEntity> entry : entities.entrySet()) {
perms.add(new DisguisePerm(
entry.getValue().isLiving() ? DisguiseType.CUSTOM_LIVING : DisguiseType.CUSTOM_MISC,
entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC,
entry.getValue().getName()));
}
@@ -147,7 +147,7 @@ public class ModdedManager implements PluginMessageListener {
player.setMetadata("forge_mods", new FixedMetadataValue(LibsDisguises.getInstance(), mods));
for (CustomEntity e : getEntities().values()) {
for (ModdedEntity e : getEntities().values()) {
if (e.getMod() == null) {
continue;
}

View File

@@ -234,7 +234,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
if (!disguise.getType().isCustom()) {
mods.write(2, disguise.getType().getTypeId());
} else {
mods.write(2, ((CustomDisguise) disguise).getCustomEntity().getTypeId());
mods.write(2, ((ModdedDisguise) disguise).getModdedEntity().getTypeId());
}
// region Vector calculations
@@ -310,7 +310,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
Object entityType;
if (disguise.isCustomDisguise()) {
entityType = ((CustomDisguise) disguise).getCustomEntity().getEntityType();
entityType = ((ModdedDisguise) disguise).getModdedEntity().getEntityType();
} else {
entityType = ReflectionManager.getEntityType(disguise.getType().getEntityType());
}
@@ -325,7 +325,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
int objectId = disguise.getType().getObjectId();
if (disguise.isCustomDisguise()) {
objectId = ((CustomDisguise) disguise).getCustomEntity().getTypeId();
objectId = ((ModdedDisguise) disguise).getModdedEntity().getTypeId();
}
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);

View File

@@ -4,7 +4,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.disguisetypes.*;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.modded.CustomEntity;
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
import me.libraryaddict.disguise.utilities.params.ParamInfo;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
@@ -647,13 +647,13 @@ public class DisguiseParser {
name = disguisePerm.toReadable();
if (disguisePerm.getType().isCustom()) {
CustomEntity ent = ModdedManager.getCustomEntity(disguisePerm.toReadable());
ModdedEntity ent = ModdedManager.getCustomEntity(disguisePerm.toReadable());
if (ent == null) {
throw new DisguiseParseException(LibsMsg.PARSE_CANT_DISG_UNKNOWN);
}
disguise = new CustomDisguise(ent);
disguise = new ModdedDisguise(ent);
}
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);

View File

@@ -21,7 +21,6 @@ import org.bukkit.entity.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.InvalidDescriptionException;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector;
@@ -1491,9 +1490,9 @@ public class ReflectionManager {
case ARROW:
watcherClass = TippedArrowWatcher.class;
break;
case CUSTOM_LIVING:
case CUSTOM_MISC:
watcherClass = CustomWatcher.class;
case MODDED_LIVING:
case MODDED_MISC:
watcherClass = ModdedWatcher.class;
break;
case COD:
case SALMON: