mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-25 10:28:10 +01:00
Forgot to upload before release
This commit is contained in:
parent
9d906e9fff
commit
8e1bd7b832
@ -1,6 +1,6 @@
|
||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.29
|
||||
version: 0.0.30
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
commands:
|
||||
|
2
pom.xml
2
pom.xml
@ -16,7 +16,7 @@
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<version>0.0.29-snapshot</version>
|
||||
<version>0.0.30-snapshot</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
|
@ -22,6 +22,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class Listeners implements Listener {
|
||||
@ -41,11 +42,17 @@ public class Listeners implements Listener {
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
try {
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
} catch (Exception e) {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
if(ItemID == null){
|
||||
WandMaterial = Material.IRON_AXE;
|
||||
}
|
||||
else{
|
||||
try {
|
||||
WandMaterial = Material.getMaterial(Integer.parseInt(ItemID));
|
||||
} catch (Exception e) {
|
||||
WandMaterial = Material.getMaterial(ItemID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
@ -192,8 +199,8 @@ public class Listeners implements Listener {
|
||||
catch(NullPointerException e){
|
||||
|
||||
}*/
|
||||
if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == WandMaterial // was type id
|
||||
&& (!UseOnlyServerAxe || (event.getItem().getItemMeta().getDisplayName() != null && event.getItem().getItemMeta().getDisplayName().equals("\u00A7ePortal Region Selector")))) {
|
||||
if (player.getItemInHand() != null && player.getItemInHand().getType() == WandMaterial // was type id
|
||||
&& (!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.
|
||||
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)
|
||||
}
|
||||
|
||||
} 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) {
|
||||
Block block = event.getClickedBlock();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -37,22 +37,30 @@ public class PortalPlacer implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A75Portal Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.PORTAL);
|
||||
}
|
||||
else if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A78End Portal Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.ENDER_PORTAL);
|
||||
}
|
||||
else if (event.getPlayer().hasPermission("advancedportals.build") && event.getItemInHand().getItemMeta().getDisplayName().equals("\u00A78Gateway Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.END_GATEWAY);
|
||||
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);
|
||||
}
|
||||
else if (name.equals("\u00A78End Portal Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.ENDER_PORTAL);
|
||||
}
|
||||
else if (name.equals("\u00A78Gateway Block Placer")){
|
||||
event.getBlockPlaced().setType(Material.END_GATEWAY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||
Block block = event.getBlock();
|
||||
//Material material = block.getType();
|
||||
if (event.getChangedType() == Material.PORTAL/*(material == Material.PORTAL)*/ && Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius))
|
||||
Material material = block.getType();
|
||||
if (material == Material.PORTAL && Portal.inPortalRegion(block.getLocation(), PortalProtectionRadius))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user