Use PaperLib for teleport and optimize other Paper hooks

This commit is contained in:
Fabrizio La Rosa 2020-06-22 21:33:17 +02:00
parent f6d6059ad6
commit bbe39cf52c
6 changed files with 20 additions and 20 deletions

View File

@ -14,6 +14,7 @@ import com.songoda.skyblock.utils.player.OfflinePlayer;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.visit.Visit;
import com.songoda.skyblock.visit.VisitManager;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -111,7 +112,7 @@ public class TeleportCommand extends SubCommand {
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
LocationUtil.removeWaterFromLoc(skyblock, loc);
player.teleport(loc);
PaperLib.teleportAsync(player, loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);

View File

@ -41,6 +41,7 @@ import com.songoda.skyblock.utils.world.WorldBorder;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.visit.VisitManager;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
@ -269,7 +270,7 @@ public class IslandManager {
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(skyblock, () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
}, configLoad.getInt("Island.Creation.TeleportTimeout") * 20);
@ -336,7 +337,7 @@ public class IslandManager {
Bukkit.getScheduler().callSyncMethod(SkyBlock.getInstance(), () -> {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Island));
PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Island));
player.setGameMode(GameMode.SPECTATOR);
return true;
});
@ -344,7 +345,7 @@ public class IslandManager {
Bukkit.getScheduler().runTaskLater(skyblock, () -> {
if (data.isPreview()) {
Location spawn = fileManager.getLocation(fileManager.getConfig(new File(skyblock.getDataFolder(), "locations.yml")), "Location.Spawn", true);
player.teleport(spawn);
PaperLib.teleportAsync(player, spawn);
player.setGameMode(GameMode.SURVIVAL);
data.setIsland(null);
islandStorage.remove(player.getUniqueId(), island);
@ -558,15 +559,7 @@ public class IslandManager {
}
}
if (skyblock.isPaperAsync()) {
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> {
startDeletition(island, worldManager);
});
} else {
startDeletition(island, worldManager);
}
startDeletition(island, worldManager);
skyblock.getVisitManager().deleteIsland(island.getOwnerUUID());
skyblock.getBanManager().deleteIsland(island.getOwnerUUID());
@ -1113,7 +1106,7 @@ public class IslandManager {
if (island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId()) || island.hasRole(IslandRole.Owner, player.getUniqueId())) {
Location loc = island.getLocation(IslandWorld.Normal, IslandEnvironment.Main);
if(loc != null){
player.teleport(loc);
PaperLib.teleportAsync(player, loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}
@ -1153,7 +1146,7 @@ public class IslandManager {
loc = LocationUtil.getSafeLocation(loc);
}
if(loc != null){
player.teleport(loc);
PaperLib.teleportAsync(player, loc);
if(!configLoad.getBoolean("Island.Teleport.FallDamage", true)){
player.setFallDistance(0.0F);
}

View File

@ -14,6 +14,7 @@ import com.songoda.skyblock.scoreboard.Scoreboard;
import com.songoda.skyblock.scoreboard.ScoreboardManager;
import com.songoda.skyblock.usercache.UserCacheManager;
import com.songoda.skyblock.utils.world.LocationUtil;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@ -60,7 +61,7 @@ public class Join implements Listener {
if (configLoad.getBoolean("Island.Join.Spawn")) {
LocationUtil.teleportPlayerToSpawn(player);
} else if (configLoad.getBoolean("Island.Join.Island") && island != null) {
player.teleport(island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
PaperLib.teleportAsync(player, island.getLocation(IslandWorld.Normal, IslandEnvironment.Main));
player.setFallDistance(0.0F);
teleportedToIsland = true;
}

View File

@ -14,6 +14,7 @@ import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.data.Waterlogged;
@ -209,7 +210,7 @@ public class Move implements Listener {
}
}
if(loc != null){
player.teleport(loc);
PaperLib.teleportAsync(player, loc);
} else {
LocationUtil.teleportPlayerToSpawn(player);
player.sendMessage(ChatColor.translateAlternateColorCodes('&',

View File

@ -15,6 +15,7 @@ import com.songoda.skyblock.permission.event.events.PlayerEnterPortalEvent;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.world.LocationUtil;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
@ -25,6 +26,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPortalEnterEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import java.awt.print.Paper;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@ -142,7 +144,8 @@ public class Portal implements Listener {
default:
IslandWorld toWorldF = toWorld;
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> player.teleport(island.getLocation(toWorldF, spawnEnvironment)), 1L);
Bukkit.getScheduler().scheduleSyncDelayedTask(skyblock, () -> PaperLib.teleportAsync(player, island.getLocation(toWorldF, spawnEnvironment)), 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);
tick.setTick(1);
@ -166,7 +169,7 @@ public class Portal implements Listener {
if(safeLoc != null){
loc = safeLoc;
}
player.teleport(loc);
PaperLib.teleportAsync(player, loc);
}, 1L);
soundManager.playSound(player, CompatibleSound.ENTITY_ENDERMAN_TELEPORT.getSound(), 1.0F, 1.0F);
player.setFallDistance(0.0F);

View File

@ -12,6 +12,7 @@ import com.songoda.skyblock.utils.math.VectorUtil;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.world.block.BlockDegreesType;
import com.songoda.skyblock.world.WorldManager;
import io.papermc.lib.PaperLib;
import org.bukkit.*;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
@ -301,7 +302,7 @@ public final class LocationUtil {
}
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
player.teleport(spawnLocation);
PaperLib.teleportAsync(player, spawnLocation);
player.setFallDistance(0.0F);
});
}