Improve Performance of Freezing Players
This commit is contained in:
parent
de295f01b5
commit
f5f7803d50
2 changed files with 9 additions and 14 deletions
|
|
@ -45,6 +45,8 @@ public final class PS3Minigames extends JavaPlugin {
|
|||
|
||||
public MultiverseCore multiverseCore;
|
||||
|
||||
public ArrayList<UUID> frozenPlayer = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Set Instance
|
||||
|
|
@ -94,6 +96,7 @@ public final class PS3Minigames extends JavaPlugin {
|
|||
Location location = new Location(gameWorld, getConfig().getDouble(configpathtospawnloc + ".x"), getConfig().getDouble(configpathtospawnloc + ".y"), getConfig().getDouble(configpathtospawnloc + ".z"), (float) getConfig().getDouble(configpathtospawnloc + ".yaw"), (float) getConfig().getDouble(configpathtospawnloc + ".pitch"));
|
||||
System.out.println(configpathtospawnloc + ".x");
|
||||
Bukkit.getServer().getPlayer(uuid).teleport(location);
|
||||
getFrozenPlayer().add(uuid);
|
||||
}
|
||||
Timer timer = new Timer(10, PS3Minigames.INSTANCE);
|
||||
timer.start();
|
||||
|
|
@ -105,7 +108,10 @@ public final class PS3Minigames extends JavaPlugin {
|
|||
});
|
||||
timer.whenComplete(() -> {
|
||||
newGame.setGameState(GameState.RUNNING);
|
||||
gameWorld.getPlayers().forEach(player -> player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("messages.game-start-no-countdown"))));
|
||||
gameWorld.getPlayers().forEach(player -> {
|
||||
frozenPlayer.remove(player.getUniqueId());
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("messages.game-start-no-countdown")));
|
||||
});
|
||||
});
|
||||
} else {
|
||||
System.out.println("error while trying to load the world!");
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
package me.firephoenix.ps3minigames.listener;
|
||||
|
||||
import me.firephoenix.ps3minigames.PS3Minigames;
|
||||
import me.firephoenix.ps3minigames.game.Game;
|
||||
import me.firephoenix.ps3minigames.states.GameState;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author NieGestorben
|
||||
* Copyright© (c) 2023, All Rights Reserved.
|
||||
|
|
@ -19,13 +13,8 @@ public class MoveListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
// TODO: Make this less performance intensive. Currently the required performance increases exponentially.
|
||||
for (Game game : PS3Minigames.INSTANCE.getGames()) {
|
||||
if (game.getPlayers().stream().anyMatch(uuid -> e.getPlayer().getUniqueId().equals(uuid))) {
|
||||
if (game.getGameState() == GameState.STARTING) {
|
||||
e.setTo(e.getFrom());
|
||||
}
|
||||
}
|
||||
if (PS3Minigames.INSTANCE.getFrozenPlayer().contains(e.getPlayer().getUniqueId()) && e.getFrom() != e.getTo()) {
|
||||
e.setTo(e.getFrom());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue