Merge pull request #119 in MIN/mineplex from clans/alpha to develop
* commit '025615d080b8b925f319a2f7707d2c3fa4755a88': Clans Alpha 0.18b fixes
This commit is contained in:
commit
15109707f3
@ -142,6 +142,11 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Contains(String name)
|
||||
{
|
||||
return _clientList.containsKey(name);
|
||||
}
|
||||
|
||||
public CoreClient Get(Player player)
|
||||
{
|
||||
return Get(player.getName());
|
||||
|
@ -73,11 +73,6 @@ public class Task
|
||||
_cancel.run(_client);
|
||||
}
|
||||
|
||||
if (_end != null)
|
||||
{
|
||||
_end.run(_client);
|
||||
}
|
||||
|
||||
_client.cleanup(_name);
|
||||
return;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "0.18";
|
||||
public static final String VERSION = "0.18b";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
|
@ -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())
|
||||
{
|
||||
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<>();
|
||||
|
||||
@ -673,9 +673,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
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();
|
||||
}
|
||||
@ -733,11 +733,11 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
if (client.isClanChat() && clan != null)
|
||||
{
|
||||
handleClanChat(event, clan, rank);
|
||||
handleClanChat(event.getPlayer(), event.getMessage(), clan, rank);
|
||||
}
|
||||
else if (client.isAllyChat() && clan != null)
|
||||
{
|
||||
handleAllyChat(event, clan, rank);
|
||||
handleAllyChat(event.getPlayer(), event.getMessage(), clan, rank);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -776,22 +776,22 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
ClanInfo ally = _clanUtility.getClanByClanName(allyName);
|
||||
if (ally == null) continue;
|
||||
|
||||
messageClan(ally, sendMessage);
|
||||
}
|
||||
handleAllyChat(caller, message, clan, rank);
|
||||
}
|
||||
|
||||
public int getNameMin()
|
||||
|
@ -8,6 +8,7 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.NonFinalInteger;
|
||||
import mineplex.core.database.DBPool;
|
||||
@ -50,80 +51,32 @@ public class ClansBanRepository extends RepositoryBase
|
||||
public void loadBans(final String name, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
System.out.println(">> Attempting to load Clans Bans for \"" + name + "\"");
|
||||
_manager.getClientManager().loadClientByName(name, new Runnable() {
|
||||
public void run()
|
||||
{
|
||||
System.out.println("> Successfully loaded CoreClient");
|
||||
|
||||
executeQuery(GET_ALL_BANS, new ResultSetCallable()
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
loadClientByName(name, client -> {
|
||||
System.out.println("> Successfully loaded CoreClient");
|
||||
|
||||
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())
|
||||
{
|
||||
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()));
|
||||
}
|
||||
});
|
||||
}
|
||||
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);
|
||||
|
||||
public void loadBansSync(final String name, final Callback<ClansBanClient> callback)
|
||||
{
|
||||
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()
|
||||
{
|
||||
@Override
|
||||
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");
|
||||
list.add(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
|
||||
}
|
||||
|
||||
callback.run(new ClansBanClient(client.getAccountId(), list));
|
||||
|
||||
System.out.println("> Successfully handled result");
|
||||
System.out.println(">> FINISH");
|
||||
}, new ColumnInt("accountId", client.getAccountId()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -134,32 +87,36 @@ public class ClansBanRepository extends RepositoryBase
|
||||
return;
|
||||
}
|
||||
|
||||
_manager.getClientManager().loadClientByName(name, new Runnable(){
|
||||
public void run()
|
||||
{
|
||||
executeQuery(GET_LONGEST_BAN, new ResultSetCallable()
|
||||
loadClientByName(name, client -> {
|
||||
executeQuery(GET_LONGEST_BAN, resultSet -> {
|
||||
while (resultSet.next())
|
||||
{
|
||||
@Override
|
||||
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||
{
|
||||
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);
|
||||
|
||||
callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
}
|
||||
}, new ColumnInt("accountId", _manager.getClientManager().Get(name).getAccountId()));
|
||||
}
|
||||
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);
|
||||
|
||||
callback.run(new ClansBan(id, accountId, reason, banTime, unbanTime, permanent, removed));
|
||||
}
|
||||
}, new ColumnInt("accountId", client.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)
|
||||
{
|
||||
_manager.runAsync(() -> {
|
||||
|
@ -38,7 +38,7 @@ public class ClansChatCommand extends CommandBase<ClansManager>
|
||||
if (!Plugin.Get(caller).isClanChat())
|
||||
{
|
||||
ClanInfo clan = Plugin.getClanUtility().getClanByPlayer(caller);
|
||||
if (clan == null)
|
||||
if (clan == null)
|
||||
UtilPlayer.message(caller, F.main("Clans", "You are not in a Clan."));
|
||||
else
|
||||
Plugin.chatClan(clan, caller, F.combine(args, 0, null, false));
|
||||
|
@ -807,7 +807,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
}, new Callback<DelayedTaskClient>() {
|
||||
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>() {
|
||||
public void run(DelayedTaskClient client)
|
||||
|
@ -65,7 +65,7 @@ public class PlayerGear
|
||||
{
|
||||
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 + "."));
|
||||
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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user