DataItemStack - Dependencies, Better Debug, Better Order...
This commit is contained in:
parent
2c5fb79d9e
commit
a0bcc5ae8d
@ -64,10 +64,7 @@ import com.massivecraft.massivecore.engine.EngineMassiveCoreVariable;
|
||||
import com.massivecraft.massivecore.engine.EngineMassiveCoreWorldNameSet;
|
||||
import com.massivecraft.massivecore.integration.vault.IntegrationVault;
|
||||
import com.massivecraft.massivecore.item.DataBannerPattern;
|
||||
import com.massivecraft.massivecore.item.WriterBannerPattern;
|
||||
import com.massivecraft.massivecore.item.WriterFireworkEffect;
|
||||
import com.massivecraft.massivecore.item.WriterItemStack;
|
||||
import com.massivecraft.massivecore.item.WriterPotionEffect;
|
||||
import com.massivecraft.massivecore.mixin.MixinActionbar;
|
||||
import com.massivecraft.massivecore.mixin.MixinActual;
|
||||
import com.massivecraft.massivecore.mixin.MixinCommand;
|
||||
@ -86,6 +83,7 @@ import com.massivecraft.massivecore.mixin.MixinVisibility;
|
||||
import com.massivecraft.massivecore.mixin.MixinWorld;
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.mson.MsonEvent;
|
||||
import com.massivecraft.massivecore.nms.NmsItemStack;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.ps.PSAdapter;
|
||||
import com.massivecraft.massivecore.store.ModificationPollerLocal;
|
||||
@ -168,8 +166,12 @@ public class MassiveCore extends MassivePlugin
|
||||
ret.registerTypeAdapter(Mson.class, AdapterMson.get());
|
||||
ret.registerTypeAdapter(MsonEvent.class, AdapterMsonEvent.get());
|
||||
|
||||
// Items and Inventories
|
||||
// ItemStack
|
||||
ret.registerTypeAdapter(ItemStack.class, AdapterItemStack.get());
|
||||
Class<?> classCraftItemStack = NmsItemStack.get().classCraftItemStack;
|
||||
if (classCraftItemStack != null) ret.registerTypeAdapter(classCraftItemStack, AdapterItemStack.get());
|
||||
|
||||
// Inventory
|
||||
ret.registerTypeAdapter(Inventory.class, AdapterInventory.get());
|
||||
ret.registerTypeAdapter(PlayerInventory.class, AdapterPlayerInventory.get());
|
||||
|
||||
@ -240,9 +242,6 @@ public class MassiveCore extends MassivePlugin
|
||||
|
||||
// Writer,
|
||||
WriterItemStack.class,
|
||||
WriterPotionEffect.class,
|
||||
WriterFireworkEffect.class,
|
||||
WriterBannerPattern.class,
|
||||
|
||||
// Engine
|
||||
EngineMassiveCoreChestGui.class,
|
||||
|
@ -71,43 +71,55 @@ public class EngineMassiveCoreSponsor extends Engine
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INFORM
|
||||
// ENABLED
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void inform(final CommandSender sender)
|
||||
public boolean isEnabled(final CommandSender sender)
|
||||
{
|
||||
// Fail Safe
|
||||
if (sender == null) return;
|
||||
// If there is a sender ...
|
||||
if (sender == null) return false;
|
||||
|
||||
// If enabled by mconf ...
|
||||
if ( ! MassiveCoreMConf.get().sponsorEnabled) return;
|
||||
// ... and enabled by mconf ...
|
||||
if ( ! MassiveCoreMConf.get().sponsorEnabled) return false;
|
||||
|
||||
// ... and enabled by info base ...
|
||||
if ( ! MassiveCoreMSponsorInfo.get().enabled) return;
|
||||
if ( ! MassiveCoreMSponsorInfo.get().enabled) return false;
|
||||
|
||||
// ... and enabled by info time ...
|
||||
long now = System.currentTimeMillis();
|
||||
long to = MassiveCoreMSponsorInfo.get().enabledToMillis;
|
||||
long left = to - now;
|
||||
if (left <= 0) return;
|
||||
if (left <= 0) return false;
|
||||
|
||||
// ... and enabled by sender type ...
|
||||
boolean isConsole = IdUtil.isConsole(sender);
|
||||
boolean enabledByType = (isConsole ? MassiveCoreMSponsorInfo.get().consoleEnabled : MassiveCoreMSponsorInfo.get().ingameEnabled);
|
||||
if ( ! enabledByType) return;
|
||||
boolean enabledByType = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleEnabled : MassiveCoreMSponsorInfo.get().ingameEnabled);
|
||||
if ( ! enabledByType) return false;
|
||||
|
||||
// ... and enabled by sender operator ...
|
||||
if ( ! sender.isOp()) return;
|
||||
if ( ! sender.isOp()) return false;
|
||||
|
||||
// ... and enabled by in indicator files ...
|
||||
for (String indicatorFileName : MassiveCoreMSponsorInfo.get().indicatorFileNames)
|
||||
{
|
||||
File indicatorFile = new File(indicatorFileName);
|
||||
if (indicatorFile.exists()) return;
|
||||
if (indicatorFile.exists()) return false;
|
||||
}
|
||||
|
||||
// ... then schedule inner inform.
|
||||
int delayTicks = (isConsole ? MassiveCoreMSponsorInfo.get().consoleDelayTicks : MassiveCoreMSponsorInfo.get().ingameDelayTicks);
|
||||
// ... then it's actually enabled.
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INFORM
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void inform(final CommandSender sender)
|
||||
{
|
||||
// Enabled
|
||||
if ( ! this.isEnabled(sender)) return;
|
||||
|
||||
// Schedule
|
||||
int delayTicks = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleDelayTicks : MassiveCoreMSponsorInfo.get().ingameDelayTicks);
|
||||
Bukkit.getScheduler().runTaskLater(this.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
@ -120,11 +132,11 @@ public class EngineMassiveCoreSponsor extends Engine
|
||||
|
||||
public void informInner(CommandSender sender)
|
||||
{
|
||||
// Console?
|
||||
boolean isConsole = IdUtil.isConsole(sender);
|
||||
// Enabled
|
||||
if ( ! this.isEnabled(sender)) return;
|
||||
|
||||
// Messages
|
||||
List<String> msgs = (isConsole ? MassiveCoreMSponsorInfo.get().consoleMsgs : MassiveCoreMSponsorInfo.get().ingameMsgs);
|
||||
List<String> msgs = (IdUtil.isConsole(sender) ? MassiveCoreMSponsorInfo.get().consoleMsgs : MassiveCoreMSponsorInfo.get().ingameMsgs);
|
||||
String senderVisual = MixinDisplayName.get().getDisplayName(sender, sender);
|
||||
for (String msg : msgs)
|
||||
{
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.massivecraft.massivecore.item;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.massivecraft.massivecore.Engine;
|
||||
import com.massivecraft.massivecore.MassiveCoreMConf;
|
||||
import com.massivecraft.massivecore.collections.MassiveList;
|
||||
import com.massivecraft.massivecore.command.type.primitive.TypeBoolean;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.ReflectionUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
@ -14,55 +16,134 @@ public abstract class WriterAbstract<OA, OB, CA, CB, FA, FB> extends Engine
|
||||
// -------------------------------------------- //
|
||||
// WRITERS
|
||||
// -------------------------------------------- //
|
||||
// A writer may contain subwriters.
|
||||
// Writer have dependencies and child writers.
|
||||
|
||||
// A dependency is another writer that must be successfully activated for this writer to function.
|
||||
// For that reason the dependencies are activated just after the provoke logic.
|
||||
// Examples would be WriterPotionEffect and WriterFireworkEffect.
|
||||
// They are implicitly required for some ItemStack field writers.
|
||||
|
||||
private List<Class<?>> dependencyClasses = new MassiveList<>();
|
||||
public List<Class<?>> getDependencyClasses() { return this.dependencyClasses; }
|
||||
public void addDependencyClasses(Class<?>... dependencyClasses) { this.getDependencyClasses().addAll(Arrays.asList(dependencyClasses)); }
|
||||
|
||||
// This is the writer classes scheduled to be used at setup.
|
||||
// We do not yet know if they are compatible with this Minecraft version.
|
||||
// All, some or none of them may fail.
|
||||
private List<Class<?>> writerClasses = new MassiveList<>();
|
||||
public List<Class<?>> getWriterClasses() { return this.writerClasses; }
|
||||
public void addWriterClasses(Class<?>... writerClasses) { this.getWriterClasses().addAll(Arrays.asList(writerClasses)); }
|
||||
|
||||
// These are the actually functional child writers.
|
||||
// This list should only contain writers that passed the provoke routine.
|
||||
private List<WriterAbstract<CA, CB, ?, ?, ?, ?>> writers = new MassiveList<>();
|
||||
public List<WriterAbstract<CA, CB, ?, ?, ?, ?>> getWriters() { return this.writers; }
|
||||
|
||||
public List<WriterAbstract<CA, CB, ?, ?, ?, ?>> getWriters()
|
||||
// Here is the logic to perform the dependency and child writer setup.
|
||||
public void setupDependencies()
|
||||
{
|
||||
return this.writers;
|
||||
for (Class<?> dependencyClass : this.getDependencyClasses())
|
||||
{
|
||||
this.setupWriter(dependencyClass, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearWriters()
|
||||
public void setupWriters()
|
||||
{
|
||||
this.writers.clear();
|
||||
for (Class<?> writerClass : this.getWriterClasses())
|
||||
{
|
||||
this.setupWriter(writerClass, true);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addWriter(Class<?> clazz)
|
||||
public void setupWriter(Class<?> writerClass, boolean add)
|
||||
{
|
||||
boolean success = false;
|
||||
try
|
||||
{
|
||||
Class<WriterAbstract<CA, CB, ?, ?, ?, ?>> clazzInner = (Class<WriterAbstract<CA, CB, ?, ?, ?, ?>>) clazz;
|
||||
WriterAbstract<CA, CB, ?, ?, ?, ?> writer = ReflectionUtil.getSingletonInstance(clazzInner);
|
||||
writer.setActive(this.getActivePlugin());
|
||||
this.getWriters().add(writer);
|
||||
success = true;
|
||||
Class<WriterAbstract<?, ?, ?, ?, ?, ?>> writerClassInner = (Class<WriterAbstract<?, ?, ?, ?, ?, ?>>) writerClass;
|
||||
WriterAbstract<?, ?, ?, ?, ?, ?> writer = ReflectionUtil.getSingletonInstance(writerClassInner);
|
||||
|
||||
if ( ! writer.isActive()) writer.setActive(this.getActivePlugin());
|
||||
|
||||
if (add) this.getWriters().add((WriterAbstract<CA, CB, ?, ?, ?, ?>)writer);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (MassiveCoreMConf.get().debugWriters)
|
||||
{
|
||||
t.printStackTrace();
|
||||
this.reportSuccess(false, writerClass.getSimpleName(), t);
|
||||
}
|
||||
}
|
||||
|
||||
if (MassiveCoreMConf.get().debugWriters)
|
||||
public void reportSuccess(boolean success)
|
||||
{
|
||||
String message = Txt.parse("<h>%s %s", clazz.getSimpleName(), TypeBoolean.getOn().getVisual(success));
|
||||
this.getActivePlugin().log(message);
|
||||
this.reportSuccess(success, this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public void reportSuccess(boolean success, String name)
|
||||
{
|
||||
this.reportSuccess(success, name, null);
|
||||
}
|
||||
|
||||
public void reportSuccess(boolean success, String name, Throwable t)
|
||||
{
|
||||
if ( ! MassiveCoreMConf.get().debugWriters) return;
|
||||
|
||||
// Create
|
||||
List<String> messages = new MassiveList<>();
|
||||
|
||||
// Fill
|
||||
String message;
|
||||
|
||||
// Main
|
||||
message = Txt.parse("<h>%s %s", name, TypeBoolean.getOn().getVisual(success));
|
||||
messages.add(message);
|
||||
|
||||
// Throwable
|
||||
if (t != null)
|
||||
{
|
||||
message = Txt.parse("<b>### %s <i>%s", t.getClass().getSimpleName(), t.getMessage());
|
||||
messages.add(message);
|
||||
for (String s : MUtil.getStackTraceStrings(Arrays.asList(t.getStackTrace()), true))
|
||||
{
|
||||
message = Txt.parse("<b>--> %s", s);
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
public void addWriters(Class<?>... clazzs)
|
||||
// Send
|
||||
for (String s : messages)
|
||||
{
|
||||
for (Class<?> clazz : clazzs)
|
||||
{
|
||||
this.addWriter(clazz);
|
||||
this.getActivePlugin().log(s);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
// The setActive method starts out with the provoke.
|
||||
// This means it can fail immediately with a runtime exception.
|
||||
// If this happens it will not have been activated in any way.
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
// Provoke
|
||||
this.provoke();
|
||||
|
||||
// Setup Dependencies
|
||||
this.setupDependencies();
|
||||
|
||||
// Report This Success
|
||||
this.reportSuccess(true);
|
||||
|
||||
// Setup Writers
|
||||
this.setupWriters();
|
||||
}
|
||||
super.setActive(active);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CREATE
|
||||
// -------------------------------------------- //
|
||||
@ -121,17 +202,6 @@ public abstract class WriterAbstract<OA, OB, CA, CB, FA, FB> extends Engine
|
||||
return cb;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active)
|
||||
{
|
||||
this.provoke();
|
||||
super.setActive(active);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PROVOKE
|
||||
// -------------------------------------------- //
|
||||
@ -167,7 +237,7 @@ public abstract class WriterAbstract<OA, OB, CA, CB, FA, FB> extends Engine
|
||||
|
||||
public void write(OA oa, OB ob, boolean a2b)
|
||||
{
|
||||
if (!this.isActive()) throw new IllegalStateException("not active " + this.getClass().getName());
|
||||
if ( ! this.isActive()) throw new IllegalStateException("not active " + this.getClass().getName());
|
||||
|
||||
if (oa == null) throw new NullPointerException("oa");
|
||||
if (ob == null) throw new NullPointerException("ob");
|
||||
|
@ -1,9 +1,20 @@
|
||||
package com.massivecraft.massivecore.item;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
public abstract class WriterAbstractItemStackMetaState<OB, CB, FA, FB> extends WriterAbstractItemStackMeta<OB, CB, FA, FB>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public WriterAbstractItemStackMetaState()
|
||||
{
|
||||
// For the initial provoke to pass we must set a Material with a BlockStateMeta.
|
||||
this.setMaterial(Material.SHIELD);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CREATE
|
||||
// -------------------------------------------- //
|
||||
|
@ -8,22 +8,12 @@ public class WriterBannerPattern extends WriterAbstractBannerPattern<Object, Obj
|
||||
|
||||
private static final WriterBannerPattern i = new WriterBannerPattern();
|
||||
public static WriterBannerPattern get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterBannerPattern()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
WriterBannerPatternId.class,
|
||||
WriterBannerPatternColor.class
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,25 +8,15 @@ public class WriterFireworkEffect extends WriterAbstractFireworkEffect<Object, O
|
||||
|
||||
private static final WriterFireworkEffect i = new WriterFireworkEffect();
|
||||
public static WriterFireworkEffect get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterFireworkEffect()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
WriterFireworkEffectFlicker.class,
|
||||
WriterFireworkEffectTrail.class,
|
||||
WriterFireworkEffectColors.class,
|
||||
WriterFireworkEffectFadeColors.class,
|
||||
WriterFireworkEffectType.class
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,18 +8,9 @@ public class WriterItemStack extends WriterAbstractItemStackField<Object, Object
|
||||
|
||||
private static final WriterItemStack i = new WriterItemStack();
|
||||
public static WriterItemStack get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterItemStack()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
// BASIC
|
||||
WriterItemStackId.class,
|
||||
WriterItemStackCount.class,
|
||||
@ -30,5 +21,4 @@ public class WriterItemStack extends WriterAbstractItemStackField<Object, Object
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,18 +8,9 @@ public class WriterItemStackMeta extends WriterAbstractItemStackMetaMorph<Object
|
||||
|
||||
private static final WriterItemStackMeta i = new WriterItemStackMeta();
|
||||
public static WriterItemStackMeta get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterItemStackMeta()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
// UNSPECIFIC
|
||||
WriterItemStackMetaName.class,
|
||||
WriterItemStackMetaLore.class,
|
||||
|
@ -18,6 +18,9 @@ public class WriterItemStackMetaBannerPatterns extends WriterAbstractItemStackMe
|
||||
this.setMaterial(Material.BANNER);
|
||||
this.setConverterTo(ConverterToBannerPatterns.get());
|
||||
this.setConverterFrom(ConverterFromBannerPatterns.get());
|
||||
this.addDependencyClasses(
|
||||
WriterBannerPattern.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -16,6 +16,9 @@ public class WriterItemStackMetaFireworkEffect extends WriterAbstractItemStackMe
|
||||
this.setMaterial(Material.FIREWORK_CHARGE);
|
||||
this.setConverterTo(ConverterToFireworkEffect.get());
|
||||
this.setConverterFrom(ConverterFromFireworkEffect.get());
|
||||
this.addDependencyClasses(
|
||||
WriterFireworkEffect.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -18,6 +18,9 @@ public class WriterItemStackMetaFireworkEffects extends WriterAbstractItemStackM
|
||||
this.setMaterial(Material.FIREWORK);
|
||||
this.setConverterTo(ConverterToFireworkEffects.get());
|
||||
this.setConverterFrom(ConverterFromFireworkEffects.get());
|
||||
this.addDependencyClasses(
|
||||
WriterFireworkEffect.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -18,6 +18,9 @@ public class WriterItemStackMetaPotionEffects extends WriterAbstractItemStackMet
|
||||
this.setMaterial(Material.POTION);
|
||||
this.setConverterTo(ConverterToPotionEffects.get());
|
||||
this.setConverterFrom(ConverterFromPotionEffects.get());
|
||||
this.addDependencyClasses(
|
||||
WriterPotionEffect.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -8,18 +8,9 @@ public class WriterItemStackMetaState extends WriterAbstractItemStackMetaStateMo
|
||||
|
||||
private static final WriterItemStackMetaState i = new WriterItemStackMetaState();
|
||||
public static WriterItemStackMetaState get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterItemStackMetaState()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
// SHIELD
|
||||
WriterItemStackMetaStateShieldBase.class,
|
||||
WriterItemStackMetaStateShieldPatterns.class
|
||||
|
@ -18,6 +18,9 @@ public class WriterItemStackMetaStateShieldPatterns extends WriterAbstractItemSt
|
||||
this.setMaterial(Material.SHIELD);
|
||||
this.setConverterTo(ConverterToBannerPatterns.get());
|
||||
this.setConverterFrom(ConverterFromBannerPatterns.get());
|
||||
this.addDependencyClasses(
|
||||
WriterBannerPattern.class
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -8,18 +8,9 @@ public class WriterPotionEffect extends WriterAbstractPotionEffect<Object, Objec
|
||||
|
||||
private static final WriterPotionEffect i = new WriterPotionEffect();
|
||||
public static WriterPotionEffect get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ACTIVE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void setActiveInner(boolean active)
|
||||
public WriterPotionEffect()
|
||||
{
|
||||
if ( ! active) return;
|
||||
this.clearWriters();
|
||||
|
||||
this.addWriters(
|
||||
this.addWriterClasses(
|
||||
WriterPotionEffectId.class,
|
||||
WriterPotionEffectDuraction.class,
|
||||
WriterPotionEffectAmplifier.class,
|
||||
@ -27,7 +18,6 @@ public class WriterPotionEffect extends WriterAbstractPotionEffect<Object, Objec
|
||||
WriterPotionEffectParticles.class,
|
||||
WriterPotionEffectColor.class
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class NmsItemStack extends NmsAbstract
|
||||
// Fill
|
||||
if (this.isAvailable())
|
||||
{
|
||||
ret = ReflectionUtil.invokeConstructor(this.constructorCraftItemStack, (Object[])null);
|
||||
ret = ReflectionUtil.invokeConstructor(this.constructorCraftItemStack, (Object)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -117,6 +117,11 @@ public class ReflectionUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T invokeMethod(Method method, Object target, Object argument)
|
||||
{
|
||||
return invokeMethod(method, target, new Object[]{argument});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T invokeMethod(Method method, Object target)
|
||||
{
|
||||
@ -160,6 +165,11 @@ public class ReflectionUtil
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> T invokeConstructor(Constructor<?> constructor, Object argument)
|
||||
{
|
||||
return invokeConstructor(constructor, new Object[]{argument});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T invokeConstructor(Constructor<?> constructor)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user