few changes
This commit is contained in:
parent
2e9562fc50
commit
6172be5d76
@ -10,16 +10,18 @@ public class ClansBan
|
||||
private int _id;
|
||||
private int _accountId;
|
||||
private String _reason;
|
||||
private String _admin;
|
||||
private Timestamp _banTime;
|
||||
private Timestamp _unbanTime;
|
||||
private boolean _permanent;
|
||||
private boolean _removed;
|
||||
|
||||
public ClansBan(int id, int accountId, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed)
|
||||
public ClansBan(int id, int accountId, String admin, String reason, Timestamp banTime, Timestamp unbanTime, boolean permanent, boolean removed)
|
||||
{
|
||||
_id = id;
|
||||
_accountId = accountId;
|
||||
_reason = reason;
|
||||
_admin = admin;
|
||||
_banTime = banTime;
|
||||
_unbanTime = unbanTime;
|
||||
_permanent = permanent;
|
||||
@ -36,6 +38,11 @@ public class ClansBan
|
||||
return _accountId;
|
||||
}
|
||||
|
||||
public String getAdmin()
|
||||
{
|
||||
return _admin;
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return _reason;
|
||||
|
@ -30,8 +30,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ban.commands.ClansBanCommand;
|
||||
import mineplex.game.clans.clans.ban.commands.ClansBanListCommand;
|
||||
import mineplex.game.clans.clans.ban.ui.ClansBanListShop;
|
||||
import mineplex.game.clans.clans.ban.ui.ClansBanShop;
|
||||
|
||||
public class ClansBanManager extends MiniPlugin
|
||||
@ -41,7 +39,6 @@ public class ClansBanManager extends MiniPlugin
|
||||
private Map<String, ClansBanClient> _clients;
|
||||
private Map<String, String> _cache;
|
||||
private ClansBanShop _shop;
|
||||
private ClansBanListShop _shop2;
|
||||
|
||||
private Object _lock = new Object();
|
||||
|
||||
@ -57,14 +54,12 @@ public class ClansBanManager extends MiniPlugin
|
||||
_cache = new HashMap<>();
|
||||
|
||||
_shop = new ClansBanShop(this, clientManager, donationManager);
|
||||
_shop2 = new ClansBanListShop(this, clientManager, donationManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClansBanCommand(this));
|
||||
addCommand(new ClansBanListCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -85,9 +80,9 @@ public class ClansBanManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public void ban(ClansBanClient client, String name, long time, String reason, Callback<ClansBanClient> callback)
|
||||
public void ban(ClansBanClient client, String name, String admin, long time, String reason, Callback<ClansBanClient> callback)
|
||||
{
|
||||
_repository.ban(client.AccountId, time, reason, time == -1);
|
||||
_repository.ban(client.AccountId, admin, time, reason, time == -1);
|
||||
|
||||
LoadClient(name, callback);
|
||||
}
|
||||
@ -217,11 +212,6 @@ public class ClansBanManager extends MiniPlugin
|
||||
return _shop;
|
||||
}
|
||||
|
||||
public ClansBanListShop getShop2()
|
||||
{
|
||||
return _shop2;
|
||||
}
|
||||
|
||||
public void cache(Player player, String playerName)
|
||||
{
|
||||
_cache.put(player.getName(), playerName);
|
||||
@ -248,9 +238,4 @@ public class ClansBanManager extends MiniPlugin
|
||||
|
||||
LoadClient(name, callback);
|
||||
}
|
||||
|
||||
public void listRecordedNames(Callback<List<ClansBanClient>> callback)
|
||||
{
|
||||
GetRepository().loadAll(callback);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package mineplex.game.clans.clans.ban;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -10,10 +8,8 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.EnclosedObject;
|
||||
import mineplex.core.database.MinecraftRepository;
|
||||
import mineplex.serverdata.database.DBPool;
|
||||
import mineplex.serverdata.database.ResultSetCallable;
|
||||
import mineplex.serverdata.database.column.ColumnBoolean;
|
||||
import mineplex.serverdata.database.column.ColumnInt;
|
||||
import mineplex.serverdata.database.column.ColumnTimestamp;
|
||||
@ -24,10 +20,9 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
private ClansBanManager _manager;
|
||||
|
||||
private static final String GET_LONGEST_BAN = "SELECT * FROM clanBans WHERE (NOW() < unbanTime OR permanent=1) AND accountId = ? ORDER BY permanent DESC, unbanTime DESC LIMIT 1;";
|
||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?);";
|
||||
private static final String BAN_PLAYER = "INSERT INTO clanBans (accountId, admin, reason, banTime, unbanTime, permanent, removed) VALUES (?, ?, ?, ?, ?, ?, ?);";
|
||||
private static final String REMOVE_BAN = "UPDATE clanBans SET removed = 1 WHERE id = ?;";
|
||||
private static final String GET_ALL_BANS = "SELECT * FROM clanBans WHERE accountId = ?;";
|
||||
private static final String GET_ALL_ACCOUNTS = "SELECT DISTINCT accountId FROM clanBans;";
|
||||
|
||||
public ClansBanRepository(JavaPlugin plugin, ClansBanManager manager)
|
||||
{
|
||||
@ -36,10 +31,11 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
_manager = manager;
|
||||
}
|
||||
|
||||
public void ban(int accountId, long time, String reason, boolean permanent)
|
||||
public void ban(int accountId, String admin, long time, String reason, boolean permanent)
|
||||
{
|
||||
executeInsert(BAN_PLAYER, null,
|
||||
new ColumnInt("accountId", accountId),
|
||||
new ColumnVarChar("admin", 16, admin),
|
||||
new ColumnVarChar("reason", 128, reason),
|
||||
new ColumnTimestamp("banTime", new Timestamp(System.currentTimeMillis())),
|
||||
new ColumnTimestamp("unbanTime", new Timestamp(System.currentTimeMillis() + time)),
|
||||
@ -63,13 +59,14 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
int accountId = resultSet.getInt(2);
|
||||
String reason = resultSet.getString(3);
|
||||
Timestamp banTime = resultSet.getTimestamp(4);
|
||||
Timestamp unbanTime = resultSet.getTimestamp(5);
|
||||
boolean permanent = resultSet.getBoolean(6);
|
||||
boolean removed = resultSet.getBoolean(7);
|
||||
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, accountId, reason, banTime, unbanTime, permanent, removed));
|
||||
list.add(new ClansBan(id, accountId, admin, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(client.getAccountId(), list));
|
||||
@ -93,13 +90,14 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
{
|
||||
int id = resultSet.getInt(1);
|
||||
int accountId = resultSet.getInt(2);
|
||||
String reason = resultSet.getString(3);
|
||||
Timestamp banTime = resultSet.getTimestamp(4);
|
||||
Timestamp unbanTime = resultSet.getTimestamp(5);
|
||||
boolean permanent = resultSet.getBoolean(6);
|
||||
boolean removed = resultSet.getBoolean(7);
|
||||
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);
|
||||
|
||||
callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
|
||||
callback.run(new ClansBan(id, accountId, admin, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
}, new ColumnInt("accountId", client.getAccountId()));
|
||||
});
|
||||
@ -117,34 +115,6 @@ public class ClansBanRepository extends MinecraftRepository
|
||||
}
|
||||
}
|
||||
|
||||
public void loadAll(Callback<List<ClansBanClient>> callback)
|
||||
{
|
||||
_manager.runAsync(() -> {
|
||||
executeQuery(GET_ALL_ACCOUNTS, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
final List<ClansBanClient> clients = new ArrayList<>();
|
||||
final EnclosedObject<Integer> resultsProcessed = new EnclosedObject<>();
|
||||
int resultsFound = 0;
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
resultsFound++;
|
||||
|
||||
int accountId = resultSet.getInt(0);
|
||||
|
||||
// loadBans(_manager.getClientManager().)
|
||||
|
||||
}
|
||||
|
||||
System.out.println("Found: " + resultsFound + ", Processed: " + resultsProcessed);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize()
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
if (target != null)
|
||||
{
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.ban(client, target.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
|
||||
Plugin.ban(client, target.getName(), caller.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
|
||||
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + F.time(c.getBanTimeFormatted()) + "."));
|
||||
Plugin.runSync(() -> target.kickPlayer(C.cRedB + "You have been banned from Clans " + c.getBanTimeFormatted() + "."));
|
||||
});
|
||||
@ -79,7 +79,7 @@ public class ClansBanCommand extends CommandBase<ClansBanManager>
|
||||
}
|
||||
|
||||
Plugin.LoadClient(playerName, client -> {
|
||||
Plugin.ban(client, playerName, permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
|
||||
Plugin.ban(client, playerName, caller.getName(), permanent ? -1 : (long) (time * 24.f * 60.f * 60.f * 1000.f), finalReason, c -> {
|
||||
UtilPlayer.message(caller, F.main("Clans", F.elem(playerName) + " is now banned " + c.getBanTimeFormatted() + "."));
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +0,0 @@
|
||||
package mineplex.game.clans.clans.ban.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanListCommand extends CommandBase<ClansBanManager>
|
||||
{
|
||||
public ClansBanListCommand(ClansBanManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "listbans");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
Plugin.getShop2().attemptShopOpen(caller);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package mineplex.game.clans.clans.ban.ui;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBanClient;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanListPage extends ShopPageBase<ClansBanManager, ClansBanListShop>
|
||||
{
|
||||
public ClansBanListPage(final ClansBanManager banManager, final ClansBanListShop shop, final CoreClientManager clientManager, final DonationManager donationManager, final String name, final Player player)
|
||||
{
|
||||
super(banManager, shop, clientManager, donationManager, name, player);
|
||||
|
||||
buildPage();
|
||||
}
|
||||
|
||||
protected void buildPage()
|
||||
{
|
||||
getPlugin().listRecordedNames(clients -> {
|
||||
for (ClansBanClient client : clients)
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package mineplex.game.clans.clans.ban.ui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.game.clans.clans.ban.ClansBanManager;
|
||||
|
||||
public class ClansBanListShop extends ShopBase<ClansBanManager>
|
||||
{
|
||||
public ClansBanListShop(final ClansBanManager plugin, final CoreClientManager clientManager, final DonationManager donationManager)
|
||||
{
|
||||
super(plugin, clientManager, donationManager, "Clans Punish");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ShopPageBase<ClansBanManager, ? extends ShopBase<ClansBanManager>> buildPagesFor(final Player player)
|
||||
{
|
||||
return new ClansBanListPage(getPlugin(), this, getClientManager(), getDonationManager(), "Clans Punish", player);
|
||||
}
|
||||
|
||||
}
|
@ -75,10 +75,10 @@ public class ClansRegions extends MiniPlugin
|
||||
claimArea("Fields", FIELDS_RADIUS, 0, false, true, worldCenter);
|
||||
claimArea("Borderlands", BORDERLANDS_RADIUS, 48, false, true, worldCenter);
|
||||
|
||||
//debugClan("Spawn");
|
||||
//debugClan("Shops");
|
||||
//debugClan("Fields");
|
||||
//debugClan("Borderlands");
|
||||
debugClan("Spawn");
|
||||
debugClan("Shops");
|
||||
debugClan("Fields");
|
||||
debugClan("Borderlands");
|
||||
}
|
||||
|
||||
public void initializeBorder()
|
||||
@ -114,10 +114,14 @@ public class ClansRegions extends MiniPlugin
|
||||
private void clearClaims(String name)
|
||||
{
|
||||
ClanInfo clan = _manager.getClan(name);
|
||||
System.out.println("Clearing claims for " + name + " with clan id " + clan.getId() + "!");
|
||||
|
||||
if (clan != null)
|
||||
if (clan == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Clearing claims for " + name + " with clan id " + clan + "!");
|
||||
|
||||
for (String chunk : clan.getClaimSet())
|
||||
{
|
||||
_manager.getClaimMap().remove(chunk);
|
||||
@ -126,7 +130,6 @@ public class ClansRegions extends MiniPlugin
|
||||
clan.getClaimSet().clear();
|
||||
_manager.getClanDataAccess().getRepository().removeTerritoryClaims(clan.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a server-side clan and claims area according to the
|
||||
@ -141,8 +144,8 @@ public class ClansRegions extends MiniPlugin
|
||||
{
|
||||
final ClanInfo clan = _manager.getClan(clanName);
|
||||
|
||||
// Only claim if the clan doesn't exist yet. Speeds up startup time
|
||||
if (clan == null)
|
||||
// Only claim if the clan doesn't have claims. Speeds up startup time
|
||||
if (clan == null || clan.getClaimSet().size() == 0)
|
||||
{
|
||||
_manager.getClanDataAccess().create("ClansRegions", clanName, true, new Callback<ClanInfo>()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user