Added no spectator mode setting

This commit is contained in:
Alastair 2017-11-30 19:13:52 +00:00
parent bfc473ec85
commit 1cd97d2bc1
2 changed files with 11 additions and 2 deletions

View File

@ -70,6 +70,8 @@ CustomPrefix: '&a[&eAdvancedPortals&a]'
CustomPrefixFail: '&c[&7AdvancedPortals&c]' CustomPrefixFail: '&c[&7AdvancedPortals&c]'
BlockSpectatorMode: false
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate. PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback

View File

@ -33,10 +33,11 @@ public class Portal {
private static double throwback; private static double throwback;
private static Sound portalSound; private static Sound portalSound;
private static int portalProtectionRadius; private static int portalProtectionRadius;
private static boolean blockSpectatorMode;
public Portal(AdvancedPortalsPlugin plugin) { public Portal(AdvancedPortalsPlugin plugin) {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml"); ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage"); this.showBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage", false);
this.cooldelay = config.getConfig().getInt("PortalCooldown", 5); this.cooldelay = config.getConfig().getInt("PortalCooldown", 5);
this.portalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius"); this.portalProtectionRadius = config.getConfig().getInt("PortalProtectionRadius");
@ -44,6 +45,7 @@ public class Portal {
this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7); this.throwback = config.getConfig().getDouble("ThrowbackAmount", 0.7);
this.portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL"); this.portalSound = WarpEffects.findSound(plugin, "BLOCK_PORTAL_TRAVEL", "PORTAL_TRAVEL");
this.blockSpectatorMode = config.getConfig().getBoolean("BlockSpectatorMode", false);
Portal.plugin = plugin; Portal.plugin = plugin;
Portal.loadPortals(); Portal.loadPortals();
@ -209,7 +211,6 @@ public class Portal {
return "\u00A7aPortal creation successful!"; return "\u00A7aPortal creation successful!";
} }
// make this actually work!
private static boolean checkPortalOverlap(Location pos1, Location pos2) { private static boolean checkPortalOverlap(Location pos1, Location pos2) {
if (portalsActive) { if (portalsActive) {
@ -365,6 +366,7 @@ public class Portal {
return posX != null; return posX != null;
} }
public static boolean activate(Player player, String portalName) { public static boolean activate(Player player, String portalName) {
for (AdvancedPortal portal : Portal.portals) { for (AdvancedPortal portal : Portal.portals) {
if (portal.getName().equals(portalName)) return activate(player, portal); if (portal.getName().equals(portalName)) return activate(player, portal);
@ -382,6 +384,11 @@ public class Portal {
// check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded. // check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded.
// When a portal is added or removed it reloads all portals(i think) so add code for unloading too. // When a portal is added or removed it reloads all portals(i think) so add code for unloading too.
if(blockSpectatorMode && player.getGameMode() == GameMode.SPECTATOR) {
player.sendMessage(PluginMessages.customPrefixFail + "\u00A7c You cannot enter a portal in spectator mode!");
return false;
}
String permission = portal.getArg("permission"); String permission = portal.getArg("permission");
/*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/ /*if((permission == null || (permission != null && player.hasPermission(permission)) || player.isOp())){*/
// 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op. // 3 checks, 1st is if it doesnt need perms. 2nd is if it does do they have it. And third is are they op.