geforkt von Mirrors/Paper
Implemented PlayerChangedWorldEvent.
Dieser Commit ist enthalten in:
Ursprung
d532136903
Commit
199a5c2a77
@ -47,18 +47,18 @@ public class ServerConfigurationManager {
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
private CraftServer cserver;
|
private CraftServer cserver;
|
||||||
|
|
||||||
public void changeListName(EntityPlayer entityPlayer, String newName) {
|
public void changeListName(EntityPlayer entityPlayer, String newName) {
|
||||||
String oldName = entityPlayer.listName;
|
String oldName = entityPlayer.listName;
|
||||||
|
|
||||||
if (oldName.equals(newName)) {
|
if (oldName.equals(newName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newName.length() > 16) {
|
if (newName.length() > 16) {
|
||||||
throw new IllegalArgumentException("Player list names can only be a maximum of 16 characters long");
|
throw new IllegalArgumentException("Player list names can only be a maximum of 16 characters long");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collisions will make for invisible people
|
// Collisions will make for invisible people
|
||||||
for (int i = 0; i < this.players.size(); ++i) {
|
for (int i = 0; i < this.players.size(); ++i) {
|
||||||
if (((EntityPlayer) this.players.get(i)).listName.equals(newName)) {
|
if (((EntityPlayer) this.players.get(i)).listName.equals(newName)) {
|
||||||
@ -67,29 +67,29 @@ public class ServerConfigurationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entityPlayer.listName = newName;
|
entityPlayer.listName = newName;
|
||||||
|
|
||||||
// Change the name on the client side
|
// Change the name on the client side
|
||||||
this.sendAll(new Packet201PlayerInfo(oldName, false, 9999));
|
this.sendAll(new Packet201PlayerInfo(oldName, false, 9999));
|
||||||
this.sendAll(new Packet201PlayerInfo(newName, true, entityPlayer.i));
|
this.sendAll(new Packet201PlayerInfo(newName, true, entityPlayer.i));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void detectListNameConflict(EntityPlayer entityPlayer) {
|
private void detectListNameConflict(EntityPlayer entityPlayer) {
|
||||||
// Collisions will make for invisible people
|
// Collisions will make for invisible people
|
||||||
for (int i = 0; i < this.players.size(); ++i) {
|
for (int i = 0; i < this.players.size(); ++i) {
|
||||||
EntityPlayer testEntityPlayer = (EntityPlayer) this.players.get(i);
|
EntityPlayer testEntityPlayer = (EntityPlayer) this.players.get(i);
|
||||||
|
|
||||||
// We have a problem!
|
// We have a problem!
|
||||||
if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) {
|
if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) {
|
||||||
String oldName = entityPlayer.listName;
|
String oldName = entityPlayer.listName;
|
||||||
int spaceLeft = 16 - oldName.length();
|
int spaceLeft = 16 - oldName.length();
|
||||||
|
|
||||||
if (spaceLeft <= 1) { // We also hit the list name length limit!
|
if (spaceLeft <= 1) { // We also hit the list name length limit!
|
||||||
entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft)
|
entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft)
|
||||||
+ String.valueOf(System.currentTimeMillis() % 99);
|
+ String.valueOf(System.currentTimeMillis() % 99);
|
||||||
} else {
|
} else {
|
||||||
entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99);
|
entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -279,6 +279,7 @@ public class ServerConfigurationManager {
|
|||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
EntityPlayer entityplayer1 = entityplayer;
|
EntityPlayer entityplayer1 = entityplayer;
|
||||||
|
org.bukkit.World fromWorld = entityplayer1.getBukkitEntity().getWorld();
|
||||||
|
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
boolean isBedSpawn = false;
|
boolean isBedSpawn = false;
|
||||||
@ -331,6 +332,10 @@ public class ServerConfigurationManager {
|
|||||||
entityplayer1.spawnIn(worldserver);
|
entityplayer1.spawnIn(worldserver);
|
||||||
entityplayer1.dead = false;
|
entityplayer1.dead = false;
|
||||||
entityplayer1.netServerHandler.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch));
|
entityplayer1.netServerHandler.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch));
|
||||||
|
|
||||||
|
org.bukkit.event.player.PlayerChangedWorldEvent event = new org.bukkit.event.player.PlayerChangedWorldEvent((Player) entityplayer1.getBukkitEntity(), fromWorld);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
this.a(entityplayer1, worldserver);
|
this.a(entityplayer1, worldserver);
|
||||||
this.getPlayerManager(entityplayer1.dimension).addPlayer(entityplayer1);
|
this.getPlayerManager(entityplayer1.dimension).addPlayer(entityplayer1);
|
||||||
@ -387,7 +392,7 @@ public class ServerConfigurationManager {
|
|||||||
}
|
}
|
||||||
this.p = 200; // <-- this resetting of flushtime is missing! though whole code is commented out now :)
|
this.p = 200; // <-- this resetting of flushtime is missing! though whole code is commented out now :)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i < this.server.worlds.size(); ++i) {
|
for (i = 0; i < this.server.worlds.size(); ++i) {
|
||||||
this.server.worlds.get(i).manager.flush();
|
this.server.worlds.get(i).manager.flush();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren