Work on /server and /send commands with permissions (more permissions need to be implemented).

This commit is contained in:
Peter Miller 2014-06-24 22:34:17 -04:00
parent 46849745c4
commit bb5aa8e0f3

View File

@ -9,12 +9,16 @@ import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -29,6 +33,8 @@ public class Portal extends MiniPlugin
private List<String> _transfers = new ArrayList<String>();
private boolean _retrieve = true;
private CoreClientManager _clientier;
public Portal(JavaPlugin plugin)
{
super("Portal", plugin);
@ -36,6 +42,7 @@ public class Portal extends MiniPlugin
Bukkit.getMessenger().registerOutgoingPluginChannel(GetPlugin(), "BungeeCord");
_repository.initialize(plugin.getConfig().getBoolean("serverstatus.us"));
_clientier = CoreClientManager.Initialize(plugin, plugin.getConfig().getString("webServer"));
}
public void SendAllPlayers(String serverName)
@ -146,4 +153,69 @@ public class Portal extends MiniPlugin
});
}
}
@EventHandler
public void onPreCommand(PlayerCommandPreprocessEvent e)
{
String[] baseArgs = e.getMessage().split(" ");
String command = baseArgs[0];
String[] args = new String[baseArgs.length - 1];
for (int i = 0; i < args.length; i++)
{
args[i] = baseArgs[i + 1];
}
Player player = e.getPlayer();
if (command.equalsIgnoreCase("/server"))
{
e.setCancelled(true);
if(args.length == 0)
{
player.sendMessage(ChatColor.YELLOW + "You are currently on server: " + Bukkit.getServerName());
return;
}
else if(args.length == 1)
{
// NEED TO IMPLEMENT OTHER PERMISSION LEVELS!!!
if(_clientier.Get(player).GetRank().Has(Rank.MAPDEV))
{
SendPlayerToServer(player, args[1]);
player.sendMessage(ChatColor.YELLOW + "You have been sent to server: " + args[1] + "!");
return;
}
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are not allowed for this command!");
return;
}
else
{
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are inappropriate for this command!");
return;
}
}
if (command.equalsIgnoreCase("/send"))
{
e.setCancelled(true);
if(args.length == 2)
{
// NEED TO ADD OTHER PERMISSION LEVELS!!!
if(_clientier.Get(player).GetRank().Has(Rank.ADMIN))
{
// ADD TRANSFER RECORD IN Queue.playerServerTransfer!!!
player.sendMessage(ChatColor.BOLD + "Functionality not implemented, yet...");
return;
}
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are not allowed for this command!");
return;
}
else
{
player.sendMessage(ChatColor.DARK_PURPLE + "Your arrrguments are inappropriate for this command!");
return;
}
}
}
}