From 74b26b4a4e15b7b3f0bfedde1e893f19f56efc29 Mon Sep 17 00:00:00 2001 From: sekwah Date: Thu, 22 Feb 2018 12:44:56 +0000 Subject: [PATCH] Added what i think is the code for portal placing --- TODO.md | 6 +---- .../advancedportals/core/CoreListeners.java | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index d5d8975..45e11fd 100644 --- a/TODO.md +++ b/TODO.md @@ -4,15 +4,11 @@ Main Tasks (Generally should be done in order) Tag registration system (Mostly done, just needs to be tested and implemented) -Portal loading system - Portal trigger system Configs for language files to allow all messages to change -Destination Command - -Portal Command +Change item data from strings to an object with strings in maybe Bungee Support Set Locations diff --git a/src/com/sekwah/advancedportals/core/CoreListeners.java b/src/com/sekwah/advancedportals/core/CoreListeners.java index 0dc5d27..d99269d 100644 --- a/src/com/sekwah/advancedportals/core/CoreListeners.java +++ b/src/com/sekwah/advancedportals/core/CoreListeners.java @@ -72,6 +72,31 @@ public class CoreListeners { return true; } + /** + * @player player causing the event (or null if not a player) + * @param blockPos + * @param blockMaterial + * @return if the block is allowed to be placed + */ + public boolean blockPlace(PlayerContainer player, PortalLocation blockPos, String blockMaterial, String itemInHandMaterial, String itemInHandName) { + if(player != null && player.hasPermission("advancedportals.build")) { + WorldContainer world = player.getWorld(); + if(itemInHandName.equals("\u00A75Portal Block Placer")) { + world.setBlock(blockPos, "PORTAL"); + return false; + } + else if(itemInHandName.equals("\u00A78End Portal Block Placer")) { + world.setBlock(blockPos, "ENDER_PORTAL"); + return false; + } + else if(itemInHandName.equals("\u00A78Gateway Block Placer")) { + world.setBlock(blockPos, "END_GATEWAY"); + return false; + } + } + return true; + } + /** * If the block is allowed to be interacted with e.g. a lever * @player player causing the event (or null if not a player) @@ -96,7 +121,7 @@ public class CoreListeners { AdvancedPortalsCore.getPortalManager().playerSelectorActivate(player, blockLoc, leftClick); return false; } - else if(leftClick || itemName.equals("\u00A75Portal Block Placer")) { + else if(leftClick && itemName.equals("\u00A75Portal Block Placer") && player.hasPermission("advancedportals.build")) { WorldContainer world = player.getWorld(); if(world.getBlockData(blockLoc) == 1) { world.setBlockData(blockLoc, (byte) 2);