Added stuff for backporting the new versions
This commit is contained in:
parent
5de6385051
commit
f658776315
|
@ -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)
|
||||
#
|
||||
|
|
|
@ -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:
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -9,6 +9,16 @@
|
|||
<directory>${basedir}/Resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
|
@ -16,7 +26,7 @@
|
|||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<version>0.0.41-snapshot</version>
|
||||
<version>0.0.46-1.8-1.12-snapshot</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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("<EFBFBD>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();
|
||||
|
|
Loading…
Reference in New Issue