|
@@ -364,7 +364,7 @@ public class MinecraftFunctions
|
|
return new Location(((EntityPlayer) in[0].get(sc)).world,
|
|
return new Location(((EntityPlayer) in[0].get(sc)).world,
|
|
Utils.getTargetBlock((EntityPlayer) in[0].get(sc), in[1].getInt(sc), in[2].getBoolean(sc)));
|
|
Utils.getTargetBlock((EntityPlayer) in[0].get(sc), in[1].getInt(sc), in[2].getBoolean(sc)));
|
|
}
|
|
}
|
|
- return new Location(((EntityPlayer) in[0].get(sc)).world, Utils.getTargetBlock((EntityPlayer) in[0].get(sc), in[1].getInt(sc)));
|
|
+ return new Location(((EntityPlayer) in[0].get(sc)).world, Utils.getTargetBlock((EntityPlayer) in[0].get(sc), in[1].getInt(sc), true));
|
|
});
|
|
});
|
|
|
|
|
|
parser.registerFunction("player.gettargetentity", (sc, in) -> Utils.getTargetedEntity((EntityPlayer) in[0].get(sc), in[1].getDouble(sc), getClass(in[2].getString(sc))));
|
|
parser.registerFunction("player.gettargetentity", (sc, in) -> Utils.getTargetedEntity((EntityPlayer) in[0].get(sc), in[1].getDouble(sc), getClass(in[2].getString(sc))));
|
|
@@ -455,25 +455,14 @@ public class MinecraftFunctions
|
|
p.sendPlayerAbilities();
|
|
p.sendPlayerAbilities();
|
|
return true;
|
|
return true;
|
|
});
|
|
});
|
|
- parser.registerFunction("player.near", (sc, in) ->
|
|
+ parser.registerFunction("player.near", (sc, in) -> Utils.getPlayers((Entity) in[0].get(sc), in[1].getDouble(sc)));
|
|
- {
|
|
+ parser.registerFunction("player.getinvslot", (sc, in) -> ((EntityPlayer) in[0].get(sc)).inventory.mainInventory.get(in[1].getInt(sc)));
|
|
- EntityPlayer p = (EntityPlayer) in[1].get(sc);
|
|
|
|
- in[0].set(sc, Utils.getPlayers(p, in[2].getDouble(sc)));
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("player.getinvslot", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- return ((EntityPlayer) in[0].get(sc)).inventory.mainInventory.get(in[1].getInt(sc));
|
|
|
|
- });
|
|
|
|
parser.registerFunction("player.setinvslot", (sc, in) ->
|
|
parser.registerFunction("player.setinvslot", (sc, in) ->
|
|
{
|
|
{
|
|
((EntityPlayer) in[0].get(sc)).inventory.mainInventory.set(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
((EntityPlayer) in[0].get(sc)).inventory.mainInventory.set(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
- parser.registerFunction("player.getenderslot", (sc, in) ->
|
|
+ parser.registerFunction("player.getenderslot", (sc, in) -> ((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().getStackInSlot(in[1].getInt(sc)));
|
|
- {
|
|
|
|
- return ((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().getStackInSlot(in[1].getInt(sc));
|
|
|
|
- });
|
|
|
|
parser.registerFunction("player.setenderslot", (sc, in) ->
|
|
parser.registerFunction("player.setenderslot", (sc, in) ->
|
|
{
|
|
{
|
|
((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().setInventorySlotContents(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().setInventorySlotContents(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
@@ -610,9 +599,11 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
parser.registerFunction("world.settime", (sc, in) ->
|
|
parser.registerFunction("world.settime", (sc, in) ->
|
|
{
|
|
{
|
|
- ((World) in[0].get(sc)).setWorldTime(in[0].getLong(sc));
|
|
+ ((World) in[0].get(sc)).setWorldTime(in[1].getLong(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
+ parser.registerFunction("world.gettime", (sc, in) -> (double) ((World) in[0].get(sc)).getWorldTime());
|
|
|
|
+ parser.registerFunction("world.hasstorm", (sc, in) -> ((World) in[0].get(sc)).isRaining());
|
|
parser.registerFunction("world.clearweather", (sc, in) ->
|
|
parser.registerFunction("world.clearweather", (sc, in) ->
|
|
{
|
|
{
|
|
WorldInfo wi = ((World) in[0].get(sc)).getWorldInfo();
|
|
WorldInfo wi = ((World) in[0].get(sc)).getWorldInfo();
|
|
@@ -749,7 +740,7 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
parser.registerFunction("item.addflag", (sc, in) ->
|
|
parser.registerFunction("item.addflag", (sc, in) ->
|
|
{
|
|
{
|
|
- ItemStackUtils.addItemFlag((ItemStack) in[0].get(sc), ItemStackUtils.ItemFlag.valueOf(in[0].getString(sc).toUpperCase()));
|
|
+ ItemStackUtils.addItemFlag((ItemStack) in[0].get(sc), ItemStackUtils.ItemFlag.valueOf(in[1].getString(sc).toUpperCase()));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("item.addattribute", (sc, in) ->
|
|
parser.registerFunction("item.addattribute", (sc, in) ->
|
|
@@ -866,8 +857,6 @@ public class MinecraftFunctions
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- parser.registerFunction("loc.gettime", (sc, in) -> (double) ((Location) in[0].get(sc)).getWorld().getWorldTime());
|
|
|
|
- parser.registerFunction("loc.hasstorm", (sc, in) -> ((Location) in[0].get(sc)).getWorld().isRaining());
|
|
|
|
parser.registerFunction("loc.isbetween", (sc, in) ->
|
|
parser.registerFunction("loc.isbetween", (sc, in) ->
|
|
{
|
|
{
|
|
Location l1 = (Location) in[0].get(sc);
|
|
Location l1 = (Location) in[0].get(sc);
|
|
@@ -877,6 +866,34 @@ public class MinecraftFunctions
|
|
l1.getY() >= Math.min(l2.getY(), l3.getY()) && l1.getY() <= Math.max(l2.getY(), l3.getY()) &&
|
|
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());
|
|
l1.getZ() >= Math.min(l2.getZ(), l3.getZ()) && l1.getZ() <= Math.max(l2.getZ(), l3.getZ());
|
|
});
|
|
});
|
|
|
|
+ parser.registerFunction("loc.sort", (sc, in) ->
|
|
|
|
+ {
|
|
|
|
+ Location l1 = (Location) in[0].get(sc);
|
|
|
|
+ Location l2 = (Location) in[1].get(sc);
|
|
|
|
+
|
|
|
|
+ if(l1.getX() > l2.getX())
|
|
|
|
+ {
|
|
|
|
+ double tmp = l1.getX();
|
|
|
|
+ l1.setX(l2.getX());
|
|
|
|
+ l2.setX(tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(l1.getY() > l2.getY())
|
|
|
|
+ {
|
|
|
|
+ double tmp = l1.getY();
|
|
|
|
+ l1.setY(l2.getY());
|
|
|
|
+ l2.setY(tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(l1.getZ() > l2.getZ())
|
|
|
|
+ {
|
|
|
|
+ double tmp = l1.getZ();
|
|
|
|
+ l1.setZ(l2.getZ());
|
|
|
|
+ l2.setZ(tmp);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Void.TYPE;
|
|
|
|
+ });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1429,7 +1446,7 @@ public class MinecraftFunctions
|
|
BlockPos pos = l.getBlockPos();
|
|
BlockPos pos = l.getBlockPos();
|
|
if(!w.isBlockLoaded(pos))
|
|
if(!w.isBlockLoaded(pos))
|
|
{
|
|
{
|
|
- return false;
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
String type = in[0].getString(sc);
|
|
String type = in[0].getString(sc);
|
|
@@ -1437,9 +1454,11 @@ public class MinecraftFunctions
|
|
double y = l.getY();
|
|
double y = l.getY();
|
|
double z = l.getZ();
|
|
double z = l.getZ();
|
|
|
|
|
|
- if (EntityList.LIGHTNING_BOLT.equals(new ResourceLocation(type)))
|
|
+ if(EntityList.LIGHTNING_BOLT.equals(new ResourceLocation(type)))
|
|
{
|
|
{
|
|
- w.addWeatherEffect(new EntityLightningBolt(w, x, y, z, false));
|
|
+ Entity ent = new EntityLightningBolt(w, x, y, z, false);
|
|
|
|
+ w.addWeatherEffect(ent);
|
|
|
|
+ return ent;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1455,7 +1474,7 @@ public class MinecraftFunctions
|
|
}
|
|
}
|
|
catch(NBTException ex)
|
|
catch(NBTException ex)
|
|
{
|
|
{
|
|
- return false;
|
|
+ return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1463,7 +1482,7 @@ public class MinecraftFunctions
|
|
Entity entity = AnvilChunkLoader.readWorldEntityPos(nbttagcompound, w, x, y, z, true);
|
|
Entity entity = AnvilChunkLoader.readWorldEntityPos(nbttagcompound, w, x, y, z, true);
|
|
if(entity == null)
|
|
if(entity == null)
|
|
{
|
|
{
|
|
- return false;
|
|
+ return null;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -1473,15 +1492,10 @@ public class MinecraftFunctions
|
|
((EntityLiving) entity).onInitialSpawn(w.getDifficultyForLocation(new BlockPos(entity)), null);
|
|
((EntityLiving) entity).onInitialSpawn(w.getDifficultyForLocation(new BlockPos(entity)), null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return entity;
|
|
}
|
|
}
|
|
- return true;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("entity.near", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- Entity ent = (Entity) in[1].get(sc);
|
|
|
|
- in[0].set(sc, Utils.getLiving(ent, in[2].getDouble(sc)));
|
|
|
|
- return Void.TYPE;
|
|
|
|
});
|
|
});
|
|
|
|
+ parser.registerFunction("entity.near", (sc, in) -> Utils.getLiving((Entity) in[0].get(sc), in[1].getDouble(sc)));
|
|
parser.registerFunction("entity.setspeed", (sc, in) ->
|
|
parser.registerFunction("entity.setspeed", (sc, in) ->
|
|
{
|
|
{
|
|
((EntityLivingBase) in[0].get(sc)).getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(in[1].getDouble(sc));
|
|
((EntityLivingBase) in[0].get(sc)).getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(in[1].getDouble(sc));
|
|
@@ -1526,7 +1540,7 @@ public class MinecraftFunctions
|
|
|
|
|
|
parser.registerFunction("villager.showtrades", (sc, in) ->
|
|
parser.registerFunction("villager.showtrades", (sc, in) ->
|
|
{
|
|
{
|
|
- ((EntityPlayer) in[0].get(sc)).displayVillagerTradeGui(((EntityVillager) in[1].get(sc)));
|
|
+ ((EntityPlayerMP) in[0].get(sc)).displayVillagerTradeGui(((EntityVillager) in[1].get(sc)));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("villager.cleartrades", (sc, in) ->
|
|
parser.registerFunction("villager.cleartrades", (sc, in) ->
|
|
@@ -1698,143 +1712,41 @@ public class MinecraftFunctions
|
|
|
|
|
|
parser.registerFunction("databank.prepare", (sc, in) ->
|
|
parser.registerFunction("databank.prepare", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ PreparedStatement p = KajetansMod.databank.prepareUnsafeStatement(in[0].getString(sc));
|
|
- {
|
|
+ sc.addCloseable(p);
|
|
- PreparedStatement p = KajetansMod.databank.prepareUnsafeStatement(in[0].getString(sc));
|
|
+ return p;
|
|
- sc.addCloseable(p);
|
|
|
|
- return p;
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
});
|
|
});
|
|
parser.registerFunction("databank.setint", (sc, in) ->
|
|
parser.registerFunction("databank.setint", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ ((PreparedStatement) in[0].get(sc)).setInt(in[1].getInt(sc), in[2].getInt(sc));
|
|
- {
|
|
|
|
- ((PreparedStatement) in[0].get(sc)).setInt(in[1].getInt(sc), in[2].getInt(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("databank.setlong", (sc, in) ->
|
|
parser.registerFunction("databank.setlong", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ ((PreparedStatement) in[0].get(sc)).setLong(in[1].getInt(sc), in[2].getLong(sc));
|
|
- {
|
|
|
|
- ((PreparedStatement) in[0].get(sc)).setLong(in[1].getInt(sc), in[2].getLong(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("databank.setdouble", (sc, in) ->
|
|
parser.registerFunction("databank.setdouble", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ ((PreparedStatement) in[0].get(sc)).setDouble(in[1].getInt(sc), in[2].getDouble(sc));
|
|
- {
|
|
|
|
- ((PreparedStatement) in[0].get(sc)).setDouble(in[1].getInt(sc), in[2].getDouble(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("databank.setstring", (sc, in) ->
|
|
parser.registerFunction("databank.setstring", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ ((PreparedStatement) in[0].get(sc)).setString(in[1].getInt(sc), in[2].getString(sc));
|
|
- {
|
|
|
|
- ((PreparedStatement) in[0].get(sc)).setString(in[1].getInt(sc), in[2].getString(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
parser.registerFunction("databank.setbool", (sc, in) ->
|
|
parser.registerFunction("databank.setbool", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ ((PreparedStatement) in[0].get(sc)).setBoolean(in[1].getInt(sc), in[2].getBoolean(sc));
|
|
- {
|
|
|
|
- ((PreparedStatement) in[0].get(sc)).setBoolean(in[1].getInt(sc), in[2].getBoolean(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
- parser.registerFunction("databank.getint", (sc, in) ->
|
|
+ parser.registerFunction("databank.getint", (sc, in) -> (double) ((ResultSet) in[0].get(sc)).getInt(in[1].getInt(sc)));
|
|
- {
|
|
+ parser.registerFunction("databank.getlong", (sc, in) -> (double) ((ResultSet) in[0].get(sc)).getLong(in[1].getInt(sc)));
|
|
- try
|
|
+ parser.registerFunction("databank.getdouble", (sc, in) -> ((ResultSet) in[0].get(sc)).getDouble(in[1].getInt(sc)));
|
|
- {
|
|
+ parser.registerFunction("databank.getstring", (sc, in) -> ((ResultSet) in[0].get(sc)).getString(in[1].getInt(sc)));
|
|
- return (double) ((ResultSet) in[0].get(sc)).getInt(in[1].getInt(sc));
|
|
+ parser.registerFunction("databank.getbool", (sc, in) -> ((ResultSet) in[0].get(sc)).getBoolean(in[1].getInt(sc)));
|
|
- }
|
|
+ parser.registerFunction("databank.execute", (sc, in) -> ((PreparedStatement) in[0].get(sc)).executeQuery());
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("databank.getlong", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return (double) ((ResultSet) in[0].get(sc)).getLong(in[1].getInt(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("databank.getdouble", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return ((ResultSet) in[0].get(sc)).getDouble(in[1].getInt(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("databank.getstring", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return ((ResultSet) in[0].get(sc)).getString(in[1].getInt(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("databank.getbool", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return ((ResultSet) in[0].get(sc)).getBoolean(in[1].getInt(sc));
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("databank.execute", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return ((PreparedStatement) in[0].get(sc)).executeQuery();
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
parser.registerFunction("databank.workerexecute", (sc, in) ->
|
|
parser.registerFunction("databank.workerexecute", (sc, in) ->
|
|
{
|
|
{
|
|
final PreparedStatement p = (PreparedStatement) in[0].get(sc);
|
|
final PreparedStatement p = (PreparedStatement) in[0].get(sc);
|
|
@@ -1843,7 +1755,20 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- p.execute();
|
|
+ p.execute();
|
|
|
|
+ }
|
|
|
|
+ catch(SQLException ex)
|
|
|
|
+ {
|
|
|
|
+ KajetansMod.scheduler.scheduleTask(() ->
|
|
|
|
+ {
|
|
|
|
+ ChatChannel.getDevChannel().sendWarning("Worker error in script '" + name + "'");
|
|
|
|
+ ChatChannel.getDevChannel().sendWarning(ex.getLocalizedMessage());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ sc.removeCloseable(p);
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ p.close();
|
|
}
|
|
}
|
|
catch(SQLException ex)
|
|
catch(SQLException ex)
|
|
{
|
|
{
|
|
@@ -1856,82 +1781,18 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
- parser.registerFunction("databank.next", (sc, in) ->
|
|
+ parser.registerFunction("databank.next", (sc, in) -> ((ResultSet) in[0].get(sc)).next());
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return ((ResultSet) in[0].get(sc)).next();
|
|
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
parser.registerFunction("databank.close", (sc, in) ->
|
|
parser.registerFunction("databank.close", (sc, in) ->
|
|
{
|
|
{
|
|
- try
|
|
+ AutoCloseable auto = (AutoCloseable) in[0].get(sc);
|
|
- {
|
|
+ auto.close();
|
|
- ((ResultSet) in[0].get(sc)).close();
|
|
+ sc.removeCloseable(auto);
|
|
- return Void.TYPE;
|
|
+ return Void.TYPE;
|
|
- }
|
|
|
|
- catch(SQLException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalArgumentException(ex.getMessage());
|
|
|
|
- }
|
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- parser.registerFunction("plot.add", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final Location l1 = (Location) in[0].get(sc);
|
|
|
|
- final Location l2 = (Location) in[1].get(sc);
|
|
|
|
- final BlockPos pos1 = l1.getBlockPos();
|
|
|
|
- final BlockPos pos2 = l2.getBlockPos();
|
|
|
|
- final int x1 = pos1.getX();
|
|
|
|
- final int y1 = pos1.getY();
|
|
|
|
- final int z1 = pos1.getZ();
|
|
|
|
- final int x2 = pos2.getX();
|
|
|
|
- final int y2 = pos2.getY();
|
|
|
|
- final int z2 = pos2.getZ();
|
|
|
|
- final String world = ModDimensions.getWorldName(l1.getWorld());
|
|
|
|
- final String name = in[2].getString(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.plots.add(x1, y1, z1, x2, y2, z2, world, name);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("plot.remove", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final int plotId = in[0].getInt(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.plots.remove(plotId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("plot.addplayer", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final int plotId = in[0].getInt(sc);
|
|
|
|
- final int playerId = in[1].getInt(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.plots.addPlayer(plotId, playerId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("plot.removeplayer", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final int plotId = in[0].getInt(sc);
|
|
|
|
- final int playerId = in[1].getInt(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.plots.removePlayer(plotId, playerId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
parser.registerFunction("plot.getids", (sc, in) ->
|
|
parser.registerFunction("plot.getids", (sc, in) ->
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
@@ -1943,89 +1804,16 @@ public class MinecraftFunctions
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
return KajetansMod.plots.canBuild(l.getWorld(), l.getBlockPos(), (EntityPlayer) in[1].get(sc));
|
|
return KajetansMod.plots.canBuild(l.getWorld(), l.getBlockPos(), (EntityPlayer) in[1].get(sc));
|
|
});
|
|
});
|
|
- parser.registerFunction("plot.getname", (sc, in) -> KajetansMod.plots.getName(in[0].getInt(sc)));
|
|
|
|
- parser.registerFunction("plot.doesintersect", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- Location l = (Location) in[0].get(sc);
|
|
|
|
- BlockPos l1 = l.getBlockPos();
|
|
|
|
- BlockPos l2 = ((Location) in[1].get(sc)).getBlockPos();
|
|
|
|
- return KajetansMod.plots.isOverlapping(l1.getX(), l1.getY(), l1.getZ(), l2.getX(), l2.getY(), l2.getZ(), l.getWorld());
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- parser.registerFunction("protect.add", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final Location l1 = (Location) in[0].get(sc);
|
|
|
|
- final BlockPos pos1 = l1.getBlockPos();
|
|
|
|
- final int x1 = pos1.getX();
|
|
|
|
- final int y1 = pos1.getY();
|
|
|
|
- final int z1 = pos1.getZ();
|
|
|
|
- final int playerId = in[1].getInt(sc);
|
|
|
|
- final String world = ModDimensions.getWorldName(l1.getWorld());
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.blocks.getDatabank().add(x1, y1, z1, world, playerId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("protect.remove", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final Location l1 = (Location) in[0].get(sc);
|
|
|
|
- final BlockPos pos1 = l1.getBlockPos();
|
|
|
|
- final int x1 = pos1.getX();
|
|
|
|
- final int y1 = pos1.getY();
|
|
|
|
- final int z1 = pos1.getZ();
|
|
|
|
- final String world = ModDimensions.getWorldName(l1.getWorld());
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.blocks.getDatabank().remove(x1, y1, z1, world);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("protect.addplayer", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final Location l1 = (Location) in[0].get(sc);
|
|
|
|
- final BlockPos pos1 = l1.getBlockPos();
|
|
|
|
- final int x1 = pos1.getX();
|
|
|
|
- final int y1 = pos1.getY();
|
|
|
|
- final int z1 = pos1.getZ();
|
|
|
|
- final String world = ModDimensions.getWorldName(l1.getWorld());
|
|
|
|
- final int playerId = in[1].getInt(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.blocks.getDatabank().addPlayer(x1, y1, z1, world, playerId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
- parser.registerFunction("protect.removeplayer", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- final Location l1 = (Location) in[0].get(sc);
|
|
|
|
- final BlockPos pos1 = l1.getBlockPos();
|
|
|
|
- final int x1 = pos1.getX();
|
|
|
|
- final int y1 = pos1.getY();
|
|
|
|
- final int z1 = pos1.getZ();
|
|
|
|
- final String world = ModDimensions.getWorldName(l1.getWorld());
|
|
|
|
- final int playerId = in[1].getInt(sc);
|
|
|
|
- KajetansMod.scheduler.getWorker().add(() ->
|
|
|
|
- {
|
|
|
|
- KajetansMod.blocks.getDatabank().removePlayer(x1, y1, z1, world, playerId);
|
|
|
|
- });
|
|
|
|
- return Void.TYPE;
|
|
|
|
- });
|
|
|
|
parser.registerFunction("protect.hasaccess", (sc, in) ->
|
|
parser.registerFunction("protect.hasaccess", (sc, in) ->
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
BlockPos pos = l.getBlockPos();
|
|
BlockPos pos = l.getBlockPos();
|
|
return KajetansMod.blocks.getDatabank().hasAccess(pos, l.getWorld(), (EntityPlayer) in[1].get(sc));
|
|
return KajetansMod.blocks.getDatabank().hasAccess(pos, l.getWorld(), (EntityPlayer) in[1].get(sc));
|
|
});
|
|
});
|
|
- parser.registerFunction("protect.getids", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- Location l = (Location) in[0].get(sc);
|
|
|
|
- BlockPos pos = l.getBlockPos();
|
|
|
|
- return KajetansMod.blocks.getDatabank().getAllIds(pos.getX(), pos.getY(), pos.getZ(), ModDimensions.getWorldName(l.getWorld()));
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2315,7 +2103,6 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
String data = SnuviUtils.connect(sc, in, 1).replace('\'', '"');
|
|
String data = SnuviUtils.connect(sc, in, 1).replace('\'', '"');
|
|
-
|
|
|
|
try
|
|
try
|
|
{
|
|
{
|
|
NBTTagCompound nbt = JsonToNBT.getTagFromJson(data);
|
|
NBTTagCompound nbt = JsonToNBT.getTagFromJson(data);
|
|
@@ -2588,7 +2375,7 @@ public class MinecraftFunctions
|
|
doForGroup(group, sc, p -> p.sendMessage(text));
|
|
doForGroup(group, sc, p -> p.sendMessage(text));
|
|
}
|
|
}
|
|
|
|
|
|
- private static ITextComponent concat(Script sc, int start, String pre, InputProvider... ob)
|
|
+ private static ITextComponent concat(Script sc, int start, String pre, InputProvider... ob) throws Exception
|
|
{
|
|
{
|
|
TextComponentString text = new TextComponentString(pre);
|
|
TextComponentString text = new TextComponentString(pre);
|
|
Object o;
|
|
Object o;
|
|
@@ -2606,4 +2393,4 @@ public class MinecraftFunctions
|
|
}
|
|
}
|
|
return text;
|
|
return text;
|
|
}
|
|
}
|
|
-}
|
|
+}
|