Clans Alpha 0.18b fixes

This commit is contained in:
NewGarbo 2016-01-08 11:24:36 +00:00
parent 15d2118bc1
commit 025615d080
8 changed files with 77 additions and 120 deletions

View File

@ -142,6 +142,11 @@ public class CoreClientManager extends MiniPlugin
} }
} }
public boolean Contains(String name)
{
return _clientList.containsKey(name);
}
public CoreClient Get(Player player) public CoreClient Get(Player player)
{ {
return Get(player.getName()); return Get(player.getName());

View File

@ -73,11 +73,6 @@ public class Task
_cancel.run(_client); _cancel.run(_client);
} }
if (_end != null)
{
_end.run(_client);
}
_client.cleanup(_name); _client.cleanup(_name);
return; return;
} }

View File

@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin public class Clans extends JavaPlugin
{ {
public static final String VERSION = "0.18"; public static final String VERSION = "0.18b";
private String WEB_CONFIG = "webServer"; private String WEB_CONFIG = "webServer";
// Modules // Modules

View File

@ -649,17 +649,17 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
} }
} }
private void handleClanChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) private void handleClanChat(Player player, String message, ClanInfo clan, String rank)
{ {
for (Player cur : clan.getOnlinePlayers()) for (Player cur : clan.getOnlinePlayers())
{ {
String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); message = _chat.getFilteredMessage(player, message);
UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", event.getPlayer().getName(), message)); UtilPlayer.message(cur, String.format(rank + C.cAqua + "%s " + C.cDAqua + "%s", player.getName(), message));
} }
} }
private void handleAllyChat(AsyncPlayerChatEvent event, ClanInfo clan, String rank) private void handleAllyChat(Player player, String message, ClanInfo clan, String rank)
{ {
List<Player> recipients = new ArrayList<>(); List<Player> recipients = new ArrayList<>();
@ -673,9 +673,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ally.getOnlinePlayers().forEach(recipients::add); ally.getOnlinePlayers().forEach(recipients::add);
} }
String message = _chat.getFilteredMessage(event.getPlayer(), event.getMessage()); final String filtered = _chat.getFilteredMessage(player, message);
recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", event.getPlayer().getName(), message))); recipients.forEach(p -> UtilPlayer.message(p, String.format(rank + C.cDGreen + clan.getName() + " " + C.cDGreen + "%s " + C.cGreen + "%s", player.getName(), filtered)));
recipients.clear(); recipients.clear();
} }
@ -733,11 +733,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
if (client.isClanChat() && clan != null) if (client.isClanChat() && clan != null)
{ {
handleClanChat(event, clan, rank); handleClanChat(event.getPlayer(), event.getMessage(), clan, rank);
} }
else if (client.isAllyChat() && clan != null) else if (client.isAllyChat() && clan != null)
{ {
handleAllyChat(event, clan, rank); handleAllyChat(event.getPlayer(), event.getMessage(), clan, rank);
} }
else else
{ {
@ -776,22 +776,22 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
public void chatClan(ClanInfo clan, Player caller, String message) public void chatClan(ClanInfo clan, Player caller, String message)
{ {
messageClan(clan, C.cAqua + caller.getName() + " " + C.cDAqua + message); String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " ";
if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH))
rank = "";
handleClanChat(caller, message, clan, rank);
} }
public void chatAlly(ClanInfo clan, Player caller, String message) public void chatAlly(ClanInfo clan, Player caller, String message)
{ {
String sendMessage = C.cDGreen + clan.getName() + " " + C.cDGreen + caller.getName() + " " + C.cGreen + message; String rank = _clientManager.Get(caller).GetRank().getTag(true, true) + " ";
messageClan(clan, sendMessage); if (!_clientManager.Get(caller).GetRank().has(Rank.TWITCH))
rank = "";
for (String allyName : clan.getAllyMap().keySet()) handleAllyChat(caller, message, clan, rank);
{
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
if (ally == null) continue;
messageClan(ally, sendMessage);
}
} }
public int getNameMin() public int getNameMin()

View File

