Had added wrong type of null checker, errors were occouring when no portals rather than anything else.

This commit is contained in:
Alastair 2015-11-08 19:46:04 +00:00
parent 1511016221
commit e12a65bf69
6 changed files with 133 additions and 97 deletions

View File

@ -33,12 +33,14 @@ ShowSelectionBlockData: 14
# WarpEffect
# 0 = disabled(no particles)
# 1 = Eye of ender explode efffect(loads of portal particles)
# 1 = Eye of ender explode effect(loads of portal particles)
# adding more soon and may create some custom ones
WarpParticles: 1
# WarpSound generally suggested to keep the same as warpeffect but can usually be used for just the sound and no particle effects
# 0 = disabled(no sound)
# 1 = Enderman Warp Sound
# adding more soon
WarpSound: 1
# In case you want to show the bungee attempting warp message
@ -48,14 +50,19 @@ ShowBungeeWarpMessage: false
ShowSelectionShowDuration: 10
# If a player is riding a entity, warp the entity too?(unless its a bungee portal)
# If a player is riding a entity, warp the entity too?(unless its a bungee portal or any non teleporting portal)
WarpRiddenEntity: true
# Where to display the message 0 = disabled(replaces PortalWarpMessages), 1 = in chat and 2 = action bar(1.8 and above only, anything lower will print the message that would
# generally on the action bar in the chat without a prefix or extra chat formatting)
WarpMessageDisplay: 2
# Set to true if you want to use the warp command from another plugin
DisableWarpCommand: false
# Use plugin name in the warp messages
UseWarpPrefix: true

View File

@ -463,6 +463,9 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
boolean isBungeePortal = false;
boolean needsPermission = false;
// TODO change auto complete when quotes are opened and closed. Such as autocomplete @Player and stuff when specifying commands
for(int i = 1; i < args.length; i++){
if(args[i].toLowerCase().startsWith("name:") && args[i].length() > 5){
hasName = true;

View File

@ -34,6 +34,10 @@ public class FlowStopper implements Listener {
Block blockTo = event.getToBlock();
Block block = event.getBlock();
if(!Portal.portalsActive){
return;
}
for(AdvancedPortal portal : Portal.Portals){
if(portal.worldName.equals(block.getWorld().getName())){

View File

@ -81,7 +81,10 @@ public class Listeners implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if(Portal.portalsActive){
if(!Portal.portalsActive){
return;
}
Player player = event.getPlayer();
Location fromloc = event.getFrom();
@ -163,10 +166,11 @@ public class Listeners implements Listener {
}
}
@EventHandler
public void onCombustEntityEvent(EntityCombustEvent event) {
if(!Portal.portalsActive){
return;
}
Location loc = event.getEntity().getLocation();
for(AdvancedPortal portal : Portal.Portals){
if(portal.worldName.equals(loc.getWorld().getName())){
@ -185,6 +189,9 @@ public class Listeners implements Listener {
@EventHandler
public void onDamEvent(EntityDamageEvent event) {
if(!Portal.portalsActive){
return;
}
//System.out.println(event.getCause());
if(event.getCause() == EntityDamageEvent.DamageCause.LAVA || event.getCause() == EntityDamageEvent.DamageCause.FIRE || event.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK){
Location loc = event.getEntity().getLocation();
@ -214,8 +221,9 @@ public class Listeners implements Listener {
@SuppressWarnings("deprecation")
@EventHandler
public void onPortalEvent(PlayerPortalEvent event) {
if(Portal.portalsActive){
if(!Portal.portalsActive){
return;
}
Player player = event.getPlayer();
if(player.hasMetadata("hasWarped")){
@ -240,18 +248,24 @@ public class Listeners implements Listener {
}
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onItemInteract(PlayerInteractEvent event) {
// will detect if the player is using an axe so the points of a portal can be set
// also any other detections such as sign interaction or basic block protection
Player player = event.getPlayer();
if(player.hasMetadata("selectingPortal") && (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_BLOCK)){
if(!Portal.portalsActive){
player.sendMessage("\u00A7a[§7AdvancedPortals§c] There are no portals that exist to select. Portal sselection canceled.");
event.setCancelled(true);
player.removeMetadata("selectingPortal", plugin);
return;
}
Block block = event.getClickedBlock();
for(AdvancedPortal portal : Portal.Portals){
if(portal.worldName.equals(block.getWorld().getName())){
@ -260,7 +274,6 @@ public class Listeners implements Listener {
if((portal.pos2.getX()) <= block.getX() && (portal.pos2.getY()) <= block.getY() && (portal.pos2.getZ()) <= block.getZ()){
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have selected: \u00A7e" + portal.portalName);
player.removeMetadata("selectingPortal", plugin);
player.setMetadata("selectedPortal", new FixedMetadataValue(plugin, portal.portalName)); // adds the name to the metadata of the character
event.setCancelled(true);
player.removeMetadata("selectingPortal", plugin);
@ -271,7 +284,7 @@ public class Listeners implements Listener {
}
}
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal was selected - if you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
player.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] No portal was selected. If you would like to stop selecting please type \u00A7e/portal select \u00A7cagain!");
event.setCancelled(true);
return;
}

View File

@ -18,8 +18,14 @@ public class WarpCommand implements CommandExecutor, TabCompleter {
public WarpCommand(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
boolean useWarpCommand = !config.getConfig().getBoolean("DisableWarpCommand");
if(useWarpCommand){
plugin.getCommand("warp").setExecutor(this);
}
plugin.getCommand("awarp").setExecutor(this);
}
@Override

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
version: 0.0.8
version: 0.0.10
author: SEKWAH41
description: An advanced portals plugin for bukkit.
commands:
@ -15,6 +15,9 @@ commands:
warp:
description: Used to warp to destinations.
usage: /<command>
awarp:
description: Used to warp to destinations (mostly used when /warp is disabled.
usage: /<command>
permissions:
advancedportals.*:
description: Gives access to all portal commands