Add AdvancedShulkerFix and optimize LoginLocationFix

This commit is contained in:
HaHaWTH 2023-12-31 17:19:30 +08:00
parent c89a818696
commit be976b6738
6 changed files with 87 additions and 14 deletions

View File

@ -24,7 +24,8 @@ MCBBS Link: [Click Here](https://www.mcbbs.net/forum.php?mod=viewthread&tid=1471
13. Offhand Menu compatibility(Thats amazing)
14. Automatically fix portal stuck issue
15. Automatically login for Bedrock players(configurable)
16. More......
16. Fix shulker box crash bug on legacy versions(MC 1.13-)
17. More......
**Download links:**
[Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest)

35
pom.xml
View File

@ -444,6 +444,14 @@
<pattern>com.google.protobuf</pattern>
<shadedPattern>fr.xephi.authme.libs.com.google.protobuf</shadedPattern>
</relocation>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>fr.xephi.authme.libs.io.netty</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.validator</pattern>
<shadedPattern>fr.xephi.authme.libs.org.apache.commons.validator</shadedPattern>
</relocation>
</relocations>
<filters>
@ -511,6 +519,15 @@
</build>
<repositories>
<repository>
<id>opencollab-snapshot-main</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>
<repository>
<id>opencollab-maven-snapshots</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
</repository>
<!-- Apache snapshots repo -->
<repository>
<id>apache-snapshots</id>
@ -629,10 +646,6 @@
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>opencollab-snapshot-main</id>
<url>https://repo.opencollab.dev/main/</url>
</repository>
</repositories>
<dependencies>
@ -869,13 +882,19 @@
</exclusions>
</dependency>
<!-- &lt;!&ndash; XSeries &ndash;&gt;-->
<!-- dependencies used by HAProxy feature -->
<!-- <dependency>-->
<!-- <groupId>com.github.cryptomorin</groupId>-->
<!-- <artifactId>XSeries</artifactId>-->
<!-- <version>9.8.0</version>-->
<!-- <groupId>io.netty</groupId>-->
<!-- <artifactId>netty-codec-haproxy</artifactId>-->
<!-- <version>4.1.104.Final</version>-->
<!-- <scope>compile</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>commons-validator</groupId>-->
<!-- <artifactId>commons-validator</artifactId>-->
<!-- <version>1.8.0</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
<!-- zPermissions plugin -->
<dependency>

View File

@ -11,6 +11,7 @@ import fr.xephi.authme.initialization.OnShutdownPlayerSaver;
import fr.xephi.authme.initialization.OnStartupTasks;
import fr.xephi.authme.initialization.SettingsProvider;
import fr.xephi.authme.initialization.TaskCloser;
import fr.xephi.authme.listener.AdvancedShulkerFixListener;
import fr.xephi.authme.listener.BedrockAutoLoginListener;
import fr.xephi.authme.listener.BlockListener;
import fr.xephi.authme.listener.DoubleLoginFixListener;
@ -359,6 +360,9 @@ public class AuthMe extends JavaPlugin {
if (settings.getProperty(SecuritySettings.ANTI_GHOST_PLAYERS)) {
pluginManager.registerEvents(injector.getSingleton(DoubleLoginFixListener.class), this);
}
if (settings.getProperty(SecuritySettings.ADVANCED_SHULKER_FIX)) {
pluginManager.registerEvents(injector.getSingleton(AdvancedShulkerFixListener.class), this);
}
}
/**

View File

@ -0,0 +1,43 @@
package fr.xephi.authme.listener;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockDispenseEvent;
//This fix is only for Minecraft 1.13-
public class AdvancedShulkerFixListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onDispenserActivate(BlockDispenseEvent event) {
Block block = event.getBlock();
if (block.getFace(block) == BlockFace.DOWN) {
//If the block is in y = 0
if (block.getY() == 0) {
event.setCancelled(true);
}
}
if (block.getFace(block) == BlockFace.UP) {
//If the block is in y = 255
if (block.getY() == 255) {
event.setCancelled(true);
}
}
}
//This implementation method will be available in my another plugin
// @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
// public void onDispenserBePlaced(BlockPlaceEvent event){
// Block block = event.getBlock();
// if (block.getType().equals(Material.DISPENSER)){
// if (block.getFace(block) == BlockFace.DOWN && block.getY() == 0){
// event.setCancelled(true);
// }
// if (block.getFace(block) == BlockFace.UP && block.getY() == 255){
// event.setCancelled(true);
// }
// }
// }
}

View File

@ -35,7 +35,7 @@ public class LoginLocationFixListener implements Listener {
private static Material materialPortal = Material.matchMaterial("PORTAL");
private static boolean isChecked = false; // false: unchecked/method not available true: method is available
private static boolean isAvailable; // false: unchecked/method not available true: method is available
private final boolean isSmartAsyncTeleport = AuthMe.settings.getProperty(SecuritySettings.SMART_ASYNC_TELEPORT);
private final boolean isFixPortalStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_PORTAL);
private final boolean isFixGroundStuck = AuthMe.settings.getProperty(SecuritySettings.LOGIN_LOC_FIX_SUB_UNDERGROUND);
@ -50,15 +50,15 @@ public class LoginLocationFixListener implements Listener {
}
try {
Method getMinHeightMethod = World.class.getMethod("getMinHeight");
isChecked = true;
isAvailable = true;
} catch (NoSuchMethodException e) {
isChecked = false;
isAvailable = false;
}
}
private int getMinHeight(World world) {
//This keeps compatibility of 1.16.x and lower
if (isChecked) {
if (isAvailable) {
return world.getMinHeight();
} else {
return 0;
@ -97,10 +97,11 @@ public class LoginLocationFixListener implements Listener {
Material UpType = JoinLocation.getBlock().getRelative(BlockFace.UP).getType();
World world = player.getWorld();
int MaxHeight = world.getMaxHeight();
int MinHeight = getMinHeight(world);
if (!UpType.isOccluding() && !UpType.equals(Material.LAVA)) {
return;
}
for (int i = getMinHeight(world); i <= MaxHeight; i++) {
for (int i = MinHeight; i <= MaxHeight; i++) {
JoinLocation.setY(i);
Block JoinBlock = JoinLocation.getBlock();
if ((JoinBlock.getRelative(BlockFace.DOWN).getType().isBlock())

View File

@ -35,6 +35,11 @@ public final class SecuritySettings implements SettingsHolder {
public static final Property<Boolean> ANTI_GHOST_PLAYERS =
newProperty("3rdPartyFeature.fixes.antiGhostPlayer", false);
@Comment({"(MC1.13- only)",
"Should we fix the shulker crash bug with advanced method?"})
public static final Property<Boolean> ADVANCED_SHULKER_FIX =
newProperty("3rdPartyFeature.fixes.advancedShulkerFix", true);
@Comment({"Choose the best teleport method by server brand?",
"(Enable this if you are using Paper)"})
public static final Property<Boolean> SMART_ASYNC_TELEPORT =