Some COOL stuff
Fixed PathfinderGoalMeleeAttack Fixed error when using remove/clear pathfinder goals on an armor stand (why is it considered a living entity?!?) Forgot to make NBTListIndex return a single value, now fixed Added "Minecraft ID of %itemtype%" (to return for example "minecraft:planks") Also some stuff I don't remember (see the changes!)
This commit is contained in:
parent
36b069fa3e
commit
48685db4be
@ -6,6 +6,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -34,6 +35,7 @@ import me.TheBukor.SkStuff.effects.EffPasteSchematic;
|
|||||||
import me.TheBukor.SkStuff.effects.EffRememberChanges;
|
import me.TheBukor.SkStuff.effects.EffRememberChanges;
|
||||||
import me.TheBukor.SkStuff.effects.EffRemovePathGoal;
|
import me.TheBukor.SkStuff.effects.EffRemovePathGoal;
|
||||||
import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE;
|
import me.TheBukor.SkStuff.effects.EffReplaceBlocksWE;
|
||||||
|
import me.TheBukor.SkStuff.effects.EffRestoreInv;
|
||||||
import me.TheBukor.SkStuff.effects.EffSetBlocksWE;
|
import me.TheBukor.SkStuff.effects.EffSetBlocksWE;
|
||||||
import me.TheBukor.SkStuff.effects.EffSetPathGoal;
|
import me.TheBukor.SkStuff.effects.EffSetPathGoal;
|
||||||
import me.TheBukor.SkStuff.effects.EffShowEntityEffect;
|
import me.TheBukor.SkStuff.effects.EffShowEntityEffect;
|
||||||
@ -48,7 +50,9 @@ import me.TheBukor.SkStuff.expressions.ExprEditSessionLimit;
|
|||||||
import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks;
|
import me.TheBukor.SkStuff.expressions.ExprEndermanBlocks;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprFileNBT;
|
import me.TheBukor.SkStuff.expressions.ExprFileNBT;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprFireProof;
|
import me.TheBukor.SkStuff.expressions.ExprFireProof;
|
||||||
|
import me.TheBukor.SkStuff.expressions.ExprGlideState;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprItemNBT;
|
import me.TheBukor.SkStuff.expressions.ExprItemNBT;
|
||||||
|
import me.TheBukor.SkStuff.expressions.ExprMCIdOf;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprNBTListContents;
|
import me.TheBukor.SkStuff.expressions.ExprNBTListContents;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprNBTListIndex;
|
import me.TheBukor.SkStuff.expressions.ExprNBTListIndex;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprNBTOf;
|
import me.TheBukor.SkStuff.expressions.ExprNBTOf;
|
||||||
@ -58,6 +62,7 @@ import me.TheBukor.SkStuff.expressions.ExprSchematicArea;
|
|||||||
import me.TheBukor.SkStuff.expressions.ExprSelectionArea;
|
import me.TheBukor.SkStuff.expressions.ExprSelectionArea;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer;
|
import me.TheBukor.SkStuff.expressions.ExprSelectionOfPlayer;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprSelectionPos;
|
import me.TheBukor.SkStuff.expressions.ExprSelectionPos;
|
||||||
|
import me.TheBukor.SkStuff.expressions.ExprSerializedInv;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprTagOf;
|
import me.TheBukor.SkStuff.expressions.ExprTagOf;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
|
import me.TheBukor.SkStuff.expressions.ExprTimespanToNumber;
|
||||||
import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
|
import me.TheBukor.SkStuff.expressions.ExprToLowerCase;
|
||||||
@ -87,13 +92,32 @@ public class SkStuff extends JavaPlugin {
|
|||||||
getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
|
getLogger().info("SkStuff " + this.getDescription().getVersion() + " has been successfully enabled!");
|
||||||
getLogger().info("Registering general non version specific stuff...");
|
getLogger().info("Registering general non version specific stuff...");
|
||||||
Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0圩irework[s] explo(de|sion)|1多urt|2吆[iron] golem] (give|offer) (rose|poppy)|3吆sheep] eat grass|4安olf shake) at %entity%");
|
Skript.registerEffect(EffShowEntityEffect.class, "(display|play|show) entity effect (0圩irework[s] explo(de|sion)|1多urt|2吆[iron] golem] (give|offer) (rose|poppy)|3吆sheep] eat grass|4安olf shake) at %entity%");
|
||||||
|
Skript.registerEffect(EffRestoreInv.class, "[(skstuff|1.9)] restore %inventory% (to|from) [serialized [inventory [conents]]] %string%");
|
||||||
Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%");
|
Skript.registerExpression(ExprToUpperCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] (cap[ital]s|upper[ ]case)", "convert %string% to [all] (cap[ital]s|upper[ ]case)", "capitalize [all] [char[acter]s (of|in)] %string%");
|
||||||
Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%");
|
Skript.registerExpression(ExprToLowerCase.class, String.class, ExpressionType.SIMPLE, "%string% [converted] to [all] lower[ ]case", "convert %string% to [all] lower[ ]case", "un[( |-)]capitalize [all] [char[acter]s (of|in)] %string%");
|
||||||
Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])");
|
Skript.registerExpression(ExprWordsToUpperCase.class, String.class, ExpressionType.SIMPLE, "(first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% [converted] to (cap[ital]s|upper[ ]case) (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])", "convert (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% to (cap[ital]s|upper[ ]case) (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])", "capitalize (first|1st) (letter|char[acter]) (of|in) (each word|[all] words) (of|in) %string% (0帆1夷gnoring [other] upper[ ]case [(char[acter]s|letters)])");
|
||||||
Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0宇icks|1存ec[ond]s|2妃in[ute]s|3多ours|4圬ays)");
|
Skript.registerExpression(ExprTimespanToNumber.class, Number.class, ExpressionType.SIMPLE, "%timespan% [converted] [in]to (0宇icks|1存ec[ond]s|2妃in[ute]s|3多ours|4圬ays)");
|
||||||
Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory");
|
Skript.registerExpression(ExprClickedInventory.class, Inventory.class, ExpressionType.SIMPLE, "[skstuff] clicked inventory");
|
||||||
effAmount += 1;
|
Skript.registerExpression(ExprSerializedInv.class, String.class, ExpressionType.PROPERTY, "[(skstuff|1.9)] serialized [contents of] %inventory%");
|
||||||
exprAmount += 5;
|
Skript.registerExpression(ExprMCIdOf.class, String.class, ExpressionType.PROPERTY, "minecraft [(string|native)] id of %itemtype%", "%itemtype%'s minecraft [(string|native)] id");
|
||||||
|
effAmount += 2;
|
||||||
|
exprAmount += 7;
|
||||||
|
if (Skript.isRunningMinecraft(1, 9)) {
|
||||||
|
getLogger().info("WOW! You're using Minecraft 1.9! Lemme register some cool stuff right away!");
|
||||||
|
Skript.registerEvent("Elytra glide toggle", SimpleEvent.class, EntityToggleGlideEvent.class, "[entity] elytra (fl(y|ight)|glid(e|ing)) toggl(e|ing)", "[entity] toggle elytra (fl(y|ight)|glid(e|ing))");
|
||||||
|
Skript.registerExpression(ExprGlideState.class, Boolean.class, ExpressionType.PROPERTY, "elytra (fl(y|ight)|glid(e|ing)) state of %player%", "%player%'s elytra (fl(y|ight)|glid(e|ing)) state");
|
||||||
|
/* Don't register it yet, Spigot isn't doing it properly as of now.
|
||||||
|
EventValues.registerEventValue(EntityToggleGlideEvent.class, Entity.class, new Getter<Entity, EntityToggleGlideEvent>() {
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Entity get(EntityToggleGlideEvent e) {
|
||||||
|
return e.getEntity();
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
*/
|
||||||
|
evtAmount += 1;
|
||||||
|
exprAmount += 1;
|
||||||
|
}
|
||||||
if (setupNMSVersion()) {
|
if (setupNMSVersion()) {
|
||||||
getLogger().info("Trying to register version specific stuff...");
|
getLogger().info("Trying to register version specific stuff...");
|
||||||
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentities%");
|
Skript.registerEffect(EffClearPathGoals.class, "(clear|delete) [all] pathfind[er] goals (of|from) %livingentities%");
|
||||||
|
@ -2,6 +2,7 @@ package me.TheBukor.SkStuff.effects;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -31,7 +32,7 @@ public class EffClearPathGoals extends Effect {
|
|||||||
protected void execute(Event e) {
|
protected void execute(Event e) {
|
||||||
LivingEntity[] ents = entities.getAll(e);
|
LivingEntity[] ents = entities.getAll(e);
|
||||||
for (LivingEntity ent : ents) {
|
for (LivingEntity ent : ents) {
|
||||||
if (ent instanceof Player || ent == null)
|
if (ent instanceof Player || ent instanceof ArmorStand || ent == null)
|
||||||
continue;
|
continue;
|
||||||
SkStuff.getNMSMethods().clearPathfinderGoals(ent);
|
SkStuff.getNMSMethods().clearPathfinderGoals(ent);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Blaze;
|
import org.bukkit.entity.Blaze;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
@ -45,7 +46,7 @@ public class EffRemovePathGoal extends Effect {
|
|||||||
protected void execute(Event e) {
|
protected void execute(Event e) {
|
||||||
LivingEntity[] ents = entities.getAll(e);
|
LivingEntity[] ents = entities.getAll(e);
|
||||||
for (LivingEntity ent : ents) {
|
for (LivingEntity ent : ents) {
|
||||||
if (ent instanceof Player || ent == null)
|
if (ent instanceof Player || ent instanceof ArmorStand || ent == null)
|
||||||
return;
|
return;
|
||||||
Object obcEnt = craftLivEnt.cast(ent);
|
Object obcEnt = craftLivEnt.cast(ent);
|
||||||
Object nmsEnt = null;
|
Object nmsEnt = null;
|
||||||
|
@ -9,6 +9,7 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Animals;
|
import org.bukkit.entity.Animals;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Blaze;
|
import org.bukkit.entity.Blaze;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
import org.bukkit.entity.Enderman;
|
import org.bukkit.entity.Enderman;
|
||||||
@ -149,7 +150,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
protected void execute(Event e) {
|
protected void execute(Event e) {
|
||||||
LivingEntity[] ents = entities.getAll(e);
|
LivingEntity[] ents = entities.getAll(e);
|
||||||
for (LivingEntity ent : ents) {
|
for (LivingEntity ent : ents) {
|
||||||
if (ent == null || ent instanceof Player)
|
if (ent == null || ent instanceof Player || ent instanceof ArmorStand)
|
||||||
return;
|
return;
|
||||||
int priority = (goalPriority == null ? 4 : goalPriority.getSingle(e).intValue());
|
int priority = (goalPriority == null ? 4 : goalPriority.getSingle(e).intValue());
|
||||||
|
|
||||||
@ -174,7 +175,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -188,7 +189,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -239,7 +240,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -268,7 +269,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -284,7 +285,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -297,18 +298,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue());
|
double spd = (meleeSpeed == null ? 1.0D : meleeSpeed.getSingle(e).doubleValue());
|
||||||
boolean memorize = (meleeMemorize == null ? false : meleeMemorize.getSingle(e));
|
boolean memorize = (meleeMemorize == null ? false : meleeMemorize.getSingle(e));
|
||||||
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
|
Class<?> goalMeleeAttack = ReflectionUtils.getNMSClass("PathfinderGoalMeleeAttack");
|
||||||
for (EntityData<?> entData : types) {
|
newGoals.add(goalMeleeAttack.getConstructor(entCreature, double.class, boolean.class).newInstance(nmsEnt, spd, memorize));
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
|
||||||
return;
|
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
|
||||||
if (className.equals("HumanEntity")) {
|
|
||||||
className = "Human";
|
|
||||||
} else if (className.equals("EntityLiving")) {
|
|
||||||
className = "Living";
|
|
||||||
}
|
|
||||||
Class<?> nmsClass = ReflectionUtils.getNMSClass("Entity" + className);
|
|
||||||
newGoals.add(goalMeleeAttack.getConstructor(entCreature, Class.class, double.class, boolean.class).newInstance(nmsEnt, nmsClass, spd, memorize));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (mark == 13) {
|
} else if (mark == 13) {
|
||||||
double spd = (moveTargetSpeed == null ? 1.0D : moveTargetSpeed.getSingle(e).doubleValue());
|
double spd = (moveTargetSpeed == null ? 1.0D : moveTargetSpeed.getSingle(e).doubleValue());
|
||||||
@ -323,7 +313,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -338,7 +328,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
@ -449,7 +439,7 @@ public class EffSetPathGoal extends Effect {
|
|||||||
for (EntityData<?> entData : types) {
|
for (EntityData<?> entData : types) {
|
||||||
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
if (!LivingEntity.class.isAssignableFrom(entData.getType()))
|
||||||
return;
|
return;
|
||||||
String className = entData.getType().getClass().getSimpleName();
|
String className = entData.getType().getSimpleName();
|
||||||
if (className.equals("HumanEntity")) {
|
if (className.equals("HumanEntity")) {
|
||||||
className = "Human";
|
className = "Human";
|
||||||
} else if (className.equals("EntityLiving")) {
|
} else if (className.equals("EntityLiving")) {
|
||||||
|
69
src/me/TheBukor/SkStuff/expressions/ExprGlideState.java
Normal file
69
src/me/TheBukor/SkStuff/expressions/ExprGlideState.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package me.TheBukor.SkStuff.expressions;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
|
||||||
|
import ch.njol.skript.classes.Changer.ChangeMode;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
import net.minecraft.server.v1_9_R1.EntityPlayer;
|
||||||
|
|
||||||
|
public class ExprGlideState extends SimpleExpression<Boolean> {
|
||||||
|
private Expression<Player> player;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends Boolean> getReturnType() {
|
||||||
|
return Boolean.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
|
||||||
|
player = (Expression<Player>) expr[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean debug) {
|
||||||
|
return "elytra gliding state of " + player.toString(e, debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected Boolean[] get(Event e) {
|
||||||
|
Player p = player.getSingle(e);
|
||||||
|
EntityPlayer nmsPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
return new Boolean[] { nmsPlayer.cB() };
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
return CollectionUtils.array(Boolean.class);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void change(Event e, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
|
Player p = player.getSingle(e);
|
||||||
|
EntityPlayer nmsPlayer = ((CraftPlayer) p).getHandle();
|
||||||
|
if (mode == ChangeMode.SET) {
|
||||||
|
boolean newValue = (boolean) delta[0];
|
||||||
|
nmsPlayer.setFlag(7, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java
Normal file
49
src/me/TheBukor/SkStuff/expressions/ExprMCIdOf.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package me.TheBukor.SkStuff.expressions;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import ch.njol.skript.aliases.ItemType;
|
||||||
|
import ch.njol.skript.lang.Expression;
|
||||||
|
import ch.njol.skript.lang.SkriptParser.ParseResult;
|
||||||
|
import ch.njol.skript.lang.util.SimpleExpression;
|
||||||
|
import ch.njol.util.Kleenean;
|
||||||
|
import me.TheBukor.SkStuff.SkStuff;
|
||||||
|
|
||||||
|
public class ExprMCIdOf extends SimpleExpression<String> {
|
||||||
|
private Expression<ItemType> itemType;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSingle() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<? extends String> getReturnType() {
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public boolean init(Expression<?>[] expr, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
|
||||||
|
itemType = (Expression<ItemType>) expr[0];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(@Nullable Event e, boolean debug) {
|
||||||
|
return "minecraft id of " + itemType.toString(e, debug);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
protected String[] get(Event e) {
|
||||||
|
ItemType type = itemType.getSingle(e);
|
||||||
|
ItemStack item = new ItemStack(type.getTypes().get(0).getId());
|
||||||
|
return new String[] { SkStuff.getNMSMethods().getMCId(item) };
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,7 @@ public class ExprNBTListIndex extends SimpleExpression<Object> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSingle() {
|
public boolean isSingle() {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -55,4 +55,6 @@ public interface NMSInterface {
|
|||||||
public Object convertToNBT(Number number);
|
public Object convertToNBT(Number number);
|
||||||
|
|
||||||
public Object convertToNBT(String string);
|
public Object convertToNBT(String string);
|
||||||
|
|
||||||
|
public String getMCId(ItemStack itemStack);
|
||||||
}
|
}
|
||||||
|
@ -30,20 +30,21 @@ import ch.njol.skript.classes.Parser;
|
|||||||
import ch.njol.skript.lang.ParseContext;
|
import ch.njol.skript.lang.ParseContext;
|
||||||
import ch.njol.skript.registrations.Classes;
|
import ch.njol.skript.registrations.Classes;
|
||||||
import ch.njol.util.coll.CollectionUtils;
|
import ch.njol.util.coll.CollectionUtils;
|
||||||
|
import net.minecraft.server.v1_7_R4.Item;
|
||||||
import net.minecraft.server.v1_7_R4.MojangsonParser;
|
import net.minecraft.server.v1_7_R4.MojangsonParser;
|
||||||
import net.minecraft.server.v1_7_R4.NBTBase;
|
import net.minecraft.server.v1_7_R4.NBTBase;
|
||||||
import net.minecraft.server.v1_7_R4.NBTCompressedStreamTools;
|
import net.minecraft.server.v1_7_R4.NBTCompressedStreamTools;
|
||||||
|
import net.minecraft.server.v1_7_R4.NBTTagByte;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
import net.minecraft.server.v1_7_R4.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagDouble;
|
import net.minecraft.server.v1_7_R4.NBTTagDouble;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagFloat;
|
import net.minecraft.server.v1_7_R4.NBTTagFloat;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagInt;
|
import net.minecraft.server.v1_7_R4.NBTTagInt;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagList;
|
import net.minecraft.server.v1_7_R4.NBTTagList;
|
||||||
|
import net.minecraft.server.v1_7_R4.NBTTagLong;
|
||||||
|
import net.minecraft.server.v1_7_R4.NBTTagShort;
|
||||||
import net.minecraft.server.v1_7_R4.NBTTagString;
|
import net.minecraft.server.v1_7_R4.NBTTagString;
|
||||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||||
import net.minecraft.server.v1_7_R4.World;
|
import net.minecraft.server.v1_7_R4.World;
|
||||||
import net.minecraft.server.v1_8_R3.NBTTagByte;
|
|
||||||
import net.minecraft.server.v1_8_R3.NBTTagLong;
|
|
||||||
import net.minecraft.server.v1_8_R3.NBTTagShort;
|
|
||||||
|
|
||||||
public class NMS_v1_7_R4 implements NMSInterface {
|
public class NMS_v1_7_R4 implements NMSInterface {
|
||||||
|
|
||||||
@ -456,48 +457,33 @@ public class NMS_v1_7_R4 implements NMSInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NBTTagByte convertToNBT(byte b) {
|
@Override
|
||||||
return new NBTTagByte(b);
|
public NBTBase convertToNBT(Number number) {
|
||||||
}
|
if (number instanceof Byte) {
|
||||||
|
return new NBTTagByte((byte) number);
|
||||||
public NBTTagShort convertToNBT(short s) {
|
} else if (number instanceof Short) {
|
||||||
return new NBTTagShort(s);
|
return new NBTTagShort((short) number);
|
||||||
}
|
} else if (number instanceof Integer) {
|
||||||
|
return new NBTTagInt((int) number);
|
||||||
public NBTTagInt convertToNBT(int i) {
|
} else if (number instanceof Long) {
|
||||||
return new NBTTagInt(i);
|
return new NBTTagLong((long) number);
|
||||||
}
|
} else if (number instanceof Float) {
|
||||||
|
return new NBTTagFloat((float) number);
|
||||||
public NBTTagLong convertToNBT(long l) {
|
} else if (number instanceof Double) {
|
||||||
return new NBTTagLong(l);
|
return new NBTTagDouble((double) number);
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
public NBTTagFloat convertToNBT(float f) {
|
|
||||||
return new NBTTagFloat(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NBTTagDouble convertToNBT(double d) {
|
|
||||||
return new NBTTagDouble(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public NBTTagString convertToNBT(String string) {
|
public NBTTagString convertToNBT(String string) {
|
||||||
return new NBTTagString(string);
|
return new NBTTagString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object convertToNBT(Number number) {
|
public String getMCId(ItemStack itemStack) {
|
||||||
if (number instanceof Byte)
|
net.minecraft.server.v1_7_R4.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
return convertToNBT((byte) number);
|
String test = Item.REGISTRY.c(nmsItem.getItem());
|
||||||
else if (number instanceof Short)
|
return test;
|
||||||
return convertToNBT((short) number);
|
|
||||||
else if (number instanceof Integer)
|
|
||||||
return convertToNBT((int) number);
|
|
||||||
else if (number instanceof Long)
|
|
||||||
return convertToNBT((long) number);
|
|
||||||
else if (number instanceof Float)
|
|
||||||
return convertToNBT((float) number);
|
|
||||||
else if (number instanceof Double)
|
|
||||||
return convertToNBT((double) number);
|
|
||||||
return number;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -48,6 +48,8 @@ import net.minecraft.server.v1_8_R1.PathfinderGoal;
|
|||||||
import net.minecraft.server.v1_8_R1.PathfinderGoalSelector;
|
import net.minecraft.server.v1_8_R1.PathfinderGoalSelector;
|
||||||
import net.minecraft.server.v1_8_R1.TileEntity;
|
import net.minecraft.server.v1_8_R1.TileEntity;
|
||||||
import net.minecraft.server.v1_8_R1.World;
|
import net.minecraft.server.v1_8_R1.World;
|
||||||
|
import net.minecraft.server.v1_8_R1.Item;
|
||||||
|
import net.minecraft.server.v1_8_R1.MinecraftKey;
|
||||||
|
|
||||||
public class NMS_v1_8_R1 implements NMSInterface {
|
public class NMS_v1_8_R1 implements NMSInterface {
|
||||||
|
|
||||||
@ -560,4 +562,11 @@ public class NMS_v1_8_R1 implements NMSInterface {
|
|||||||
public NBTTagString convertToNBT(String string) {
|
public NBTTagString convertToNBT(String string) {
|
||||||
return new NBTTagString(string);
|
return new NBTTagString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCId(ItemStack itemStack) {
|
||||||
|
net.minecraft.server.v1_8_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
MinecraftKey mcKey = (MinecraftKey) Item.REGISTRY.c(nmsItem.getItem());
|
||||||
|
return mcKey.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -50,6 +50,8 @@ import net.minecraft.server.v1_8_R2.PathfinderGoal;
|
|||||||
import net.minecraft.server.v1_8_R2.PathfinderGoalSelector;
|
import net.minecraft.server.v1_8_R2.PathfinderGoalSelector;
|
||||||
import net.minecraft.server.v1_8_R2.TileEntity;
|
import net.minecraft.server.v1_8_R2.TileEntity;
|
||||||
import net.minecraft.server.v1_8_R2.World;
|
import net.minecraft.server.v1_8_R2.World;
|
||||||
|
import net.minecraft.server.v1_8_R2.Item;
|
||||||
|
import net.minecraft.server.v1_8_R2.MinecraftKey;
|
||||||
|
|
||||||
public class NMS_v1_8_R2 implements NMSInterface {
|
public class NMS_v1_8_R2 implements NMSInterface {
|
||||||
|
|
||||||
@ -566,4 +568,11 @@ public class NMS_v1_8_R2 implements NMSInterface {
|
|||||||
public NBTTagString convertToNBT(String string) {
|
public NBTTagString convertToNBT(String string) {
|
||||||
return new NBTTagString(string);
|
return new NBTTagString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCId(ItemStack itemStack) {
|
||||||
|
net.minecraft.server.v1_8_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
MinecraftKey mcKey = Item.REGISTRY.c(nmsItem.getItem());
|
||||||
|
return mcKey.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -50,6 +50,8 @@ import net.minecraft.server.v1_8_R3.PathfinderGoal;
|
|||||||
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
|
import net.minecraft.server.v1_8_R3.PathfinderGoalSelector;
|
||||||
import net.minecraft.server.v1_8_R3.TileEntity;
|
import net.minecraft.server.v1_8_R3.TileEntity;
|
||||||
import net.minecraft.server.v1_8_R3.World;
|
import net.minecraft.server.v1_8_R3.World;
|
||||||
|
import net.minecraft.server.v1_8_R3.Item;
|
||||||
|
import net.minecraft.server.v1_8_R3.MinecraftKey;
|
||||||
|
|
||||||
public class NMS_v1_8_R3 implements NMSInterface {
|
public class NMS_v1_8_R3 implements NMSInterface {
|
||||||
|
|
||||||
@ -566,4 +568,11 @@ public class NMS_v1_8_R3 implements NMSInterface {
|
|||||||
public NBTTagString convertToNBT(String string) {
|
public NBTTagString convertToNBT(String string) {
|
||||||
return new NBTTagString(string);
|
return new NBTTagString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCId(ItemStack itemStack) {
|
||||||
|
net.minecraft.server.v1_8_R3.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
MinecraftKey mcKey = Item.REGISTRY.c(nmsItem.getItem());
|
||||||
|
return mcKey.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -11,11 +11,9 @@ import java.io.OutputStream;
|
|||||||
import java.io.StreamCorruptedException;
|
import java.io.StreamCorruptedException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
||||||
@ -36,6 +34,8 @@ import ch.njol.yggdrasil.Fields;
|
|||||||
import net.minecraft.server.v1_9_R1.BlockPosition;
|
import net.minecraft.server.v1_9_R1.BlockPosition;
|
||||||
import net.minecraft.server.v1_9_R1.EntityInsentient;
|
import net.minecraft.server.v1_9_R1.EntityInsentient;
|
||||||
import net.minecraft.server.v1_9_R1.IBlockData;
|
import net.minecraft.server.v1_9_R1.IBlockData;
|
||||||
|
import net.minecraft.server.v1_9_R1.Item;
|
||||||
|
import net.minecraft.server.v1_9_R1.MinecraftKey;
|
||||||
import net.minecraft.server.v1_9_R1.MojangsonParseException;
|
import net.minecraft.server.v1_9_R1.MojangsonParseException;
|
||||||
import net.minecraft.server.v1_9_R1.MojangsonParser;
|
import net.minecraft.server.v1_9_R1.MojangsonParser;
|
||||||
import net.minecraft.server.v1_9_R1.NBTBase;
|
import net.minecraft.server.v1_9_R1.NBTBase;
|
||||||
@ -171,7 +171,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
if (entity instanceof EntityInsentient) {
|
if (entity instanceof EntityInsentient) {
|
||||||
((EntityInsentient) entity).setGoalTarget(null);
|
((EntityInsentient) entity).setGoalTarget(null);
|
||||||
if (isTargetSelector) {
|
if (isTargetSelector) {
|
||||||
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
|
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).targetSelector)).iterator();
|
||||||
while (goals.hasNext()) {
|
while (goals.hasNext()) {
|
||||||
Object goal = goals.next();
|
Object goal = goals.next();
|
||||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||||
@ -179,7 +179,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Iterator<?> goals = ((List<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
|
Iterator<?> goals = ((LinkedHashSet<?>) ReflectionUtils.getField("b", PathfinderGoalSelector.class, ((EntityInsentient) entity).goalSelector)).iterator();
|
||||||
while (goals.hasNext()) {
|
while (goals.hasNext()) {
|
||||||
Object goal = goals.next();
|
Object goal = goals.next();
|
||||||
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
if (ReflectionUtils.getField("a", goal.getClass(), goal).getClass() == goalClass) {
|
||||||
@ -208,26 +208,15 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Class<?>[] acceptChange(ChangeMode mode) {
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE || mode == ChangeMode.SET) {
|
if (mode == ChangeMode.ADD || mode == ChangeMode.REMOVE) {
|
||||||
return CollectionUtils.array(String[].class, NBTTagCompound[].class);
|
return CollectionUtils.array(String.class, NBTTagCompound.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void change(NBTTagCompound[] NBT, @Nullable Object[] delta, ChangeMode mode) {
|
public void change(NBTTagCompound[] NBT, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
Bukkit.broadcastMessage("Changing a compound");
|
if (mode == ChangeMode.ADD) {
|
||||||
if (mode == ChangeMode.SET) {
|
|
||||||
Bukkit.broadcastMessage("is setting");
|
|
||||||
if (delta[0] instanceof NBTTagCompound) {
|
|
||||||
NBT[0] = (NBTTagCompound) delta[0];
|
|
||||||
} else {
|
|
||||||
NBTTagCompound parsedNBT = null;
|
|
||||||
parsedNBT = parseRawNBT((String) delta[0]);
|
|
||||||
NBT[0] = parsedNBT;
|
|
||||||
}
|
|
||||||
} else if (mode == ChangeMode.ADD) {
|
|
||||||
Bukkit.broadcastMessage("is adding");
|
|
||||||
if (delta[0] instanceof String) {
|
if (delta[0] instanceof String) {
|
||||||
NBTTagCompound parsedNBT = null;
|
NBTTagCompound parsedNBT = null;
|
||||||
parsedNBT = parseRawNBT((String) delta[0]);
|
parsedNBT = parseRawNBT((String) delta[0]);
|
||||||
@ -236,7 +225,6 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
addToCompound(NBT[0], delta[0]);
|
addToCompound(NBT[0], delta[0]);
|
||||||
}
|
}
|
||||||
} else if (mode == ChangeMode.REMOVE) {
|
} else if (mode == ChangeMode.REMOVE) {
|
||||||
Bukkit.broadcastMessage("is removing");
|
|
||||||
if (delta[0] instanceof NBTTagCompound)
|
if (delta[0] instanceof NBTTagCompound)
|
||||||
return;
|
return;
|
||||||
for (Object s : delta) {
|
for (Object s : delta) {
|
||||||
@ -322,7 +310,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Class<?>[] acceptChange(ChangeMode mode) {
|
public Class<?>[] acceptChange(ChangeMode mode) {
|
||||||
if (mode == ChangeMode.ADD || mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
if (mode == ChangeMode.ADD) {
|
||||||
return CollectionUtils.array(Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, String.class, NBTTagCompound.class, NBTTagList.class);
|
return CollectionUtils.array(Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, String.class, NBTTagCompound.class, NBTTagList.class);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -330,46 +318,16 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void change(NBTTagList[] nbtList, @Nullable Object[] delta, ChangeMode mode) {
|
public void change(NBTTagList[] nbtList, @Nullable Object[] delta, ChangeMode mode) {
|
||||||
Bukkit.broadcastMessage("Changing a NBTList");
|
if (delta.length == 0)
|
||||||
int typeId = 0;
|
|
||||||
if (delta instanceof Byte[]) {
|
|
||||||
typeId = 1;
|
|
||||||
} else if (delta instanceof Short[]) {
|
|
||||||
typeId = 2;
|
|
||||||
} else if (delta instanceof Integer[]) {
|
|
||||||
typeId = 3;
|
|
||||||
} else if (delta instanceof Long[]) {
|
|
||||||
typeId = 4;
|
|
||||||
} else if (delta instanceof Float[]) {
|
|
||||||
typeId = 5;
|
|
||||||
} else if (delta instanceof Double[]) {
|
|
||||||
typeId = 6;
|
|
||||||
} else if (delta instanceof String[]) {
|
|
||||||
typeId = 8;
|
|
||||||
} else if (delta instanceof NBTTagList[]) {
|
|
||||||
typeId = 9;
|
|
||||||
} else if (delta instanceof NBTTagCompound[]) {
|
|
||||||
typeId = 10;
|
|
||||||
} else {
|
|
||||||
Bukkit.broadcastMessage("No compatible class: " + delta.getClass() + "\nStopping...");
|
|
||||||
return;
|
return;
|
||||||
|
if (mode == ChangeMode.ADD) {
|
||||||
|
if (delta[0] instanceof Number) {
|
||||||
|
addToList(nbtList[0], convertToNBT((Number) delta[0]));
|
||||||
|
} else if (delta[0] instanceof String) {
|
||||||
|
addToList(nbtList[0], convertToNBT((String) delta[0]));
|
||||||
|
} else if (delta[0] instanceof NBTBase) {
|
||||||
|
addToList(nbtList[0], delta[0]);
|
||||||
}
|
}
|
||||||
if (mode == ChangeMode.SET) {
|
|
||||||
Bukkit.broadcastMessage("is setting");
|
|
||||||
if (typeId == 9)
|
|
||||||
nbtList[0] = (NBTTagList) delta[0];
|
|
||||||
} else if (mode == ChangeMode.ADD) {
|
|
||||||
if (getContentsId(nbtList[0]) == typeId) {
|
|
||||||
if (delta[0] instanceof Number)
|
|
||||||
addToList(nbtList, convertToNBT((Number) delta[0]));
|
|
||||||
else if (delta[0] instanceof String)
|
|
||||||
addToList(nbtList, convertToNBT((String) delta[0]));
|
|
||||||
else if (delta[0] instanceof NBTTagCompound || delta[0] instanceof NBTTagList)
|
|
||||||
addToList(nbtList, delta[0]);
|
|
||||||
}
|
|
||||||
} else if (mode == ChangeMode.DELETE || mode == ChangeMode.RESET) {
|
|
||||||
Bukkit.broadcastMessage("Is deleting/resetting");
|
|
||||||
nbtList[0] = new NBTTagList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).parser(new Parser<NBTTagList>() {
|
}).parser(new Parser<NBTTagList>() {
|
||||||
@ -558,6 +516,7 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public NBTBase convertToNBT(Number number) {
|
public NBTBase convertToNBT(Number number) {
|
||||||
if (number instanceof Byte) {
|
if (number instanceof Byte) {
|
||||||
return new NBTTagByte((byte) number);
|
return new NBTTagByte((byte) number);
|
||||||
@ -575,7 +534,15 @@ public class NMS_v1_9_R1 implements NMSInterface {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public NBTTagString convertToNBT(String string) {
|
public NBTTagString convertToNBT(String string) {
|
||||||
return new NBTTagString(string);
|
return new NBTTagString(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMCId(ItemStack itemStack) {
|
||||||
|
net.minecraft.server.v1_9_R1.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||||
|
MinecraftKey mcKey = Item.REGISTRY.b(nmsItem.getItem());
|
||||||
|
return mcKey.toString();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user