|
@@ -16,13 +16,13 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
import java.util.function.Consumer;
|
|
|
import java.util.stream.Collectors;
|
|
|
import me.hammerle.code.ISnuviLogger;
|
|
|
import me.hammerle.code.Script;
|
|
|
import me.hammerle.code.ScriptUtils;
|
|
|
-import me.hammerle.exceptions.SnuviException;
|
|
|
import me.km.api.Location;
|
|
|
import me.km.api.TitleAPI;
|
|
|
import me.km.dimensions.ModDimensions;
|
|
@@ -77,6 +77,9 @@ import me.hammerle.exceptions.PreScriptException;
|
|
|
import me.hammerle.exceptions.IllegalStringException;
|
|
|
import me.hammerle.code.SnuviParser;
|
|
|
import me.hammerle.exceptions.HoldCodeException;
|
|
|
+import me.hammerle.math.Fraction;
|
|
|
+import me.km.inventory.CustomContainer;
|
|
|
+import net.minecraft.entity.item.EntityItem;
|
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
|
|
|
public class MinecraftFunctions implements ISnuviLogger
|
|
@@ -130,15 +133,15 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
|
|
|
|
|
|
parser.registerFunction("player.getitemamount", (args, qd) ->
|
|
|
- InventoryUtils.searchInventoryFor(((EntityPlayer) args[0]).inventory, (ItemStack) args[2], (boolean) args[1]));
|
|
|
+ new Fraction(InventoryUtils.searchInventoryFor(((EntityPlayer) args[0]).inventory, (ItemStack) args[2], (boolean) args[1])));
|
|
|
parser.registerFunction("player.removeitem", (args, qd) ->
|
|
|
removeItem(args));
|
|
|
parser.registerFunction("player.giveitem", (args, qd) ->
|
|
|
giveItem(args));
|
|
|
- parser.registerConsumer("player.shootprojectile", (args, qd) ->
|
|
|
+ parser.registerFunction("player.shootprojectile", (args, qd) ->
|
|
|
EffectUtils.launchProjectile((EntityPlayer) args[0], getClass(args[1].toString()), ScriptUtils.getDouble(args[2]), args[3]));
|
|
|
parser.registerConsumer("player.respawn", (args, qd) ->
|
|
|
- respawnPlayer(args));
|
|
|
+ respawnPlayer(qd, args));
|
|
|
parser.registerConsumer("player.inventorytolist", (args, qd) ->
|
|
|
qd.setVar(args[0].toString(), ((EntityPlayer) args[1]).inventory.mainInventory));
|
|
|
parser.registerFunction("player.getnearest", (args, qd) ->
|
|
@@ -152,11 +155,11 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("player.setcompass", (args, qd) ->
|
|
|
((EntityPlayerMP) args[0]).connection.sendPacket(new SPacketSpawnPosition(((Location) args[1]).getBlockPos())));
|
|
|
parser.registerFunction("player.gethunger", (args, qd) ->
|
|
|
- ((EntityPlayer) args[0]).getFoodStats().getFoodLevel());
|
|
|
+ new Fraction(((EntityPlayer) args[0]).getFoodStats().getFoodLevel()));
|
|
|
parser.registerConsumer("player.sethunger", (args, qd) ->
|
|
|
((EntityPlayer) args[0]).getFoodStats().setFoodLevel(ScriptUtils.getInt(args[1])));
|
|
|
parser.registerFunction("player.getsaturation", (args, qd) ->
|
|
|
- ReflectionUtils.getSaturation(((EntityPlayer) args[0]).getFoodStats()));
|
|
|
+ Fraction.fromDouble(ReflectionUtils.getSaturation(((EntityPlayer) args[0]).getFoodStats())));
|
|
|
parser.registerConsumer("player.setsaturation", (args, qd) ->
|
|
|
ReflectionUtils.setSaturation(((EntityPlayer) args[0]).getFoodStats(), ScriptUtils.getFloat(args[1])));
|
|
|
parser.registerFunction("player.getname", (args, qd) ->
|
|
@@ -182,11 +185,13 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("player.settag", (args, qd) ->
|
|
|
setTag(args));
|
|
|
parser.registerFunction("player.gettag", (args, qd) ->
|
|
|
- (double) getTag(args));
|
|
|
+ getTag(args));
|
|
|
parser.registerConsumer("player.dropinventory", (args, qd) ->
|
|
|
dropInventory(args));
|
|
|
parser.registerFunction("player.gettarget", (args, qd) ->
|
|
|
- Utils.getPlayerTarget((EntityPlayer) args[0], ScriptUtils.getInt(args[1])));
|
|
|
+ new Location(((EntityPlayer) args[0]).world, Utils.getPlayerTarget((EntityPlayer) args[0], ScriptUtils.getInt(args[1]))));
|
|
|
+ parser.registerFunction("player.gettargetentity", (args, qd) ->
|
|
|
+ Utils.getTargetedEntity((EntityPlayer) args[0], ScriptUtils.getDouble(args[1]), getClass(args[2].toString())));
|
|
|
parser.registerFunction("player.hasquest", (args, qd) ->
|
|
|
KajetansMod.scripts.hasScript((EntityPlayer) args[0]));
|
|
|
parser.registerConsumer("player.action", (args, qd) ->
|
|
@@ -206,13 +211,13 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
|
|
|
|
|
|
parser.registerFunction("players.getamount", (args, qd) ->
|
|
|
- KajetansMod.server.getCurrentPlayerCount());
|
|
|
+ new Fraction(KajetansMod.server.getCurrentPlayerCount()));
|
|
|
parser.registerConsumer("players.tolist", (args, qd) ->
|
|
|
- qd.setVar(args[0].toString(), Arrays.asList(KajetansMod.server.getOnlinePlayerNames())));
|
|
|
+ qd.setVar(args[0].toString(), new ArrayList(KajetansMod.server.getPlayerList().getPlayers())));
|
|
|
parser.registerConsumer("players.toworldlist", (args, qd) ->
|
|
|
qd.setVar(args[0].toString(), new ArrayList(ModDimensions.getWorldFromName(args[1].toString()).playerEntities)));
|
|
|
parser.registerConsumer("players.near", (args, qd) ->
|
|
|
- qd.setVar(args[0].toString(), Utils.getNearbyEntities(((Location) args[1]).getWorld(), ((Location) args[1]).getPos(), ScriptUtils.getDouble(args[2]), EntityPlayer.class).stream().map(p -> p.getName()).collect(Collectors.toList())));
|
|
|
+ qd.setVar(args[0].toString(), new ArrayList(Utils.getNearbyEntities(((Location) args[1]).getWorld(), ((Location) args[1]).getPos(), ScriptUtils.getDouble(args[2]), EntityPlayer.class))));
|
|
|
|
|
|
|
|
|
|
|
@@ -269,11 +274,11 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerFunction("item.gettype", (args, qd) ->
|
|
|
((ItemStack) args[0]).getItem().getRegistryName().toString());
|
|
|
parser.registerFunction("item.getdata", (args, qd) ->
|
|
|
- ((ItemStack) args[0]).getMetadata());
|
|
|
+ new Fraction(((ItemStack) args[0]).getMetadata()));
|
|
|
parser.registerConsumer("item.setdata", (args, qd) ->
|
|
|
((ItemStack) args[0]).setItemDamage(ScriptUtils.getInt(args[1])));
|
|
|
parser.registerFunction("item.getamount", (args, qd) ->
|
|
|
- ((ItemStack) args[0]).getCount());
|
|
|
+ new Fraction(((ItemStack) args[0]).getCount()));
|
|
|
parser.registerConsumer("item.setamount", (args, qd) ->
|
|
|
((ItemStack) args[0]).setCount(ScriptUtils.getInt(args[1])));
|
|
|
parser.registerFunction("item.getname", (args, qd) ->
|
|
@@ -287,7 +292,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("item.addlore", (args, qd) ->
|
|
|
ItemStackUtils.addLore((ItemStack) args[0], ScriptUtils.connect(args, 2), ScriptUtils.getInt(args[1])));
|
|
|
parser.registerFunction("item.getenchantlevel", (args, qd) ->
|
|
|
- EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation(args[1].toString()), (ItemStack) args[0]));
|
|
|
+ new Fraction(EnchantmentHelper.getEnchantmentLevel(Enchantment.getEnchantmentByLocation(args[1].toString()), (ItemStack) args[0])));
|
|
|
parser.registerConsumer("item.setcooldown", (args, qd) ->
|
|
|
((EntityPlayer) args[0]).getCooldownTracker().setCooldown(((ItemStack) args[1]).getItem(), ScriptUtils.getInt(args[2])));
|
|
|
parser.registerFunction("item.gettooltype", (args, qd) ->
|
|
@@ -297,7 +302,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
|
|
|
|
|
|
parser.registerFunction("loc.distance", (args, qd) ->
|
|
|
- ((Location) args[0]).getPos().distanceTo(((Location) args[1]).getPos()));
|
|
|
+ Fraction.fromDouble(((Location) args[0]).getPos().distanceTo(((Location) args[1]).getPos())));
|
|
|
parser.registerConsumer("loc.setyaw", (args, qd) ->
|
|
|
((Location) args[0]).setYaw(ScriptUtils.getFloat(args[1])));
|
|
|
parser.registerConsumer("loc.setpitch", (args, qd) ->
|
|
@@ -307,7 +312,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerFunction("loc.getcoord", (args, qd) ->
|
|
|
getCoordOfLocation(args));
|
|
|
parser.registerFunction("loc.gettime", (args, qd) ->
|
|
|
- ((Long) ((Location) args[0]).getWorld().getWorldTime()).doubleValue());
|
|
|
+ new Fraction(((Location) args[0]).getWorld().getWorldTime()));
|
|
|
parser.registerFunction("loc.hasstorm", (args, qd) ->
|
|
|
((Location) args[0]).getWorld().isRaining());
|
|
|
parser.registerFunction("loc.isbetween", (args, qd) ->
|
|
@@ -319,7 +324,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerFunction("block.gettype", (args, qd) ->
|
|
|
((Location) args[0]).getWorld().getBlockState(((Location) args[0]).getBlockPos()).getBlock().getRegistryName().toString());
|
|
|
parser.registerFunction("block.getdata", (args, qd) ->
|
|
|
- (double) getBlockData((Location) args[0]));
|
|
|
+ getBlockData((Location) args[0]));
|
|
|
parser.registerConsumer("block.clone", (args, qd) ->
|
|
|
cloneBlock(args));
|
|
|
parser.registerConsumer("block.set", (args, qd) ->
|
|
@@ -369,13 +374,13 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
|
|
|
|
|
|
parser.registerFunction("job.getlevel", (args, qd) ->
|
|
|
- (double) KajetansMod.jobs.getLevel((EntityPlayer) args[0], ScriptUtils.getByte(args[1])));
|
|
|
+ new Fraction(KajetansMod.jobs.getLevel((EntityPlayer) args[0], ScriptUtils.getByte(args[1]))));
|
|
|
parser.registerConsumer("job.addlevel", (args, qd) ->
|
|
|
KajetansMod.jobs.addLevel((EntityPlayer) args[0], ScriptUtils.getByte(args[1]), ScriptUtils.getByte(args[2])));
|
|
|
parser.registerConsumer("job.setlevel", (args, qd) ->
|
|
|
KajetansMod.jobs.setLevel((EntityPlayer) args[0], ScriptUtils.getByte(args[1]), ScriptUtils.getByte(args[2])));
|
|
|
parser.registerFunction("job.getxp", (args, qd) ->
|
|
|
- (double) KajetansMod.jobs.getXP((EntityPlayer) args[0], ScriptUtils.getByte(args[1])));
|
|
|
+ new Fraction(KajetansMod.jobs.getXP((EntityPlayer) args[0], ScriptUtils.getByte(args[1]))));
|
|
|
parser.registerConsumer("job.addxp", (args, qd) ->
|
|
|
KajetansMod.jobs.addXP((EntityPlayer) args[0], ScriptUtils.getByte(args[1]), ScriptUtils.getByte(args[2])));
|
|
|
parser.registerConsumer("job.setxp", (args, qd) ->
|
|
@@ -389,17 +394,17 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("job.registerskill", (args, qd) ->
|
|
|
KajetansMod.jobs.registerSkill(ScriptUtils.getByte(args[0]), KajetansMod.skills.getSkill(ScriptUtils.getInt(args[1])), ScriptUtils.getByte(args[2]), ScriptUtils.getByte(args[3])));
|
|
|
parser.registerFunction("job.getamount", (args, qd) ->
|
|
|
- (double) KajetansMod.jobs.getNumberOfJobs());
|
|
|
+ new Fraction(KajetansMod.jobs.getNumberOfJobs()));
|
|
|
parser.registerFunction("job.getname", (args, qd) ->
|
|
|
KajetansMod.jobs.getJobName(ScriptUtils.getByte(args[0])));
|
|
|
parser.registerFunction("job.geteffectlevel", (args, qd) ->
|
|
|
- (double) EffectUtils.getEffectLevel((EntityPlayer) args[0], me.km.effects.Effect.valueOf(args[1].toString())));
|
|
|
+ new Fraction(EffectUtils.getEffectLevel((EntityPlayer) args[0], me.km.effects.Effect.valueOf(args[1].toString()))));
|
|
|
parser.registerFunction("job.hasjob", (args, qd) ->
|
|
|
KajetansMod.jobs.hasJob((EntityPlayer) args[0], ScriptUtils.getByte(args[1])));
|
|
|
parser.registerFunction("job.hasrecipe", (args, qd) ->
|
|
|
KajetansMod.jobs.hasRecipe((EntityPlayer) args[0], ScriptHelper.getItem(args[1].toString())));
|
|
|
parser.registerConsumer("job.getjobs", (args, qd) ->
|
|
|
- qd.setVar(args[0].toString(), KajetansMod.jobs.getJobs((EntityPlayer) args[1]).stream().map(b -> (double) b).collect(Collectors.toList())));
|
|
|
+ qd.setVar(args[0].toString(), KajetansMod.jobs.getJobs((EntityPlayer) args[1]).stream().map(b -> new Fraction(b)).collect(Collectors.toList())));
|
|
|
parser.registerFunction("job.isregmaterial", (args, qd) ->
|
|
|
KajetansMod.jobs.isPreferedMaterial((EntityPlayer) args[0],Block.getBlockFromName(args[1].toString())));
|
|
|
parser.registerConsumer("job.setjob", (args, qd) ->
|
|
@@ -415,7 +420,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("entity.damage", (args, qd) ->
|
|
|
damageEntity(args));
|
|
|
parser.registerFunction("entity.gethealth", (args, qd) ->
|
|
|
- ((EntityLivingBase) args[0]).getHealth());
|
|
|
+ Fraction.fromDouble(((EntityLivingBase) args[0]).getHealth()));
|
|
|
parser.registerConsumer("entity.sethealth", (args, qd) ->
|
|
|
((EntityLivingBase) args[0]).setHealth(ScriptUtils.getFloat(args[1])));
|
|
|
parser.registerConsumer("entity.setname", (args, qd) ->
|
|
@@ -445,7 +450,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("entity.setvars", (args, qd) ->
|
|
|
ScriptVars.setEntityVars(qd, Utils.getNearestEntity(((Location) args[0]).getWorld(), ((Location) args[0]).getPos(), 3, (Class<? extends Entity>) getClass("net.minecraft.entity." + args[1]))));
|
|
|
parser.registerConsumer("entity.addeffect", (args, qd) ->
|
|
|
- EffectUtils.addPotionTo((EntityLivingBase) args[0], Potion.getPotionFromResourceLocation(args[1].toString()), ScriptUtils.getInt(args[2]), ScriptUtils.getInt(args[3])));
|
|
|
+ addEffect(args));
|
|
|
parser.registerFunction("entity.haseffect", (args, qd) ->
|
|
|
((EntityLivingBase) args[0]).isPotionActive(Potion.getPotionFromResourceLocation(args[1].toString())));
|
|
|
parser.registerConsumer("entity.goto", (args, qd) ->
|
|
@@ -462,18 +467,22 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
((Entity) args[0]).setNoGravity(!(boolean) args[1]));
|
|
|
parser.registerConsumer("entity.iswet", (args, qd) ->
|
|
|
((Entity) args[0]).isWet());
|
|
|
+ parser.registerConsumer("entity.setpickupdelay", (args, qd) ->
|
|
|
+ ((EntityItem) args[0]).setPickupDelay(ScriptUtils.getInt(args[1])));
|
|
|
+ parser.registerConsumer("entity.setage", (args, qd) ->
|
|
|
+ ReflectionUtils.setAge((EntityItem) args[0], ScriptUtils.getInt(args[1])));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser.registerFunction("status.getmana", (args, qd) ->
|
|
|
- (double) EnvironmentAPI.getMana(((EntityPlayer) args[0])));
|
|
|
+ new Fraction(EnvironmentAPI.getMana(((EntityPlayer) args[0]))));
|
|
|
parser.registerFunction("status.getcold", (args, qd) ->
|
|
|
- (double) EnvironmentAPI.getCold(((EntityPlayer) args[0])));
|
|
|
+ new Fraction(EnvironmentAPI.getCold(((EntityPlayer) args[0]))));
|
|
|
parser.registerFunction("status.getenergy", (args, qd) ->
|
|
|
- (double) EnvironmentAPI.getEnergy(((EntityPlayer) args[0])));
|
|
|
+ new Fraction(EnvironmentAPI.getEnergy(((EntityPlayer) args[0]))));
|
|
|
parser.registerFunction("status.getthirst", (args, qd) ->
|
|
|
- (double) EnvironmentAPI.getThirst(((EntityPlayer) args[0])));
|
|
|
+ new Fraction(EnvironmentAPI.getThirst(((EntityPlayer) args[0]))));
|
|
|
parser.registerConsumer("status.changemange", (args, qd) ->
|
|
|
EnvironmentAPI.changeMana(((EntityPlayer) args[0]), ScriptUtils.getInt(args[1])));
|
|
|
parser.registerConsumer("status.changecold", (args, qd) ->
|
|
@@ -491,7 +500,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("status.resetthirst", (args, qd) ->
|
|
|
EnvironmentAPI.resetThirst(((EntityPlayer) args[0])));
|
|
|
parser.registerFunction("status.gettemperature", (args, qd) ->
|
|
|
- (double) EnvironmentAPI.getTemperature(((Location) args[0]).getWorld(), ((Location) args[0]).getBlockPos()));
|
|
|
+ new Fraction(EnvironmentAPI.getTemperature(((Location) args[0]).getWorld(), ((Location) args[0]).getBlockPos())));
|
|
|
|
|
|
|
|
|
|
|
@@ -545,11 +554,11 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerFunction("table.get", (args, qd) ->
|
|
|
((Table) args[0]).getElement(ScriptUtils.getInt(args[1]), ScriptUtils.getInt(args[2])));
|
|
|
parser.registerFunction("table.getindexof", (args, qd) ->
|
|
|
- (double) ((Table) args[0]).getIndexOf(args[1]));
|
|
|
+ new Fraction(((Table) args[0]).getIndexOf(args[1])));
|
|
|
parser.registerConsumer("table.setsortcolumn", (args, qd) ->
|
|
|
((Table) args[0]).setSortColumn(ScriptUtils.getInt(args[1])));
|
|
|
parser.registerFunction("table.getsize", (args, qd) ->
|
|
|
- (double) ((Table) args[0]).getSize());
|
|
|
+ new Fraction(((Table) args[0]).getSize()));
|
|
|
|
|
|
|
|
|
|
|
@@ -558,8 +567,8 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
KajetansMod.plots.getDataBank(ProtectionBank.class).hasTag(((Location) args[0]).getWorld(), ((Location) args[0]).getBlockPos(), args[1].toString()));
|
|
|
parser.registerConsumer("plot.add", (args, qd) ->
|
|
|
addPlot(args));
|
|
|
- parser.registerFunction("plot.getid", (args, qd) ->
|
|
|
- KajetansMod.plots.getDataBank(ProtectionBank.class).getFirstRegionId(((Location) args[0]).getWorld(), ((Location) args[0]).getBlockPos()));
|
|
|
+ parser.registerConsumer("plot.getids", (args, qd) ->
|
|
|
+ qd.setVar(args[0].toString(), getPlotIds(args)));
|
|
|
parser.registerFunction("plot.canbuild", (args, qd) ->
|
|
|
KajetansMod.plots.getDataBank(ProtectionBank.class).canBuild(((Location) args[0]).getWorld(), ((Location) args[0]).getBlockPos(), (EntityPlayer) args[1]));
|
|
|
parser.registerFunction("plot.getname", (args, qd) ->
|
|
@@ -575,7 +584,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("quest.playerstolist", (args, qd) ->
|
|
|
qd.setVar(args[0].toString(), new ArrayList<>(((PlayerScript) qd).getPlayers())));
|
|
|
parser.registerFunction("quest.getplayeramount", (args, qd) ->
|
|
|
- ((PlayerScript) qd).getPlayers().size());
|
|
|
+ new Fraction(((PlayerScript) qd).getPlayers().size()));
|
|
|
parser.registerConsumer("quest.start", (args, qd) ->
|
|
|
startPlayerScript(args, qd));
|
|
|
parser.registerFunction("quest.isactive", (args, qd) ->
|
|
@@ -615,7 +624,7 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
parser.registerConsumer("inv.open", (args, qd) ->
|
|
|
new ScriptInventoryHolder((SnuviInventory) args[0], (EntityPlayerMP) args[1], (MinecraftScript) qd).openForPlayer((EntityPlayerMP) args[1]));
|
|
|
parser.registerConsumer("inv.close", (args, qd) ->
|
|
|
- ((EntityPlayer) args[0]).closeScreen());
|
|
|
+ invClose(args));
|
|
|
|
|
|
|
|
|
|
|
@@ -663,25 +672,24 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void printException(SnuviException ex)
|
|
|
+ public void printException(Exception ex)
|
|
|
{
|
|
|
if(KajetansMod.debugMode || KajetansMod.scripts.getSnuviParser().printStack)
|
|
|
{
|
|
|
- printConsoleException(ex, null);
|
|
|
+ printConsoleException(ex, null, -1);
|
|
|
}
|
|
|
- sendToDevsWithSuffix("§cError in '" + ex.getScriptName() + "'");
|
|
|
- printGeneralException(ex);
|
|
|
+ printGeneralException(ex, -1);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void printException(SnuviException ex, Script sc)
|
|
|
+ public void printException(Exception ex, Script sc, int line)
|
|
|
{
|
|
|
if(KajetansMod.debugMode || KajetansMod.scripts.getSnuviParser().printStack)
|
|
|
{
|
|
|
- printConsoleException(ex, sc);
|
|
|
+ printConsoleException(ex, sc, line);
|
|
|
}
|
|
|
sendToDevsWithSuffix("§cError in '" + sc.getName()+ "'");
|
|
|
- printGeneralException(ex);
|
|
|
+ printGeneralException(ex, line);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -696,90 +704,24 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
sendWarningToAllDevs(s);
|
|
|
}
|
|
|
|
|
|
- private void printGeneralException(SnuviException ex)
|
|
|
+ private void printGeneralException(Exception ex, int line)
|
|
|
{
|
|
|
- if(ex.getCode() != null)
|
|
|
+ if(line != -1)
|
|
|
{
|
|
|
- ArrayList<String> list = ex.getWholeCode();
|
|
|
- for(int i = 1; i <= list.size(); i++)
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cZeile " + i + ":", list.get(i - 1));
|
|
|
- }
|
|
|
- }
|
|
|
- if(ex.getLine() != -1)
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cZeilennummer:", String.valueOf(ex.getLine()));
|
|
|
- }
|
|
|
-
|
|
|
- if(ex.getOriginalException() != null)
|
|
|
- {
|
|
|
- Exception another = ex.getOriginalException();
|
|
|
- if(another.getLocalizedMessage() == null)
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cFehler:", another.getClass().getSimpleName());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cFehler:", another.getClass().getSimpleName() + " - " + another.getLocalizedMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cFehler:", ex.getClass().getSimpleName());
|
|
|
- if(ex instanceof PreScriptException)
|
|
|
- {
|
|
|
- sendToDevsWithList("§c" + ((PreScriptException) ex).getException());
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if(ex instanceof IllegalStringException)
|
|
|
- {
|
|
|
- sendToDevsWithHelpList("§cUngültiger Wert:", ((IllegalStringException) ex).getBadString());
|
|
|
+ sendToDevsWithHelpList("§cZeile:", String.valueOf(line));
|
|
|
}
|
|
|
+ sendToDevsWithHelpList("§cFehler:", ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage());
|
|
|
}
|
|
|
|
|
|
- public void printConsoleException(SnuviException ex, Script sc)
|
|
|
+ public void printConsoleException(Exception ex, Script sc, int line)
|
|
|
{
|
|
|
Module m = KajetansMod.scripts;
|
|
|
- m.sendWarningToConsole("Error in '" + (sc == null ? ex.getScriptName() : sc.getName()) + "'");
|
|
|
- if(ex.getCode() != null)
|
|
|
- {
|
|
|
- ArrayList<String> list = ex.getWholeCode();
|
|
|
- for(int i = 1; i <= list.size(); i++)
|
|
|
- {
|
|
|
- m.sendWarningToConsole("Zeile " + i + ": " + list.get(i - 1));
|
|
|
- }
|
|
|
- }
|
|
|
- if(ex.getLine() != -1)
|
|
|
- {
|
|
|
- m.sendWarningToConsole("Zeilennummer: " + ex.getLine());
|
|
|
- }
|
|
|
-
|
|
|
- if(ex.getOriginalException() != null)
|
|
|
- {
|
|
|
- Exception another = ex.getOriginalException();
|
|
|
- if(another.getLocalizedMessage() == null)
|
|
|
- {
|
|
|
- m.sendWarningToConsole("Fehler: " + another.getClass().getSimpleName());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m.sendWarningToConsole("Fehler: " + another.getClass().getSimpleName() + " - " + another.getLocalizedMessage());
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ m.sendWarningToConsole("Error in '" + (sc == null ? "null": sc.getName()) + "'");
|
|
|
+ if(line != -1)
|
|
|
{
|
|
|
- m.sendWarningToConsole("Fehler: " + ex.getClass().getSimpleName());
|
|
|
- if(ex instanceof PreScriptException)
|
|
|
- {
|
|
|
- m.sendWarningToConsole(((PreScriptException) ex).getException());
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- if(ex instanceof IllegalStringException)
|
|
|
- {
|
|
|
- m.sendWarningToConsole("Ungültiger Wert: " + ((IllegalStringException) ex).getBadString());
|
|
|
+ m.sendWarningToConsole("Zeilen: " + line);
|
|
|
}
|
|
|
+ m.sendWarningToConsole("Fehler: " + ex.getClass().getSimpleName() + " - " + ex.getLocalizedMessage());
|
|
|
}
|
|
|
|
|
|
private static void printTable(Object[] args, Script sc)
|
|
@@ -831,16 +773,19 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void respawnPlayer(Object[] args)
|
|
|
+ private static void respawnPlayer(Script sc, Object[] args)
|
|
|
{
|
|
|
- try
|
|
|
+ KajetansMod.scheduler.scheduleTask(() ->
|
|
|
{
|
|
|
- ((EntityPlayerMP) args[0]).connection.processClientStatus(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
|
|
|
- }
|
|
|
- catch(ThreadQuickExitException ex)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ((EntityPlayerMP) args[0]).connection.processClientStatus(new CPacketClientStatus(CPacketClientStatus.State.PERFORM_RESPAWN));
|
|
|
+ }
|
|
|
+ catch(ThreadQuickExitException ex)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
private static Class getClass(String s)
|
|
@@ -855,15 +800,15 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static int getItemAmountChest(Object[] args) throws IllegalStringLocationException, IllegalItemStackStringException
|
|
|
+ private static Fraction getItemAmountChest(Object[] args) throws IllegalStringLocationException, IllegalItemStackStringException
|
|
|
{
|
|
|
Location l = (Location) args[0];
|
|
|
TileEntity te = l.getWorld().getTileEntity(l.getBlockPos());
|
|
|
if(te == null || !(te instanceof TileEntityChest))
|
|
|
{
|
|
|
- return 0;
|
|
|
+ return new Fraction(0);
|
|
|
}
|
|
|
- return InventoryUtils.searchInventoryFor(((TileEntityChest) te), (ItemStack) args[2], (boolean) args[1]);
|
|
|
+ return new Fraction(InventoryUtils.searchInventoryFor(((TileEntityChest) te), (ItemStack) args[2], (boolean) args[1]));
|
|
|
}
|
|
|
|
|
|
private static ItemStack addItemAmountChest(Object[] args) throws IllegalStringLocationException, IllegalItemStackStringException
|
|
@@ -898,17 +843,17 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
switch(args[1].toString())
|
|
|
{
|
|
|
case "x":
|
|
|
- return l.getX();
|
|
|
+ return Fraction.fromDouble(l.getX());
|
|
|
case "y":
|
|
|
- return l.getY();
|
|
|
+ return Fraction.fromDouble(l.getY());
|
|
|
case "z":
|
|
|
- return l.getZ();
|
|
|
+ return Fraction.fromDouble(l.getZ());
|
|
|
case "bx":
|
|
|
- return (double) MathHelper.floor(l.getX());
|
|
|
+ return new Fraction(MathHelper.floor(l.getX()));
|
|
|
case "by":
|
|
|
- return (double) MathHelper.floor(l.getY());
|
|
|
+ return new Fraction(MathHelper.floor(l.getY()));
|
|
|
case "bz":
|
|
|
- return (double) MathHelper.floor(l.getZ());
|
|
|
+ return new Fraction(MathHelper.floor(l.getZ()));
|
|
|
case "w":
|
|
|
return ModDimensions.getWorldName(l.getWorld());
|
|
|
default:
|
|
@@ -1063,6 +1008,19 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
return ItemStack.EMPTY;
|
|
|
}
|
|
|
|
|
|
+ private static void invClose(Object[] args)
|
|
|
+ {
|
|
|
+ EntityPlayer p = (EntityPlayer) args[0];
|
|
|
+ if(p.openContainer instanceof CustomContainer)
|
|
|
+ {
|
|
|
+ ((CustomContainer) p.openContainer).closeSafe(p);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p.closeScreen();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private static void removeEntities(Object[] args) throws IllegalStringLocationException
|
|
|
{
|
|
@@ -1280,6 +1238,15 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
return KajetansMod.playerbank.getDataBank().getUUID(o.toString());
|
|
|
}
|
|
|
|
|
|
+ private static Set<Fraction> getPlotIds(Object[] args)
|
|
|
+ {
|
|
|
+ return KajetansMod.plots.getDataBank(ProtectionBank.class).getRegionIds(
|
|
|
+ ((Location) args[1]).getWorld(),
|
|
|
+ ((Location) args[1]).getBlockPos()).stream()
|
|
|
+ .map(o -> new Fraction(Integer.parseInt(o.toString())))
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+
|
|
|
@SuppressWarnings("")
|
|
|
private static String getPotionType(Object[] args)
|
|
|
{
|
|
@@ -1296,13 +1263,13 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
KajetansMod.playerbank.getDataBank().setTag(KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()), args[1].toString(), ScriptUtils.getInt(args[2]));
|
|
|
}
|
|
|
|
|
|
- private static int getTag(Object[] args)
|
|
|
+ private static Fraction getTag(Object[] args)
|
|
|
{
|
|
|
if(args[0] instanceof EntityPlayer)
|
|
|
{
|
|
|
- return KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) args[0], args[1].toString());
|
|
|
+ return new Fraction(KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) args[0], args[1].toString()));
|
|
|
}
|
|
|
- return KajetansMod.playerbank.getDataBank().getTag(KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()), args[1].toString());
|
|
|
+ return new Fraction(KajetansMod.playerbank.getDataBank().getTag(KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()), args[1].toString()));
|
|
|
}
|
|
|
|
|
|
private static void setGlobalVar(Object[] args)
|
|
@@ -1323,15 +1290,34 @@ public class MinecraftFunctions implements ISnuviLogger
|
|
|
}
|
|
|
return KajetansMod.scripts.getDataBank(ScriptBank.class).getVar(args[1].toString(), KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()));
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private static void addEffect(Object[] args)
|
|
|
+ {
|
|
|
+ EntityLivingBase base = (EntityLivingBase) args[0];
|
|
|
+ Potion potion = Potion.getPotionFromResourceLocation(args[1].toString());
|
|
|
+ if(base == null)
|
|
|
+ {
|
|
|
+ throw new NullPointerException("null not allowed for entity");
|
|
|
+ }
|
|
|
+ else if(potion == null)
|
|
|
+ {
|
|
|
+ throw new NullPointerException("potion does not exist");
|
|
|
+ }
|
|
|
+ EffectUtils.addPotionTo(base, potion, ScriptUtils.getInt(args[2]), ScriptUtils.getInt(args[3]));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private static int getBlockData(Location l)
|
|
|
+ private static Fraction getBlockData(Location l)
|
|
|
{
|
|
|
IBlockState state = l.getWorld().getBlockState(l.getBlockPos());
|
|
|
- return state.getBlock().getMetaFromState(state);
|
|
|
+ return new Fraction(state.getBlock().getMetaFromState(state));
|
|
|
}
|
|
|
|
|
|
private static IBlockState getBlockState(Location l)
|