@ -8,6 +8,7 @@ import java.util.List;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.common.util.Callback; import mineplex.core.common.util.Callback;
import mineplex.core.common.util.NonFinalInteger; import mineplex.core.common.util.NonFinalInteger;
import mineplex.core.database.DBPool; import mineplex.core.database.DBPool;
@ -50,80 +51,32 @@ public class ClansBanRepository extends RepositoryBase
public void loadBans(final String name, final Callback<ClansBanClient> callback) public void loadBans(final String name, final Callback<ClansBanClient> callback)
{ {
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\""); System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
_manager.getClientManager().loadClientByName(name, new Runnable() { loadClientByName(name, client -> {
public void run() System.out.println("> Successfully loaded CoreClient");
{
System.out.println("> Successfully loaded CoreClient");
executeQuery(GET_ALL_BANS, new ResultSetCallable() executeQuery(GET_ALL_BANS, resultSet -> {
{ System.out.println("> Successfully executed query, result set object: " + resultSet);
@Override
public void processResultSet(ResultSet resultSet) throws SQLException final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
{ {
System.out.println("> Successfully executed query, result set object: " + resultSet); 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);
final List<ClansBan> list = new ArrayList<ClansBan>(); list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
while (resultSet.next())
{
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);
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
}
callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
} }
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
}
});
}
public void loadBansSync(final String name, final Callback<ClansBanClient> callback) callback.run(new ClansBanClient(client.getAccountId(), list));
{
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
_manager.getClientManager().loadClientByNameSync(name, new Runnable() {
public void run()
{
System.out.println("> Successfully loaded CoreClient");
executeQuery(GET_ALL_BANS, new ResultSetCallable() System.out.println("> Successfully handled result");
{ System.out.println(">> FINISH");
@Override }, new ColumnInt("accountId", client.getAccountId()));
public void processResultSet(ResultSet resultSet) throws SQLException
{
System.out.println("> Successfully executed query, result set object: " + resultSet);
final List<ClansBan> list = new ArrayList<ClansBan>();
while (resultSet.next())
{
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);
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
}
callback.run(new ClansBanClient(_manager.getClientManager().Get(name).getAccountId(), list));
System.out.println("> Successfully handled result");
System.out.println(">> FINISH");
}
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
}
}); });
} }
@ -134,32 +87,36 @@ public class ClansBanRepository extends RepositoryBase
return; return;
} }
_manager.getClientManager().loadClientByName(name, new Runnable(){ loadClientByName(name, client -> {
public void run() executeQuery(GET_LONGEST_BAN, resultSet -> {
{ while (resultSet.next())
executeQuery(GET_LONGEST_BAN, new ResultSetCallable()
{ {
@Override int id = resultSet.getInt(1);
public void processResultSet(ResultSet resultSet) throws SQLException int accountId = resultSet.getInt(2);
{ String reason = resultSet.getString(3);
while (resultSet.next()) Timestamp banTime = resultSet.getTimestamp(4);
{ Timestamp unbanTime = resultSet.getTimestamp(5);
int id = resultSet.getInt(1); boolean permanent = resultSet.getBoolean(6);
int accountId = resultSet.getInt(2); boolean removed = resultSet.getBoolean(7);
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);
callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed)); callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
} }
} }, new ColumnInt("accountId", client.getAccountId()));
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
}
}); });
} }
public void loadClientByName(String name, Callback<CoreClient> client)
{
if (_manager.getClientManager().Contains(name))
{
client.run(_manager.getClientManager().Get(name));
}
else
{
_manager.getClientManager().loadClientByName(name, () -> client.run(_manager.getClientManager().Get(name)));
}
}
public void loadAll(Callback<List<ClansBanClient>> callback) public void loadAll(Callback<List<ClansBanClient>> callback)
{ {
_manager.runAsync(() -> { _manager.runAsync(() -> {

View File

@ -807,7 +807,7 @@ public class ClansCommand extends CommandBase<ClansManager>
}, new Callback<DelayedTaskClient>() { }, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client) public void run(DelayedTaskClient client)
{ {
UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0); UtilTextMiddle.display("", "Teleporting to Clan Home in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Home Teleport")))), 0, 5, 0, client.getPlayer());
} }
}, new Callback<DelayedTaskClient>() { }, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client) public void run(DelayedTaskClient client)

View File

@ -65,7 +65,7 @@ public class PlayerGear
{ {
legendary.OriginalOwner = getPlayer().getUniqueId().toString(); legendary.OriginalOwner = getPlayer().getUniqueId().toString();
UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + ".")); UtilServer.broadcast(F.main("Clans", F.elem(getPlayer().getName()) + " has picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.mBody + "."));
UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + "."); UtilTextMiddle.display(C.cDPurple + "Legendary", F.elem(getPlayer().getName()) + C.cWhite + " picked up " + F.vowelAN(legendary.getDisplayName()) + " " + legendary.getDisplayName() + C.cWhite + ".", 20, 60, 20);
getPlayer().setItemInHand(legendary.toItemStack()); getPlayer().setItemInHand(legendary.toItemStack());
} }