Finished up the Unban feature...
This commit is contained in:
parent
1726aa2530
commit
9336eb19fa
|
@ -1,8 +1,12 @@
|
||||||
package mineplex.core.stats.command;
|
package mineplex.core.stats.command;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.command.CommandBase;
|
import mineplex.core.command.CommandBase;
|
||||||
import mineplex.core.common.Rank;
|
import mineplex.core.common.Rank;
|
||||||
|
import mineplex.core.common.util.Callback;
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
import mineplex.core.stats.StatsManager;
|
import mineplex.core.stats.StatsManager;
|
||||||
|
@ -28,29 +32,71 @@ public class MasterBuilderUnban extends CommandBase<StatsManager>
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Plugin.getClientManager().loadClientByName(args[0], new Runnable()
|
Plugin.getClientManager().getRepository().matchPlayerName(new Callback<List<String>>()
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run(List<String> matches)
|
||||||
{
|
{
|
||||||
CoreClient theClient = Plugin.getClientManager().Get(args[0]);
|
boolean matchedExact = false;
|
||||||
|
|
||||||
if(theClient != null)
|
for (String match : matches)
|
||||||
{
|
{
|
||||||
Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true);
|
if (match.equalsIgnoreCase(args[0]))
|
||||||
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + args[0] + " has been unbanned for Master Builders"));
|
{
|
||||||
|
matchedExact = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (matchedExact)
|
||||||
{
|
{
|
||||||
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!"));
|
for (Iterator<String> matchIterator = matches.iterator(); matchIterator.hasNext();)
|
||||||
return;
|
{
|
||||||
|
if (!matchIterator.next().equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
matchIterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
UtilPlayer.searchOffline(matches, new Callback<String>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(String target)
|
||||||
|
{
|
||||||
|
if(target == null)
|
||||||
|
{
|
||||||
|
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + args[0] + "'s account!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plugin.getClientManager().loadClientByName(target, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
CoreClient theClient = Plugin.getClientManager().Get(target);
|
||||||
|
|
||||||
|
if(theClient != null)
|
||||||
|
{
|
||||||
|
Plugin.incrementStat(theClient.getAccountId(), "Global.Build Draw Abuse", 0, true); // True = Resets the stat
|
||||||
|
caller.sendMessage(F.main("MasterBuilder Unban", "The user " + target + " has been unbanned from Master Builders"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
caller.sendMessage(F.main("MasterBuilder Unban", "Couldn't find " + target + "'s client!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, caller, args[0], false);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
}, args[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
e.printStackTrace();
|
||||||
caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened."));
|
caller.sendMessage(F.main("MasterBuilder Unban", "Exception caught! Please contact Morten and explain what happened."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class PasswordRepository extends RepositoryBase
|
||||||
|
|
||||||
public PasswordRepository(JavaPlugin plugin, String serverName)
|
public PasswordRepository(JavaPlugin plugin, String serverName)
|
||||||
{
|
{
|
||||||
super(plugin, DBPool.ACCOUNT);
|
super(plugin, DBPool.getAccount());
|
||||||
_serverName = serverName;
|
_serverName = serverName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue