diff --git a/Resources/config.yml b/Resources/config.yml
index d9cc242..a88573f 100644
--- a/Resources/config.yml
+++ b/Resources/config.yml
@@ -75,6 +75,8 @@ BlockSpectatorMode: false
PortalCooldown: 5 # How long after trying to enter a portal until the player can try to enter another. 0 or lower to deactivate.
ThrowbackAmount: 0.7 # How fast to throw them back, 0 or lower to disable throwback
+DisableGatewayBeam: true
+
# Letters are flags. Include them to activate. n always disables everything, remove if you want it to work.
# Lettering may not make too much sense but meh its useful. Examples are "ocpk" or "cop" (doesnt matter order)
#
diff --git a/Resources/plugin.yml b/Resources/plugin.yml
index a66e0bf..0c525e9 100644
--- a/Resources/plugin.yml
+++ b/Resources/plugin.yml
@@ -1,6 +1,6 @@
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
name: AdvancedPortals
-version: 0.0.41
+version: 0.0.46
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:
diff --git a/pom.xml b/pom.xml
index 4fbea12..1b35a72 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,6 +9,16 @@
${basedir}/Resources
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
@@ -16,7 +26,7 @@
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
- 0.0.41-snapshot
+ 0.0.46-1.8-1.12-snapshot
UTF-8
1.7
diff --git a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java
index 1095a42..5278e13 100644
--- a/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java
+++ b/src/com/sekwah/advancedportals/AdvancedPortalsCommand.java
@@ -55,7 +55,6 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
if (sender.hasPermission("advancedportals.portal")) {
if (args.length > 0) { switch (args[0].toLowerCase()) {
- case "wand":
case "warp":
if (args.length == 2 && player.hasPermission("advancedportals.portal.warp")){
for (AdvancedPortal portal: Portal.portals){
@@ -296,6 +295,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
sender.sendMessage("");
sender.sendMessage("\u00A7aExample command: \u00A7e/portal create name:test triggerId:portal");
break;
+ case "wand":
case "select":
// TODO finish the select command and the hit block to replace!
if (!player.hasMetadata("selectingPortal")) {
diff --git a/src/com/sekwah/advancedportals/compat/CraftBukkit.java b/src/com/sekwah/advancedportals/compat/CraftBukkit.java
index a2c2775..4706299 100644
--- a/src/com/sekwah/advancedportals/compat/CraftBukkit.java
+++ b/src/com/sekwah/advancedportals/compat/CraftBukkit.java
@@ -1,6 +1,7 @@
package com.sekwah.advancedportals.compat;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
+import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
@@ -32,6 +33,13 @@ public class CraftBukkit {
private boolean useEnumType = false;
+ // Data for beacon
+ private Class> endGatewayClass;
+ private Class> tileEntityEndGatewayClass;
+ private Constructor> blockPositionConstructor;
+ private Method getWorldHandleMethod;
+ private Method getTileEntityMethod;
+
// Classes so it doesnt keep fetching them.
@@ -80,6 +88,19 @@ public class CraftBukkit {
this.playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection"); // get player connection
Class> packet = Class.forName(minecraftPackage + "Packet");
this.sendPacket = playerConnection.getType().getMethod("sendPacket", packet);
+
+
+ // Data for beacon
+ this.endGatewayClass = Class.forName(craftBukkitPackage + "block.CraftEndGateway");
+ this.tileEntityEndGatewayClass = Class.forName(minecraftPackage + "TileEntityEndGateway");
+
+ Class> blockPos = Class.forName(minecraftPackage + "BlockPosition");
+
+ this.blockPositionConstructor = blockPos.getConstructor(int.class, int.class, int.class);
+
+ getWorldHandleMethod = Class.forName(craftBukkitPackage + "CraftWorld").getMethod("getHandle");
+
+ getTileEntityMethod = Class.forName(minecraftPackage + "WorldServer").getMethod("getTileEntity", blockPos);
} catch (Exception e) {
e.printStackTrace();
plugin.getLogger().warning("Attempting to use backup porekit locations");
@@ -144,5 +165,21 @@ public class CraftBukkit {
return null;
}
+ public void setGatewayAgeHigh(Block block) {
+ if(block.getState().getClass().isAssignableFrom(this.endGatewayClass)) {
+ try {
+ Object tileEntity = this.getTileEntityMethod.invoke(this.getWorldHandleMethod.invoke(block.getWorld()),
+ this.blockPositionConstructor.newInstance(block.getX(), block.getY(), block.getZ()));
+ if(tileEntity.getClass().isAssignableFrom(this.tileEntityEndGatewayClass)) {
+ Field g = tileEntity.getClass().getDeclaredField("g");
+ g.setAccessible(true);
+ g.set(tileEntity, Integer.MAX_VALUE);
+ }
+ } catch (IllegalAccessException| InvocationTargetException | InstantiationException | NoSuchFieldException e) {
+ this.plugin.getLogger().warning("Error setting gateway time");
+ e.printStackTrace();
+ }
+ }
+ }
}
diff --git a/src/com/sekwah/advancedportals/listeners/PortalPlacer.java b/src/com/sekwah/advancedportals/listeners/PortalPlacer.java
index 675e81c..36cff9c 100644
--- a/src/com/sekwah/advancedportals/listeners/PortalPlacer.java
+++ b/src/com/sekwah/advancedportals/listeners/PortalPlacer.java
@@ -3,18 +3,22 @@ package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.Portal;
+import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
+import org.bukkit.block.BlockState;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
+import org.bukkit.event.world.ChunkLoadEvent;
public class PortalPlacer implements Listener {
@SuppressWarnings("unused")
private final AdvancedPortalsPlugin plugin;
+ private final boolean DISABLE_GATEWAY_BEAM;
// The needed config values will be stored so they are easier to access later
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("�eP...
@@ -26,6 +30,8 @@ public class PortalPlacer implements Listener {
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
this.PortalPlace = config.getConfig().getBoolean("CanBuildPortalBlock");
+ this.DISABLE_GATEWAY_BEAM = config.getConfig().getBoolean("DisableGatewayBeam", true);
+
if (PortalPlace) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@@ -47,11 +53,33 @@ public class PortalPlacer implements Listener {
}
else if (name.equals("\u00A78Gateway Block Placer")){
event.getBlockPlaced().setType(Material.END_GATEWAY);
+ if(this.DISABLE_GATEWAY_BEAM) {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
+ this.plugin.compat.setGatewayAgeHigh(event.getBlock());
+ }, 1);
+ }
}
}
}
+ @EventHandler
+ public void onChunkLoad(ChunkLoadEvent event) {
+ if(!this.DISABLE_GATEWAY_BEAM) {
+ return;
+ }
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
+ BlockState[] tileEntities = event.getChunk().getTileEntities();
+ if(tileEntities.length >0) {
+ System.out.println("TILE ENTITIES");
+ }
+ for(BlockState block : tileEntities) {
+ this.plugin.compat.setGatewayAgeHigh(block.getBlock());
+ }
+ }, 10);
+ //event.getHandlers();
+ }
+
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock();