|
@@ -19,7 +19,6 @@ import me.km.Server;
|
|
import me.km.blockprotections.IBlockProtection;
|
|
import me.km.blockprotections.IBlockProtection;
|
|
import me.km.databank.DataBank;
|
|
import me.km.databank.DataBank;
|
|
import me.km.utils.Location;
|
|
import me.km.utils.Location;
|
|
-import me.km.utils.TitleUtils;
|
|
|
|
import me.km.utils.Utils;
|
|
import me.km.utils.Utils;
|
|
import me.km.world.WorldManager;
|
|
import me.km.world.WorldManager;
|
|
import me.km.effects.EffectUtils;
|
|
import me.km.effects.EffectUtils;
|
|
@@ -28,7 +27,6 @@ import me.km.entities.ModEntities;
|
|
import me.km.inventory.InventoryUtils;
|
|
import me.km.inventory.InventoryUtils;
|
|
import me.km.utils.ItemStackUtils;
|
|
import me.km.utils.ItemStackUtils;
|
|
import me.km.utils.ReflectionUtils;
|
|
import me.km.utils.ReflectionUtils;
|
|
-import me.km.utils.SpecialBlockUtils;
|
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
import net.minecraft.enchantment.Enchantment;
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
import net.minecraft.enchantment.EnchantmentHelper;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.Entity;
|
|
@@ -44,18 +42,15 @@ import net.minecraft.util.math.Vec3d;
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.World;
|
|
import me.km.events.CustomEventCaller;
|
|
import me.km.events.CustomEventCaller;
|
|
import me.km.events.PlayerMoveData;
|
|
import me.km.events.PlayerMoveData;
|
|
-import me.km.exception.IllegalStringException;
|
|
|
|
-import me.km.exception.PlayerNotFoundException;
|
|
|
|
import me.km.inventory.CustomContainer;
|
|
import me.km.inventory.CustomContainer;
|
|
import me.km.networking.ModPacketHandler;
|
|
import me.km.networking.ModPacketHandler;
|
|
import me.km.overrides.ModEntityPlayerMP;
|
|
import me.km.overrides.ModEntityPlayerMP;
|
|
import me.km.permissions.PermissionManager;
|
|
import me.km.permissions.PermissionManager;
|
|
import me.km.playerbank.IPlayerBank;
|
|
import me.km.playerbank.IPlayerBank;
|
|
-import me.km.playerbank.PlayerManager;
|
|
|
|
import me.km.plots.IProtection;
|
|
import me.km.plots.IProtection;
|
|
import me.km.scheduler.SnuviScheduler;
|
|
import me.km.scheduler.SnuviScheduler;
|
|
-import me.km.scoreboard.ScoreboardUtils;
|
|
|
|
import me.km.utils.Mapper;
|
|
import me.km.utils.Mapper;
|
|
|
|
+import net.minecraft.block.Block;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.BlockState;
|
|
import net.minecraft.block.ChestBlock;
|
|
import net.minecraft.block.ChestBlock;
|
|
import net.minecraft.block.CropsBlock;
|
|
import net.minecraft.block.CropsBlock;
|
|
@@ -82,6 +77,8 @@ import net.minecraft.nbt.NBTUtil;
|
|
import net.minecraft.network.play.client.CChatMessagePacket;
|
|
import net.minecraft.network.play.client.CChatMessagePacket;
|
|
import net.minecraft.network.play.client.CClientStatusPacket;
|
|
import net.minecraft.network.play.client.CClientStatusPacket;
|
|
import net.minecraft.network.play.server.SSpawnPositionPacket;
|
|
import net.minecraft.network.play.server.SSpawnPositionPacket;
|
|
|
|
+import net.minecraft.network.play.server.STitlePacket;
|
|
|
|
+import net.minecraft.network.play.server.SUpdateTileEntityPacket;
|
|
import net.minecraft.potion.Effect;
|
|
import net.minecraft.potion.Effect;
|
|
import net.minecraft.potion.EffectInstance;
|
|
import net.minecraft.potion.EffectInstance;
|
|
import net.minecraft.server.MinecraftServer;
|
|
import net.minecraft.server.MinecraftServer;
|
|
@@ -114,7 +111,7 @@ public class MinecraftFunctions
|
|
@SuppressWarnings("")
|
|
@SuppressWarnings("")
|
|
public static void registerFunctions(ScriptManager sm, Scripts scripts,
|
|
public static void registerFunctions(ScriptManager sm, Scripts scripts,
|
|
PermissionManager perms, SnuviScheduler scheduler, MinecraftServer server,
|
|
PermissionManager perms, SnuviScheduler scheduler, MinecraftServer server,
|
|
- IPlayerBank playerBank, PlayerManager pManager, CustomEventCaller cec,
|
|
|
|
|
|
+ IPlayerBank playerBank, CustomEventCaller cec,
|
|
IScriptBank scriptBank, DataBank dataBank, IBlockProtection blockProtection,
|
|
IScriptBank scriptBank, DataBank dataBank, IBlockProtection blockProtection,
|
|
IProtection protection)
|
|
IProtection protection)
|
|
{
|
|
{
|
|
@@ -164,27 +161,31 @@ public class MinecraftFunctions
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
sm.registerFunction("title.settime", (sc, in) ->
|
|
sm.registerFunction("title.settime", (sc, in) ->
|
|
{
|
|
{
|
|
- TitleUtils.setTitleTime((ServerPlayerEntity) in[0].get(sc), in[1].getInt(sc), in[2].getInt(sc), in[3].getInt(sc));
|
|
|
|
|
|
+ ((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(in[1].getInt(sc), in[2].getInt(sc), in[3].getInt(sc)));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("title.clear", (sc, in) ->
|
|
sm.registerFunction("title.clear", (sc, in) ->
|
|
{
|
|
{
|
|
- TitleUtils.clearTitle((ServerPlayerEntity) in[0].get(sc));
|
|
|
|
|
|
+ ServerPlayerEntity p = (ServerPlayerEntity) in[0].get(sc);
|
|
|
|
+ p.connection.sendPacket(new STitlePacket(STitlePacket.Type.CLEAR, null));
|
|
|
|
+ p.connection.sendPacket(new STitlePacket(STitlePacket.Type.RESET, null));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("title.reset", (sc, in) ->
|
|
sm.registerFunction("title.reset", (sc, in) ->
|
|
{
|
|
{
|
|
- TitleUtils.resetTitle((ServerPlayerEntity) in[0].get(sc));
|
|
|
|
|
|
+ ((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(STitlePacket.Type.RESET, null));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("title.send", (sc, in) ->
|
|
sm.registerFunction("title.send", (sc, in) ->
|
|
{
|
|
{
|
|
- TitleUtils.setTitle((ServerPlayerEntity) in[0].get(sc), SnuviUtils.connect(sc, in, 1));
|
|
|
|
|
|
+ ITextComponent text = new StringTextComponent(SnuviUtils.connect(sc, in, 1));
|
|
|
|
+ ((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(STitlePacket.Type.TITLE, text));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("title.setsub", (sc, in) ->
|
|
sm.registerFunction("title.setsub", (sc, in) ->
|
|
{
|
|
{
|
|
- TitleUtils.setSubTitle((ServerPlayerEntity) in[0].get(sc), SnuviUtils.connect(sc, in, 1));
|
|
|
|
|
|
+ ITextComponent text = new StringTextComponent(SnuviUtils.connect(sc, in, 1));
|
|
|
|
+ ((ServerPlayerEntity) in[0].get(sc)).connection.sendPacket(new STitlePacket(STitlePacket.Type.SUBTITLE, text));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -285,11 +286,8 @@ public class MinecraftFunctions
|
|
}
|
|
}
|
|
return playerBank.getUUID(o.toString());
|
|
return playerBank.getUUID(o.toString());
|
|
});
|
|
});
|
|
- sm.registerFunction("player.getid", (sc, in) -> (double) pManager.getPlayerId(getUUID(in[0].get(sc))));
|
|
|
|
- sm.registerFunction("player.get", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- return server.getPlayerList().getPlayerByUUID(getUUID(in[0].get(sc)));
|
|
|
|
- });
|
|
|
|
|
|
+ sm.registerFunction("player.getid", (sc, in) -> getId(playerBank, in[0].get(sc)));
|
|
|
|
+ sm.registerFunction("player.get", (sc, in) -> server.getPlayerList().getPlayerByUUID(getUUID(in[0].get(sc))));
|
|
sm.registerFunction("player.getuuidfromid", (sc, in) -> playerBank.getUUIDfromID(in[0].getInt(sc)));
|
|
sm.registerFunction("player.getuuidfromid", (sc, in) -> playerBank.getUUIDfromID(in[0].getInt(sc)));
|
|
sm.registerFunction("player.getnamefromid", (sc, in) -> playerBank.getNamefromID(in[0].getInt(sc)));
|
|
sm.registerFunction("player.getnamefromid", (sc, in) -> playerBank.getNamefromID(in[0].getInt(sc)));
|
|
sm.registerFunction("player.getip", (sc, in) -> ((ServerPlayerEntity) in[0].get(sc)).connection.netManager.getRemoteAddress().toString());
|
|
sm.registerFunction("player.getip", (sc, in) -> ((ServerPlayerEntity) in[0].get(sc)).connection.netManager.getRemoteAddress().toString());
|
|
@@ -647,12 +645,12 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
stack.setCount(stack.getMaxStackSize());
|
|
stack.setCount(stack.getMaxStackSize());
|
|
amount -= stack.getMaxStackSize();
|
|
amount -= stack.getMaxStackSize();
|
|
- ItemStackUtils.drop(w, pos, stack.copy());
|
|
|
|
|
|
+ Block.spawnAsEntity(w, pos, stack.copy());
|
|
}
|
|
}
|
|
if(amount > 0)
|
|
if(amount > 0)
|
|
{
|
|
{
|
|
stack.setCount(amount);
|
|
stack.setCount(amount);
|
|
- ItemStackUtils.drop(w, pos, stack);
|
|
|
|
|
|
+ Block.spawnAsEntity(w, pos, stack);
|
|
}
|
|
}
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
@@ -677,7 +675,7 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
sm.registerFunction("item.setlore", (sc, in) ->
|
|
sm.registerFunction("item.setlore", (sc, in) ->
|
|
{
|
|
{
|
|
- ItemStackUtils.setLore((ItemStack) in[0].get(sc), (List<String>) in[1].get(sc));
|
|
|
|
|
|
+ ItemStackUtils.setLore((ItemStack) in[0].get(sc), (List<Object>) in[1].get(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("item.addlore", (sc, in) ->
|
|
sm.registerFunction("item.addlore", (sc, in) ->
|
|
@@ -916,14 +914,22 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
SignTileEntity sign = (SignTileEntity) l.getWorld().getTileEntity(l.getBlockPos());
|
|
SignTileEntity sign = (SignTileEntity) l.getWorld().getTileEntity(l.getBlockPos());
|
|
- SpecialBlockUtils.setSignLine(sign, in[1].getInt(sc), SnuviUtils.connect(sc, in, 2));
|
|
|
|
|
|
+ sign.signText[in[1].getInt(sc)] = new StringTextComponent(SnuviUtils.connect(sc, in, 2));
|
|
|
|
+
|
|
|
|
+ SUpdateTileEntityPacket packet = sign.getUpdatePacket();
|
|
|
|
+ World w = sign.getWorld();
|
|
|
|
+ if(w != null)
|
|
|
|
+ {
|
|
|
|
+ w.getPlayers().stream().filter(p -> p instanceof ServerPlayerEntity)
|
|
|
|
+ .forEach(p -> ((ServerPlayerEntity) p).connection.sendPacket(packet));
|
|
|
|
+ }
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("block.getsign", (sc, in) ->
|
|
sm.registerFunction("block.getsign", (sc, in) ->
|
|
{
|
|
{
|
|
Location l = (Location) in[0].get(sc);
|
|
Location l = (Location) in[0].get(sc);
|
|
SignTileEntity sign = (SignTileEntity) l.getWorld().getTileEntity(l.getBlockPos());
|
|
SignTileEntity sign = (SignTileEntity) l.getWorld().getTileEntity(l.getBlockPos());
|
|
- return sign.signText[in[1].getInt(sc)].getFormattedText();
|
|
|
|
|
|
+ return sign.signText[in[1].getInt(sc)].getString();
|
|
});
|
|
});
|
|
sm.registerFunction("block.setdoorstatus", (sc, in) ->
|
|
sm.registerFunction("block.setdoorstatus", (sc, in) ->
|
|
{
|
|
{
|
|
@@ -1188,7 +1194,7 @@ public class MinecraftFunctions
|
|
ent.setCustomNameVisible(false);
|
|
ent.setCustomNameVisible(false);
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
- sm.registerFunction("entity.getname", (sc, in) -> ((Entity) in[0].get(sc)).getDisplayName().getFormattedText());
|
|
|
|
|
|
+ sm.registerFunction("entity.getname", (sc, in) -> ((Entity) in[0].get(sc)).getDisplayName().getString());
|
|
sm.registerFunction("entity.throw", (sc, in) ->
|
|
sm.registerFunction("entity.throw", (sc, in) ->
|
|
{
|
|
{
|
|
Utils.setVelocity((Entity) in[0].get(sc), in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc));
|
|
Utils.setVelocity((Entity) in[0].get(sc), in[1].getDouble(sc), in[2].getDouble(sc), in[3].getDouble(sc));
|
|
@@ -1707,18 +1713,18 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
int id = in[1].getInt(sc);
|
|
int id = in[1].getInt(sc);
|
|
String message = SnuviUtils.connect(sc, in, 2);
|
|
String message = SnuviUtils.connect(sc, in, 2);
|
|
- doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ScoreboardUtils.get((ServerPlayerEntity) p).addText(id, message));
|
|
|
|
|
|
+ doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ((ModEntityPlayerMP) p).getScoreboard().addText(id, message));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("sb.remove", (sc, in) ->
|
|
sm.registerFunction("sb.remove", (sc, in) ->
|
|
{
|
|
{
|
|
int id = in[1].getInt(sc);
|
|
int id = in[1].getInt(sc);
|
|
- doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ScoreboardUtils.get((ServerPlayerEntity) p).removeText(id));
|
|
|
|
|
|
+ doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ((ModEntityPlayerMP) p).getScoreboard().removeText(id));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("sb.reset", (sc, in) ->
|
|
sm.registerFunction("sb.reset", (sc, in) ->
|
|
{
|
|
{
|
|
- doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ScoreboardUtils.get((ServerPlayerEntity) p).clear(server));
|
|
|
|
|
|
+ doForGroup(server, scripts, perms, in[0].get(sc), sc, p -> ((ModEntityPlayerMP) p).getScoreboard().clear((ModEntityPlayerMP) p));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -1921,17 +1927,7 @@ public class MinecraftFunctions
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
// Read-library
|
|
// Read-library
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
- sm.registerFunction("read.player", (sc, in) ->
|
|
|
|
- {
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return Utils.getPlayerByName(server, in[0].getString(sc));
|
|
|
|
- }
|
|
|
|
- catch(PlayerNotFoundException ex)
|
|
|
|
- {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ sm.registerFunction("read.player", (sc, in) -> Utils.getPlayerByName(server, in[0].getString(sc)));
|
|
sm.registerFunction("read.location", (sc, in) -> new Location(server, in[0].getString(sc)));
|
|
sm.registerFunction("read.location", (sc, in) -> new Location(server, in[0].getString(sc)));
|
|
sm.registerFunction("read.item", (sc, in) ->
|
|
sm.registerFunction("read.item", (sc, in) ->
|
|
{
|
|
{
|
|
@@ -1945,7 +1941,7 @@ public class MinecraftFunctions
|
|
{
|
|
{
|
|
s = "minecraft:" + s;
|
|
s = "minecraft:" + s;
|
|
}
|
|
}
|
|
- Item item = ItemStackUtils.getItem(s);
|
|
|
|
|
|
+ Item item = Mapper.getItem(s);
|
|
int amount = in.length >= 2 ? in[1].getInt(sc) : 1;
|
|
int amount = in.length >= 2 ? in[1].getInt(sc) : 1;
|
|
ItemStack stack = new ItemStack(item, amount);
|
|
ItemStack stack = new ItemStack(item, amount);
|
|
if(in.length >= 3)
|
|
if(in.length >= 3)
|
|
@@ -2110,25 +2106,25 @@ public class MinecraftFunctions
|
|
// ---------------------------------------------------------------------
|
|
// ---------------------------------------------------------------------
|
|
sm.registerFunction("data.set", (sc, in) ->
|
|
sm.registerFunction("data.set", (sc, in) ->
|
|
{
|
|
{
|
|
- pManager.setPlayerVar(getUUID(in[0].get(sc)), in[1].getString(sc), in[2].get(sc));
|
|
|
|
|
|
+ ((ModEntityPlayerMP) in[0].get(sc)).setVar(in[1].getString(sc), in[2].get(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("data.settimer", (sc, in) ->
|
|
sm.registerFunction("data.settimer", (sc, in) ->
|
|
{
|
|
{
|
|
- pManager.setPlayerTimer(getUUID(in[0].get(sc)), in[1].getString(sc), in[2].getInt(sc));
|
|
|
|
|
|
+ ((ModEntityPlayerMP) in[0].get(sc)).setTimer(in[1].getString(sc), in[2].getInt(sc));
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
sm.registerFunction("data.get", (sc, in) ->
|
|
sm.registerFunction("data.get", (sc, in) ->
|
|
{
|
|
{
|
|
- return pManager.getPlayerVar(getUUID(in[0].get(sc)), in[1].getString(sc));
|
|
|
|
|
|
+ return ((ModEntityPlayerMP) in[0].get(sc)).getVar(in[1].getString(sc));
|
|
});
|
|
});
|
|
sm.registerFunction("data.gettimer", (sc, in) ->
|
|
sm.registerFunction("data.gettimer", (sc, in) ->
|
|
{
|
|
{
|
|
- return (double) pManager.getPlayerTimer(getUUID(in[0].get(sc)), in[1].getString(sc));
|
|
|
|
|
|
+ return (double) ((ModEntityPlayerMP) in[0].get(sc)).getTimer(in[1].getString(sc));
|
|
});
|
|
});
|
|
sm.registerFunction("data.clear", (sc, in) ->
|
|
sm.registerFunction("data.clear", (sc, in) ->
|
|
{
|
|
{
|
|
- pManager.clearPlayerData(getUUID(in[0].get(sc)));
|
|
|
|
|
|
+ ((ModEntityPlayerMP) in[0].get(sc)).clearData();
|
|
return Void.TYPE;
|
|
return Void.TYPE;
|
|
});
|
|
});
|
|
|
|
|
|
@@ -2182,16 +2178,9 @@ public class MinecraftFunctions
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- private static Class getClass(String s)
|
|
|
|
|
|
+ private static Class getClass(String s) throws ClassNotFoundException
|
|
{
|
|
{
|
|
- try
|
|
|
|
- {
|
|
|
|
- return Class.forName(s);
|
|
|
|
- }
|
|
|
|
- catch(ClassNotFoundException ex)
|
|
|
|
- {
|
|
|
|
- throw new IllegalStringException(s);
|
|
|
|
- }
|
|
|
|
|
|
+ return Class.forName(s);
|
|
}
|
|
}
|
|
|
|
|
|
private static BlockState getBlockState(Location l)
|
|
private static BlockState getBlockState(Location l)
|