|
@@ -1,9 +1,11 @@
|
|
|
package me.km.snuviscript;
|
|
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
+import java.io.File;
|
|
|
import me.km.KajetansMod;
|
|
|
import me.km.utils.NBTUtils;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Date;
|
|
|
import java.util.GregorianCalendar;
|
|
|
import java.util.List;
|
|
@@ -91,6 +93,7 @@ import net.minecraft.util.NonNullList;
|
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
import net.minecraft.util.text.TextComponentString;
|
|
|
+import net.minecraft.world.EnumDifficulty;
|
|
|
import net.minecraft.world.GameType;
|
|
|
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
|
|
|
import net.minecraft.world.storage.WorldInfo;
|
|
@@ -281,6 +284,7 @@ public class MinecraftFunctions
|
|
|
}
|
|
|
return KajetansMod.playerbank.getDataBank().getUUID(o.toString());
|
|
|
});
|
|
|
+ parser.registerFunction("player.getid", (sc, in) -> KajetansMod.playerbank.getPlayerId(getUUID(in[0].get(sc))));
|
|
|
parser.registerFunction("player.get", (sc, in) ->
|
|
|
{
|
|
|
return KajetansMod.server.getPlayerList().getPlayerByUUID(getUUID(in[0].get(sc)));
|
|
@@ -467,6 +471,24 @@ public class MinecraftFunctions
|
|
|
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) ->
|
|
|
+ {
|
|
|
+ ((EntityPlayer) in[0].get(sc)).inventory.mainInventory.set(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("player.getenderslot", (sc, in) ->
|
|
|
+ {
|
|
|
+ return ((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().getStackInSlot(in[1].getInt(sc));
|
|
|
+ });
|
|
|
+ parser.registerFunction("player.setenderslot", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityPlayer) in[0].get(sc)).getInventoryEnderChest().setInventorySlotContents(in[1].getInt(sc), ((ItemStack) in[2].get(sc)).copy());
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Players-library
|
|
@@ -544,12 +566,58 @@ public class MinecraftFunctions
|
|
|
{
|
|
|
return ModDimensions.getWorldFromName(in[0].getString(sc));
|
|
|
});
|
|
|
+ parser.registerFunction("world.load", (sc, in) ->
|
|
|
+ {
|
|
|
+ String name = in[0].getString(sc);
|
|
|
+ if(!new File("./" + name).isDirectory())
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return ModDimensions.loadWorld(name, ModDimensions.CUSTOM_WORLD);
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.unload", (sc, in) ->
|
|
|
+ {
|
|
|
+ return ModDimensions.unloadWorld(in[0].getString(sc));
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.getname", (sc, in) ->
|
|
|
+ {
|
|
|
+ return ModDimensions.getWorldName((World) in[0].get(sc));
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.setdiffi", (sc, in) ->
|
|
|
+ {
|
|
|
+ EnumDifficulty diffi = EnumDifficulty.valueOf(in[1].getString(sc).toUpperCase());
|
|
|
+ ((World) in[0].get(sc)).getWorldInfo().setDifficulty(diffi);
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.setgamerule", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((World) in[0].get(sc)).getGameRules().setOrCreateGameRule(in[1].getString(sc), in[2].getString(sc));
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.getgamerule", (sc, in) ->
|
|
|
+ {
|
|
|
+ return ((World) in[0].get(sc)).getGameRules().getString(in[1].getString(sc));
|
|
|
+ });
|
|
|
parser.registerFunction("world.setspawn", (sc, in) ->
|
|
|
{
|
|
|
Location l = ((Location) in[0].get(sc));
|
|
|
l.getWorld().setSpawnPoint(l.getBlockPos());
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("world.getspawn", (sc, in) ->
|
|
|
+ {
|
|
|
+ World w = (World) in[0].get(sc);
|
|
|
+ return new Location(w, w.getSpawnPoint());
|
|
|
+ });
|
|
|
+ parser.registerFunction("world.getall", (sc, in) ->
|
|
|
+ {
|
|
|
+ ArrayList<World> worlds = new ArrayList<>();
|
|
|
+ for(World w : KajetansMod.server.worlds)
|
|
|
+ {
|
|
|
+ worlds.add(w);
|
|
|
+ }
|
|
|
+ return worlds;
|
|
|
+ });
|
|
|
parser.registerFunction("world.settime", (sc, in) ->
|
|
|
{
|
|
|
((World) in[0].get(sc)).setWorldTime(in[0].getLong(sc));
|
|
@@ -1218,6 +1286,11 @@ public class MinecraftFunctions
|
|
|
EffectUtils.addPotionTo(base, potion, in[2].getInt(sc), in[3].getInt(sc));
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
+ parser.registerFunction("entity.cleareffects", (sc, in) ->
|
|
|
+ {
|
|
|
+ ((EntityLivingBase) in[0].get(sc)).clearActivePotions();
|
|
|
+ return Void.TYPE;
|
|
|
+ });
|
|
|
parser.registerFunction("entity.haseffect", (sc, in) -> ((EntityLivingBase) in[0].get(sc)).isPotionActive(Potion.getPotionFromResourceLocation(in[1].getString(sc))));
|
|
|
parser.registerFunction("entity.explode", (sc, in) ->
|
|
|
{
|
|
@@ -1423,56 +1496,148 @@ public class MinecraftFunctions
|
|
|
// ---------------------------------------------------------------------
|
|
|
// Plot-library
|
|
|
// ---------------------------------------------------------------------
|
|
|
- parser.registerFunction("plot.hastag", (sc, in) -> true);//KajetansMod.plots.getDataBank(ProtectionBank.class).hasTag(((Location) in[0].get(sc)).getWorld(), ((Location) in[0].get(sc)).getBlockPos(), in[1].getString(sc)));
|
|
|
parser.registerFunction("plot.add", (sc, in) ->
|
|
|
{
|
|
|
- /*final Location l1 = (Location) in[0].get(sc);
|
|
|
+ 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.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, in[2].getString(sc));
|
|
|
- });*/
|
|
|
+ KajetansMod.plots.removePlayer(plotId, playerId);
|
|
|
+ });
|
|
|
return Void.TYPE;
|
|
|
});
|
|
|
parser.registerFunction("plot.getids", (sc, in) ->
|
|
|
{
|
|
|
- /*Location l = (Location) in[1].get(sc);
|
|
|
- in[0].set(sc, KajetansMod.plots.getDataBank(ProtectionBank.class).getRegionIds(l.getWorld(),
|
|
|
- l.getBlockPos()).stream().map(o -> ((Number) o).doubleValue()).collect(Collectors.toSet())); */
|
|
|
- return Void.TYPE;
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ BlockPos pos = l.getBlockPos();
|
|
|
+ return KajetansMod.plots.getIds(pos.getX(), pos.getY(), pos.getZ(), ModDimensions.getWorldName(l.getWorld()));
|
|
|
});
|
|
|
parser.registerFunction("plot.canbuild", (sc, in) ->
|
|
|
{
|
|
|
- return false;
|
|
|
- /*Location l = (Location) in[0].get(sc);
|
|
|
- return KajetansMod.plots.getDataBank(ProtectionBank.class).canBuild(l.getWorld(), l.getBlockPos(), (EntityPlayer) in[1].get(sc));*/
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ return KajetansMod.plots.canBuild(l.getWorld(), l.getBlockPos(), (EntityPlayer) in[1].get(sc));
|
|
|
});
|
|
|
- parser.registerFunction("plot.getname", (sc, in) ->
|
|
|
+ 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);
|
|
|
- KajetansMod.plots.getDataBank(ProtectionBank.class).getFirstRegionName(l.getWorld(), l.getBlockPos()); */
|
|
|
- return Void.TYPE;
|
|
|
+ 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("plot.doesintersect", (sc, in) ->
|
|
|
+
|
|
|
+ // ---------------------------------------------------------------------
|
|
|
+ // block protection library
|
|
|
+ // ---------------------------------------------------------------------
|
|
|
+ parser.registerFunction("protect.add", (sc, in) ->
|
|
|
{
|
|
|
- return false;
|
|
|
- /*Location l1 = (Location) in[0].get(sc);
|
|
|
- Location l2 = (Location) in[1].get(sc);
|
|
|
- int x1 = (int) Math.min(l1.getX(), l2.getX());
|
|
|
- int x2 = (int) Math.max(l1.getX(), l2.getX());
|
|
|
- int y1 = (int) Math.min(l1.getY(), l2.getY());
|
|
|
- int y2 = (int) Math.max(l1.getY(), l2.getY());
|
|
|
- int z1 = (int) Math.min(l1.getZ(), l2.getZ());
|
|
|
- int z2 = (int) Math.max(l1.getZ(), l2.getZ());
|
|
|
- return KajetansMod.plots.getDataBank(ProtectionBank.class).isPlotOverlapping(x1, y1, z1, x2, y2, z2, l1.getWorld());*/
|
|
|
+ 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) ->
|
|
|
+ {
|
|
|
+ Location l = (Location) in[0].get(sc);
|
|
|
+ BlockPos pos = l.getBlockPos();
|
|
|
+ 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()));
|
|
|
});
|
|
|
|
|
|
// ---------------------------------------------------------------------
|