Remove/update deprecated commands, fix an unchecked setting in AchievementManager and fix issues preventing plugin from building

This commit is contained in:
AlexTheCoder 2017-11-29 02:52:07 -05:00 committed by Alexander Meech
parent fedbf2397b
commit c281603898
4 changed files with 36 additions and 88 deletions

View File

@ -210,22 +210,25 @@ public class AchievementManager extends MiniPlugin
{
CoreClient client = _clientManager.Get(sender);
int level = get(sender, Achievement.GLOBAL_MINEPLEX_LEVEL).getLevel();
if (client.hasPermission(Perm.FAKE_LEVEL_50))
if (fakeLevels)
{
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_30))
{
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_15))
{
level = Math.max(level, 15);
}
else if (client.hasPermission(Perm.FAKE_LEVEL_5))
{
level = Math.max(level, 5);
if (client.hasPermission(Perm.FAKE_LEVEL_50))
{
level = Math.max(level, 50 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_30))
{
level = Math.max(level, 30 + get(sender, Achievement.GLOBAL_GEM_HUNTER).getLevel());
}
else if (client.hasPermission(Perm.FAKE_LEVEL_15))
{
level = Math.max(level, 15);
}
else if (client.hasPermission(Perm.FAKE_LEVEL_5))
{
level = Math.max(level, 5);
}
}
return level;

View File

@ -28,6 +28,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTasks;
import mineplex.core.leaderboard.LeaderboardManager;
import mineplex.core.stats.command.GiveStatCommand;
import mineplex.core.stats.command.SetLevelCommand;
import mineplex.core.stats.command.TimeCommand;
import mineplex.core.stats.event.StatChangeEvent;
import mineplex.core.thread.ThreadPool;
@ -44,7 +45,6 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>//MiniDbClientPlu
GIVE_STAT_COMMAND,
TIME_COMMAND,
SET_LEVEL_COMMAND,
MASTER_BUILDERS_UNBAN_COMMAND,
}
private static final Object STATS_LOCK = new Object();
@ -121,7 +121,6 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>//MiniDbClientPlu
PermissionGroup.ADMIN.setPermission(Perm.GIVE_STAT_COMMAND, true, true);
PermissionGroup.MOD.setPermission(Perm.TIME_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.SET_LEVEL_COMMAND, true, true);
PermissionGroup.ADMIN.setPermission(Perm.MASTER_BUILDERS_UNBAN_COMMAND, true, true);
}
/**
@ -433,8 +432,7 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>//MiniDbClientPlu
{
addCommand(new TimeCommand(this));
addCommand(new GiveStatCommand(this));
//addCommand(new SetLevelCommand(this));
//addCommand(new MasterBuilderUnban(this));
addCommand(new SetLevelCommand(this));
}
@Override
@ -458,6 +456,11 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>//MiniDbClientPlu
{
_loading.remove(uuid);
}
public CoreClientManager getClientManager()
{
return _coreClientManager;
}
/* @Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException

View File

@ -1,65 +0,0 @@
package mineplex.core.stats.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.stats.StatsManager;
public class MasterBuilderUnban extends CommandBase<StatsManager>
{
public MasterBuilderUnban(StatsManager plugin)
{
super(plugin, StatsManager.Perm.MASTER_BUILDERS_UNBAN_COMMAND, "buildunban");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length != 1)
{
UtilPlayer.message(caller, F.main("MasterBuilder Unban", "/buildunban [player]"));
return;
}
Plugin.getClientManager().getRepository().matchPlayerName(matches ->
{
boolean matchedExact = false;
for (String match : matches)
{
if (match.equalsIgnoreCase(args[0]))
{
matchedExact = true;
}
}
if (matchedExact)
{
matches.removeIf(s -> !s.equalsIgnoreCase(args[0]));
}
UtilPlayer.searchOffline(matches, target ->
{
if (target == null)
{
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + F.elem(args[0]) + "'s account!"));
return;
}
Plugin.getClientManager().loadClientByName(target, theClient ->
{
if (theClient == null)
{
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + F.elem(target) + "'s client!"));
return;
}
Plugin.setStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0);
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + F.elem(target) + " has been unbanned from Master Builders"));
});
}, caller, args[0], false);
}, args[0]);
}
}

View File

@ -1,10 +1,9 @@
package mineplex.core.stats.command;
import mineplex.core.achievement.leveling.LevelingManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import mineplex.core.achievement.Achievement;
import mineplex.core.achievement.leveling.LevelingManager;
import mineplex.core.command.CommandBase;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
@ -57,8 +56,16 @@ public class SetLevelCommand extends CommandBase<StatsManager>
{
amountNeeded += Achievement.GLOBAL_MINEPLEX_LEVEL.getLevels()[i];
}
Plugin.setStat(target, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], amountNeeded);
long amountHas = Plugin.Get(target).getStat(Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0]);
if (amountNeeded - amountHas <= 0)
{
UtilPlayer.message(caller, F.main("Stats", "That target already has level " + F.elem(level) + " or higher!"));
return;
}
Plugin.incrementStat(target, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], amountNeeded - amountHas);
UtilPlayer.message(caller, F.main("Stats", "Updated " + F.elem(target.getName()) + "'s level to " + F.elem(level)));
}
}