Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
Added PlayerKick (setReason, setLeaveMessage, setCancelled) and PlayerRespawn (setLocation)
Dieser Commit ist enthalten in:
Ursprung
228b5e7ccd
Commit
002b5ebefc
@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
// CraftBukkit end
|
||||
@ -66,7 +67,6 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
|
||||
public void a() {
|
||||
this.b.a();
|
||||
if (this.f++ % 20 == 0) {
|
||||
@ -75,10 +75,21 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
|
||||
}
|
||||
|
||||
public void a(String s) {
|
||||
this.b.a((Packet) (new Packet255KickDisconnect(s)));
|
||||
this.b.c();
|
||||
this.d.f.a((Packet) (new Packet3Chat("§e" + this.e.name + " left the game.")));
|
||||
// CraftBukkit start
|
||||
String leaveMessage = "§e" + this.e.name + " left the game.";
|
||||
PlayerKickEvent kickEvent = new PlayerKickEvent(org.bukkit.event.Event.Type.PLAYER_KICK, server.getPlayer(this.e), s, leaveMessage);
|
||||
server.getPluginManager().callEvent(kickEvent);
|
||||
if (kickEvent.isCancelled()) {
|
||||
// Do not kick the player
|
||||
return;
|
||||
}
|
||||
// Send the possibly modified leave message
|
||||
this.d.f.a((Packet) (new Packet3Chat( kickEvent.getLeaveMessage() )));
|
||||
this.d.f.c(this.e);
|
||||
this.b.a((Packet) (new Packet255KickDisconnect( kickEvent.getReason() )));
|
||||
// CraftBukkit end
|
||||
|
||||
this.b.c();
|
||||
this.c = true;
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,14 @@ import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
public class ServerConfigurationManager {
|
||||
@ -36,12 +38,18 @@ public class ServerConfigurationManager {
|
||||
private File k;
|
||||
private PlayerNBTManager l;
|
||||
|
||||
private CraftServer server; // CraftBukkit
|
||||
// CraftBukkit start
|
||||
private CraftServer server;
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
public ServerConfigurationManager(MinecraftServer minecraftserver) {
|
||||
// CraftBukkit 2 lines!
|
||||
minecraftserver.server = new CraftServer(minecraftserver, this);
|
||||
server = minecraftserver.server;
|
||||
// CraftBukkit end
|
||||
|
||||
this.c = minecraftserver;
|
||||
this.i = minecraftserver.a("banned-players.txt");
|
||||
this.j = minecraftserver.a("banned-ips.txt");
|
||||
@ -56,12 +64,6 @@ public class ServerConfigurationManager {
|
||||
this.j();
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
public int getMaxPlayers() {
|
||||
return this.e;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
public void a(WorldServer worldserver) {
|
||||
this.l = new PlayerNBTManager(new File(worldserver.t, "players"));
|
||||
}
|
||||
@ -101,13 +103,12 @@ public class ServerConfigurationManager {
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
|
||||
public EntityPlayer a(NetLoginHandler netloginhandler, String s, String s1) {
|
||||
// CraftBukkit start - note: this entire method needs to be changed
|
||||
// Instead of kicking then returning, we need to store the kick reason
|
||||
// in the event, check with plugins to see if it's ok, and THEN kick
|
||||
// depending on the outcome.
|
||||
EntityPlayer entity = new EntityPlayer(c, ((World) (c.e)), s, new ItemInWorldManager(((World) (c.e))));
|
||||
EntityPlayer entity = new EntityPlayer(c, (World) c.e, s, new ItemInWorldManager((World) c.e));
|
||||
Player player = (entity == null) ? null : (Player) entity.getBukkitEntity();
|
||||
PlayerLoginEvent event = new PlayerLoginEvent(Type.PLAYER_LOGIN, player);
|
||||
|
||||
@ -158,6 +159,18 @@ public class ServerConfigurationManager {
|
||||
entityplayer1.a(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
Player respawnPlayer = server.getPlayer(entityplayer);
|
||||
Location respawnLocation = new Location(respawnPlayer.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(Event.Type.PLAYER_RESPAWN, respawnPlayer, respawnLocation );
|
||||
server.getPluginManager().callEvent(respawnEvent);
|
||||
entityplayer1.locX = respawnEvent.getRespawnLocation().getX();
|
||||
entityplayer1.locY = respawnEvent.getRespawnLocation().getY();
|
||||
entityplayer1.locZ = respawnEvent.getRespawnLocation().getZ();
|
||||
entityplayer1.yaw = respawnEvent.getRespawnLocation().getYaw();
|
||||
entityplayer1.pitch = respawnEvent.getRespawnLocation().getPitch();
|
||||
// CraftBukkit end
|
||||
|
||||
entityplayer1.a.b((Packet) (new Packet9Respawn()));
|
||||
entityplayer1.a.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
|
||||
this.d.a(entityplayer1);
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren