Forgot to upload before release

This commit is contained in:
Alastair 2017-06-12 15:44:03 +01:00
parent 9d906e9fff
commit 8e1bd7b832
4 changed files with 38 additions and 19 deletions

View File

@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals name: AdvancedPortals
version: 0.0.29 version: 0.0.30
author: sekwah41 author: sekwah41
description: An advanced portals plugin for bukkit. description: An advanced portals plugin for bukkit.
commands: commands:

View File

@ -16,7 +16,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
</repositories> </repositories>
<version>0.0.29-snapshot</version> <version>0.0.30-snapshot</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>

View File

@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
public class Listeners implements Listener { public class Listeners implements Listener {
@ -41,11 +42,17 @@ public class Listeners implements Listener {
String ItemID = config.getConfig().getString("AxeItemId"); String ItemID = config.getConfig().getString("AxeItemId");
if(ItemID == null){
WandMaterial = Material.IRON_AXE;
}
else{
try { try {
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID)); WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
} catch (Exception e) { } catch (Exception e) {
WandMaterial = Material.getMaterial(ItemID); WandMaterial = Material.getMaterial(ItemID);
} }
}
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@ -192,8 +199,8 @@ public class Listeners implements Listener {
catch(NullPointerException e){ catch(NullPointerException e){
}*/ }*/
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == WandMaterial // was type id if (player.getItemInHand() != null && player.getItemInHand().getType() == WandMaterial // was type id
&& (!UseOnlyServerAxe || (event.getItem().getItemMeta().getDisplayName() != null && event.getItem().getItemMeta().getDisplayName().equals("\u00A7ePortal Region Selector")))) { && (!UseOnlyServerAxe || (checkItemForName(event.getItem()) && event.getItem().getItemMeta().getDisplayName().equals("\u00A7ePortal Region Selector")))) {
// This checks if the action was a left or right click and if it was directly effecting a block. // This checks if the action was a left or right click and if it was directly effecting a block.
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
@ -226,7 +233,7 @@ public class Listeners implements Listener {
// Returns the event so no more code is executed(stops unnecessary code being executed) // Returns the event so no more code is executed(stops unnecessary code being executed)
} }
} else if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer") && } else if (checkItemForName(event.getItem()) && event.getItem().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer") &&
event.getAction() == Action.LEFT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.PORTAL) { event.getAction() == Action.LEFT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.PORTAL) {
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
if (block.getData() == 1) { if (block.getData() == 1) {
@ -240,5 +247,9 @@ public class Listeners implements Listener {
} }
private boolean checkItemForName(ItemStack item){
return item != null && item.hasItemMeta() && item.getItemMeta().hasDisplayName();
}
} }

View File

@ -37,22 +37,30 @@ public class PortalPlacer implements Listener {
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer")){ if(event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand() != null &&
event.getItemInHand().hasItemMeta()){
String name = event.getItemInHand().getItemMeta().getDisplayName();
if(name == null) return;
if (name.equals("\u00A75Portal Block Placer")){
event.getBlockPlaced().setType(Material.PORTAL); event.getBlockPlaced().setType(Material.PORTAL);
} }
else if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A78End Portal Block Placer")){ else if (name.equals("\u00A78End Portal Block Placer")){
event.getBlockPlaced().setType(Material.ENDER_PORTAL); event.getBlockPlaced().setType(Material.ENDER_PORTAL);
} }
else if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A78Gateway Block Placer")){ else if (name.equals("\u00A78Gateway Block Placer")){
event.getBlockPlaced().setType(Material.END_GATEWAY); event.getBlockPlaced().setType(Material.END_GATEWAY);
} }
} }
}
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) { public void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock(); Block block = event.getBlock();
//Material material = block.getType(); Material material = block.getType();
if (event.getChangedType() == Material.PORTAL/*(material == Material.PORTAL)*/ && Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius)) if (material == Material.PORTAL && Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius))
event.setCancelled(true); event.setCancelled(true);
} }
} }