mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-26 17:05:01 +00:00
Update NMS + Use PaperLib for teleportAsync
This commit is contained in:
parent
c61f7e78fd
commit
43b266f17d
17
pom.xml
17
pom.xml
@ -46,7 +46,12 @@
|
||||
|
||||
<repository>
|
||||
<id>CodeMC</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>nms-repo</id>
|
||||
<url>https://repo.codemc.org/repository/nms/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
@ -142,7 +147,7 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@ -197,10 +202,10 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
@ -197,7 +198,7 @@ public class LoginProcess extends FreedomService
|
||||
int z = FUtil.randomInteger(-10000, 10000);
|
||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||
player.teleport(location);
|
||||
PaperLib.teleportAsync(player, location);
|
||||
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
||||
return;
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ package me.totalfreedom.totalfreedommod;
|
||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -61,7 +62,7 @@ public class MovementValidator extends FreedomService
|
||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||
}
|
||||
|
||||
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||
@ -110,7 +111,7 @@ public class MovementValidator extends FreedomService
|
||||
// Validate position
|
||||
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||
{
|
||||
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,7 +132,7 @@ public class MovementValidator extends FreedomService
|
||||
|
||||
private Boolean exploitItem(ItemStack item)
|
||||
{
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
MojangsonCompound compound = new MojangsonCompound();
|
||||
boolean foundNegative = false;
|
||||
@ -168,7 +169,7 @@ public class MovementValidator extends FreedomService
|
||||
}
|
||||
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
|
@ -4,14 +4,14 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
|
||||
|
||||
public class ServerInterface extends FreedomService
|
||||
{
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R1";
|
||||
public static final String COMPILE_NMS_VERSION = "v1_16_R2";
|
||||
|
||||
@Override
|
||||
public void onStart()
|
||||
|
@ -1,10 +1,10 @@
|
||||
package me.totalfreedom.totalfreedommod.blocking;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -35,7 +35,7 @@ public class SignBlocker extends FreedomService
|
||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||
{
|
||||
ItemStack sign = event.getItemInHand();
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||
String line1 = bet.getString("Text1");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.caging;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -71,7 +72,7 @@ public class Cager extends FreedomService
|
||||
|
||||
if (outOfCage)
|
||||
{
|
||||
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
||||
PaperLib.teleportAsync(player.getPlayer(), cageLoc.subtract(0, 0.1, 0));
|
||||
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||
cage.regenerate();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_hubworld extends FreedomCommand
|
||||
if (hubWorld == null || playerSender.getWorld() == hubWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -12,7 +13,7 @@ public class Command_localspawn extends FreedomCommand
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
playerSender.teleport(playerSender.getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, playerSender.getWorld().getSpawnLocation());
|
||||
msg("Teleported to spawnpoint for world \"" + playerSender.getWorld().getName() + "\".");
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_masterbuilderworld extends FreedomCommand
|
||||
if (masterBuilderWorld == null || playerSender.getWorld() == masterBuilderWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -5,13 +5,13 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -149,7 +149,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
{
|
||||
return false;
|
||||
}
|
||||
net.minecraft.server.v1_16_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||
NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
|
||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||
NBTTagCompound cmpnd = new NBTTagCompound();
|
||||
@ -199,7 +199,7 @@ public class Command_modifyitem extends FreedomCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R1.ItemStack stack)
|
||||
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||
{
|
||||
if (stack.getTag() == null)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -10,14 +11,13 @@ import org.bukkit.entity.Player;
|
||||
@CommandParameters(description = "Go to the PlotWorld.", usage = "/<command>", aliases = "pw")
|
||||
public class Command_plotworld extends FreedomCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||
{
|
||||
World plotworld = server.getWorld("plotworld");
|
||||
if (plotworld != null)
|
||||
{
|
||||
playerSender.teleport(plotworld.getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, plotworld.getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TimerTask;
|
||||
@ -55,7 +56,7 @@ public class Command_ride extends FreedomCommand
|
||||
|
||||
if (requester.getWorld() != playerSender.getWorld())
|
||||
{
|
||||
requester.teleport(playerSender);
|
||||
PaperLib.teleportAsync(requester, playerSender.getLocation());
|
||||
}
|
||||
|
||||
playerSender.addPassenger(requester);
|
||||
@ -145,7 +146,7 @@ public class Command_ride extends FreedomCommand
|
||||
|
||||
if (player.getWorld() != playerSender.getWorld())
|
||||
{
|
||||
playerSender.teleport(player);
|
||||
PaperLib.teleportAsync(playerSender, player.getLocation());
|
||||
}
|
||||
|
||||
player.addPassenger(playerSender);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
@ -40,7 +41,7 @@ public class Command_spectate extends FreedomCommand
|
||||
|
||||
if (playerSender.getWorld() != player.getWorld())
|
||||
{
|
||||
playerSender.teleport(player);
|
||||
PaperLib.teleportAsync(playerSender, player.getLocation());
|
||||
}
|
||||
|
||||
playerSender.setSpectatorTarget(player);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -72,7 +73,7 @@ public class Command_staffworld extends FreedomCommand
|
||||
if (staffWorld == null || playerSender.getWorld() == staffWorld)
|
||||
{
|
||||
msg("Going to the main world.");
|
||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.command;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,7 +20,7 @@ public class Command_tprandom extends FreedomCommand
|
||||
int z = FUtil.randomInteger(-50000, 50000);
|
||||
int y = playerSender.getWorld().getHighestBlockYAt(x, z);
|
||||
Location location = new Location(playerSender.getLocation().getWorld(), x, y, z);
|
||||
playerSender.teleport(location);
|
||||
PaperLib.teleportAsync(playerSender, location);
|
||||
msg("Poof!", ChatColor.GREEN);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.world;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
@ -49,7 +50,7 @@ public abstract class CustomWorld extends FreedomService
|
||||
{
|
||||
try
|
||||
{
|
||||
player.teleport(getWorld().getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, getWorld().getSpawnLocation());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.totalfreedom.totalfreedommod.world;
|
||||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
@ -127,7 +128,7 @@ public class WorldManager extends FreedomService
|
||||
if (player.getWorld().getName().equalsIgnoreCase(targetWorld))
|
||||
{
|
||||
playerMsg(player, "Going to main world.", ChatColor.GRAY);
|
||||
player.teleport(Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, Bukkit.getWorlds().get(0).getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -136,12 +137,11 @@ public class WorldManager extends FreedomService
|
||||
if (world.getName().equalsIgnoreCase(targetWorld))
|
||||
{
|
||||
playerMsg(player, "Going to world: " + targetWorld, ChatColor.GRAY);
|
||||
player.teleport(world.getSpawnLocation());
|
||||
PaperLib.teleportAsync(player, world.getSpawnLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
playerMsg(player, "World " + targetWorld + " not found.", ChatColor.GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user