From 33a6de0f13d0849b70ebf7880182d11adebe739b Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 28 Apr 2018 11:31:26 -0400 Subject: [PATCH] Add Ban Methods to Player Objects Allows a more logical API for banning players. player.banPlayer("Breaking the rules"); --- ...97-Add-Ban-Methods-to-Player-Objects.patch | 232 ++++++++++++++++++ ...-explosions-processing-dead-entities.patch | 6 +- .../0030-Generator-Settings.patch | 4 +- .../0031-Optimize-explosions.patch | 4 +- ...lowing-block-if-material-has-changed.patch | 6 +- .../0033-Fast-draining.patch | 4 +- .../0034-Configurable-lava-flow-speed.patch | 4 +- .../0035-Add-player-view-distance-API.patch | 6 +- .../0036-Disable-explosion-knockback.patch | 6 +- 9 files changed, 252 insertions(+), 20 deletions(-) create mode 100644 Spigot-API-Patches/0097-Add-Ban-Methods-to-Player-Objects.patch diff --git a/Spigot-API-Patches/0097-Add-Ban-Methods-to-Player-Objects.patch b/Spigot-API-Patches/0097-Add-Ban-Methods-to-Player-Objects.patch new file mode 100644 index 000000000..9fc09c68e --- /dev/null +++ b/Spigot-API-Patches/0097-Add-Ban-Methods-to-Player-Objects.patch @@ -0,0 +1,232 @@ +From 49542a3fdb8594cc0e398a21dee2664f87d0993f Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 28 Apr 2018 10:28:50 -0400 +Subject: [PATCH] Add Ban Methods to Player Objects + +Allows a more logical API for banning players. + +player.banPlayer("Breaking the rules"); + +diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java +index 3ab2e4c7..8daf2ddc 100644 +--- a/src/main/java/org/bukkit/OfflinePlayer.java ++++ b/src/main/java/org/bukkit/OfflinePlayer.java +@@ -40,6 +40,56 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio + * @return true if banned, otherwise false + */ + public boolean isBanned(); ++ // Paper start ++ ++ /** ++ * Permanently Bans this player from the server ++ * ++ * @param reason Reason for Ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayer(String reason) { ++ return banPlayer(reason, null, null); ++ } ++ ++ /** ++ * Permanently Bans this player from the server ++ * @param reason Reason for Ban ++ * @param source Source of the ban, or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayer(String reason, String source) { ++ return banPlayer(reason, null, source); ++ } ++ ++ /** ++ * Bans this player from the server ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayer(String reason, Date expires) { ++ return banPlayer(reason, expires, null); ++ } ++ ++ /** ++ * Bans this player from the server ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @param source Source of the ban or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayer(String reason, Date expires, String source) { ++ return banPlayer(reason, expires, source, true); ++ } ++ public default BanEntry banPlayer(String reason, Date expires, String source, boolean kickIfOnline) { ++ BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.NAME).addBan(getName(), reason, expires, source); ++ if (kickIfOnline && isOnline()) { ++ getPlayer().kickPlayer(reason); ++ } ++ return banEntry; ++ } ++ // Paper end + + /** + * Checks if this player is whitelisted or not +diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java +index 87a9b750..d874d166 100644 +--- a/src/main/java/org/bukkit/entity/Player.java ++++ b/src/main/java/org/bukkit/entity/Player.java +@@ -1,10 +1,14 @@ + package org.bukkit.entity; + + import java.net.InetSocketAddress; ++import java.util.Date; + + import com.destroystokyo.paper.Title; + import com.destroystokyo.paper.profile.PlayerProfile; + import org.bukkit.Achievement; ++import org.bukkit.BanEntry; ++import org.bukkit.BanList; ++import org.bukkit.Bukkit; + import org.bukkit.ChatColor; + import org.bukkit.Effect; + import org.bukkit.GameMode; +@@ -397,6 +401,139 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline + public void sendMap(MapView map); + + // Paper start ++ /** ++ * Permanently Bans the Profile and IP address currently used by the player. ++ * ++ * @param reason Reason for ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerFull(String reason) { ++ return banPlayerFull(reason, null, null); ++ } ++ ++ /** ++ * Permanently Bans the Profile and IP address currently used by the player. ++ * ++ * @param reason Reason for ban ++ * @param source Source of ban, or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerFull(String reason, String source) { ++ return banPlayerFull(reason, null, source); ++ } ++ ++ /** ++ * Bans the Profile and IP address currently used by the player. ++ * ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerFull(String reason, Date expires) { ++ return banPlayerFull(reason, expires, null); ++ } ++ ++ /** ++ * Bans the Profile and IP address currently used by the player. ++ * ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @param source Source of the ban, or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerFull(String reason, Date expires, String source) { ++ banPlayer(reason, expires, source); ++ return banPlayerIP(reason, expires, source, true); ++ } ++ ++ /** ++ * Permanently Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * ++ * @param reason Reason for ban ++ * @param kickPlayer Whether or not to kick the player afterwards ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, boolean kickPlayer) { ++ return banPlayerIP(reason, null, null, kickPlayer); ++ } ++ ++ /** ++ * Permanently Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * @param reason Reason for ban ++ * @param source Source of ban, or null for default ++ * @param kickPlayer Whether or not to kick the player afterwards ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, String source, boolean kickPlayer) { ++ return banPlayerIP(reason, null, source, kickPlayer); ++ } ++ ++ /** ++ * Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @param kickPlayer Whether or not to kick the player afterwards ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, Date expires, boolean kickPlayer) { ++ return banPlayerIP(reason, expires, null, kickPlayer); ++ } ++ ++ /** ++ * Permanently Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * ++ * @param reason Reason for ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason) { ++ return banPlayerIP(reason, null, null); ++ } ++ ++ /** ++ * Permanently Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * @param reason Reason for ban ++ * @param source Source of ban, or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, String source) { ++ return banPlayerIP(reason, null, source); ++ } ++ ++ /** ++ * Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, Date expires) { ++ return banPlayerIP(reason, expires, null); ++ } ++ ++ /** ++ * Bans the IP address currently used by the player. ++ * Does not ban the Profile, use {@link #banPlayerFull(String, Date, String)} ++ * @param reason Reason for Ban ++ * @param expires When to expire the ban ++ * @param source Source of the banm or null for default ++ * @return Ban Entry ++ */ ++ public default BanEntry banPlayerIP(String reason, Date expires, String source) { ++ return banPlayerIP(reason, expires, source, true); ++ } ++ public default BanEntry banPlayerIP(String reason, Date expires, String source, boolean kickPlayer) { ++ BanEntry banEntry = Bukkit.getServer().getBanList(BanList.Type.IP).addBan(getAddress().getAddress().getHostAddress(), reason, expires, source); ++ if (kickPlayer && isOnline()) { ++ getPlayer().kickPlayer(reason); ++ } ++ ++ return banEntry; ++ } + + /** + * Sends an Action Bar message to the client. +-- +2.17.0 + diff --git a/Spigot-Server-Patches/0029-Fix-lag-from-explosions-processing-dead-entities.patch b/Spigot-Server-Patches/0029-Fix-lag-from-explosions-processing-dead-entities.patch index 1e9b5671a..15213f291 100644 --- a/Spigot-Server-Patches/0029-Fix-lag-from-explosions-processing-dead-entities.patch +++ b/Spigot-Server-Patches/0029-Fix-lag-from-explosions-processing-dead-entities.patch @@ -1,11 +1,11 @@ -From d0691988443de01bda2253f429d0d19fe988a125 Mon Sep 17 00:00:00 2001 +From 546315b2c4410127330c66a51e4dc275640dde34 Mon Sep 17 00:00:00 2001 From: Iceee Date: Wed, 2 Mar 2016 01:39:52 -0600 Subject: [PATCH] Fix lag from explosions processing dead entities diff --git a/src/main/java/net/minecraft/server/Explosion.java b/src/main/java/net/minecraft/server/Explosion.java -index 98c2bdcf..a1ebcf85 100644 +index 98c2bdcf7..a1ebcf858 100644 --- a/src/main/java/net/minecraft/server/Explosion.java +++ b/src/main/java/net/minecraft/server/Explosion.java @@ -104,7 +104,14 @@ public class Explosion { @@ -25,5 +25,5 @@ index 98c2bdcf..a1ebcf85 100644 for (int l1 = 0; l1 < list.size(); ++l1) { -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0030-Generator-Settings.patch b/Spigot-Server-Patches/0030-Generator-Settings.patch index aabef021d..54c5d4127 100644 --- a/Spigot-Server-Patches/0030-Generator-Settings.patch +++ b/Spigot-Server-Patches/0030-Generator-Settings.patch @@ -1,4 +1,4 @@ -From 1041665a9111bf437a33aef1bc08d7842c5ae211 Mon Sep 17 00:00:00 2001 +From 44be4254d3e0b4553144b3e11ef864c9eaf57d13 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 02:17:54 -0600 Subject: [PATCH] Generator Settings @@ -308,5 +308,5 @@ index 66a80a776..34fd7edfe 100644 ObjectIterator objectiterator = this.c.values().iterator(); -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0031-Optimize-explosions.patch b/Spigot-Server-Patches/0031-Optimize-explosions.patch index 017a71d0c..390d97dce 100644 --- a/Spigot-Server-Patches/0031-Optimize-explosions.patch +++ b/Spigot-Server-Patches/0031-Optimize-explosions.patch @@ -1,4 +1,4 @@ -From 345e60055a56d14763a2e9902b54079ca1ce7f72 Mon Sep 17 00:00:00 2001 +From 4a3ce0b9f53b9cb651783d272853855f45ac78dd Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 11:59:48 -0600 Subject: [PATCH] Optimize explosions @@ -156,5 +156,5 @@ index 77ed2d249..fc7315f7d 100644 public CraftWorld getWorld() { return this.world; -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0032-Stop-updating-flowing-block-if-material-has-changed.patch b/Spigot-Server-Patches/0032-Stop-updating-flowing-block-if-material-has-changed.patch index 8e616e4b0..2941b53f7 100644 --- a/Spigot-Server-Patches/0032-Stop-updating-flowing-block-if-material-has-changed.patch +++ b/Spigot-Server-Patches/0032-Stop-updating-flowing-block-if-material-has-changed.patch @@ -1,11 +1,11 @@ -From d03ae937e89c84d1069229eb94714aa1f2b2e009 Mon Sep 17 00:00:00 2001 +From 491235cd2a7ab7a9eaff4d02718c37d657b78167 Mon Sep 17 00:00:00 2001 From: Iceee Date: Wed, 2 Mar 2016 12:03:23 -0600 Subject: [PATCH] Stop updating flowing block if material has changed diff --git a/src/main/java/net/minecraft/server/BlockFlowing.java b/src/main/java/net/minecraft/server/BlockFlowing.java -index 62234a7c..3b47253a 100644 +index 62234a7c9..3b47253a4 100644 --- a/src/main/java/net/minecraft/server/BlockFlowing.java +++ b/src/main/java/net/minecraft/server/BlockFlowing.java @@ -90,6 +90,7 @@ public class BlockFlowing extends BlockFluids { @@ -17,5 +17,5 @@ index 62234a7c..3b47253a 100644 IBlockData iblockdata2 = world.getType(blockposition.down()); -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0033-Fast-draining.patch b/Spigot-Server-Patches/0033-Fast-draining.patch index ac6945539..885882edb 100644 --- a/Spigot-Server-Patches/0033-Fast-draining.patch +++ b/Spigot-Server-Patches/0033-Fast-draining.patch @@ -1,4 +1,4 @@ -From dfbf1e7d43cafde4cfcd6a4c03e53d61bc454f06 Mon Sep 17 00:00:00 2001 +From ebb2e432e50bb6758f584920396ae4ed8ef98b0e Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 12:20:52 -0600 Subject: [PATCH] Fast draining @@ -109,5 +109,5 @@ index 3b47253a4..3aaa19b2f 100644 + // Paper end } -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0034-Configurable-lava-flow-speed.patch b/Spigot-Server-Patches/0034-Configurable-lava-flow-speed.patch index 1a4bf9d71..927eec0f2 100644 --- a/Spigot-Server-Patches/0034-Configurable-lava-flow-speed.patch +++ b/Spigot-Server-Patches/0034-Configurable-lava-flow-speed.patch @@ -1,4 +1,4 @@ -From 39fb008250a9039f1547408fbd9769db26333787 Mon Sep 17 00:00:00 2001 +From f764c07be09e378b2e3561779358108f37bb82f0 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 12:27:07 -0600 Subject: [PATCH] Configurable lava flow speed @@ -47,5 +47,5 @@ index f3eb2a797..d0265f960 100644 return this.e; } -- -2.14.3 +2.17.0 diff --git a/Spigot-Server-Patches/0035-Add-player-view-distance-API.patch b/Spigot-Server-Patches/0035-Add-player-view-distance-API.patch index 69ddaeb9e..dd2d9761f 100644 --- a/Spigot-Server-Patches/0035-Add-player-view-distance-API.patch +++ b/Spigot-Server-Patches/0035-Add-player-view-distance-API.patch @@ -1,11 +1,11 @@ -From 3a5c6b152a7a804921e9ff7f2057eb5c6f79a9e4 Mon Sep 17 00:00:00 2001 +From b37938d4ce59d4ae17feb44e60dd1f8124c1a4d8 Mon Sep 17 00:00:00 2001 From: Byteflux Date: Wed, 2 Mar 2016 14:35:27 -0600 Subject: [PATCH] Add player view distance API diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java -index 9829cdd89..5b0675718 100644 +index dfaab774d..3058dfef0 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -66,6 +66,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting { @@ -224,5 +224,5 @@ index 44d0db180..b2b707305 100644 private final Player.Spigot spigot = new Player.Spigot() { -- -2.16.1 +2.17.0 diff --git a/Spigot-Server-Patches/0036-Disable-explosion-knockback.patch b/Spigot-Server-Patches/0036-Disable-explosion-knockback.patch index e4485085c..97262798d 100644 --- a/Spigot-Server-Patches/0036-Disable-explosion-knockback.patch +++ b/Spigot-Server-Patches/0036-Disable-explosion-knockback.patch @@ -1,4 +1,4 @@ -From f16a164dfccddfb47a36c363b71dd7788bcd2134 Mon Sep 17 00:00:00 2001 +From 3205346921413de13db17a2fa51e33847237783c Mon Sep 17 00:00:00 2001 From: Sudzzy Date: Wed, 2 Mar 2016 14:48:03 -0600 Subject: [PATCH] Disable explosion knockback @@ -19,7 +19,7 @@ index b0b3033e7..afc13e851 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java -index 756590ac0..05d1fc10d 100644 +index d15cfdd76..2aaeac324 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -906,6 +906,7 @@ public abstract class EntityLiving extends Entity { @@ -70,5 +70,5 @@ index e7f0e84d4..e148901e5 100644 } } -- -2.14.3 +2.17.0