Fixed Hub class shop.
Added chat logging. Added message with file updater.
This commit is contained in:
parent
b6ee99596a
commit
efee9fdcbf
Binary file not shown.
@ -1,5 +1,8 @@
|
||||
package mineplex.core.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
@ -8,9 +11,12 @@ import mineplex.core.account.CoreClientManager;
|
||||
//import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.chat.command.BroadcastCommand;
|
||||
import mineplex.core.chat.command.SilenceCommand;
|
||||
import mineplex.core.chat.repository.ChatMessage;
|
||||
import mineplex.core.chat.repository.ChatRepository;
|
||||
//import mineplex.core.chat.repository.ChatRepository;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
@ -20,21 +26,27 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Chat extends MiniClientPlugin<ChatClient>
|
||||
{
|
||||
private static Object _messageLock = new Object();
|
||||
private CoreClientManager _clientManager;
|
||||
//private ChatRepository _repository;
|
||||
private ChatRepository _repository;
|
||||
|
||||
private List<ChatMessage> _messages = new ArrayList<ChatMessage>();
|
||||
|
||||
private long _silenced = 0;
|
||||
|
||||
public Chat(JavaPlugin plugin, CoreClientManager clientManager)
|
||||
private NautHashMap<String, String> _playerLastMessage = new NautHashMap<String, String>();
|
||||
|
||||
public Chat(JavaPlugin plugin, CoreClientManager clientManager, String serverName)
|
||||
{
|
||||
super("Chat", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
//_repository = new ChatRepository(plugin);
|
||||
_repository = new ChatRepository(serverName, plugin.getConfig().getBoolean("serverstatus.us"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -150,6 +162,17 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
UtilPlayer.message(sender, F.main("Chat", "You are sending messages too fast."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (_playerLastMessage.containsKey(sender.getName()) && _playerLastMessage.get(sender.getName()).equalsIgnoreCase(event.getMessage()))
|
||||
{
|
||||
UtilPlayer.message(sender, F.main("Chat", "You can't repeat the same message."));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerLastMessage.put(sender.getName(), event.getMessage());
|
||||
|
||||
_repository.saveChatMessage(sender.getName(), event.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public long Silenced()
|
||||
@ -157,6 +180,12 @@ public class Chat extends MiniClientPlugin<ChatClient>
|
||||
return _silenced;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_playerLastMessage.remove(event.getPlayer().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChatClient AddPlayer(String player)
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
package mineplex.core.chat.repository;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -11,26 +13,62 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.mysql.AccountPreferenceRepository;
|
||||
|
||||
public class ChatRepository extends AccountPreferenceRepository
|
||||
public class ChatRepository
|
||||
{
|
||||
private static String ALTER_ACCOUNT_PREFERENCE_TABLE = "SET @s = (SELECT IF((SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'accountPreferences' AND table_schema = DATABASE() AND column_name = 'filterChat') > 0, 'SELECT 1', 'ALTER TABLE accountPreferences ADD filterChat BOOL')); PREPARE stmt FROM @s; EXECUTE stmt;";
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/PlayerStats?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_FILTERED_TABLE = "CREATE TABLE IF NOT EXISTS filteredWords (id INT NOT NULL AUTO_INCREMENT, word VARCHAR(256), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_FILTERED_WORDS = "SELECT word FROM filteredWords;";
|
||||
private static String SAVE_FILTER_VALUE = "REPLACE INTO accountPreferences (filterChat) VALUES (?) WHERE playerName = ?;";
|
||||
// private static String ALTER_ACCOUNT_PREFERENCE_TABLE = "SET @s = (SELECT IF((SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'accountPreferences' AND table_schema = DATABASE() AND column_name = 'filterChat') > 0, 'SELECT 1', 'ALTER TABLE accountPreferences ADD filterChat BOOL')); PREPARE stmt FROM @s; EXECUTE stmt;";
|
||||
|
||||
public ChatRepository(JavaPlugin plugin)
|
||||
private static String CREATE_CHATLOG_TABLE = "CREATE TABLE IF NOT EXISTS chatLog (id INT NOT NULL AUTO_INCREMENT, serverName VARCHAR(255), playerName VARCHAR(16), message VARCHAR(255), day VARCHAR(100), PRIMARY KEY (id));";
|
||||
private static String INSERT_CHATWORDS = "INSERT INTO chatLog (serverName, playerName, message, day) VALUES (?, ?, ?, now());";
|
||||
//private static String SAVE_FILTER_VALUE = "REPLACE INTO accountPreferences (filterChat) VALUES (?) WHERE playerName = ?;";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
private String _serverName;
|
||||
|
||||
public ChatRepository(String serverName, boolean us)
|
||||
{
|
||||
super(plugin);
|
||||
initialize();
|
||||
|
||||
_serverName = (us ? "US " : "EU ") + serverName;
|
||||
}
|
||||
|
||||
protected void initialize()
|
||||
public void initialize()
|
||||
{
|
||||
super.initialize();
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
executeQuery(CREATE_FILTERED_TABLE);
|
||||
try
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_CHATLOG_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
protected void update()
|
||||
{
|
||||
super.update();
|
||||
@ -160,4 +198,43 @@ public class ChatRepository extends AccountPreferenceRepository
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
*/
|
||||
|
||||
public void saveChatMessage(String playerName, String message)
|
||||
{
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
if (_connection.isClosed())
|
||||
{
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
}
|
||||
|
||||
preparedStatement = _connection.prepareStatement(INSERT_CHATWORDS, Statement.RETURN_GENERATED_KEYS);
|
||||
preparedStatement.setString(1, _serverName);
|
||||
preparedStatement.setString(2, playerName);
|
||||
preparedStatement.setString(3, message);
|
||||
|
||||
preparedStatement.executeUpdate();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class MobCommand extends MultiCommandBase<Creature>
|
||||
{
|
||||
public MobCommand(Creature plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "mob");
|
||||
super(plugin, Rank.ADMIN, "mob");
|
||||
|
||||
AddCommand(new KillCommand(Plugin));
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
@ -53,6 +55,11 @@ public class FileUpdater extends MiniPlugin
|
||||
|
||||
if (!restartEvent.isCancelled())
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
player.sendMessage(F.main("Updater", "Server is restarting for an update."));
|
||||
}
|
||||
|
||||
GetPlugin().getServer().getScheduler().scheduleSyncDelayedTask(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
|
@ -34,7 +34,6 @@ import mineplex.minecraft.game.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.classcombat.Condition.SkillConditionManager;
|
||||
import mineplex.minecraft.game.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatCustomBuildShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatPurchaseShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
@ -85,8 +84,9 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
PartyManager partyManager = new PartyManager(this, clientManager);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), new DisguiseManager(this, packetHandler), new TaskManager(this, GetWebServerAddress()), portal, partyManager);
|
||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, new ServerStatusManager(this, new LagMeter(this, clientManager)), hubManager, new StackerManager(hubManager));
|
||||
new Chat(this, clientManager);
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, clientManager));
|
||||
new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, new StackerManager(hubManager));
|
||||
new Chat(this, clientManager, serverStatusManager.getCurrentServerName());
|
||||
new MemoryFix(this);
|
||||
new FileUpdater(this, portal);
|
||||
|
||||
@ -103,9 +103,7 @@ public class Hub extends JavaPlugin implements INautilusPlugin, IRelation
|
||||
ClassManager classManager = new ClassManager(this, clientManager, donationManager, skillManager, GetWebServerAddress());
|
||||
|
||||
ClassShopManager shopManager = new ClassShopManager(this, classManager, skillManager, null);
|
||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Select Class Here");
|
||||
new ClassCombatPurchaseShop(shopManager, clientManager, donationManager, "Class Shop");
|
||||
new ClassCombatCustomBuildShop(shopManager, clientManager, donationManager, "Class Setup");
|
||||
new ClassCombatCustomBuildShop(shopManager, clientManager, donationManager, "Class Shop");
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
|
@ -6,6 +6,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.ShopBase;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.ArmorPage;
|
||||
|
||||
public class ClassCombatCustomBuildShop extends ClassCombatShop
|
||||
{
|
||||
@ -17,6 +18,6 @@ public class ClassCombatCustomBuildShop extends ClassCombatShop
|
||||
@Override
|
||||
protected ShopPageBase<ClassShopManager, ? extends ShopBase<ClassShopManager>> BuildPagesFor(Player player)
|
||||
{
|
||||
return null;
|
||||
return new ArmorPage(Plugin, this, ClientManager, DonationManager, player, true);
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
Spawn spawn = new Spawn(this);
|
||||
Teleport teleport = new Teleport(this, _clientManager, spawn);
|
||||
new FileUpdater(this, new Portal(this));
|
||||
new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||
ServerStatusManager serverStatusManager = new ServerStatusManager(this, new LagMeter(this, _clientManager));
|
||||
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||
@ -109,7 +109,7 @@ public class Arcade extends JavaPlugin implements INautilusPlugin
|
||||
Portal portal = new Portal(this);
|
||||
|
||||
//Arcade Manager
|
||||
_gameManager = new ArcadeManager(this, ReadServerConfig(), _clientManager, _donationManager, conditionManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, GetWebServerAddress());
|
||||
_gameManager = new ArcadeManager(this, serverStatusManager, ReadServerConfig(), _clientManager, _donationManager, conditionManager, _damageManager, disguiseManager, creature, teleport, new Blood(this), antistack, portal, packetHandler, GetWebServerAddress());
|
||||
|
||||
Punish punish = new Punish(this, GetWebServerAddress(), _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal);
|
||||
|
@ -62,6 +62,7 @@ import mineplex.core.explosion.Explosion;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
|
||||
public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
@ -106,7 +107,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
//Games
|
||||
private Game _game;
|
||||
|
||||
public ArcadeManager(Arcade plugin, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, String webAddress)
|
||||
public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, ConditionManager conditionManager, DamageManager damageManager, DisguiseManager disguiseManager, Creature creature, Teleport teleport, Blood blood, AntiStack antistack, Portal portal, PacketHandler packetHandler, String webAddress)
|
||||
{
|
||||
super("Game Manager", plugin);
|
||||
|
||||
@ -126,7 +127,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
|
||||
_clientManager = clientManager;
|
||||
|
||||
_chat = new Chat(plugin, _clientManager);
|
||||
_chat = new Chat(plugin, _clientManager, serverStatusManager.getCurrentServerName());
|
||||
|
||||
_creature = creature;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user