Skip to content

Commit

Permalink
Attempted fixes for bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
NotThorny committed Sep 19, 2022
1 parent 31eecb0 commit ce47828
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,8 @@ public void execute(Player sender, Player targetPlayer, List<String> args) {
else{
this.sendUsageMessage(sender);
}

}
public void allLevel(Player sender, Player targetPlayer, List<String> args) {
int scene = targetPlayer.getSceneId();

List<Avatar> 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<String> args) {
int scene = targetPlayer.getSceneId();

Expand Down Expand Up @@ -108,6 +85,23 @@ private void setLevels(Player sender, Player targetPlayer, List<String> args) {
reloadLevel(targetPlayer, scene, args);
}

public void allLevel(Player sender, Player targetPlayer, List<String> args) {
int scene = targetPlayer.getSceneId();

List<Avatar> 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<String> args) {
try {
Position targetPlayerPos = targetPlayer.getPosition();
Expand All @@ -121,14 +115,23 @@ public void reloadLevel(Player targetPlayer, int scene, List<String> 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;
}
}
4 changes: 0 additions & 4 deletions src/main/java/thorny/grasscutters/setLevel/setLevel.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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() {
Expand Down

0 comments on commit ce47828

Please sign in to comment.