Add support for 1.14

This commit is contained in:
Michael Smith 2019-06-20 23:44:37 -07:00
parent 5a7342ebf3
commit 31cc911a9a
No known key found for this signature in database
GPG Key ID: 41F47A53EDE95BE1
6 changed files with 69 additions and 62 deletions

6
README
View File

@ -162,7 +162,7 @@ handleVehicles - Whether or not to handle vehicles going through gates. Set to f
sortLists - If true, network lists will be sorted alphabetically. sortLists - If true, network lists will be sorted alphabetically.
protectEntrance - If true, will protect from users breaking gate entrance blocks (This is more resource intensive than the usual check, and should only be enabled for servers that use solid open/close blocks) protectEntrance - If true, will protect from users breaking gate entrance blocks (This is more resource intensive than the usual check, and should only be enabled for servers that use solid open/close blocks)
signColor: This allows you to specify the color of the gate signs. Valid colors: signColor: This allows you to specify the color of the gate signs. Valid colors:
verifyPortals: Whether or not all the non-sign blocks are checked to match the gate layout when a stargate is loaded. verifyPortals: Whether or not all the non-sign blocks are checked to match the gate layout when an old stargate is loaded.
debug - Whether to show massive debug output debug - Whether to show massive debug output
permdebug - Whether to show massive permission debug output permdebug - Whether to show massive permission debug output
@ -211,8 +211,8 @@ Stargates are stored under player names, not UUIDs. This will be changed in the
Changes Changes
============= =============
[Version 0.8.0.0] PseudoKnight fork [Version 0.8.0.0] PseudoKnight fork
- Update for 1.13 compatibility. This changes gate layouts to use new material names instead of numeric ids. You need to update your gate layout configs. - Update for 1.13/1.14 compatibility. This changes gate layouts to use new material names instead of numeric ids. You need to update your gate layout configs.
- Adds "verifyPortals" config option, which sets whether a stargate layout is verified when it is loaded. - Adds "verifyPortals" config option, which sets whether an old stargate's blocks are verified when loaded.
[Version 0.7.9.11] PseudoKnight fork [Version 0.7.9.11] PseudoKnight fork
- Removed iConomy support. Updated Vault support. Changed setting from "useiconomy" to "useeconomy". - Removed iConomy support. Updated Vault support. Changed setting from "useiconomy" to "useeconomy".
- Updated to support Metrics for 1.7.10 - Updated to support Metrics for 1.7.10

View File

