|
@@ -60,14 +60,17 @@ import net.minecraft.entity.passive.EntityVillager;
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
|
|
+import net.minecraft.entity.projectile.EntityPotion;
|
|
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
|
|
import net.minecraft.inventory.IInventory;
|
|
|
import net.minecraft.item.Item;
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
import net.minecraft.network.play.server.SPacketSpawnPosition;
|
|
|
+import net.minecraft.potion.PotionUtils;
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
import net.minecraft.tileentity.TileEntityChest;
|
|
|
import net.minecraft.tileentity.TileEntitySign;
|
|
|
+import net.minecraft.util.DamageSource;
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
import net.minecraft.util.EnumParticleTypes;
|
|
|
import net.minecraft.util.SoundCategory;
|
|
@@ -162,8 +165,8 @@ public class QuestParser
|
|
|
// TODO Utils.shootItemWithEvent((EntityPlayer) args[0], ((ItemStack) args[5]).clone(), QuestUtils.getDouble(args[1]), QuestUtils.getDouble(args[2]), QuestUtils.getDouble(args[3]), QuestUtils.getDouble(args[4])));
|
|
|
registerConsumer(list, "player.shootprojectile", (args, qd) -> nothing());
|
|
|
// TODO Utils.shootProjectile(((EntityPlayer) args[0]), (Class<? extends Projectile>) getClass("org.bukkit.entity." + args[1]), QuestUtils.getDouble(args[2])));
|
|
|
- registerConsumer(list, "player.respawn", (args, qd) ->
|
|
|
- ((EntityPlayer) args[0]).respawnPlayer());
|
|
|
+ registerConsumer(list, "player.respawn", (args, qd) -> nothing()
|
|
|
+ /* TODO ((EntityPlayerMP) args[0]).respawnPlayer()*/);
|
|
|
registerConsumer(list, "player.inventorytolist", (args, qd) ->
|
|
|
qd.setVar(args[0], ((EntityPlayer) args[1]).inventory.mainInventory));
|
|
|
registerFunction(list, "player.getamount", (args, qd) ->
|
|
@@ -492,7 +495,7 @@ public class QuestParser
|
|
|
registerConsumer(list, "entity.setname", (args, qd) ->
|
|
|
nameEntity(args));
|
|
|
registerConsumer(list, "entity.throw", (args, qd) ->
|
|
|
- ((Entity) args[0]).setVelocity(QuestUtils.getDouble(args[1]), QuestUtils.getDouble(args[2]), QuestUtils.getDouble(args[3])));
|
|
|
+ throwEntity(args));
|
|
|
registerConsumer(list, "entity.teleport", (args, qd) ->
|
|
|
Utils.teleportEntity((Entity) args[0], (Location) args[1]));
|
|
|
registerConsumer(list, "entity.setequip", (args, qd) ->
|
|
@@ -1320,7 +1323,7 @@ public class QuestParser
|
|
|
return;
|
|
|
}
|
|
|
EntityPlayer p = qd.getPlayers().get(0);
|
|
|
- if(Permission.hasPermission(p, Permissions.SCRIPT_ERROR))
|
|
|
+ if(Permission.has(p, Permissions.SCRIPT_ERROR))
|
|
|
{
|
|
|
qd.loadNewCode(args[0].toString(), p);
|
|
|
return;
|
|
@@ -1411,27 +1414,35 @@ public class QuestParser
|
|
|
throw new HoldCodeException();
|
|
|
}
|
|
|
|
|
|
+ private void throwEntity(Object[] args)
|
|
|
+ {
|
|
|
+ Entity ent = (Entity) args[0];
|
|
|
+ ent.motionX = QuestUtils.getDouble(args[1]);
|
|
|
+ ent.motionY = QuestUtils.getDouble(args[2]);
|
|
|
+ ent.motionZ = QuestUtils.getDouble(args[3]);
|
|
|
+ }
|
|
|
+
|
|
|
private void damageEntity(Object[] args)
|
|
|
{
|
|
|
if(args.length >= 4)
|
|
|
{
|
|
|
- ((EntityLivingBase) args[0]).damage(QuestUtils.getDouble(args[1]), (Entity) args[2]);
|
|
|
+ ((EntityLivingBase) args[0]).attackEntityFrom(DamageSource.causeMobDamage((EntityLivingBase) args[2]), QuestUtils.getFloat(args[1]));
|
|
|
return;
|
|
|
}
|
|
|
- ((EntityLivingBase) args[0]).damage(QuestUtils.getDouble(args[1]));
|
|
|
+ ((EntityLivingBase) args[0]).attackEntityFrom(DamageSource.GENERIC, QuestUtils.getFloat(args[1]));
|
|
|
}
|
|
|
|
|
|
private boolean isBetween(Object[] args)
|
|
|
{
|
|
|
- Location l1 = (Location) args[0];
|
|
|
- Location l2 = (Location) args[1];
|
|
|
- Location l3 = (Location) args[2];
|
|
|
- return l1.getX() >= Math.min(l2.getX(), l3.getX()) &&
|
|
|
- l1.getX() <= Math.max(l2.getX(), l3.getX()) &&
|
|
|
- l1.getY() >= Math.min(l2.getY(), l3.getY()) &&
|
|
|
- l1.getY() <= Math.max(l2.getY(), l3.getY()) &&
|
|
|
- l1.getZ() >= Math.min(l2.getZ(), l3.getZ()) &&
|
|
|
- l1.getZ() <= Math.max(l2.getZ(), l3.getZ());
|
|
|
+ Vec3d l1 = ((Location) args[0]).getPos();
|
|
|
+ Vec3d l2 = ((Location) args[1]).getPos();
|
|
|
+ Vec3d l3 = ((Location) args[2]).getPos();
|
|
|
+ return l1.xCoord >= Math.min(l2.xCoord, l3.xCoord) &&
|
|
|
+ l1.xCoord <= Math.max(l2.xCoord, l3.xCoord) &&
|
|
|
+ l1.yCoord >= Math.min(l2.yCoord, l3.yCoord) &&
|
|
|
+ l1.yCoord <= Math.max(l2.yCoord, l3.yCoord) &&
|
|
|
+ l1.zCoord >= Math.min(l2.zCoord, l3.zCoord) &&
|
|
|
+ l1.zCoord <= Math.max(l2.zCoord, l3.zCoord);
|
|
|
}
|
|
|
|
|
|
private Number increaseVar(Object var, QuestData qd, int value)
|
|
@@ -1445,13 +1456,15 @@ public class QuestParser
|
|
|
{
|
|
|
Location l1 = (Location) args[0];
|
|
|
Location l2 = (Location) args[1];
|
|
|
- KajetansMod.plots.getDataBank(ProtectionBank.class).addPlot(Math.min(l1.getBlockX(), l2.getBlockX()),
|
|
|
- Math.min(l1.getBlockY(), l2.getBlockY()),
|
|
|
- Math.min(l1.getBlockZ(), l2.getBlockZ()),
|
|
|
- Math.max(l1.getBlockX(), l2.getBlockX()),
|
|
|
- Math.max(l1.getBlockY(), l2.getBlockY()),
|
|
|
- Math.max(l1.getBlockZ(), l2.getBlockZ()),
|
|
|
- l1.getWorld().getName(), null, args[2].toString());
|
|
|
+ BlockPos pos1 = l1.getBlockPos();
|
|
|
+ BlockPos pos2 = l2.getBlockPos();
|
|
|
+ KajetansMod.plots.getDataBank(ProtectionBank.class).addPlot(Math.min(pos1.getX(), pos2.getX()),
|
|
|
+ Math.min(pos1.getY(), pos2.getY()),
|
|
|
+ Math.min(pos1.getZ(), pos2.getZ()),
|
|
|
+ Math.max(pos1.getX(), pos2.getX()),
|
|
|
+ Math.max(pos1.getY(), pos2.getY()),
|
|
|
+ Math.max(pos1.getZ(), pos2.getZ()),
|
|
|
+ ModDimensions.getWorldName(l1.getWorld()), null, args[2].toString());
|
|
|
}
|
|
|
|
|
|
private boolean isEqual(Object[] args)
|
|
@@ -1466,7 +1479,7 @@ public class QuestParser
|
|
|
}
|
|
|
else if(args[1] instanceof ItemStack && args[0] instanceof ItemStack)
|
|
|
{
|
|
|
- return ((ItemStack) args[0]).isSimilar((ItemStack) args[0]);
|
|
|
+ return InventoryUtils.doItemStacksMatch((ItemStack) args[0], (ItemStack) args[1]);
|
|
|
}
|
|
|
else if(args[1] instanceof Number && args[0] instanceof Number)
|
|
|
{
|
|
@@ -1476,9 +1489,11 @@ public class QuestParser
|
|
|
{
|
|
|
Location l = (Location) args[0];
|
|
|
Location l2 = (Location) args[1];
|
|
|
- return l.getBlockX() == l2.getBlockX() &&
|
|
|
- l.getBlockY() == l2.getBlockY() &&
|
|
|
- l.getBlockZ() == l2.getBlockZ();
|
|
|
+ BlockPos pos1 = l.getBlockPos();
|
|
|
+ BlockPos pos2 = l2.getBlockPos();
|
|
|
+ return pos1.getX() == pos2.getX() &&
|
|
|
+ pos1.getY() == pos2.getY() &&
|
|
|
+ pos1.getZ() == pos2.getZ() && l.getWorld().equals(l2.getWorld());
|
|
|
}
|
|
|
return args[0].equals(args[1]);
|
|
|
}
|
|
@@ -1498,19 +1513,22 @@ public class QuestParser
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Inventory newInventory(Location l, QuestData qd, String s)
|
|
|
+ private SnuviInventory newInventory(Location l, QuestData qd, String s)
|
|
|
{
|
|
|
- Inventory inv = ((InventoryHolder) l.getBlock().getState()).getInventory();
|
|
|
- int size = inv.getSize();
|
|
|
+ TileEntityChest chest = (TileEntityChest) l.getWorld().getTileEntity(l.getBlockPos());
|
|
|
+ int size = chest.getSizeInventory();
|
|
|
if(size % 9 != 0)
|
|
|
{
|
|
|
size /= 9;
|
|
|
size++;
|
|
|
size *= 9;
|
|
|
}
|
|
|
- Inventory inv2 = Bukkit.createInventory(new QuestInventoryHolder(qd.getId(), qd.getNewId()), size, s);
|
|
|
- inv2.setContents(inv.getContents());
|
|
|
- return inv2;
|
|
|
+ SnuviInventory inv = new SnuviInventory(s, size, qd.getNewId());
|
|
|
+ for(int i = 0; i < chest.getSizeInventory(); i++)
|
|
|
+ {
|
|
|
+ inv.setInventorySlotContents(i, chest.getStackInSlot(i).copy());
|
|
|
+ }
|
|
|
+ return inv;
|
|
|
}
|
|
|
|
|
|
private void split(Object[] args, QuestData qd)
|
|
@@ -1539,7 +1557,7 @@ public class QuestParser
|
|
|
private String getName(Object[] args)
|
|
|
{
|
|
|
Object o = args[0];
|
|
|
- if(o instanceof Player)
|
|
|
+ if(o instanceof EntityPlayer)
|
|
|
{
|
|
|
return ((EntityPlayer) o).getName();
|
|
|
}
|
|
@@ -1549,22 +1567,21 @@ public class QuestParser
|
|
|
private String getUuid(Object[] args)
|
|
|
{
|
|
|
Object o = args[0];
|
|
|
- if(o instanceof Player)
|
|
|
+ if(o instanceof EntityPlayer)
|
|
|
{
|
|
|
- return ((EntityPlayer) o).getUniqueId().toString();
|
|
|
+ return ((EntityPlayer) o).getUniqueID().toString();
|
|
|
}
|
|
|
return KajetansMod.playerbank.getDataBank().getUUID(o.toString());
|
|
|
}
|
|
|
|
|
|
private String getPotionType(Object[] args)
|
|
|
{
|
|
|
- PotionMeta meta = (PotionMeta) ((SplashPotion) args[0]).getItem().getItemMeta();
|
|
|
- return meta.getBasePotionData().getType().toString();
|
|
|
+ return PotionUtils.getPotionFromItem(((EntityPotion) args[0]).getPotion()).toString();
|
|
|
}
|
|
|
|
|
|
private void setTag(Object[] args)
|
|
|
{
|
|
|
- if(args[0] instanceof Player)
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
{
|
|
|
KajetansMod.playerbank.getDataBank().setTag((EntityPlayer) args[0], args[1].toString(), QuestUtils.getInt(args[2]));
|
|
|
return;
|
|
@@ -1574,7 +1591,7 @@ public class QuestParser
|
|
|
|
|
|
private int getTag(Object[] args)
|
|
|
{
|
|
|
- if(args[0] instanceof Player)
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
{
|
|
|
return KajetansMod.playerbank.getDataBank().getTag((EntityPlayer) args[0], args[1].toString());
|
|
|
}
|
|
@@ -1583,9 +1600,9 @@ public class QuestParser
|
|
|
|
|
|
private void setGlobalVar(Object[] args)
|
|
|
{
|
|
|
- if(args[0] instanceof Player)
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
{
|
|
|
- KajetansMod.quest.getDataBank(QuestBank.class).setVar(args[2].toString(), args[1].toString(), ((EntityPlayer) args[0]).getUniqueId().toString());
|
|
|
+ KajetansMod.quest.getDataBank(QuestBank.class).setVar(args[2].toString(), args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
|
return;
|
|
|
}
|
|
|
KajetansMod.quest.getDataBank(QuestBank.class).setVar(args[2].toString(), args[1].toString(), KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()));
|
|
@@ -1593,9 +1610,9 @@ public class QuestParser
|
|
|
|
|
|
private Object getGlobalVar(Object[] args)
|
|
|
{
|
|
|
- if(args[0] instanceof Player)
|
|
|
+ if(args[0] instanceof EntityPlayer)
|
|
|
{
|
|
|
- return KajetansMod.quest.getDataBank(QuestBank.class).getVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueId().toString());
|
|
|
+ return KajetansMod.quest.getDataBank(QuestBank.class).getVar(args[1].toString(), ((EntityPlayer) args[0]).getUniqueID().toString());
|
|
|
}
|
|
|
return KajetansMod.quest.getDataBank(QuestBank.class).getVar(args[1].toString(), KajetansMod.playerbank.getDataBank().getUUID(args[0].toString()));
|
|
|
}
|
|
@@ -1629,7 +1646,8 @@ public class QuestParser
|
|
|
|
|
|
private void registerEnchantmentRecipe(Object[] args)
|
|
|
{
|
|
|
- Enchantment e = Enchantment.getByName(args[0].toString());
|
|
|
+ // TODO
|
|
|
+ /*Enchantment e = Enchantment.getByName(args[0].toString());
|
|
|
if(e == null)
|
|
|
{
|
|
|
throw new IllegalStringException(args[0].toString());
|
|
@@ -1639,22 +1657,24 @@ public class QuestParser
|
|
|
{
|
|
|
stacks[i] = (ItemStack) args[i + 3];
|
|
|
}
|
|
|
- KajetansMod.customs.registerEnchantmentRecipe(e, QuestUtils.getInt(args[1]), QuestUtils.getInt(args[2]), stacks);
|
|
|
+ KajetansMod.customs.registerEnchantmentRecipe(e, QuestUtils.getInt(args[1]), QuestUtils.getInt(args[2]), stacks);*/
|
|
|
}
|
|
|
|
|
|
private void registerShapelessRecipe(Object[] args)
|
|
|
{
|
|
|
- ItemStack[] stacks = new ItemStack[args.length - 1];
|
|
|
+ // TODO
|
|
|
+ /*ItemStack[] stacks = new ItemStack[args.length - 1];
|
|
|
for(int i = 0; i < stacks.length; i++)
|
|
|
{
|
|
|
stacks[i] = (ItemStack) args[i + 1];
|
|
|
}
|
|
|
- KajetansMod.customs.registerShapelessRecipe((ItemStack) args[0], stacks);
|
|
|
+ KajetansMod.customs.registerShapelessRecipe((ItemStack) args[0], stacks);*/
|
|
|
}
|
|
|
|
|
|
private void registerShapedRecipe(Object[] args)
|
|
|
{
|
|
|
- int counter = 0;
|
|
|
+ // TODO
|
|
|
+ /*int counter = 0;
|
|
|
while(args[counter + 1].getClass() == String.class)
|
|
|
{
|
|
|
counter++;
|
|
@@ -1670,7 +1690,7 @@ public class QuestParser
|
|
|
{
|
|
|
stacks[i] = (ItemStack) args[i + 1 + counter];
|
|
|
}
|
|
|
- KajetansMod.customs.registerShapedRecipe((ItemStack) args[0], s, stacks);
|
|
|
+ KajetansMod.customs.registerShapedRecipe((ItemStack) args[0], s, stacks);*/
|
|
|
}
|
|
|
|
|
|
// -------------------------------------------------------------------------
|
|
@@ -1749,18 +1769,18 @@ public class QuestParser
|
|
|
qd.getPlayers().forEach(p -> c.accept(p));
|
|
|
break;
|
|
|
case "online":
|
|
|
- Bukkit.getOnlinePlayers().forEach(p -> c.accept(p));
|
|
|
+ KajetansMod.server.getPlayerList().getPlayers().forEach(p -> c.accept(p));
|
|
|
break;
|
|
|
case "dev":
|
|
|
if(qd.isScript())
|
|
|
{
|
|
|
- Bukkit.getOnlinePlayers().stream().filter(p -> p.hasPermission("kt.quest.error")).forEach(p -> c.accept(p));
|
|
|
+ KajetansMod.server.getPlayerList().getPlayers().stream().filter(p -> Permission.has(p, Permissions.SCRIPT_ERROR)).forEach(p -> c.accept(p));
|
|
|
return;
|
|
|
}
|
|
|
- qd.getPlayers().stream().filter(p -> p.hasPermission("kt.quest.error")).forEach(p -> c.accept(p));
|
|
|
+ qd.getPlayers().stream().filter(p -> Permission.has(p, Permissions.SCRIPT_ERROR)).forEach(p -> c.accept(p));
|
|
|
break;
|
|
|
case "server":
|
|
|
- c.accept(Bukkit.getConsoleSender());
|
|
|
+ c.accept(KajetansMod.server);
|
|
|
break;
|
|
|
default:
|
|
|
c.accept(Utils.getPlayerByName(group.toString()));
|
|
@@ -1773,7 +1793,8 @@ public class QuestParser
|
|
|
|
|
|
private void sendMessageToGroup(Object group, QuestData qd, String message)
|
|
|
{
|
|
|
- doForGroup(group, qd, p -> p.sendMessage(message));
|
|
|
+ TextComponentString comp = new TextComponentString(message);
|
|
|
+ doForGroup(group, qd, p -> p.sendMessage(comp));
|
|
|
}
|
|
|
|
|
|
public void sendMessageWithSuffix(QuestData qd, String message)
|
|
@@ -1794,7 +1815,7 @@ public class QuestParser
|
|
|
{
|
|
|
Module m = KajetansMod.quest;
|
|
|
String warnMessage = "§4" + message;
|
|
|
- Bukkit.getOnlinePlayers().stream().filter(p -> p.hasPermission("kt.quest.error")).forEach(p -> m.send(p, warnMessage));
|
|
|
+ KajetansMod.server.getPlayerList().getPlayers().stream().filter(p -> Permission.has(p, Permissions.SCRIPT_ERROR)).forEach(p -> m.send(p, warnMessage));
|
|
|
}
|
|
|
|
|
|
private void sendToDevsWithList(QuestData qd, String message)
|