Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit bf82da1

Browse files
committed
Bedrock Capabilities
1 parent fec706b commit bf82da1

File tree

7 files changed

+268
-245
lines changed

7 files changed

+268
-245
lines changed

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<id>central</id>
3535
<url>https://repo.maven.apache.org/maven2</url>
3636
</repository>
37+
3738
</repositories>
3839

3940
<dependencies>
@@ -72,13 +73,12 @@
7273
<version>0.4</version>
7374
</dependency>
7475

75-
<!-- Geyser-Floodgate API for Bedrock support -->
76-
<dependency>
77-
<groupId>org.geysermc.floodgate</groupId>
78-
<artifactId>floodgate-api</artifactId>
79-
<version>2.2.0-SNAPSHOT</version>
80-
<scope>provided</scope>
81-
</dependency>
76+
<!--
77+
Note: For Bedrock support, install Floodgate on your server.
78+
Download from: https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/
79+
and place in the server's plugins folder.
80+
Bedrock support will be automatically enabled if Floodgate is present.
81+
-->
8282
</dependencies>
8383

8484
<build>

src/main/java/com/lightlogin/listener/PlayerListener.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.bukkit.event.inventory.InventoryClickEvent;
1414
import org.bukkit.event.inventory.InventoryOpenEvent;
1515
import org.bukkit.event.player.*;
16-
import org.geysermc.floodgate.api.FloodgateApi;
16+
// Floodgate API is optional - checked at runtime using reflection
1717

