Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
65b2e14689
@ -12,7 +12,7 @@ public class SimpleStatsRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Queue?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _connectionString = "jdbc:mysql://sqlstats.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh"; //try to obfuscate this in the future!
|
||||
|
||||
|
@ -62,6 +62,7 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.commands.ForcefieldRadius;
|
||||
import mineplex.hub.commands.GadgetToggle;
|
||||
import mineplex.hub.commands.NewsCommand;
|
||||
import mineplex.hub.gadget.GadgetManager;
|
||||
import mineplex.hub.modules.*;
|
||||
import mineplex.hub.mount.MountManager;
|
||||
@ -93,6 +94,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
private TextManager _textCreator;
|
||||
private ParkourManager _parkour;
|
||||
private PreferencesManager _preferences;
|
||||
private NewsManager _news;
|
||||
|
||||
private Location _spawn;
|
||||
private int _scoreboardTick = 0;
|
||||
@ -130,8 +132,8 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
new MapManager(this);
|
||||
new WorldManager(this);
|
||||
new JumpManager(this);
|
||||
new NewsManager(this);
|
||||
|
||||
_news = new NewsManager(this);
|
||||
|
||||
_mountManager = new MountManager(this);
|
||||
_gadgetManager = new GadgetManager(this, _mountManager, petManager);
|
||||
@ -283,6 +285,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
public void AddCommands()
|
||||
{
|
||||
AddCommand(new GadgetToggle(this));
|
||||
AddCommand(new NewsCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -889,6 +892,11 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
this._gadgetsEnabled = _enabled;
|
||||
}
|
||||
|
||||
public NewsManager GetNewsManager()
|
||||
{
|
||||
return _news;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadClientInformation(RetrieveClientInformationEvent event)
|
||||
|
71
Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java
Normal file
71
Plugins/Mineplex.Hub/src/mineplex/hub/HubRepository.java
Normal file
@ -0,0 +1,71 @@
|
||||
package mineplex.hub;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.status.ServerStatusData;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HubRepository
|
||||
{
|
||||
private static Object _connectionLock = new Object();
|
||||
|
||||
private String _connectionString = "jdbc:mysql://db.mineplex.com:3306/Mineplex?autoReconnect=true&failOverReadOnly=false&maxReconnects=10";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private boolean _us = true;
|
||||
|
||||
private static String CREATE_NEWS_TABLE = "CREATE TABLE IF NOT EXISTS newsList (id INT NOT NULL AUTO_INCREMENT, newsString VARCHAR(256), newsPosition INT, PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_NEWS_ENTRIES = "SELECT newsString, newsPosition FROM newsList;";
|
||||
private static String ADD_NEWS_ENTRY = "INSERT INTO newsList (newsString, newsPosition) VALUES(?,?);";
|
||||
private static String SET_NEWS_ENTRY = "UPDATE newsList SET newsString = ? WHERE newsPosition = ?;";
|
||||
private static String DELETE_NEWS_ENTRY = "DELETE FROM newsList WHERE newsPosition = ?;";
|
||||
|
||||
private Connection _connection = null;
|
||||
|
||||
public void initialize(boolean us)
|
||||
{
|
||||
_us = us;
|
||||
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
|
||||
_connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = _connection.prepareStatement(CREATE_NEWS_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "news");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
NewsManager blorp = Plugin.GetNewsManager();
|
||||
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages will be listed here..."));
|
||||
}
|
||||
else if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "This is where future messages like, '" + C.cGold + args[1] + "' will be added to server news!"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "This is where future messages at positions like, " + C.cGold + "'News Position: " + C.cGold + args[1] + "'" + C.cGray + " will be removed from server news!"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.HubRepository;
|
||||
import mineplex.hub.mount.Mount;
|
||||
import mineplex.hub.mount.types.Dragon;
|
||||
|
||||
@ -24,6 +25,8 @@ public class NewsManager extends MiniPlugin
|
||||
private long _newsTime = System.currentTimeMillis();
|
||||
|
||||
private int _mineplexIndex = 0;
|
||||
|
||||
private HubRepository _repository = new HubRepository();
|
||||
|
||||
public NewsManager(HubManager manager)
|
||||
{
|
||||
@ -31,6 +34,8 @@ public class NewsManager extends MiniPlugin
|
||||
|
||||
Manager = manager;
|
||||
|
||||
_repository.initialize(manager.GetPlugin().getConfig().getBoolean("serverstatus.us"));
|
||||
|
||||
_news = new String[]
|
||||
{
|
||||
"Champions: " + C.cYellow + C.Bold + "Team Deathmatch Beta",
|
||||
|
137
Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java
Normal file
137
Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapData.java
Normal file
@ -0,0 +1,137 @@
|
||||
package mineplex.mapparser;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MapData
|
||||
{
|
||||
public String MapFolder;
|
||||
|
||||
public String GameType = "null";
|
||||
public String MapName = "null";
|
||||
public String MapCreator = "null";
|
||||
|
||||
public HashSet<String> WhiteList;
|
||||
public HashSet<String> BuildList;
|
||||
|
||||
public MapData(String mapFolder)
|
||||
{
|
||||
MapFolder = mapFolder;
|
||||
|
||||
WhiteList = new HashSet<String>();
|
||||
BuildList = new HashSet<String>();
|
||||
|
||||
if ((new File(MapFolder + File.separator + "Map.dat")).exists())
|
||||
Read();
|
||||
else
|
||||
Write();
|
||||
}
|
||||
|
||||
public void Read()
|
||||
{
|
||||
String line = null;
|
||||
|
||||
try
|
||||
{
|
||||
FileInputStream fstream = new FileInputStream(MapFolder + File.separator + "Map.dat");
|
||||
DataInputStream in = new DataInputStream(fstream);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
while ((line = br.readLine()) != null)
|
||||
{
|
||||
String[] tokens = line.split(":");
|
||||
|
||||
if (tokens.length < 2)
|
||||
continue;
|
||||
|
||||
if (tokens[0].length() == 0)
|
||||
continue;
|
||||
|
||||
//Name & Author
|
||||
if (tokens[0].equalsIgnoreCase("MAP_NAME"))
|
||||
{
|
||||
MapName = tokens[1];
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("MAP_AUTHOR"))
|
||||
{
|
||||
MapCreator = tokens[1];
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("GAME_TYPE"))
|
||||
{
|
||||
GameType = tokens[1];
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("WHITE_LIST"))
|
||||
{
|
||||
for (String cur : tokens[1].split(","))
|
||||
WhiteList.add(cur);
|
||||
}
|
||||
else if (tokens[0].equalsIgnoreCase("BUILD_LIST"))
|
||||
{
|
||||
for (String cur : tokens[1].split(","))
|
||||
BuildList.add(cur);
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.err.println("Line: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
public void Write()
|
||||
{
|
||||
//Save
|
||||
try
|
||||
{
|
||||
FileWriter fstream = new FileWriter(MapFolder + File.separator + "Map.dat");
|
||||
BufferedWriter out = new BufferedWriter(fstream);
|
||||
|
||||
out.write("MAP_NAME:"+MapName);
|
||||
out.write("\n");
|
||||
out.write("MAP_AUTHOR:"+MapCreator);
|
||||
out.write("\n");
|
||||
out.write("GAME_TYPE:"+GameType);
|
||||
|
||||
String whiteList = "";
|
||||
for (String cur : WhiteList)
|
||||
whiteList += cur + ",";
|
||||
|
||||
out.write("\n");
|
||||
out.write("WHITE_LIST:"+whiteList);
|
||||
|
||||
String buildList = "";
|
||||
for (String cur : BuildList)
|
||||
buildList += cur + ",";
|
||||
|
||||
out.write("\n");
|
||||
out.write("BUILD_LIST:"+buildList);
|
||||
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean CanBuild(Player player)
|
||||
{
|
||||
return BuildList.contains(player.getName()) || player.isOp();
|
||||
}
|
||||
|
||||
public boolean CanJoin(Player player)
|
||||
{
|
||||
return BuildList.contains(player.getName()) || WhiteList.contains(player.getName()) || player.isOp();
|
||||
}
|
||||
}
|
@ -92,6 +92,8 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
UtilPlayer.message(player, F.value("/name <name>", "Set name for current map"));
|
||||
UtilPlayer.message(player, F.value("/author <name>", "Set author for current map"));
|
||||
UtilPlayer.message(player, F.value("/gametype <type", "Set gametype for current map"));
|
||||
UtilPlayer.message(player, " ");
|
||||
UtilPlayer.message(player, C.cYellow + "Documentation: " + C.cGreen + "http://tinyurl.com/mpxmaps");
|
||||
|
||||
}
|
||||
|
||||
@ -309,6 +311,9 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
|
||||
UtilPlayer.message(caller, F.main("Parser", "Listing Maps;"));
|
||||
|
||||
String maps = "";
|
||||
ChatColor color = ChatColor.YELLOW;
|
||||
|
||||
File mapsFolder = new File(".");
|
||||
for (File file : mapsFolder.listFiles())
|
||||
{
|
||||
@ -318,8 +323,15 @@ public class MapParser extends JavaPlugin implements Listener
|
||||
if (!file.getName().toLowerCase().startsWith("map_"))
|
||||
continue;
|
||||
|
||||
caller.sendMessage(file.getName());
|
||||
maps += color + file.getName().substring(4) + " ";
|
||||
|
||||
if (color == ChatColor.YELLOW)
|
||||
color = ChatColor.GOLD;
|
||||
else
|
||||
color = ChatColor.YELLOW;
|
||||
}
|
||||
|
||||
event.getPlayer().sendMessage(maps);
|
||||
}
|
||||
else if (event.getMessage().toLowerCase().startsWith("/parse"))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user