Added some verbage around command center block.

Fixed async chat connection stuff.
This commit is contained in:
Jonathan Williams 2014-04-29 12:13:32 -07:00
parent 3ec1653532
commit cee2883786
4 changed files with 69 additions and 50 deletions

View File

@ -164,9 +164,16 @@ public class CoreClientManager implements Listener
// Load client in miniplugins
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
try
{
// Mysql
Bukkit.getServer().getPluginManager().callEvent(new RetrieveClientInformationEvent(client.GetPlayerName(), uuid));
}
catch (Exception exception)
{
System.out.println("Error running RetrieveClientInformationEvent" + exception.getMessage());
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void Login(PlayerLoginEvent event)

View File

@ -16,8 +16,6 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import mineplex.core.MiniClientPlugin;
import mineplex.core.packethandler.IPacketRunnable;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
@ -304,14 +302,6 @@ public class Chat extends MiniClientPlugin<ChatClient>
return hasharray;
}
private String parseResponse(String response)
{
JSONObject checkresponse = (JSONObject) JSONValue.parse(response);
String display = checkresponse.get("response").toString();
return display;
}
private JSONObject buildJsonChatObject(String filtertype, String name, String player, String msg, int rule)
{
JSONObject message = new JSONObject();
@ -489,6 +479,11 @@ public class Chat extends MiniClientPlugin<ChatClient>
_repository.saveFilterChat(caller.getUniqueId().toString(), !Get(caller).GetFilterChat());
Get(caller).SetFilterChat(!Get(caller).GetFilterChat());
caller.sendMessage(F.main("Chat", "You have turned chat filtering " + (Get(caller).GetFilterChat() ? "on" : "off") + "."));
if (Get(caller).GetFilterChat())
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 2f, 2f);
else
caller.playSound(caller.getLocation(), Sound.NOTE_PIANO, 1f, 1f);
caller.sendMessage(F.main("Chat", "You have turned chat filtering " + ChatColor.YELLOW + (Get(caller).GetFilterChat() ? "ON" : "OFF") + ChatColor.GRAY + "."));
}
}

View File

@ -9,6 +9,8 @@ import java.util.UUID;
public class ChatRepository
{
private static Object _connectionLock = new Object();
private String _connectionString;
private String _userName = "root";
private String _password = "tAbechAk3wR7tuTh";
@ -74,6 +76,8 @@ public class ChatRepository
int affectedRows = 0;
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
@ -92,6 +96,7 @@ public class ChatRepository
System.out.println("Error saving FilterChat option.");
}
}
}
catch (Exception exception)
{
exception.printStackTrace();
@ -118,6 +123,8 @@ public class ChatRepository
PreparedStatement preparedStatement = null;
try
{
synchronized (_connectionLock)
{
if (_connection.isClosed())
{
@ -145,6 +152,7 @@ public class ChatRepository
return resultSet.getBoolean(1);
}
}
}
catch (Exception exception)
{
exception.printStackTrace();

View File

@ -1,7 +1,9 @@
package mineplex.core.command;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.F;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.recharge.Recharge;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -47,11 +49,18 @@ public class CommandCenter implements Listener
args = event.getMessage().substring(event.getMessage().indexOf(' ') + 1).split(" ");
}
ICommand command = Commands.get(commandName);
ICommand command = Commands.get(commandName.toLowerCase());
if (command != null && ClientManager.Get(event.getPlayer()).GetRank().Has(event.getPlayer(), command.GetRequiredRank(), true))
{
command.SetAliasUsed(commandName);
if (!Recharge.Instance.use(event.getPlayer(), "Command", 500, false, false))
{
event.getPlayer().sendMessage(F.main("Command Center", "You can't spam commands that fast."));
event.setCancelled(true);
return;
}
command.SetAliasUsed(commandName.toLowerCase());
command.Execute(event.getPlayer(), args);
event.setCancelled(true);
@ -62,7 +71,7 @@ public class CommandCenter implements Listener
{
for (String commandRoot : command.Aliases())
{
Commands.put(commandRoot, command);
Commands.put(commandRoot.toLowerCase(), command);
command.SetCommandCenter(this);
}
}
@ -71,7 +80,7 @@ public class CommandCenter implements Listener
{
for (String commandRoot : command.Aliases())
{
Commands.remove(commandRoot);
Commands.remove(commandRoot.toLowerCase());
command.SetCommandCenter(null);
}
}