1818
import java.util.HashSet;
1919
import java.util.Set;
@@ -48,8 +48,31 @@ public void onPlayerJoin(PlayerJoinEvent event) {
4848

4949
private boolean isBedrockPlayer(Player player) {
5050
try {
51-
return Bukkit.getPluginManager().getPlugin("floodgate") != null &&
52-
FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId());
51+
// Check if Floodgate plugin is installed and loaded
52+
if (Bukkit.getPluginManager().getPlugin("floodgate") == null) {
53+
return false;
54+
}
55+
56+
// Use reflection to check if player is from Bedrock
57+
try {
58+
// Get Floodgate API class
59+
Class<?> floodgateApiClass = Class.forName("org.geysermc.floodgate.api.FloodgateApi");
60+
// Get getInstance() method
61+
java.lang.reflect.Method getInstanceMethod = floodgateApiClass.getMethod("getInstance");
62+
// Invoke getInstance()
63+
Object floodgateApi = getInstanceMethod.invoke(null);
64+
// Get isFloodgatePlayer method
65+
java.lang.reflect.Method isFloodgatePlayerMethod = floodgateApiClass.getMethod("isFloodgatePlayer", java.util.UUID.class);
66+
// Call isFloodgatePlayer with player's UUID
67+
return (boolean) isFloodgatePlayerMethod.invoke(floodgateApi, player.getUniqueId());
68+
} catch (ClassNotFoundException e) {
69+
plugin.getLogger().info("Floodgate API not found. Bedrock support disabled.");
70+
plugin.getLogger().info("To enable Bedrock support, install Floodgate on your server.");
71+
return false;
72+
} catch (Exception e) {
73+
plugin.getLogger().warning("Error checking Bedrock player status: " + e.getMessage());
74+
return false;
75+
}
5376
} catch (Exception e) {
5477
plugin.getLogger().warning("Error checking if player is from Bedrock: " + e.getMessage());
5578
return false;
@@ -61,7 +84,7 @@ private void handleBedrockPlayer(Player player, UUID uuid, String ipAddress) {
6184
if (!databaseManager.isPlayerRegistered(uuid)) {
6285
// Generate a random secure password for the Bedrock player
6386
String password = generateRandomPassword();
64-
if (databaseManager.registerPlayer(uuid, player.getName(), password, ipAddress)) {
87+
if (databaseManager.registerPlayer(player, password)) {
6588
player.sendMessage(plugin.getConfig().getString(
6689
"messages.bedrock-auto-register",
6790
"§aWelcome Bedrock player! You've been automatically registered."));

src/main/resources/config.yml

Lines changed: 117 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,138 @@
1-
2-
3-
#
4-
# ▄█ ▄█ ▄██████▄ ▄█ █▄ ███ ▄█ ▄██████▄ ▄██████▄ ▄█ ███▄▄▄▄
5-
# ███ ███ ███ ███ ███ ███ ▀█████████▄ ███ ███ ███ ███ ███ ███ ███▀▀▀██▄
6-
# ███ ███▌ ███ █▀ ███ ███ ▀███▀▀██ ███ ███ ███ ███ █▀ ███▌ ███ ███
7-
# ███ ███▌ ▄███ ▄███▄▄▄▄███▄▄ ███ ▀ ███ ███ ███ ▄███ ███▌ ███ ███
8-
# ███ ███▌ ▀▀███ ████▄ ▀▀███▀▀▀▀███▀ ███ ███ ███ ███ ▀▀███ ████▄ ███▌ ███ ███
9-
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
10-
# ███▌ ▄ ███ ███ ███ ███ ███ ███ ███▌ ▄ ███ ███ ███ ███ ███ ███ ███
11-
# █████▄▄██ █▀ ████████▀ ███ █▀ ▄████▀ █████▄▄██ ▀██████▀ ████████▀ █▀ ▀█ █▀
12-
#
13-
# Copyright 2025 itz_intellij
141
# LightLogin Configuration
152

16-
# Placeholders
17-
18-
# %prefix% - Plugin Prefix
19-
# %server% - Server Name
20-
# %version% - Plugin Version
21-
# %date% - Current Date
22-
# %player% - Player Name
23-
# %op% - OP Name
24-
# %uuid% - Player UUID
25-
# %discord% - Player Discord ID
26-
# %ip% - Player IP
27-
# %port% - Player Port
28-
# %world% - Player World
29-
303
# Database settings
314
database:
32-
# H2 database file will be stored in plugins/LightLogin/data.mv.db
5+
# Database type (H2, MySQL, etc.)
336
type: H2
34-
# MySQL configuration (uncomment and configure if using MySQL)
35-
# type: MYSQL
36-
# host: localhost
37-
# database: minecraft
38-
# username: user
39-
# password: password
7+
# Database file name (for H2) or connection URL
8+
file: LightLogin
9+
# Only needed for MySQL
10+
mysql:
11+
host: localhost
12+
port: 3306
13+
database: lightlogin
14+
username: root
15+
password: ''
16+
use-ssl: false
4017

41-
# Session settings
18+
# Session management
4219
session:
20+
# Enable session management
21+
enabled: true
22+
# Session duration in minutes (0 = until server restart)
23+
duration: 1440 # 24 hours
24+
# Check IP address for session validation
25+
check-ip: true
26+
27+
# Auto-login settings
28+
auto-login:
29+
# Enable auto-login for returning players
4330
enabled: true
44-
duration: 2592000 # 30 days in seconds
45-
check-ip: false # If true, session is only valid from the same IP
31+
# Require IP address to match for auto-login
32+
require-same-ip: false
33+
34+
# Bedrock Edition settings
35+
bedrock:
36+
# Enable Bedrock (Geyser/Floodgate) support
37+
enabled: true
38+
# Auto-register Bedrock players
39+
auto-register: true
40+
# Auto-login Bedrock players
41+
auto-login: true
42+
# Kick Bedrock players if Floodgate is not installed
43+
kick-if-no-floodgate: false
44+
45+
# Password requirements
46+
password:
47+
# Minimum password length
48+
min-length: 6
49+
# Require at least one number
50+
require-number: true
51+
# Require at least one uppercase letter
52+
require-uppercase: true
53+
# Require at least one special character
54+
require-special-char: true
55+
56+
# Messages
57+
messages:
58+
# General messages
59+
prefix: "&8[&bLightLogin&8] &7"
60+
no-permission: "&cYou don't have permission to use this command!"
61+
player-only: "&cThis command can only be used by players!"
62+
63+
# Registration messages
64+
register-prompt: "&aWelcome! Please register using /register <password> <confirmPassword>"
65+
register-success: "&aRegistration successful! You are now logged in."
66+
register-error: "&cAn error occurred during registration. Please try again."
67+
register-password-mismatch: "&cPasswords do not match!"
68+
register-already-registered: "&cYou are already registered!"
69+
register-password-weak: "&cPassword is too weak! It must be at least %min_length% characters long and contain %requirements%"
70+
71+
# Login messages
72+
login-required: "&aWelcome back! Please login using /login <password>"
73+
login-success: "&aSuccessfully logged in!"
74+
login-error: "&cIncorrect password!"
75+
login-already: "&cYou are already logged in!"
76+
77+
# Logout messages
78+
logout-success: "&aSuccessfully logged out!"
79+
80+
# Session messages
81+
auto-login: "&aAutomatically logged in!"
82+
session-expired: "&cYour session has expired. Please log in again."
83+
84+
# Bedrock messages
85+
bedrock-auto-register: "&aWelcome Bedrock player! You've been automatically registered."
86+
bedrock-auto-login: "&aWelcome back, Bedrock player! You've been automatically logged in."
87+
bedrock-not-supported: "&cBedrock players are not supported on this server!"
88+
89+
# Error messages
90+
error-occurred: "&cAn error occurred. Please contact an administrator."
91+
player-not-found: "&cPlayer not found!"
92+
registration-error: "&cFailed to register your account. Please contact an administrator."
4693

4794
# Discord integration
4895
discord:
49-
enabled: false
50-
# Bot token from Discord Developer Portal
96+
# Enable Discord bot
97+
enabled: true
98+
# Discord bot token
5199
token: "YOUR_DISCORD_BOT_TOKEN"
52-
# Your Discord server ID (right-click server name -> Copy Server ID)
53-
guild-id: "YOUR_DISCORD_SERVER_ID"
54-
# Channel where verification messages will be sent
55-
verification-channel: "verification"
56-
# Role to assign after successful verification
57-
verified-role: "Verified"
58-
# Whether to require verification to join the server
59-
require-verification: true
60-
# Command prefix for Discord bot commands (e.g., !verify)
100+
# Discord server ID where the bot should operate
101+
guild-id: "YOUR_DISCORD_GUILD_ID"
102+
# Discord bot command prefix
61103
command-prefix: "!"
104+
# Channel ID for logging (leave empty to disable)
105+
log-channel: ""
62106

63-
# Messages
64-
messages:
65-
prefix: "&8[&aLightLogin&8] &7"
66-
not-logged-in: "&cYou must be logged in to do that!"
67-
already-logged-in: "&aYou are already logged in!"
68-
login-required: "&cPlease login first using /login <password>"
69-
register-required: "&cPlease register first using /register <password> <confirmPassword>"
70-
login-success: "&aSuccessfully logged in!"
71-
login-failed: "&cIncorrect password!"
72-
register-success: "&aSuccessfully registered and logged in!"
73-
register-failed: "&cFailed to register. Please try again later."
74-
password-mismatch: "&cPasswords do not match!"
75-
password-too-short: "&cPassword must be at least 6 characters long!"
76-
# Discord related messages
77-
discord-linked: "&aSuccessfully linked your Discord account!"
78-
discord-link-failed: "&cFailed to link Discord account. Please try again."
79-
discord-unlinked: "&aSuccessfully unlinked your Discord account!"
80-
discord-not-linked: "&cYour account is not linked to Discord!"
81-
discord-verification-sent: "&aVerification code sent to your DMs! Check your Discord messages."
82-
discord-verification-failed: "&cFailed to send verification code. Please try again."
83-
discord-invalid-username: "&cInvalid Discord username format. Please use: Username#1234"
84-
discord-already-linked: "&cThis Discord account is already linked to another Minecraft account."
85-
discord-verify-instructions: "&aTo verify your account, join our Discord server and use the command: &e/verify <code>&a\n&7Your verification code is: &e%code%"
86-
discord-verify-success: "&aYour Discord account has been successfully verified!"
87-
discord-verify-failed: "&cVerification failed. The code is invalid or has expired."
88-
password-reset-requested: "&aA password reset code has been sent to your Discord DMs. Check your messages!"
89-
password-reset-dm: "**\u26A1 Password Reset Request**\n\nYour password reset code is: `%code%`\n\nUse this command in-game to reset your password:\n`/pf %code% <newpassword>`\n\nThis code will expire in 10 minutes."
90-
password-reset-dm-failed: "\u274C Could not send you a DM. Please enable DMs from server members and try again."
91-
password-reset-success: "&aYour password has been successfully reset!"
92-
password-reset-invalid-code: "&cInvalid or expired reset code. Please request a new one."
93-
password-reset-not-linked: "&cYour Minecraft account is not linked to a Discord account."
94-
password-reset-usage: "&cUsage: /pf <code> <newpassword>"
95-
password-reset-channel-notice: "%user% Please enable DMs from server members to receive your password reset code."
107+
# Logging
108+
logging:
109+
# Enable logging to file
110+
enabled: true
111+
# Log file name
112+
file: "LightLogin.log"
113+
# Log level (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST)
114+
level: "INFO"
96115

97116
# Protection settings
98117
protection:
118+
# Prevent movement before login
99119
prevent-movement: true
100-
prevent-chat: true
101-
prevent-commands: true
120+
# Prevent interaction with blocks/entities
121+
prevent-interaction: true
122+
# Prevent damage before login
102123
prevent-damage: true
103-
prevent-block-break: true
104-
prevent-block-place: true
124+
# Prevent dropping items before login
105125
prevent-item-drop: true
126+
# Prevent picking up items before login
106127
prevent-item-pickup: true
107-
prevent-inventory-interaction: true
108-
109-
# Auto-login settings
110-
auto-login:
111-
enabled: true
112-
# Time in seconds before auto-kick if not logged in
113-
login-timeout: 120
114-
# Allow auto-login from the same IP
115-
allow-ip-auto-login: true
116-
# Require re-login after server restart
117-
persist-across-restart: true
118-
119-
# Security settings
120-
security:
121-
# Force players to use strong passwords (requires at least one number and one special character)
122-
strong-passwords: true
123-
# Maximum login attempts before kicking the player
124-
max-login-attempts: 5
125-
# Time in minutes to block login attempts after reaching max attempts
126-
login-attempts-timeout: 15
127-
# Log failed login attempts to console
128-
log-failed-attempts: true
129-
130-
# Update checker
131-
update-checker:
132-
enabled: true
133-
# Check for updates on plugin enable
134-
check-on-enable: true
135-
# Notify OPs about updates
136-
notify-ops: true
137-
# Download updates automatically (requires proper permissions)
138-
auto-download: false
128+
# Prevent opening inventories before login
129+
prevent-inventory-open: true
130+
# Prevent using commands before login (except /login, /register, etc.)
131+
prevent-commands: true
132+
# List of commands that are always allowed (without the /)
133+
allowed-commands:
134+
- login
135+
- register
136+
- l
137+
- reg
138+
- help
1.31 KB
Binary file not shown.

target/LightLogin-1.0-SNAPSHOT.jar

1.31 KB
Binary file not shown.
3.77 KB
Binary file not shown.

0 commit comments

Comments
 (0)