i think clans ban is broken in this commit, and i removed some unnecessary spammy debug messages.

This commit is contained in:
Ben 2016-03-24 08:58:48 +00:00
parent 2e41f906d0
commit 2eb4d89875
3 changed files with 66 additions and 11 deletions

View File

@ -245,7 +245,7 @@ public class ClansAdmin
{
public void run()
{
if (nameExists)
if (nameExists.booleanValue())
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Player name."));
else
{

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans.ban;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -20,6 +22,7 @@ import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
@ -31,7 +34,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
public class ClansBanManager extends MiniPlugin
public class ClansBanManager extends MiniPlugin implements ILoginProcessor
{
private CoreClientManager _clientManager;
private ClansBanRepository _repository;
@ -39,6 +42,8 @@ public class ClansBanManager extends MiniPlugin
private Map<String, Pair<String, String>> _cache;
private ClansBanShop _shop;
private Map<String, String> _toKick = new HashMap<>();
private Object _lock = new Object();
public ClansBanManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
@ -53,6 +58,8 @@ public class ClansBanManager extends MiniPlugin
_cache = new HashMap<>();
_shop = new ClansBanShop(this, clientManager, donationManager);
clientManager.addStoredProcedureLoginProcessor(this);
}
@Override
@ -229,4 +236,27 @@ public class ClansBanManager extends MiniPlugin
LoadClient(name, callback);
}
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
_repository.loadBans(playerName, client -> {
if (client.isBanned())
{
String time = UtilTime.convertString(client.getLongestBan().getTimeLeft(), 0, TimeUnit.FIT);
if (client.getLongestBan().isPermanent())
time = "Permanent";
String reason = C.cRedB + "You are banned from Clans for " + time +
"\n" + C.cWhite + client.getLongestBan().getReason();
_toKick.put(playerName, reason);
}
});
}
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT * FROM clanBans WHERE uuid = '" + uuid + "';";
}
}

View File

@ -1,5 +1,6 @@
package mineplex.game.clans.clans.ban;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
@ -47,15 +48,10 @@ public class ClansBanRepository extends MinecraftRepository
public void loadBans(final String name, final Callback<ClansBanClient> callback)
{
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
loadClientByName(name, client -> {
System.out.println("> Successfully loaded CoreClient");
String uuid = UUIDFetcher.getUUIDOf(client.GetPlayerName()).toString();
executeQuery(GET_ALL_BANS, resultSet -> {
System.out.println("> Successfully executed query, result set object: " + resultSet);
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
@ -70,18 +66,47 @@ public class ClansBanRepository extends MinecraftRepository
boolean removed = resultSet.getBoolean(8);
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
System.out.println("Got ban for " + name);
}
callback.run(new ClansBanClient(uuid, list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
}, new ColumnVarChar("uuid", 36, uuid));
});
}
public void loadBans(final String name, final String uuid, final ResultSet resultSet, final Callback<ClansBanClient> callback)
{
try
{
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
{
int id = resultSet.getInt(1);
String ruuid = resultSet.getString(2);
String admin = resultSet.getString(3);
String reason = resultSet.getString(4);
Timestamp banTime = resultSet.getTimestamp(5);
Timestamp unbanTime = resultSet.getTimestamp(6);
boolean permanent = resultSet.getBoolean(7);
boolean removed = resultSet.getBoolean(8);
list.add(new ClansBan(id, UUID.fromString(ruuid), admin, reason, banTime, unbanTime, permanent, removed));
System.out.println("Got ban for " + name);
}
callback.run(new ClansBanClient(uuid, list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
}
catch (Exception exception)
{
exception.printStackTrace();
}
}
private void loadClientByName(String name, Callback<CoreClient> client)
{
if (_manager.getClientManager().Contains(name))