From ce4782831d59be013d28759c179a8695990211b3 Mon Sep 17 00:00:00 2001 From: NotThorny Date: Mon, 19 Sep 2022 00:33:04 -0600 Subject: [PATCH] Attempted fixes for bugs --- README.md | 3 +- .../setLevel/commands/setLevelCommand.java | 55 ++++++++++--------- .../grasscutters/setLevel/setLevel.java | 4 -- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 06512ce..5fd12bf 100644 --- a/README.md +++ b/README.md @@ -32,4 +32,5 @@ This uses the Grasscutters plugin template for 1.3.1. ## Issues -None yet. +Promote level (max level within ascension) does not apply until relog. +I had it working and then it broke at some point and no amount of hours reverted fixed it, so now relog is required instead. diff --git a/src/main/java/thorny/grasscutters/setLevel/commands/setLevelCommand.java b/src/main/java/thorny/grasscutters/setLevel/commands/setLevelCommand.java index b417c2c..998785d 100644 --- a/src/main/java/thorny/grasscutters/setLevel/commands/setLevelCommand.java +++ b/src/main/java/thorny/grasscutters/setLevel/commands/setLevelCommand.java @@ -49,31 +49,8 @@ public void execute(Player sender, Player targetPlayer, List args) { else{ this.sendUsageMessage(sender); } - } - public void allLevel(Player sender, Player targetPlayer, List args) { - int scene = targetPlayer.getSceneId(); - List avatars = DatabaseHelper.getAvatars(getPlayer(sender, targetPlayer)); - for (Avatar avatar : avatars) { - int avatarId = avatar.getAvatarId(); - avatar = sender.getAvatars().getAvatarById(avatarId); - int level = Integer.parseInt(args.get(1)); - int promoteLevel = Avatar.getMinPromoteLevel(level); - avatar.setPromoteLevel(promoteLevel); - avatar.setLevel(level); - avatar.recalcStats(); - avatar.save(); - } - reloadLevel(targetPlayer, scene, args); - } - - // Wonky way to get player because I couldn't get an easier way to work - private Player getPlayer(Player sender, Player targetPlayer) { - Avatar avatar = sender.getAvatars().getAvatarById(targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar().getAvatarId()); - Player player = avatar.getPlayer(); - return player; - } public void teamLevel(Player sender, Player targetPlayer, List args) { int scene = targetPlayer.getSceneId(); @@ -108,6 +85,23 @@ private void setLevels(Player sender, Player targetPlayer, List args) { reloadLevel(targetPlayer, scene, args); } + public void allLevel(Player sender, Player targetPlayer, List args) { + int scene = targetPlayer.getSceneId(); + + List avatars = DatabaseHelper.getAvatars(getPlayer(sender, targetPlayer)); + for (Avatar avatar : avatars) { + int avatarId = avatar.getAvatarId(); + avatar = sender.getAvatars().getAvatarById(avatarId); + int level = Integer.parseInt(args.get(1)); + int promoteLevel = Avatar.getMinPromoteLevel(level); + avatar.setPromoteLevel(promoteLevel); + avatar.setLevel(level); + avatar.recalcStats(); + avatar.save(); + } + reloadLevel(targetPlayer, scene, args); + } + public void reloadLevel(Player targetPlayer, int scene, List args) { try { Position targetPlayerPos = targetPlayer.getPosition(); @@ -121,14 +115,23 @@ public void reloadLevel(Player targetPlayer, int scene, List args) { "\n*YOU MUST RELOG FOR ALL CHARACTER LEVELS TO APPLY*"); break; case "team": - CommandHandler.sendMessage(targetPlayer, "Changed team levels!"); + CommandHandler.sendMessage(targetPlayer, "Changed team levels!"+ + "\n*YOU MUST RELOG FOR PROMOTE LEVELS (MAX) TO APPLY*"); break; default: - CommandHandler.sendMessage(targetPlayer, "Changed level!"); - + CommandHandler.sendMessage(targetPlayer, "Changed level!"+ + "\n*YOU MUST RELOG FOR PROMOTE LEVEL (MAX) TO APPLY*"); }//switch } catch (Exception e) { CommandHandler.sendMessage(targetPlayer, "Failed to reload! Relog to apply changes."); } } + + // Wonky way to get player because I couldn't get an easier way to work + private Player getPlayer(Player sender, Player targetPlayer) { + Avatar avatar = sender.getAvatars() + .getAvatarById(targetPlayer.getTeamManager().getCurrentAvatarEntity().getAvatar().getAvatarId()); + Player player = avatar.getPlayer(); + return player; + } } diff --git a/src/main/java/thorny/grasscutters/setLevel/setLevel.java b/src/main/java/thorny/grasscutters/setLevel/setLevel.java index 24368c5..bf272a5 100644 --- a/src/main/java/thorny/grasscutters/setLevel/setLevel.java +++ b/src/main/java/thorny/grasscutters/setLevel/setLevel.java @@ -1,7 +1,6 @@ package thorny.grasscutters.setLevel; import emu.grasscutter.plugin.Plugin; -//import thorny.grasscutters.MobWave.commands.MobWaveCommand; public final class setLevel extends Plugin { private static setLevel instance; @@ -19,9 +18,6 @@ public static setLevel getInstance() { // Log a plugin status message. this.getLogger().info("The setLevel plugin has been enabled."); - - // Read file to memory - //MobWaveCommand.readFile(); } @Override public void onDisable() {