Added StaffOnly code to ServerConfiguration

This commit is contained in:
Jonathan Williams 2015-03-02 12:33:04 -08:00
parent 789e750cbf
commit 5e78b43860
5 changed files with 27 additions and 5 deletions

View File

@ -5,22 +5,30 @@ import java.lang.reflect.Field;
import net.minecraft.server.v1_7_R4.PlayerList;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.serverdata.Region;
import mineplex.serverdata.ServerGroup;
import mineplex.serverdata.ServerManager;
public class ServerConfiguration extends MiniPlugin
{
private CoreClientManager _clientManager;
private Field _playerListMaxPlayers;
private ServerGroup _serverGroup;
public ServerConfiguration(JavaPlugin plugin)
public ServerConfiguration(JavaPlugin plugin, CoreClientManager clientManager)
{
super("Server Configuration", plugin);
_clientManager = clientManager;
Region region = plugin.getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
String groupName = plugin.getConfig().getString("serverstatus.group");
@ -45,6 +53,13 @@ public class ServerConfiguration extends MiniPlugin
((CraftServer)_plugin.getServer()).getServer().setTexturePack(_serverGroup.getResourcePack());
}
@EventHandler
public void onPlayerLogin(PlayerLoginEvent event)
{
if (_serverGroup.getStaffOnly() && !_clientManager.Get(event.getPlayer().getName()).GetRank().Has(event.getPlayer(), Rank.HELPER, false))
event.disallow(Result.KICK_OTHER, "This is a staff only server.");
}
public ServerGroup getServerGroup()
{
return _serverGroup;

View File

@ -60,7 +60,7 @@ public class Clans extends JavaPlugin
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
new ServerConfiguration(this);
new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);

View File

@ -84,7 +84,7 @@ public class Hub extends JavaPlugin implements IRelation
BlockRestore blockRestore = new BlockRestore(this);
DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress);
new ServerConfiguration(this);
new ServerConfiguration(this, clientManager);
//Other Modules
PacketHandler packetHandler = new PacketHandler(this);

View File

@ -114,5 +114,13 @@ public class StaffServer extends JavaPlugin
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("Timmy48081_").toString(), "Timmy48081_").loadProfile());
}
}, 100L);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable()
{
public void run()
{
((CraftServer)getServer()).getHandle().addWhitelist(new ProfileLoader(UUIDFetcher.getUUIDOf("issh").toString(), "issh").loadProfile());
}
}, 120L);
}
}

View File

@ -86,14 +86,13 @@ public class Arcade extends JavaPlugin
_donationManager = new DonationManager(this, _clientManager, webServerAddress);
_serverConfiguration = new ServerConfiguration(this);
_serverConfiguration = new ServerConfiguration(this, _clientManager);
PreferencesManager preferenceManager = new PreferencesManager(this, _clientManager, _donationManager);
Creature creature = new Creature(this);
ServerStatusManager serverStatusManager = new ServerStatusManager(this, _clientManager, new LagMeter(this, _clientManager));
LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager);
new Spawn(this, serverStatusManager.getCurrentServerName());
Teleport teleport = new Teleport(this);
Portal portal = new Portal(this, _clientManager, serverStatusManager.getCurrentServerName());
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion());