|
@@ -1,4 +1,4 @@
|
|
|
-package me.hammerle.kp.snuviscript.commands;
|
|
|
+package me.hammerle.mp.snuviscript.commands;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
@@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
import org.bukkit.inventory.PlayerInventory;
|
|
|
import org.bukkit.inventory.meta.SkullMeta;
|
|
|
-import me.hammerle.kp.KajetansPlugin;
|
|
|
+import me.hammerle.mp.MundusPlugin;
|
|
|
import net.citizensnpcs.api.CitizensAPI;
|
|
|
import net.kyori.adventure.text.Component;
|
|
|
|
|
@@ -69,9 +69,9 @@ public class PlayerCommands {
|
|
|
}
|
|
|
|
|
|
public static void registerFunctions() {
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getitemamount", (sc,
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getitemamount", (sc,
|
|
|
in) -> (double) countItemStack((Player) in[0].get(sc), (ItemStack) in[1].get(sc)));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.removeitem", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.removeitem", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
ItemStack stack = (ItemStack) in[1].get(sc);
|
|
|
int count = countItemStack(p, stack);
|
|
@@ -81,7 +81,7 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return (double) (stack.getAmount() - count);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.giveitem", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.giveitem", (sc, in) -> {
|
|
|
ItemStack stack = (ItemStack) in[1].get(sc);
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
HashMap<Integer, ItemStack> left = p.getInventory().addItem(stack);
|
|
@@ -91,7 +91,7 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return (double) count;
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.additem", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.additem", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
ItemStack stack = (ItemStack) in[1].get(sc);
|
|
|
ItemStack[] content = p.getInventory().getContents();
|
|
@@ -105,22 +105,22 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return (double) count;
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.respawn",
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.respawn",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).spigot().respawn());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setcompass", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setcompass", (sc, in) -> {
|
|
|
Player p = ((Player) in[0].get(sc));
|
|
|
p.setCompassTarget((Location) in[1].get(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.gethunger",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.gethunger",
|
|
|
(sc, in) -> (double) ((Player) in[0].get(sc)).getFoodLevel());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.sethunger", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.sethunger", (sc, in) -> {
|
|
|
((Player) in[0].get(sc)).setFoodLevel(in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getsaturation",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getsaturation",
|
|
|
(sc, in) -> (double) ((Player) in[0].get(sc)).getSaturation());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setsaturation",
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setsaturation",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).setSaturation(in[1].getFloat(sc)));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getname", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getname", (sc, in) -> {
|
|
|
Object o = in[0].get(sc);
|
|
|
if(o instanceof Player) {
|
|
|
return ((Player) o).getName();
|
|
@@ -131,7 +131,7 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return op.getName();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getuuid", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getuuid", (sc, in) -> {
|
|
|
Object o = in[0].get(sc);
|
|
|
if(o instanceof Player) {
|
|
|
return ((Player) o).getUniqueId();
|
|
@@ -142,37 +142,37 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return op.getUniqueId();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getid",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getid",
|
|
|
(sc, in) -> (double) CommandUtils.getUUID(in[0].get(sc)).hashCode());
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.get",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.get",
|
|
|
(sc, in) -> Bukkit.getPlayer(CommandUtils.getUUID(in[0].get(sc))));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getuuidfromid",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getuuidfromid",
|
|
|
(sc, in) -> getUUIDFromId(in[0].getInt(sc)));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getnamefromid",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getnamefromid",
|
|
|
(sc, in) -> getNameFromId(in[0].getInt(sc)));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getip",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getip",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).spigot().getRawAddress().toString());
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.iscreative",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.iscreative",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getGameMode() == GameMode.CREATIVE);
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.isspectator",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.isspectator",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getGameMode() == GameMode.SPECTATOR);
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.issurvival",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.issurvival",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getGameMode() == GameMode.SURVIVAL);
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.isadventure",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.isadventure",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getGameMode() == GameMode.ADVENTURE);
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setfly", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setfly", (sc, in) -> {
|
|
|
Player p = ((Player) in[0].get(sc));
|
|
|
boolean b = in[1].getBoolean(sc);
|
|
|
p.setAllowFlight(b);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.hasfly",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.hasfly",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getAllowFlight());
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.isflying",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.isflying",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).isFlying());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setgamemode", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setgamemode", (sc, in) -> {
|
|
|
((Player) in[0].get(sc)).setGameMode(GameMode.valueOf(in[1].get(sc).toString()));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.dropinventory", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.dropinventory", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
Location l = (Location) in[1].get(sc);
|
|
|
PlayerInventory inv = p.getInventory();
|
|
@@ -184,7 +184,7 @@ public class PlayerCommands {
|
|
|
}
|
|
|
inv.clear();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.gettargetblock", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.gettargetblock", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
FluidCollisionMode mode = FluidCollisionMode.NEVER;
|
|
|
if(in.length >= 3 && in[2].getBoolean(sc)) {
|
|
@@ -192,11 +192,11 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return p.getTargetBlockExact(in[1].getInt(sc), mode);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.gettargetentity", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.gettargetentity", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
return p.getTargetEntity(in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.gettargetcitizen", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.gettargetcitizen", (sc, in) -> {
|
|
|
Player player = (Player) in[0].get(sc);
|
|
|
Entity target = player.getTargetEntity(in[1].getInt(sc));
|
|
|
if(target != null && CitizensAPI.getNPCRegistry().isNPC(target)) {
|
|
@@ -204,37 +204,37 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return null;
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.action", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.action", (sc, in) -> {
|
|
|
Component text = (Component) in[1].get(sc);
|
|
|
CommandUtils.doForGroup(in[0].get(sc), sc, p -> ((Player) p).sendActionBar(text));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getspawn", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getspawn", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
return p.getRespawnLocation();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setspawn", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setspawn", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
Location l = (Location) in[1].get(sc);
|
|
|
p.setRespawnLocation(l, true);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.damageitem", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.damageitem", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
ItemStack stack = p.getEquipment().getItemInMainHand();
|
|
|
p.damageItemStack(stack, in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.addtotalexp", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.addtotalexp", (sc, in) -> {
|
|
|
((Player) in[0].get(sc)).giveExp(in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getlevel",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getlevel",
|
|
|
(sc, in) -> (double) ((Player) in[0].get(sc)).getLevel());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setlevel", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setlevel", (sc, in) -> {
|
|
|
((Player) in[0].get(sc)).setLevel(in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getexp",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getexp",
|
|
|
(sc, in) -> (double) ((Player) in[0].get(sc)).getExp());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setexp",
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setexp",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).setExp(in[1].getFloat(sc)));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.gethead", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.gethead", (sc, in) -> {
|
|
|
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
|
|
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
|
|
meta.setPlayerProfile(
|
|
@@ -242,33 +242,33 @@ public class PlayerCommands {
|
|
|
skull.setItemMeta(meta);
|
|
|
return skull;
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getinv",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getinv",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getInventory());
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getenderinv",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getenderinv",
|
|
|
(sc, in) -> ((Player) in[0].get(sc)).getEnderChest());
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setdisplayname", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setdisplayname", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
p.playerListName((Component) in[1].get(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.hide", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.hide", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
Player p2 = (Player) in[1].get(sc);
|
|
|
- p.hidePlayer(KajetansPlugin.instance, p2);
|
|
|
+ p.hidePlayer(MundusPlugin.instance, p2);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.show", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.show", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
Player p2 = (Player) in[1].get(sc);
|
|
|
- p.showPlayer(KajetansPlugin.instance, p2);
|
|
|
+ p.showPlayer(MundusPlugin.instance, p2);
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("players.getamount",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("players.getamount",
|
|
|
(sc, in) -> (double) Bukkit.getOnlinePlayers().size());
|
|
|
- KajetansPlugin.scriptManager.registerFunction("players.tolist",
|
|
|
+ MundusPlugin.scriptManager.registerFunction("players.tolist",
|
|
|
(sc, in) -> new ArrayList<>(Bukkit.getOnlinePlayers()));
|
|
|
- KajetansPlugin.scriptManager.registerFunction("players.near", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("players.near", (sc, in) -> {
|
|
|
Location l = (Location) in[0].get(sc);
|
|
|
return l.getWorld().getNearbyPlayers(l, in[1].getDouble(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.getnearest", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.getnearest", (sc, in) -> {
|
|
|
Location l = (Location) in[0].get(sc);
|
|
|
double distance = 10.0;
|
|
|
Collection<Player> players = l.getWorld().getNearbyPlayers(l, distance);
|
|
@@ -283,27 +283,27 @@ public class PlayerCommands {
|
|
|
}
|
|
|
return closest;
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setflyspeed", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setflyspeed", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
p.setFlySpeed(in[1].getFloat(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setwalkspeed", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setwalkspeed", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
p.setWalkSpeed(in[1].getFloat(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.issneaking", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.issneaking", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
return p.isSneaking();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerFunction("player.isblocking", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerFunction("player.isblocking", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
return p.isBlocking();
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.setslot", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.setslot", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
p.getInventory().setHeldItemSlot(in[1].getInt(sc));
|
|
|
});
|
|
|
- KajetansPlugin.scriptManager.registerConsumer("player.resetsleep", (sc, in) -> {
|
|
|
+ MundusPlugin.scriptManager.registerConsumer("player.resetsleep", (sc, in) -> {
|
|
|
Player p = (Player) in[0].get(sc);
|
|
|
p.setStatistic(org.bukkit.Statistic.TIME_SINCE_REST, 0);
|
|
|
});
|