Skip to content
This repository has been archived by the owner on Jul 21, 2024. It is now read-only.

Commit

Permalink
Fix customizable whitelist message (#327)
Browse files Browse the repository at this point in the history
Use whitelist message from spigot.yml
  • Loading branch information
LeStegii authored Dec 20, 2020
1 parent 966e691 commit 81f47df
Showing 1 changed file with 38 additions and 28 deletions.
66 changes: 38 additions & 28 deletions patches/net/minecraft/server/management/PlayerList.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import net.minecraft.world.DimensionType;
import net.minecraft.world.GameType;
import net.minecraft.world.World;
@@ -62,10 +64,39 @@
@@ -62,10 +64,40 @@
import net.minecraft.world.chunk.storage.AnvilChunkLoader;
import net.minecraft.world.storage.IPlayerFileData;
import net.minecraft.world.storage.WorldInfo;
Expand Down Expand Up @@ -79,11 +79,12 @@
+import org.bukkit.util.Vector;
+import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;
+import org.spigotmc.SpigotConfig;
+import org.spigotmc.event.player.PlayerSpawnLocationEvent;

public abstract class PlayerList
{
@@ -76,15 +107,15 @@
@@ -76,15 +108,15 @@
private static final Logger LOGGER = LogManager.getLogger();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
private final MinecraftServer mcServer;
Expand All @@ -103,7 +104,7 @@
private boolean whiteListEnforced;
protected int maxPlayers;
private int viewDistance;
@@ -92,14 +123,22 @@
@@ -92,14 +124,22 @@
private boolean commandsAllowedForAll;
private int playerPingIndex;

Expand All @@ -128,7 +129,7 @@
this.mcServer = server;
this.bannedPlayers.setLanServer(false);
this.bannedIPs.setLanServer(false);
@@ -125,6 +164,13 @@
@@ -125,6 +165,13 @@
playerIn.setPosition(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
}

Expand All @@ -142,7 +143,7 @@
playerIn.setWorld(playerWorld);
playerIn.interactionManager.setWorld((WorldServer)playerIn.world);
String s1 = "local";
@@ -134,36 +180,61 @@
@@ -134,36 +181,61 @@
s1 = netManager.getRemoteAddress().toString();
}

Expand Down Expand Up @@ -212,7 +213,7 @@
nethandlerplayserver.setPlayerLocation(playerIn.posX, playerIn.posY, playerIn.posZ, playerIn.rotationYaw, playerIn.rotationPitch);
this.updateTimeAndWeatherForPlayer(playerIn, worldserver);

@@ -217,9 +288,11 @@
@@ -217,9 +289,11 @@

playerIn.addSelfToInternalCraftingInventory();
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedIn(playerIn);
Expand All @@ -225,7 +226,7 @@
{
Set<ScoreObjective> set = Sets.<ScoreObjective>newHashSet();

@@ -246,28 +319,29 @@
@@ -246,28 +320,29 @@

public void setPlayerManager(WorldServer[] worldServers)
{
Expand Down Expand Up @@ -260,7 +261,7 @@
}
public void onDamageAmountChanged(WorldBorder border, double newAmount)
{
@@ -344,16 +418,16 @@
@@ -344,16 +419,16 @@
protected void writePlayerData(EntityPlayerMP playerIn)
{
if (playerIn.connection == null) return;
Expand All @@ -280,7 +281,7 @@

if (playeradvancements != null)
{
@@ -363,19 +437,62 @@
@@ -363,19 +438,62 @@

public void playerLoggedIn(EntityPlayerMP playerIn)
{
Expand Down Expand Up @@ -347,7 +348,7 @@
}

public void serverUpdateMovingPlayer(EntityPlayerMP playerIn)
@@ -383,11 +500,30 @@
@@ -383,11 +501,30 @@
playerIn.getServerWorld().getPlayerChunkMap().updateMovingPlayer(playerIn);
}

Expand Down Expand Up @@ -379,7 +380,7 @@
this.writePlayerData(playerIn);

if (playerIn.isRiding())
@@ -414,17 +550,35 @@
@@ -414,17 +551,35 @@
worldserver.getPlayerChunkMap().removePlayer(playerIn);
playerIn.getAdvancements().dispose();
this.playerEntityList.remove(playerIn);
Expand Down Expand Up @@ -418,7 +419,16 @@
}

public String allowUserToConnect(SocketAddress address, GameProfile profile)
@@ -463,6 +617,72 @@
@@ -443,7 +598,7 @@
}
else if (!this.canJoin(profile))
{
- return "You are not white-listed on this server!";
+ return SpigotConfig.whitelistMessage; // Magma
}
else if (this.bannedIPs.isBanned(address))
{
@@ -463,6 +618,72 @@
}
}

Expand Down Expand Up @@ -458,7 +468,7 @@
+ else if (!this.canJoin(profile))
+ {
+ // return "You are not white-listed on this server!";
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "You are not white-listed on this server!");
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, SpigotConfig.whitelistMessage); // Magma
+ }
+ else if (getBannedIPs().isBanned(socketaddress) && !getBannedIPs().getBanEntry(socketaddress).hasBanExpired())
+ {
Expand Down Expand Up @@ -491,7 +501,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile profile)
{
UUID uuid = EntityPlayer.getUUID(profile);
@@ -504,39 +724,41 @@
@@ -504,39 +725,41 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.getWorld(0), profile, playerinteractionmanager);
}

