Nouvelle correction de bug du WorldBorder avec une pile d'entité + Affichage du MOTD que quand le serveur est fini de chargé
This commit is contained in:
parent
87453e9816
commit
8ee8b09384
@ -36,6 +36,27 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 'u' = stopped
|
||||
* 'l' = loading
|
||||
* 'r' = running
|
||||
* 's' = stopping
|
||||
*/
|
||||
private static ServerState serverState = ServerState.STOPPED;
|
||||
|
||||
public static ServerState getServerState() { return serverState; }
|
||||
public static void setServerState(ServerState s) { serverState = s; }
|
||||
|
||||
public enum ServerState{
|
||||
STOPPED,
|
||||
LOADING,
|
||||
RUNNING,
|
||||
STOPPING
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//public DBConnection databaseConnection;
|
||||
|
||||
public AfkManager afkManager;
|
||||
@ -64,6 +85,8 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable(){
|
||||
|
||||
setServerState(ServerState.LOADING);
|
||||
|
||||
instance = this;
|
||||
|
||||
/*
|
||||
@ -107,9 +130,17 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
NetworkAPI.loadNewInstance();
|
||||
|
||||
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||
@Override public void run() { new PlayerDataCleaner(instance); }
|
||||
@Override public void run() {
|
||||
new PlayerDataCleaner(instance);
|
||||
}
|
||||
}, 1);
|
||||
|
||||
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||
@Override public void run() {
|
||||
setServerState(ServerState.RUNNING);
|
||||
}
|
||||
}, 30);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -117,6 +148,8 @@ public class PandacraftUtils extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable(){
|
||||
|
||||
setServerState(ServerState.STOPPING);
|
||||
|
||||
ConfigManager.getInstance().saveAll();
|
||||
|
||||
afkManager = null;
|
||||
|
@ -16,6 +16,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.PandacraftUtils.ServerState;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||
@ -105,8 +106,10 @@ public class PacketOutServerInfoListener {
|
||||
event.getPacket().getServerPings().read(0).setPlayersOnline(count_player);
|
||||
|
||||
|
||||
|
||||
if (PandacraftUtils.getServerState().equals(ServerState.RUNNING))
|
||||
event.getPacket().getServerPings().read(0).setMotD(ConfigManager.getInstance().defaultConfig.pingMOTD);
|
||||
else
|
||||
event.getPacket().getServerPings().read(0).setMotD(".");
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@ -9,6 +9,7 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.config.ConfigManager;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.config.elements.WorldBorderConfigEntry;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayer;
|
||||
import net.mc_pandacraft.java.plugin.pandacraftutils.players.OnlinePlayerManager;
|
||||
import net.mc_pandacraft.java.util.bukkit.EntityStackUtil;
|
||||
import net.mc_pandacraft.java.util.bukkit.protocol.ParticleEffect;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
@ -47,7 +48,7 @@ public class WorldBorderManager extends BukkitRunnable implements Listener {
|
||||
Location newLoc = checkPosition(op.getPlayer().getLocation(), config);
|
||||
|
||||
if (newLoc != null) { // le joueur dépasse la bordure
|
||||
op.teleportWithVehicle(newLoc);
|
||||
EntityStackUtil.teleportStack(op.getPlayer(), newLoc);
|
||||
op.getPlayer().sendMessage(ChatColor.RED+"Vous avez été téléporté car vous avez passé la limite de la carte");
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,6 @@ import net.mc_pandacraft.java.plugin.pandacraftutils.plugin_interface.Essentials
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
|
||||
@ -305,19 +303,6 @@ public class OnlinePlayer {
|
||||
}
|
||||
|
||||
|
||||
public boolean teleportWithVehicle(Location l) {
|
||||
Entity toTeleport = player;
|
||||
while (toTeleport.getVehicle() != null) {
|
||||
toTeleport = toTeleport.getVehicle();
|
||||
}
|
||||
return toTeleport.teleport(l);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
70
src/net/mc_pandacraft/java/util/bukkit/EntityStackUtil.java
Normal file
70
src/net/mc_pandacraft/java/util/bukkit/EntityStackUtil.java
Normal file
@ -0,0 +1,70 @@
|
||||
package net.mc_pandacraft.java.util.bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* Permet de gérer les entités qui se transportent les uns les autres
|
||||
*
|
||||
* Ce groupement d'entité est appelé une "pile d'entité".
|
||||
*
|
||||
* Par exemple, un cheval et son monteur représente à eux deux une pile d'entité, dont
|
||||
* l'élement tout en bas est le cheval
|
||||
*/
|
||||
public class EntityStackUtil {
|
||||
|
||||
/**
|
||||
* Déplace une pile d'entité vers l'endroit défini
|
||||
* @param e Une entité faisant parti de la pile d'entité à téléporter
|
||||
* @param l La position vers lequel envoyer toute la pile
|
||||
*/
|
||||
public static void teleportStack(Entity e, Location l)
|
||||
{
|
||||
List<Entity> stack = new ArrayList<Entity>();
|
||||
|
||||
// on se place sur l'entité tout en bas de la pile
|
||||
Entity entTemp = e;
|
||||
while (entTemp.getVehicle() != null)
|
||||
entTemp = entTemp.getVehicle();
|
||||
|
||||
do {
|
||||
stack.add(entTemp);
|
||||
entTemp = entTemp.getPassenger();
|
||||
} while (entTemp != null);
|
||||
|
||||
if (stack.size() == 1) {
|
||||
stack.get(0).teleport(l);
|
||||
return;
|
||||
}
|
||||
|
||||
stack.get(0).eject();
|
||||
stack.get(0).teleport(l);
|
||||
stack.get(0).setPassenger(stack.get(1));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user