@ -20,12 +20,12 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.13.1-R0.1-SNAPSHOT</version> <version>1.14.2-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.6</version> <version>1.7</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -5,6 +5,7 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Sign; import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign; import org.bukkit.block.data.type.WallSign;
@ -92,6 +93,10 @@ public class Blox {
return world.getBlockAt(x, y, z); return world.getBlockAt(x, y, z);
} }
public Location getLocation() {
return new Location(world, x, y, z);
}
public int getX() { public int getX() {
return x; return x;
} }
@ -119,11 +124,12 @@ public class Blox {
int offsetY = 0; int offsetY = 0;
int offsetZ = 0; int offsetZ = 0;
if (getBlock().getType() == Material.WALL_SIGN) { BlockData blk = getBlock().getBlockData();
BlockFace facing = ((WallSign) getBlock().getBlockData()).getFacing().getOppositeFace(); if (blk instanceof WallSign) {
BlockFace facing = ((WallSign) blk).getFacing().getOppositeFace();
offsetX = facing.getModX(); offsetX = facing.getModX();
offsetZ = facing.getModZ(); offsetZ = facing.getModZ();
} else if (getBlock().getType() == Material.SIGN) { } else if (blk instanceof Sign) {
offsetY = -1; offsetY = -1;
} else { } else {
return; return;

View File

@ -26,10 +26,12 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional; import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Powerable; import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.minecart.StorageMinecart; import org.bukkit.entity.minecart.StorageMinecart;
@ -339,17 +341,16 @@ public class Portal {
return frame; return frame;
} }
public Block getSign() { public Blox getSign() {
return id.getBlock(); return id;
} }
public World getWorld() { public World getWorld() {
return world; return world;
} }
public Block getButton() { public Blox getButton() {
if (button == null) return null; return button;
return button.getBlock();
} }
public void setButton(Blox button) { public void setButton(Blox button) {
@ -373,8 +374,6 @@ public class Portal {
if (isOpen() && !force) return false; if (isOpen() && !force) return false;
getWorld().loadChunk(getWorld().getChunkAt(topLeft.getBlock()));
Material openType = gate.getPortalBlockOpen(); Material openType = gate.getPortalBlockOpen();
Axis ax = openType == Material.NETHER_PORTAL ? rot : null; Axis ax = openType == Material.NETHER_PORTAL ? rot : null;
for (Blox inside : getEntrances()) { for (Blox inside : getEntrances()) {
@ -560,10 +559,6 @@ public class Portal {
return getWorld().isChunkLoaded(topLeft.getBlock().getChunk()); return getWorld().isChunkLoaded(topLeft.getBlock().getChunk());
} }
public void loadChunk() {
getWorld().loadChunk(topLeft.getBlock().getChunk());
}
public boolean isVerified() { public boolean isVerified() {
verified = true; verified = true;
if(!Stargate.verifyPortals) { if(!Stargate.verifyPortals) {
@ -698,13 +693,13 @@ public class Portal {
} }
public final void drawSign() { public final void drawSign() {
Material sMat = id.getBlock().getType(); BlockState state = id.getBlock().getState();
if (sMat != Material.SIGN && sMat != Material.WALL_SIGN) { if (!(state instanceof Sign)) {
Stargate.log.warning("[Stargate] Sign block is not a Sign object"); Stargate.log.warning("[Stargate] Sign block is not a Sign object");
Stargate.debug("Portal::drawSign", "Block: " + id.getBlock().getType() + " @ " + id.getBlock().getLocation()); Stargate.debug("Portal::drawSign", "Block: " + id.getBlock().getType() + " @ " + id.getBlock().getLocation());
return; return;
} }
Sign sign = (Sign)id.getBlock().getState(); Sign sign = (Sign) state;
Stargate.setLine(sign, 0, "-" + name + "-"); Stargate.setLine(sign, 0, "-" + name + "-");
int max = destinations.size() - 1; int max = destinations.size() - 1;
int done = 0; int done = 0;
@ -835,7 +830,7 @@ public class Portal {
} }
} }
if (id.getBlock().getType() == Material.WALL_SIGN && id.getBlock().getState() instanceof Sign) { if (id.getBlock().getBlockData() instanceof WallSign) {
Sign sign = (Sign)id.getBlock().getState(); Sign sign = (Sign)id.getBlock().getState();
sign.setLine(0, getName()); sign.setLine(0, getName());
sign.setLine(1, ""); sign.setLine(1, "");
@ -1249,6 +1244,9 @@ public class Portal {
} }
public static void saveAllGates(World world) { public static void saveAllGates(World world) {
if(!Stargate.managedWorlds.contains(world.getName())) {
Stargate.managedWorlds.add(world.getName());
}
String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db"; String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db";
try { try {
@ -1258,7 +1256,7 @@ public class Portal {
String wName = portal.world.getName(); String wName = portal.world.getName();
if (!wName.equalsIgnoreCase(world.getName())) continue; if (!wName.equalsIgnoreCase(world.getName())) continue;
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
Blox sign = new Blox(portal.id.getBlock()); Blox sign = portal.id;
Blox button = portal.button; Blox button = portal.button;
builder.append(portal.name); builder.append(portal.name);
@ -1404,23 +1402,10 @@ public class Portal {
portal.drawSign(); portal.drawSign();
portalCount++; portalCount++;
if (!portal.isFixed()) continue; if (portal.isFixed() && (Stargate.enableBungee && portal.isBungee()
|| portal.getDestination() != null && portal.isAlwaysOn())) {
if (Stargate.enableBungee && portal.isBungee()) {
OpenCount++;
portal.open(true); portal.open(true);
portal.drawSign(); OpenCount++;
continue;
}
Portal dest = portal.getDestination();
if (dest != null) {
if (portal.isAlwaysOn()) {
portal.open(true);
OpenCount++;
}
portal.drawSign();
dest.drawSign();
} }
} }
Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on"); Stargate.log.info("[Stargate] {" + world.getName() + "} Loaded " + portalCount + " stargates with " + OpenCount + " set as always-on");

View File

@ -5,6 +5,7 @@ import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
@ -26,6 +27,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.EndGateway; import org.bukkit.block.EndGateway;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.block.data.Orientable; import org.bukkit.block.data.Orientable;
import org.bukkit.block.data.type.WallSign;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -120,6 +122,8 @@ public class Stargate extends JavaPlugin {
// HashMap of player names for Bungee support // HashMap of player names for Bungee support
public static Map<String, String> bungeeQueue = new HashMap<>(); public static Map<String, String> bungeeQueue = new HashMap<>();
public static HashSet<String> managedWorlds = new HashSet<>();
public void onDisable() { public void onDisable() {
Portal.closeAllGates(); Portal.closeAllGates();
Portal.clearGates(); Portal.clearGates();
@ -162,7 +166,8 @@ public class Stargate extends JavaPlugin {
lang = new LangLoader(langFolder, Stargate.langName); lang = new LangLoader(langFolder, Stargate.langName);
this.migrate(); this.migrate();
this.reloadGates(); this.loadGates();
this.loadAllPortals();
// Check to see if Economy is loaded yet. // Check to see if Economy is loaded yet.
if (EconomyHandler.setupEconomy(pm)) { if (EconomyHandler.setupEconomy(pm)) {
@ -217,16 +222,24 @@ public class Stargate extends JavaPlugin {
this.saveConfig(); this.saveConfig();
} }
public void reloadGates() { public void closeAllPortals() {
// Close all gates prior to reloading // Close all gates prior to reloading
for (Portal p : openList) { for (Portal p : openList) {
p.close(true); p.close(true);
} }
}
public void loadGates() {
Gate.loadGates(gateFolder); Gate.loadGates(gateFolder);
log.info("[Stargate] Loaded " + Gate.getGateCount() + " gate layouts"); log.info("[Stargate] Loaded " + Gate.getGateCount() + " gate layouts");
}
public void loadAllPortals() {
for (World world : getServer().getWorlds()) { for (World world : getServer().getWorlds()) {
Portal.loadAllGates(world); if(!managedWorlds.contains(world.getName())) {
Portal.loadAllGates(world);
managedWorlds.add(world.getName());
}
} }
} }
@ -829,7 +842,7 @@ public class Stargate extends JavaPlugin {
// Right click // Right click
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (block.getType() == Material.WALL_SIGN) { if (block.getBlockData() instanceof WallSign) {
Portal portal = Portal.getByBlock(block); Portal portal = Portal.getByBlock(block);
if (portal == null) return; if (portal == null) return;
// Cancel item use // Cancel item use
@ -882,7 +895,7 @@ public class Stargate extends JavaPlugin {
// Left click // Left click
if (event.getAction() == Action.LEFT_CLICK_BLOCK) { if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
// Check if we're scrolling a sign // Check if we're scrolling a sign
if (block.getType() == Material.WALL_SIGN) { if (block.getBlockData() instanceof WallSign) {
Portal portal = Portal.getByBlock(block); Portal portal = Portal.getByBlock(block);
if (portal == null) return; if (portal == null) return;
@ -916,7 +929,7 @@ public class Stargate extends JavaPlugin {
if (event.isCancelled()) return; if (event.isCancelled()) return;
Player player = event.getPlayer(); Player player = event.getPlayer();
Block block = event.getBlock(); Block block = event.getBlock();
if (block.getType() != Material.WALL_SIGN) return; if (!(block.getBlockData() instanceof WallSign)) return;
final Portal portal = Portal.createPortal(event, player); final Portal portal = Portal.createPortal(event, player);
// Not creating a gate, just placing a sign // Not creating a gate, just placing a sign
@ -1041,7 +1054,10 @@ public class Stargate extends JavaPlugin {
private class wListener implements Listener { private class wListener implements Listener {
@EventHandler @EventHandler
public void onWorldLoad(WorldLoadEvent event) { public void onWorldLoad(WorldLoadEvent event) {
Portal.loadAllGates(event.getWorld()); if(!managedWorlds.contains(event.getWorld().getName())) {
Portal.loadAllGates(event.getWorld());
managedWorlds.add(event.getWorld().getName());
}
} }
// We need to reload all gates on world unload, boo // We need to reload all gates on world unload, boo
@ -1049,13 +1065,13 @@ public class Stargate extends JavaPlugin {
public void onWorldUnload(WorldUnloadEvent event) { public void onWorldUnload(WorldUnloadEvent event) {
Stargate.debug("onWorldUnload", "Reloading all Stargates"); Stargate.debug("onWorldUnload", "Reloading all Stargates");
World w = event.getWorld(); World w = event.getWorld();
String location = Stargate.getSaveLocation(); if(managedWorlds.contains(w.getName())) {
File db = new File(location, w.getName() + ".db"); managedWorlds.remove(w.getName());
if (db.exists()) {
Portal.clearGates(); Portal.clearGates();
for (World world : server.getWorlds()) { for(World world : server.getWorlds()) {
if (world.equals(w)) continue; if(managedWorlds.contains(world.getName())) {
Portal.loadAllGates(world); Portal.loadAllGates(world);
}
} }
} }
} }
@ -1101,7 +1117,7 @@ public class Stargate extends JavaPlugin {
BloxPopulator b = Stargate.blockPopulatorQueue.poll(); BloxPopulator b = Stargate.blockPopulatorQueue.poll();
if (b == null) return; if (b == null) return;
Block blk = b.getBlox().getBlock(); Block blk = b.getBlox().getBlock();
blk.setType(b.getMat(), false); blk.setType(b.getMat());
if(b.getMat() == Material.END_GATEWAY && blk.getWorld().getEnvironment() == World.Environment.THE_END) { if(b.getMat() == Material.END_GATEWAY && blk.getWorld().getEnvironment() == World.Environment.THE_END) {
// force a location to prevent exit gateway generation // force a location to prevent exit gateway generation
EndGateway gateway = (EndGateway) blk.getState(); EndGateway gateway = (EndGateway) blk.getState();
@ -1167,12 +1183,11 @@ public class Stargate extends JavaPlugin {
p.deactivate(); p.deactivate();
} }
// Close portals // Close portals
for (Portal p : openList) { closeAllPortals();
p.close(true);
}
// Clear all lists // Clear all lists
activeList.clear(); activeList.clear();
openList.clear(); openList.clear();
managedWorlds.clear();
Portal.clearGates(); Portal.clearGates();
Gate.clearGates(); Gate.clearGates();
@ -1180,7 +1195,8 @@ public class Stargate extends JavaPlugin {
boolean oldEnableBungee = enableBungee; boolean oldEnableBungee = enableBungee;
// Reload data // Reload data
loadConfig(); loadConfig();
reloadGates(); loadGates();
loadAllPortals();
lang.setLang(langName); lang.setLang(langName);
lang.reload(); lang.reload();

View File

@ -1,6 +1,6 @@
name: Stargate name: Stargate
main: net.TheDgtl.Stargate.Stargate main: net.TheDgtl.Stargate.Stargate
version: 0.7.9.11 version: 0.8.0.0-SNAPSHOT
description: Stargate mod for Bukkit description: Stargate mod for Bukkit
author: Drakia author: Drakia
website: http://www.thedgtl.net website: http://www.thedgtl.net