Expand Down Expand Up @@ -547,7 +557,7 @@
entityplayermp.connection = playerIn.connection;
entityplayermp.copyFrom(playerIn, conqueredEnd);
entityplayermp.dimension = dimension;
@@ -549,48 +771,179 @@
@@ -549,48 +772,179 @@
entityplayermp.addTag(s);
}

Expand Down Expand Up @@ -748,7 +758,7 @@
public void updatePermissionLevel(EntityPlayerMP player)
{
GameProfile gameprofile = player.getGameProfile();
@@ -642,7 +995,9 @@
@@ -642,7 +996,9 @@

public void transferEntityToWorld(Entity entityIn, int lastDimension, WorldServer oldWorldIn, WorldServer toWorldIn)
{
Expand All @@ -759,7 +769,7 @@
}

// TODO: Remove (1.13)
@@ -729,11 +1084,158 @@
@@ -729,11 +1085,158 @@
entityIn.setWorld(toWorldIn);
}

Expand Down Expand Up @@ -919,7 +929,7 @@
this.playerPingIndex = 0;
}
}
@@ -746,6 +1248,22 @@
@@ -746,6 +1249,22 @@
}
}

Expand All @@ -942,7 +952,7 @@
public void sendPacketToAllPlayersInDimension(Packet<?> packetIn, int dimension)
{
for (int i = 0; i < this.playerEntityList.size(); ++i)
@@ -861,12 +1379,20 @@
@@ -861,12 +1380,20 @@
int i = this.mcServer.getOpPermissionLevel();
this.ops.addEntry(new UserListOpsEntry(profile, this.mcServer.getOpPermissionLevel(), this.ops.bypassesPlayerLimit(profile)));
this.sendPlayerPermissionLevel(this.getPlayerByUUID(profile.getId()), i);
Expand All @@ -963,7 +973,7 @@
}

private void sendPlayerPermissionLevel(EntityPlayerMP player, int permLevel)
@@ -905,24 +1431,36 @@
@@ -905,24 +1432,36 @@
@Nullable
public EntityPlayerMP getPlayerByUsername(String username)
{
Expand Down Expand Up @@ -1013,7 +1023,7 @@
{
double d0 = x - entityplayermp.posX;
double d1 = y - entityplayermp.posY;
@@ -938,11 +1476,23 @@
@@ -938,11 +1477,23 @@

public void saveAllPlayerData()
{
Expand All @@ -1040,7 +1050,7 @@

public void addWhitelistedPlayer(GameProfile profile)
{
@@ -988,16 +1538,21 @@
@@ -988,16 +1539,21 @@

if (worldIn.isRaining())
{
Expand All @@ -1066,7 +1076,7 @@
playerIn.connection.sendPacket(new SPacketHeldItemChange(playerIn.inventory.currentItem));
}

@@ -1079,17 +1634,26 @@
@@ -1079,17 +1635,26 @@

public void removeAllPlayers()
{
Expand Down Expand Up @@ -1097,7 +1107,7 @@
}

public void sendMessage(ITextComponent component)
@@ -1097,10 +1661,19 @@
@@ -1097,10 +1662,19 @@
this.sendMessage(component, true);
}

Expand All @@ -1119,7 +1129,7 @@

if (statisticsmanagerserver == null)
{
@@ -1119,7 +1692,7 @@
@@ -1119,7 +1693,7 @@

statisticsmanagerserver = new StatisticsManagerServer(this.mcServer, file2);
statisticsmanagerserver.readStatFile();
Expand All @@ -1128,7 +1138,7 @@
}

return statisticsmanagerserver;
@@ -1128,14 +1701,14 @@
@@ -1128,14 +1702,14 @@
public PlayerAdvancements getPlayerAdvancements(EntityPlayerMP p_192054_1_)
{
UUID uuid = p_192054_1_.getUniqueID();
Expand All @@ -1145,7 +1155,7 @@
}

playeradvancements.setPlayer(p_192054_1_);
@@ -1148,7 +1721,7 @@
@@ -1148,7 +1722,7 @@

if (this.mcServer.worlds != null)
{
Expand All @@ -1154,7 +1164,7 @@
{
if (worldserver != null)
{
@@ -1176,9 +1749,10 @@
@@ -1176,9 +1750,10 @@

public void reloadResources()
{
Expand Down

0 comments on commit 81f47df

Please sign in to comment.