Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Nov 4, 2024
1 parent 0b11781 commit b9e2514
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 60 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@
10. Player login logic improvement to reduce lag
11. Automatically purge bot data
12. **Folia support (in active testing)**
13. Offhand Menu compatibility(Thats amazing)
14. **Velocity support (See [Velocity Support](./vc-support.md))**
15. Support Virtual Threads caching
16. Automatically fix portal stuck issue
17. Automatically login for Bedrock players(configurable)
18. Fix shulker box crash bug on legacy versions(MC 1.13-)
19. **H2 database support**
20. **100% compatibility with original authme and extensions**
21. More......
13. **Velocity support (See [Velocity Support](./vc-support.md))**
14. Support Virtual Threads caching
15. Automatically fix portal stuck issue
16. Automatically login for Bedrock players(configurable)
17. Fix shulker box crash bug on legacy versions(MC 1.13-)
18. **H2 database support**
19. **100% compatibility with original authme and extensions**
20. More......

**Download links:**
[Releases](https://github.com/HaHaWTH/AuthMeReReloaded/releases/latest)
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/fr/xephi/authme/api/v3/AuthMeApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;

import javax.inject.Inject;
import java.time.Instant;
Expand All @@ -26,8 +24,6 @@
import java.util.Locale;
import java.util.Optional;

import static fr.xephi.authme.listener.PlayerListener.PENDING_INVENTORIES;

/**
* The current API of AuthMe.
*
Expand Down Expand Up @@ -261,18 +257,6 @@ public boolean registerPlayer(String playerName, String password) {
return dataSource.saveAuth(auth);
}

/**
* Open an inventory for the given player at any time.
*
* @param player The player to open the inventory for
* @param inventory The inventory to open
* @return The inventory view
*/
public InventoryView openInventory(Player player, Inventory inventory) {
PENDING_INVENTORIES.add(inventory);
return player.openInventory(inventory);
}

/**
* Force a player to login, i.e. the player is logged in without needing his password.
*
Expand Down
27 changes: 1 addition & 26 deletions src/main/java/fr/xephi/authme/listener/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,9 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;

Expand Down Expand Up @@ -98,8 +95,6 @@ public class PlayerListener implements Listener {
@Inject
private QuickCommandsProtectionManager quickCommandsProtectionManager;

public static List<Inventory> PENDING_INVENTORIES = new ArrayList<>();

// Lowest priority to apply fast protection checks
@EventHandler(priority = EventPriority.LOWEST)
public void onAsyncPlayerPreLoginEventLowest(AsyncPlayerPreLoginEvent event) {
Expand Down Expand Up @@ -500,17 +495,6 @@ public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
}
}

private boolean isInventoryOpenedByApi(Inventory inventory) {
if (inventory == null) {
return false;
}
if (PENDING_INVENTORIES.contains(inventory)) {
PENDING_INVENTORIES.remove(inventory);
return true;
} else {
return false;
}
}
@SuppressWarnings("all")
private boolean isInventoryWhitelisted(InventoryView inventory) {
if (inventory == null) {
Expand All @@ -537,8 +521,7 @@ private boolean isInventoryWhitelisted(InventoryView inventory) {
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
final HumanEntity player = event.getPlayer();
if (listenerService.shouldCancelEvent(player)
&& !isInventoryWhitelisted(event.getView())
&& !isInventoryOpenedByApi(event.getInventory())) {
&& !isInventoryWhitelisted(event.getView())) {
event.setCancelled(true);

/*
Expand All @@ -556,12 +539,4 @@ public void onPlayerInventoryClick(InventoryClickEvent event) {
event.setCancelled(true);
}
}
// @EventHandler(priority = EventPriority.LOWEST)
// public void onSwitchHand(PlayerSwapHandItemsEvent event) {
// Player player = event.getPlayer();
// if (!player.isSneaking() || !player.hasPermission("keybindings.use"))
// return;
// event.setCancelled(true);
// Bukkit.dispatchCommand(event.getPlayer(), "help");
// }
}
23 changes: 14 additions & 9 deletions src/main/java/fr/xephi/authme/task/Updater.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package fr.xephi.authme.task;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.util.Scanner;

public class Updater {
private final String currentVersion;
Expand Down Expand Up @@ -32,14 +35,16 @@ public boolean isUpdateAvailable() {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(10000);
conn.setReadTimeout(10000);
Scanner scanner = new Scanner(conn.getInputStream());
String response = scanner.useDelimiter("\\Z").next();
scanner.close();
String latestVersion = response.substring(response.indexOf("tag_name") + 11);
latestVersion = latestVersion.substring(0, latestVersion.indexOf("\""));
this.latestVersion = latestVersion;
isUpdateAvailable = !currentVersion.equals(latestVersion);
return isUpdateAvailable;
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/vnd.github+json");
try (InputStreamReader reader = new InputStreamReader(conn.getInputStream())) {
JsonObject jsonObject = new JsonParser().parse(reader).getAsJsonObject();
String latest = jsonObject.get("tag_name").getAsString();
latestVersion = latest;
isUpdateAvailable = !currentVersion.equals(latest);
reader.close();
return isUpdateAvailable;
}
} catch (IOException ignored) {
this.latestVersion = null;
isUpdateAvailable = false;
Expand Down

0 comments on commit b9e2514

Please sign in to comment.