-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better hook into geyser, resource filtering and general fixes
- Loading branch information
1 parent
7125ccf
commit 463cdae
Showing
10 changed files
with
132 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/main/java/de/hdg/keklist/events/GeyserConnectionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.hdg.keklist.events; | ||
|
||
import de.hdg.keklist.Keklist; | ||
import de.hdg.keklist.extentions.WebhookManager; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.entity.Player; | ||
import org.geysermc.geyser.api.event.connection.ConnectionRequestEvent; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.SQLException; | ||
|
||
public class GeyserConnectionEvent { | ||
|
||
private static final FileConfiguration config = Keklist.getInstance().getConfig(); | ||
|
||
public static void onConnectionRequestEvent(ConnectionRequestEvent event) { | ||
String ip = event.getInetSocketAddress().getAddress().getHostAddress(); | ||
|
||
try (ResultSet rsIp = Keklist.getDatabase().onQuery("SELECT * FROM blacklistIp WHERE ip = ?", ip)) { | ||
if (rsIp.next()) { | ||
if (config.getBoolean("blacklist.allow-join-with-admin")) { | ||
for (Player player : Keklist.getInstance().getServer().getOnlinePlayers()) { | ||
if (player.hasPermission(config.getString("blacklist.admin-permission"))) { | ||
return; | ||
} | ||
} | ||
} | ||
|
||
if (Keklist.getInstance().getConfig().getBoolean("chat-notify")) | ||
Bukkit.broadcast(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("notify.kick", ip)), "keklist.notify.kicked"); | ||
|
||
if (Keklist.getWebhookManager() != null) | ||
Keklist.getWebhookManager().fireBlacklistEvent(WebhookManager.EVENT_TYPE.BLACKLIST_KICK, ip, rsIp.getString("byPlayer"), null, System.currentTimeMillis()); | ||
|
||
Bukkit.getConsoleSender().sendMessage(Keklist.getInstance().getMiniMessage().deserialize(Keklist.getTranslations().get("notify.kick", ip))); | ||
|
||
event.setCancelled(true); | ||
} | ||
} catch (SQLException e) { | ||
Keklist.getInstance().getLogger().severe(Keklist.getTranslations().get("geyser.events.error", e.getMessage())); | ||
Keklist.getInstance().getLogger().severe(Keklist.getTranslations().get("geyser.events.fallback")); | ||
event.setCancelled(true); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/de/hdg/keklist/extentions/GeyserEventRegistrar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package de.hdg.keklist.extentions; | ||
|
||
import de.hdg.keklist.Keklist; | ||
import de.hdg.keklist.events.GeyserConnectionEvent; | ||
import lombok.SneakyThrows; | ||
import org.geysermc.event.PostOrder; | ||
import org.geysermc.geyser.api.GeyserApi; | ||
import org.geysermc.geyser.api.event.EventRegistrar; | ||
import org.geysermc.geyser.api.event.connection.ConnectionRequestEvent; | ||
|
||
public class GeyserEventRegistrar implements EventRegistrar { | ||
|
||
private final GeyserApi geyserApi; | ||
private final Keklist keklist; | ||
|
||
public GeyserEventRegistrar(GeyserApi geyserApi, Keklist keklist) { | ||
this.geyserApi = geyserApi; | ||
this.keklist = keklist; | ||
} | ||
|
||
@SneakyThrows | ||
public void registerEvents() { | ||
geyserApi.eventBus().subscribe(this, ConnectionRequestEvent.class, GeyserConnectionEvent::onConnectionRequestEvent, PostOrder.FIRST); | ||
keklist.getLogger().info(Keklist.getTranslations().get("geyser.events.registered")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters