Fixes some bugs regarding sign drawing and button updating
Fixes a bug displaying a portal as usable even if it's been unregistered Fixes a bug which causes the portal button to be re-generated, even if the portal has been unregistered
This commit is contained in:
parent
ee0e66e9be
commit
aa3bb58b33
@ -21,6 +21,7 @@ public class Portal {
|
||||
private final String name;
|
||||
private final String network;
|
||||
private final PortalOwner portalOwner;
|
||||
private boolean isRegistered;
|
||||
|
||||
private final PortalOptions options;
|
||||
private final PortalOpener portalOpener;
|
||||
@ -54,6 +55,24 @@ public class Portal {
|
||||
this.portalActivator = portalOpener.getPortalActivator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this portal is registered
|
||||
*
|
||||
* @return <p>True if this portal is registered</p>
|
||||
*/
|
||||
public boolean isRegistered() {
|
||||
return isRegistered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this portal is registered
|
||||
*
|
||||
* @param isRegistered <p>True if this portal is registered</p>
|
||||
*/
|
||||
public void setRegistered(boolean isRegistered) {
|
||||
this.isRegistered = isRegistered;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location data for this portal
|
||||
*
|
||||
|
@ -231,6 +231,7 @@ public class PortalRegistry {
|
||||
}
|
||||
|
||||
PortalFileHelper.saveAllPortals(portal.getWorld());
|
||||
portal.setRegistered(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -293,6 +294,7 @@ public class PortalRegistry {
|
||||
}
|
||||
|
||||
allPortals.add(portal);
|
||||
portal.setRegistered(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -218,7 +218,10 @@ public final class PortalFileHelper {
|
||||
|
||||
//Re-draw the signs in case a bug in the config prevented the portal from loading and has been fixed since
|
||||
for (Portal portal : PortalRegistry.getAllPortals()) {
|
||||
portal.drawSign();
|
||||
if (portal.isRegistered()) {
|
||||
portal.drawSign();
|
||||
updatePortalButton(portal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +253,7 @@ public final class PortalFileHelper {
|
||||
|
||||
//Load extra portal data
|
||||
String destination = (portalData.length > 8) ? portalData[8] : "";
|
||||
String network = (portalData.length > 9 && !portalData[9].isEmpty()) ? portalData[9] :
|
||||
String network = (portalData.length > 9 && !portalData[9].isEmpty()) ? portalData[9] :
|
||||
Stargate.getDefaultNetwork();
|
||||
String ownerString = (portalData.length > 10) ? portalData[10] : "";
|
||||
|
||||
@ -261,10 +264,8 @@ public final class PortalFileHelper {
|
||||
Portal portal = new Portal(portalLocation, button, destination, name, network, gate, owner,
|
||||
PortalHandler.getPortalOptions(portalData));
|
||||
|
||||
//Update the portal's button if it's the wrong material
|
||||
updatePortalButton(portal);
|
||||
|
||||
//Register the portal, and close it in case it wasn't properly closed when the server stopped
|
||||
setButtonVector(portal);
|
||||
PortalHandler.registerPortal(portal);
|
||||
portal.getPortalOpener().closePortal(true);
|
||||
}
|
||||
@ -275,7 +276,6 @@ public final class PortalFileHelper {
|
||||
* @param portal <p>The portal update the button of</p>
|
||||
*/
|
||||
private static void updatePortalButton(Portal portal) {
|
||||
setButtonVector(portal);
|
||||
BlockLocation buttonLocation = getButtonLocation(portal);
|
||||
BlockData buttonData = buttonLocation.getBlock().getBlockData();
|
||||
if (portal.getOptions().isAlwaysOn()) {
|
||||
@ -305,6 +305,9 @@ public final class PortalFileHelper {
|
||||
portal.getYaw());
|
||||
if (controlLocation != portal.getLocation().getSignLocation()) {
|
||||
portal.getLocation().setButtonVector(control);
|
||||
BlockLocation buttonLocation = controlLocation.getRelativeLocation(
|
||||
new RelativeBlockVector(0, 0, 1), portal.getYaw());
|
||||
portal.getStructure().setButton(buttonLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user