mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
Had added wrong type of null checker, errors were occouring when no portals rather than anything else.
This commit is contained in:
parent
1511016221
commit
e12a65bf69
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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())){
|
||||
|
||||
|
@ -81,92 +81,96 @@ 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){
|
||||
Player player = event.getPlayer();
|
||||
if(!Portal.portalsActive){
|
||||
return;
|
||||
}
|
||||
|
||||
Location fromloc = event.getFrom();
|
||||
Location loc = event.getTo();
|
||||
// Potentially fixes that stupid error cauzed by a bukkit update.
|
||||
// Would save event.getTo() as eyeLoc and change the Y position but that seemed to teleport players.
|
||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
||||
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
|
||||
// This is probably the culprite of the bloody problem, setting the location its pointing to the event location
|
||||
// rather than sorta making a clone of the object.
|
||||
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
|
||||
AdvancedPortal[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : portals){
|
||||
if(loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())){
|
||||
if(portal.trigger.equals(loc.getBlock().getType())
|
||||
|| portal.trigger.equals(eyeLoc.getBlock().getType())){
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
if(portal.pos2.getX() <= loc.getX() && portal.pos2.getY() <= loc.getY() && portal.pos2.getZ() <= loc.getZ()){
|
||||
Player player = event.getPlayer();
|
||||
|
||||
Location fromloc = event.getFrom();
|
||||
Location loc = event.getTo();
|
||||
// Potentially fixes that stupid error cauzed by a bukkit update.
|
||||
// Would save event.getTo() as eyeLoc and change the Y position but that seemed to teleport players.
|
||||
Location eyeLoc = new Location(loc.getWorld(), loc.getX(), loc.getY() + player.getEyeHeight(), loc.getZ());
|
||||
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
|
||||
// This is probably the culprite of the bloody problem, setting the location its pointing to the event location
|
||||
// rather than sorta making a clone of the object.
|
||||
//System.out.println(loc.getBlock().getType()); // for debugging, remove or comment out when not needed
|
||||
AdvancedPortal[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : portals){
|
||||
if(loc.getWorld() != null && portal.worldName.equals(loc.getWorld().getName())){
|
||||
if(portal.trigger.equals(loc.getBlock().getType())
|
||||
|| portal.trigger.equals(eyeLoc.getBlock().getType())){
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
if(portal.pos2.getX() <= loc.getX() && portal.pos2.getY() <= loc.getY() && portal.pos2.getZ() <= loc.getZ()){
|
||||
|
||||
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
|
||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||
WarpEvent warpEvent = new WarpEvent(player, portal.portalName);
|
||||
plugin.getServer().getPluginManager().callEvent(warpEvent);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(PortalMessagesDisplay == 1 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7.");
|
||||
player.sendMessage("");
|
||||
}
|
||||
else if(PortalMessagesDisplay == 2 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player);
|
||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
|
||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||
}
|
||||
|
||||
if(warped){
|
||||
//event.setFrom(player.getLocation());
|
||||
//event.setTo(player.getLocation());
|
||||
|
||||
//event.setCancelled(true);
|
||||
}
|
||||
else{
|
||||
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (!event.isCancelled()) {
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(PortalMessagesDisplay == 1 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] You have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7.");
|
||||
player.sendMessage("");
|
||||
}
|
||||
else if(PortalMessagesDisplay == 2 && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
plugin.nmsAccess.sendActionBarMessage("{text:\"\u00A7aYou have been warped to \u00A7e" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ") + "\u00A7a.\"}", player);
|
||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
|
||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||
}
|
||||
|
||||
if(portal.trigger.equals(Material.PORTAL)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
finalplayer.removeMetadata("hasWarped", plugin);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
if(warped){
|
||||
//event.setFrom(player.getLocation());
|
||||
//event.setTo(player.getLocation());
|
||||
|
||||
//event.setCancelled(true);
|
||||
}
|
||||
else if(portal.trigger.equals(Material.LAVA)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
|
||||
else{
|
||||
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(portal.trigger.equals(Material.PORTAL)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
if(player.getGameMode().equals(GameMode.CREATIVE)){
|
||||
player.setMetadata("hasWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
finalplayer.removeMetadata("lavaWarped", plugin);
|
||||
finalplayer.setFireTicks(-1);
|
||||
finalplayer.removeMetadata("hasWarped", plugin);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if(portal.trigger.equals(Material.LAVA)){
|
||||
final Player finalplayer = event.getPlayer();
|
||||
player.setMetadata("lavaWarped", new FixedMetadataValue(plugin, true));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
public void run(){
|
||||
finalplayer.removeMetadata("lavaWarped", plugin);
|
||||
finalplayer.setFireTicks(-1);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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,44 +221,51 @@ public class Listeners implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPortalEvent(PlayerPortalEvent event) {
|
||||
|
||||
if(Portal.portalsActive){
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("hasWarped")){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Object[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(player.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
|
||||
if((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!Portal.portalsActive){
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("hasWarped")){
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Object[] portals = Portal.Portals;
|
||||
for(AdvancedPortal portal : Portal.Portals){
|
||||
if(portal.worldName.equals(player.getWorld().getName())){
|
||||
|
||||
if((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()){
|
||||
|
||||
if((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()){
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
@ -17,8 +17,14 @@ public class WarpCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
public WarpCommand(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
plugin.getCommand("warp").setExecutor(this);
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user