Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #48

Merged
merged 4 commits into from
Oct 14, 2024
Merged

Bug #48

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Dependabot auto-approve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:
jobs:
dependabot:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'owner/my_repo'
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'zhinghu/CatSeedLogin'
steps:
- name: Dependabot metadata
id: metadata
Expand Down
41 changes: 22 additions & 19 deletions src/main/java/cc/baka9/catseedlogin/bukkit/CatSeedLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,35 @@ public class CatSeedLogin extends JavaPlugin implements Listener {
private LoginPlayerHelper timeoutManager;

@Override
public void onEnable(){
public void onEnable() {
instance = this;
morePaperLib = new MorePaperLib(this);
HandySchedulerUtil.init(this);
getServer().getPluginManager().registerEvents(this, this);
timeoutManager = new LoginPlayerHelper();
//Config

// Config
try {
Config.load();
Config.save();
} catch (Exception e) {
e.printStackTrace();
getServer().getLogger().warning("加载配置文件时出错,请检查你的配置文件。");
}

sql = Config.MySQL.Enable ? new MySQL(this) : new SQLite(this);
try {

sql.init();

Cache.refreshAll();
} catch (Exception e) {
getLogger().warning("§c加载数据库时出错");
e.printStackTrace();
}
//Listeners

// Listeners
getServer().getPluginManager().registerEvents(new Listeners(), this);

//ProtocolLibListeners
// ProtocolLibListeners
if (Config.Settings.Emptybackpack) {
try {
Class.forName("com.comphenix.protocol.ProtocolLib");
Expand All @@ -75,17 +76,24 @@ public void onEnable(){
}
}

// bc
// BungeeCord
if (Config.BungeeCord.Enable) {
Communication.socketServerStartAsync();
}

// Floodgate
if (Bukkit.getPluginManager().getPlugin("floodgate") != null && Config.Settings.BedrockLoginBypass){
if (Bukkit.getPluginManager().getPlugin("floodgate") != null && Config.Settings.BedrockLoginBypass) {
getLogger().info("检测到floodgate,基岩版兼容已装载");
}

//Commands
// Commands
registerCommands();

// Task
Task.runAll();
}

private void registerCommands() {
getServer().getPluginCommand("login").setExecutor(new CommandLogin());
getServer().getPluginCommand("login").setTabCompleter((commandSender, command, s, args)
-> args.length == 1 ? Collections.singletonList("密码") : new ArrayList<>(0));
Expand Down Expand Up @@ -114,6 +122,7 @@ public void onEnable(){
}
return Collections.emptyList();
});

PluginCommand resetpassword = getServer().getPluginCommand("resetpassword");
resetpassword.setExecutor(new CommandResetPassword());
resetpassword.setTabCompleter((commandSender, command, s, args) -> {
Expand All @@ -130,12 +139,9 @@ public void onEnable(){
}
return Collections.emptyList();
});

PluginCommand catseedlogin = getServer().getPluginCommand("catseedlogin");
catseedlogin.setExecutor(new CommandCatSeedLogin());

//Task
Task.runAll();

}

@EventHandler
Expand All @@ -153,17 +159,16 @@ public void run() {
}.runTaskTimer(this, 0L, 20L);
}


@Override
public void onDisable(){
public void onDisable() {
Task.cancelAll();
Bukkit.getOnlinePlayers().forEach(p -> {
if (!LoginPlayerHelper.isLogin(p.getName())) return;
if (!p.isDead() || Config.Settings.DeathStateQuitRecordLocation) {
Config.setOfflineLocation(p);
}

});

try {
sql.getConnection().close();
} catch (Exception e) {
Expand All @@ -174,9 +179,7 @@ public void onDisable(){
super.onDisable();
}

public void runTaskAsync(Runnable runnable){
public void runTaskAsync(Runnable runnable) {
CatScheduler.runTaskAsync(runnable);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
if (bindEmailOptional.isPresent() && bindEmailOptional.get().getEmail().equals(mail)) {
sender.sendMessage("§c已经向 " + mail + " 邮箱中发送验证码,请不要重复此操作");
} else {
EmailCode bindEmail = EmailCode.create(name, mail, 1000 * 60 * 20, EmailCode.Type.Bind);
EmailCode bindEmail = EmailCode.create(name, mail, 1000 * 60 * 5, EmailCode.Type.Bind);
sender.sendMessage("§6向邮箱发送验证码中...");
sendEmailCode(sender, name, mail, bindEmail);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
sender.sendMessage(Config.Language.RESETPASSWORD_EMAIL_REPEAT_SEND_MESSAGE.replace("{email}", optionalEmailCode.get().getEmail()));
} else {
//20分钟有效期的验证码
EmailCode emailCode = EmailCode.create(name, lp.getEmail(), 1000 * 60 * 20, EmailCode.Type.ResetPassword);
EmailCode emailCode = EmailCode.create(name, lp.getEmail(), 1000 * 60 * 5, EmailCode.Type.ResetPassword);
sender.sendMessage(Config.Language.RESETPASSWORD_EMAIL_SENDING_MESSAGE.replace("{email}", lp.getEmail()));
CatSeedLogin.instance.runTaskAsync(() -> {
try {
Expand Down
Loading