Whitelist fixes. Implemented MapSource.

This commit is contained in:
William Burns 2015-08-04 11:21:58 +01:00
parent 817b8b03f6
commit 644d6c9914
7 changed files with 63 additions and 45 deletions

View File

@ -33,8 +33,8 @@ public class ChooseMapButton implements IButton
@Override
public void onClick(Player player, ClickType clickType)
{
_arcadeManager.GetGameCreationManager().MapPref = _map;
_arcadeManager.GetGameCreationManager().MapSource = _gameType.GetName();
_arcadeManager.GetGameCreationManager().MapPref = _map;
_arcadeManager.GetGame().setGame(_gameType, player, true);
player.closeInventory();
return;

View File

@ -32,11 +32,6 @@ public class WhitelistButton implements IButton
@Override
public void onClick(Player player, ClickType clickType)
{
List<String> strings = new ArrayList<>();
for (String s : _arcadeManager.GetGameHostManager().getWhitelist())
{
strings.add(s);
}
_shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player, strings));
_shop.openPageForPlayer(player, new WhitelistedPage(_arcadeManager, _shop, player));
}
}

View File

@ -124,6 +124,11 @@ public class OptionsPage extends BasePage
private void togglePublic()
{
if (_config.PlayerServerWhitelist==true)
{
_config.PublicServer = false;
return;
}
_config.PublicServer = !_config.PublicServer;
refresh();
}

View File

@ -38,7 +38,7 @@ public abstract class PlayerPage extends BasePage
{
addBackButton(4);
List<Player> players = null;
List<Player> players = new ArrayList<>();
if (useOtherList)
{
players = new ArrayList<>();

View File

@ -2,9 +2,14 @@ package nautilus.game.arcade.gui.privateServer.page;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.shop.item.IButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
@ -15,33 +20,38 @@ import nautilus.game.arcade.gui.privateServer.PrivateServerShop;
* consent of William Burns. 2015.
* 29/07/15
*/
public class WhitelistedPage extends PlayerPage
public class WhitelistedPage extends BasePage
{
public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player, List<String> players)
public WhitelistedPage(ArcadeManager plugin, PrivateServerShop shop, Player player)
{
super(plugin, shop, "Whitelisted Players", player, players);
super(plugin, shop, "Whitelisted Players", player);
buildPage();
}
@Override
public boolean showPlayer(Player player)
protected void buildPage()
{
if (getPlugin().GetGameHostManager().getWhitelist().contains(player.getName()))
return true;
return false;
}
addBackButton(4);
@Override
public void clicked(int slot, Player player)
{
getPlugin().GetGameHostManager().getWhitelist().remove(player.getName());
getPlugin().GetPortal().sendToHub(player, "You are no longer whitelisted.");
getPlayer().sendMessage(F.main("Whitelist", "§e" + player.getName() + " §7is no longer whitelisted."));
}
int slot = 9;
for (final String s : getPlugin().GetGameHostManager().getWhitelist())
{
ItemStack head = getPlayerHead(s, C.cGreen + C.Bold + s, new String[]{C.cGray + "Click to un-whitelist player"});
final int i = slot;
addButton(slot, head, new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
getPlugin().GetGameHostManager().getWhitelist().remove(s);
removeButton(i);
getPlayer().sendMessage(F.main("Whitelist", "§e" + s + " §7is no longer whitelisted."));
if (Bukkit.getPlayer(s)!=null)
getPlugin().GetPortal().sendToHub(Bukkit.getPlayer(s), "You are no longer whitelisted.");
}
});
@Override
public String getDisplayString(Player player)
{
return "Click to remove from whitelist";
slot++;
}
}
}

View File

