Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex
This commit is contained in:
commit
a455042c07
@ -0,0 +1,71 @@
|
||||
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.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsAddCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsAddCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "add");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 128)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
String newsEntry = "";
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
newsMang.AddNewsEntry(newsEntry, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,215 +1,27 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.command.MultiCommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsCommand extends CommandBase<HubManager>
|
||||
public class NewsCommand extends MultiCommandBase<HubManager>
|
||||
{
|
||||
public NewsCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "news");
|
||||
|
||||
AddCommand(new NewsAddCommand(plugin));
|
||||
AddCommand(new NewsDeleteCommand(plugin));
|
||||
AddCommand(new NewsConfirmCommand(plugin));
|
||||
AddCommand(new NewsListCommand(plugin));
|
||||
AddCommand(new NewsSetCommand(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
protected void Help(Player caller, String args[])
|
||||
{
|
||||
final NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Available news arguments for this command:"));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news list" + C.cGray + " - Lists (numbered) stored news messages from database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news add <newsEntry>" + C.cGray + " - Adds specified news entry string to database at end of table."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news delete #" + C.cGray + " - Removes specified (numbered) news entry string from database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "news set # <newsEntry>" + C.cGray + " - Updates specified (numbered) news entry string in database."));
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cWhite + "*Please Note: " + C.cGray + "Updates to server news entries from the database are on a 4 minute refresh cycle!"));
|
||||
return;
|
||||
}
|
||||
else if (args.length == 1 && args[0].equalsIgnoreCase("list"))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:"));
|
||||
|
||||
newsMang.RetriveNewsEntries(new Callback<HashMap<String, String>>()
|
||||
{
|
||||
public void run(final HashMap<String, String> newsEntries)
|
||||
{
|
||||
// Order newsEntries set or its output by newsPosition, not hash order...
|
||||
newsMang.RetrieveMaxNewsPosition(new Callback<Integer>()
|
||||
{
|
||||
public void run(Integer maxPosition)
|
||||
{
|
||||
String[] newsStrings = new String[maxPosition];
|
||||
for (Iterator<String> iterator = newsEntries.keySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
String newsPosition = iterator.next();
|
||||
newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition);
|
||||
}
|
||||
|
||||
for (int i = 0; i < newsStrings.length; i++)
|
||||
{
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args.length >= 2 && args.length <= 128)
|
||||
{
|
||||
if (args[0].equals("¢¤₦₣¡₨₥") && args.length == 2)
|
||||
{
|
||||
int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}");
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("delete") && args.length == 2)
|
||||
{
|
||||
final int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.DeleteNewsEntry(newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("add"))
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
newsMang.AddNewsEntry(newsEntry, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry: " + C.cGold + newsEntry + C.cGray + " has been added to the database!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error adding the news entry to the database!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("set") && args.length >= 3)
|
||||
{
|
||||
final int newsPosition;
|
||||
String newsEntry = "";
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
Plugin.GetNewsManager().Help(caller);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
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.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
|
||||
public class NewsConfirmCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsConfirmCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "¢¤₦₣¡₨₥");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[CONFIRM] \", color:green, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news delete " + newsPosition + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Are you absolutely sure???\"}}, {\"text\":\"News Entry " + newsPosition + "\", color:gold}, {\"text\":\" deletion?\", color:gray}]}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
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.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsDeleteCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsDeleteCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0 || args.length > 1)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
final int newsPosition;
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.DeleteNewsEntry(newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been deleted!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error deleting the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package mineplex.hub.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
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.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsListCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsListCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length == 0)
|
||||
{
|
||||
final NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "Current server news messages:"));
|
||||
|
||||
newsMang.RetriveNewsEntries(new Callback<HashMap<String, String>>()
|
||||
{
|
||||
public void run(final HashMap<String, String> newsEntries)
|
||||
{
|
||||
// Order newsEntries set or its output by newsPosition, not hash order...
|
||||
newsMang.RetrieveMaxNewsPosition(new Callback<Integer>()
|
||||
{
|
||||
public void run(Integer maxPosition)
|
||||
{
|
||||
String[] newsStrings = new String[maxPosition];
|
||||
for (Iterator<String> iterator = newsEntries.keySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
String newsPosition = iterator.next();
|
||||
newsStrings[Integer.parseInt(newsPosition) - 1] = newsEntries.get(newsPosition);
|
||||
}
|
||||
|
||||
for (int i = 0; i < newsStrings.length; i++)
|
||||
{
|
||||
UtilServer.getServer().dispatchCommand(UtilServer.getServer().getConsoleSender(), "tellraw " + caller.getName() + " {\"text\":\"" + Plugin.GetName() + "> \", color:blue, \"extra\":[{\"text\":\"[DELETE] \", color:red, \"clickEvent\":{\"action\":\"run_command\",\"value\":\"/news ¢¤₦₣¡₨₥ " + (i + 1) + "\"}, \"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Deletes News Entry " + (i + 1) + " : " + newsStrings[i] + "\"}}, {\"text\":\"News " + (i + 1) + "\", color:gold}, {\"text\":\" : \", color:gray}, {\"text\":\"" + newsStrings[i] + "\", color:white}]}");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
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.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.hub.HubManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
|
||||
public class NewsSetCommand extends CommandBase<HubManager>
|
||||
{
|
||||
public NewsSetCommand(HubManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ADMIN, "set");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null || args.length < 2 || args.length > 128)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "Your arguments are inappropriate for this command!"));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NewsManager newsMang = Plugin.GetNewsManager();
|
||||
|
||||
final int newsPosition;
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
// Check for 256 character length for MySQL!
|
||||
if (newsEntry.length() > 256)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news entry is too long [> 256 characters]!"));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
newsPosition = Integer.parseInt(args[0]);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "The specified news position is invalid!"));
|
||||
return;
|
||||
}
|
||||
newsMang.SetNewsEntry(newsEntry, newsPosition, new Callback<Boolean>()
|
||||
{
|
||||
public void run(Boolean success)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
String newsEntry = "";
|
||||
for (int i = 1; i < args.length; i++)
|
||||
{
|
||||
newsEntry += args[i] + " ";
|
||||
}
|
||||
newsEntry = newsEntry.substring(0, newsEntry.length() - 1);
|
||||
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cGray + "The news entry at position " + C.cGold + newsPosition + C.cGray + " has been updated to: " + C.cGold + newsEntry + C.cGray + "!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(Plugin.GetName(), C.cRed + "There was an error updating the news entry; likely the specified news position was invalid!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
@ -187,6 +188,24 @@ public class NewsManager extends MiniPlugin
|
||||
});
|
||||
}
|
||||
|
||||
public void Help(Player caller, String message)
|
||||
{
|
||||
UtilPlayer.message(caller, F.main(_moduleName, "Available news arguments for this command:"));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news list", "Lists (numbered) stored news messages from database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news add <newsEntry>", "Adds specified news entry string to database at end of table.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news delete #", "Removes specified (numbered) news entry string from database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help(C.cGold + "/news set # <newsEntry>", "Updates specified (numbered) news entry string in database.", Rank.ADMIN));
|
||||
UtilPlayer.message(caller, F.help("*Please Note:", "Updates to server news entries from the database are on a 4 minute refresh cycle!", Rank.ADMIN));
|
||||
|
||||
if (message != null)
|
||||
UtilPlayer.message(caller, F.main(_moduleName, ChatColor.RED + message));
|
||||
}
|
||||
|
||||
public void Help(Player caller)
|
||||
{
|
||||
Help(caller, null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void NewsUpdate(UpdateEvent event)
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
package nautilus.game.arcade.game.games.sneakyassassins.kits;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import mineplex.core.itemstack.*;
|
||||
import nautilus.game.arcade.*;
|
||||
import nautilus.game.arcade.kit.*;
|
||||
import nautilus.game.arcade.kit.perks.*;
|
||||
@ -19,6 +21,14 @@ public class KitRevealer extends SneakyAssassinKit
|
||||
{
|
||||
super.GiveItems(player);
|
||||
|
||||
player.getInventory().addItem(new ItemStack(Material.EMERALD, 3));
|
||||
player.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.EMERALD, (byte) 0, 3,
|
||||
C.cYellow + C.Bold + "Right-Click" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Reveal Assassins",
|
||||
new String[]
|
||||
{
|
||||
ChatColor.RESET + "Throw a revealer.",
|
||||
ChatColor.RESET + "Players within 5 blocks",
|
||||
ChatColor.RESET + "get revealed for 5 seconds.",
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,20 @@ public class ArmorPowerUp extends PowerUp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
public boolean powerUpPlayer(Player player)
|
||||
{
|
||||
if (powerUpArmor(player) || powerUpArmor(player))
|
||||
{
|
||||
if(powerUpArmor(player) || powerUpArmor(player))
|
||||
player.sendMessage("Your armor was upgraded!");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage("Your armor is already fully upgraded!");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean powerUpArmor(Player player)
|
||||
|
@ -16,6 +16,8 @@ public abstract class PowerUp
|
||||
private final Location _location;
|
||||
private Location _effectLocation;
|
||||
private Block _beaconBlock;
|
||||
private BlockState _originalBeaconBlock;
|
||||
private BlockState[][] _originalBeaconBase = new BlockState[3][3];
|
||||
private Item _item;
|
||||
|
||||
public PowerUp(PowerUpManager powerUpManager, PowerUpType powerUpType, Location location)
|
||||
@ -39,12 +41,21 @@ public abstract class PowerUp
|
||||
|
||||
public void activate()
|
||||
{
|
||||
_beaconBlock = getLocation().getBlock();
|
||||
_beaconBlock = getLocation().getBlock().getRelative(BlockFace.DOWN);
|
||||
|
||||
_originalBeaconBlock = _beaconBlock.getState();
|
||||
_beaconBlock.setType(Material.BEACON);
|
||||
|
||||
for (int x = -1; x <= 1; x++)
|
||||
for (int z = -1; z <= 1; z++)
|
||||
_beaconBlock.getRelative(x, -1, z).setType(Material.IRON_BLOCK);
|
||||
for (int x = 0; x < 3; x++)
|
||||
{
|
||||
for (int z = 0; z < 3; z++)
|
||||
{
|
||||
Block beaconBaseBlock = _beaconBlock.getRelative(x-1, -1, z-1);
|
||||
|
||||
_originalBeaconBase[x][z] = beaconBaseBlock.getState();
|
||||
beaconBaseBlock.setType(Material.IRON_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate(UpdateEvent event)
|
||||
@ -103,10 +114,14 @@ public abstract class PowerUp
|
||||
_item = null;
|
||||
}
|
||||
|
||||
_beaconBlock.setType(Material.AIR);
|
||||
_originalBeaconBlock.update(true, false);
|
||||
|
||||
for (int x = 0; x < _originalBeaconBase.length; x++)
|
||||
for (int z = 0; z < _originalBeaconBase[0].length; z++)
|
||||
_originalBeaconBase[x][z].update(true, false);
|
||||
|
||||
getPowerUpManager().removePowerUp(this);
|
||||
}
|
||||
|
||||
public abstract void powerUpPlayer(Player player);
|
||||
public abstract boolean powerUpPlayer(Player player);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class PowerUpManager implements Listener
|
||||
private final List<PowerUp> _powerUps = new ArrayList<>();
|
||||
private Location _lastLocation = null;
|
||||
private int _nextSpawnCountdown = -1;
|
||||
private final Map<UUID, PowerUp> _powerUpPickUpCooldown = new HashMap<>();
|
||||
|
||||
public PowerUpManager(Game game, Random random, List<Location> spawnLocations)
|
||||
{
|
||||
@ -146,21 +147,40 @@ public class PowerUpManager implements Listener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickUpPowerUp(PlayerPickupItemEvent event)
|
||||
public void onPlayerPickUpPowerUp(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (getGame().GetTeam(event.getPlayer()) != null)
|
||||
{
|
||||
PowerUp powerUp = getPowerUpByItem(event.getItem());
|
||||
final PowerUp powerUp = getPowerUpByItem(event.getItem());
|
||||
|
||||
if (powerUp != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
powerUp.powerUpPlayer(event.getPlayer());
|
||||
if (_powerUpPickUpCooldown.get(event.getPlayer().getUniqueId()) != powerUp)
|
||||
{
|
||||
if (powerUp.powerUpPlayer(event.getPlayer()))
|
||||
{
|
||||
powerUp.remove();
|
||||
|
||||
schedulePowerUpSpawn(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
_powerUpPickUpCooldown.put(event.getPlayer().getUniqueId(), powerUp);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_powerUpPickUpCooldown.get(event.getPlayer().getUniqueId()) == powerUp)
|
||||
_powerUpPickUpCooldown.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class WeaponPowerUp extends PowerUp
|
||||
}
|
||||
|
||||
@Override
|
||||
public void powerUpPlayer(Player player)
|
||||
public boolean powerUpPlayer(Player player)
|
||||
{
|
||||
for (int swordType = 0; swordType < SWORD_PROGRESSION.size(); swordType++)
|
||||
{
|
||||
@ -35,10 +35,12 @@ public class WeaponPowerUp extends PowerUp
|
||||
|
||||
player.sendMessage("You sword was upgraded!");
|
||||
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
player.sendMessage("Your sword is already fully upgraded!");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -33,27 +33,24 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
|
||||
public PerkRevealer()
|
||||
{
|
||||
super("Revealer", new String[]
|
||||
{
|
||||
C.cYellow + "Right-Click" + C.cGray + " with Emerald to " + C.cGreen + "throw Revealer",
|
||||
});
|
||||
super("Revealer", new String[]{C.cYellow + "Right-Click" + C.cGray + " with Emerald to " + C.cGreen + "throw Revealer"});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerThrowRevealer(PlayerInteractEvent event)
|
||||
{
|
||||
if(event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
return;
|
||||
|
||||
if(event.getPlayer().getItemInHand() == null)
|
||||
if (event.getPlayer().getItemInHand() == null)
|
||||
return;
|
||||
|
||||
if(event.getPlayer().getItemInHand().getType() != Material.EMERALD)
|
||||
if (event.getPlayer().getItemInHand().getType() != Material.EMERALD)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(!Kit.HasKit(player))
|
||||
if (!Kit.HasKit(player))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -69,15 +66,15 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
if(event.getType() == UpdateType.SEC)
|
||||
if (event.getType() == UpdateType.SEC)
|
||||
{
|
||||
for(Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext();)
|
||||
for (Iterator<Map.Entry<Player, RevealedPlayerInfo>> it = getRevealedPlayers().entrySet().iterator(); it.hasNext(); )
|
||||
{
|
||||
Map.Entry<Player, RevealedPlayerInfo> entry = it.next();
|
||||
|
||||
if(!entry.getKey().isOnline())
|
||||
if (!entry.getKey().isOnline())
|
||||
it.remove();
|
||||
else if(entry.getValue()._expirationSeconds <= 0)
|
||||
else if (entry.getValue()._expirationSeconds <= 0)
|
||||
{
|
||||
it.remove();
|
||||
|
||||
@ -119,16 +116,16 @@ public class PerkRevealer extends Perk implements IThrown
|
||||
|
||||
UtilFirework.playFirework(data.GetThrown().getLocation(), effect);
|
||||
|
||||
for(Player player : Manager.GetGame().GetPlayers(true))
|
||||
for (Player player : Manager.GetGame().GetPlayers(true))
|
||||
{
|
||||
if(player == data.GetThrower())
|
||||
if (player == data.GetThrower())
|
||||
continue;
|
||||
|
||||
if(player.getLocation().getWorld() == data.GetThrown().getWorld() && player.getLocation().distanceSquared(data.GetThrown().getLocation()) <= 25)
|
||||
if (player.getLocation().getWorld() == data.GetThrown().getWorld() && player.getLocation().distanceSquared(data.GetThrown().getLocation()) <= 25)
|
||||
{
|
||||
RevealedPlayerInfo info = getRevealedPlayers().get(player);
|
||||
|
||||
if(info == null)
|
||||
if (info == null)
|
||||
{
|
||||
info = new RevealedPlayerInfo(Manager.GetDisguise().getDisguise(player));
|
||||
getRevealedPlayers().put(player, info);
|
||||
|
Loading…
Reference in New Issue
Block a user