@ -117,9 +117,6 @@ public class GameGemManager implements Listener
@EventHandler(priority = EventPriority.MONITOR)
public void GameStateChange(GameStateChangeEvent event)
{
if (!Manager.IsRewardGems())
return;
if (event.GetState() != GameState.Dead)
return;
@ -129,12 +126,12 @@ public class GameGemManager implements Listener
public void RewardGems(Game game, Player player, boolean give)
{
if (!Manager.IsRewardGems())
return;
//Inform Gems
AnnounceGems(game, player, game.GetPlayerGems().get(player), give);
if (!Manager.IsRewardGems())
return;
//Give Gems
if (give)
GiveGems(game, player, game.GetPlayerGems().remove(player), game.GemMultiplier);
@ -145,7 +142,7 @@ public class GameGemManager implements Listener
if (!Manager.IsRewardGems())
return;
if (gems == null)
if (gems == null)
return;
int earned = 0;
@ -167,7 +164,7 @@ public class GameGemManager implements Listener
//Gem Finder
if (game.GemHunterEnabled)
{
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
if (gemFinder > 0)
{
total += (int)(earned * (gemFinder * 0.25));
@ -184,9 +181,9 @@ public class GameGemManager implements Listener
Manager.GetStatsManager().incrementStat(player, game.GetName()+".GemsEarned", total);
}
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
public void AnnounceGems(Game game, Player player, HashMap<String,GemData> gems, boolean give)
{
if (gems == null)
if (gems == null)
return;
player.playSound(player.getLocation(), Sound.LEVEL_UP, 2f, 1f);
@ -211,7 +208,7 @@ public class GameGemManager implements Listener
String amountStr = "";
if (amount > 0)
amountStr = amount + " ";
String out = "";
if (Manager.IsRewardGems())
out += F.elem(C.cGreen + "+" + (int)(gemCount * game.GemMultiplier) + " Gems") + " for ";
@ -219,9 +216,14 @@ public class GameGemManager implements Listener
UtilPlayer.message(player, out);
}
if (!Manager.IsRewardGems())
{
UtilPlayer.message(player, "");
UtilPlayer.message(player, ArcadeFormat.Line);
return;
}
earnedGems = (int) (earnedGems * game.GemMultiplier);
@ -230,7 +232,7 @@ public class GameGemManager implements Listener
//Gem Booster
if (game.GetGemBoostAmount() > 0 && game.GemBoosterEnabled)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " +
UtilPlayer.message(player, F.elem(C.cGreen + "+" + (int)(earnedGems*game.GetGemBoostAmount()) + " Gems") + " for " +
F.elem(game.GemBoosters.size() + " Gem Boosters " + C.cGreen + "+" + (int)(game.GetGemBoostAmount()*100) + "%"));
totalGems += earnedGems * game.GetGemBoostAmount();
@ -242,7 +244,7 @@ public class GameGemManager implements Listener
int gemFinder = Manager.GetAchievement().get(player.getName(), Achievement.GLOBAL_GEM_HUNTER).getLevel();
if (gemFinder > 0)
{
UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " +
UtilPlayer.message(player, F.elem(C.cGreen + "+" + ((int)(earnedGems*(gemFinder * 0.25)) + " Gems")) + " for " +
F.elem("Gem Hunter " + gemFinder + C.cGreen + " +" + (gemFinder*25) + "%"));
totalGems += earnedGems * (gemFinder * 0.25);
@ -261,7 +263,7 @@ public class GameGemManager implements Listener
UtilPlayer.message(player, "");
if (give)
{
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " +
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " +
C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getName()).GetGems() + totalGems) + " Gems"));
}
else
@ -270,8 +272,8 @@ public class GameGemManager implements Listener
UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed."));
}
UtilPlayer.message(player, ArcadeFormat.Line);
UtilPlayer.message(player, ArcadeFormat.Line);
}
}
}

View File

@ -48,6 +48,7 @@ public class GameHostManager implements Listener
ArcadeManager Manager;
private Player _host;
private String _hostName;
private Rank _hostRank;
private long _serverStartTime = System.currentTimeMillis();
private long _serverExpireTime = 21600000;
@ -208,8 +209,10 @@ public class GameHostManager implements Listener
Player p = event.getPlayer();
if (Manager.GetServerConfig().PlayerServerWhitelist){
if (!getWhitelist().contains(p.getName())){
if (_host == p)
if ((Manager.GetHost() != null) && (Manager.GetHost().equalsIgnoreCase(p.getName())))
{
return;
}
event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "This MPS is whitelisted.");
}
}
@ -368,6 +371,9 @@ public class GameHostManager implements Listener
event.setCancelled(true);
if (!isPrivateServer())
return;
if (!Manager.GetClients().Get(event.getPlayer()).GetRank().Has(event.getPlayer(), Rank.JNR_DEV, true))
return;