6 Commits

Author SHA1 Message Date
b98aec4a20 0.9.0.2 Fixes a bug in the code to prevent nether portals from generating in the nether 2021-11-01 00:38:36 +01:00
89956cf359 Updates the plugin version in plugin.yml 2021-10-31 19:51:33 +01:00
0655d85356 Updates README with the changes in 0.9.0.1 2021-10-31 18:10:19 +01:00
06cb99de44 Bumps version to 0.9.0.1 2021-10-31 18:09:56 +01:00
99f8a92857 Adds a highlightSignColor option and fixes some color inconsistencies
Makes all characters used for highlighting/marking use the highlighting color
Adds a new config option for highlighting color
Renames signColor to mainSignColor and adds the change to the config-migrations.txt file
2021-10-31 18:08:58 +01:00
01df8db0bf Moves config loading to finisSetup() to prevent a NullPointerException 2021-10-31 18:05:04 +01:00
9 changed files with 83 additions and 60 deletions

View File

@ -292,7 +292,8 @@ gates:
cosmetic:
rememberDestination - Whether to set the first destination as the last used destination for all gates
sortNetworkDestinations - If true, network lists will be sorted alphabetically.
signColor - This allows you to specify the color of the gate signs.
mainSignColor - This allows you to specify the color of the gate signs.
highlightSignColor - This allows you to specify the color of the sign markings.
integrity:
destroyedByExplosion - Whether to destroy a stargate with explosions, or stop an explosion if it contains a gates controls.
verifyPortals - Whether or not all the non-sign blocks are checked to match the gate layout when an old stargate is loaded at startup.
@ -366,6 +367,17 @@ bungeeSign=Teleport to
# Changes
#### \[Version 0.9.0.2] EpicKnarvik97 fork
- Fixes a bug causing Stargates using NETHER_PORTAL blocks to generate nether portals in the nether.
#### \[Version 0.9.0.1] EpicKnarvik97 fork
- Adds the highlightSignColor option and renames the signColor option to mainSignColor
- Fixes some inconsistencies in sign coloring by using the highlight color for all markings
- Fixes the order in which configs are loaded to prevent an exception
- Adds migrations for the config change
#### \[Version 0.9.0.0] EpicKnarvik97 fork
- Changes entire path structure to a more modern and maven-compliant one

View File

@ -4,7 +4,7 @@
<groupId>net.knarcraft</groupId>
<artifactId>Stargate</artifactId>
<version>0.9.0.0</version>
<version>0.9.0.2</version>
<licenses>
<license>

View File

@ -60,19 +60,19 @@ public final class StargateConfig {
portalFolder = dataFolderPath + "/portals/";
gateFolder = dataFolderPath + "/gates/";
languageLoader = new LanguageLoader(dataFolderPath + "/lang/");
this.loadConfig();
//Enable the required channels for Bungee support
if (stargateGateConfig.enableBungee()) {
startStopBungeeListener(true);
}
}
/**
* Finish the config setup by loading languages, gates and portals, and loading economy if vault is loaded
*/
public void finishSetup() {
this.loadConfig();
//Enable the required channels for Bungee support
if (stargateGateConfig.enableBungee()) {
startStopBungeeListener(true);
}
//Set the chosen language and reload the language loader
languageLoader.setChosenLanguage(languageName);
languageLoader.reload();

View File

@ -1,6 +1,7 @@
package net.knarcraft.stargate.config;
import net.knarcraft.stargate.Stargate;
import net.knarcraft.stargate.portal.PortalSignDrawer;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
@ -17,7 +18,6 @@ public final class StargateGateConfig {
private boolean enableBungee = true;
private boolean verifyPortals = true;
private boolean destroyExplosion = false;
private ChatColor signColor;
private String defaultGateNetwork = "central";
private static final int activeTime = 10;
private static final int openTime = 10;
@ -121,17 +121,6 @@ public final class StargateGateConfig {
return destroyExplosion;
}
/**
* Gets the color to use for drawing signs
*
* <p>Highlighting may use other colors. This is just the base color for portal names and such.</p>
*
* @return <p>The color to use for drawing signs</p>
*/
public ChatColor getSignColor() {
return signColor;
}
/**
* Gets the default portal network to use if no other network is given
*
@ -163,24 +152,26 @@ public final class StargateGateConfig {
//Cosmetic
sortNetworkDestinations = newConfig.getBoolean("gates.cosmetic.sortNetworkDestinations");
rememberDestination = newConfig.getBoolean("gates.cosmetic.rememberDestination");
loadSignColor(newConfig.getString("gates.cosmetic.signColor"));
loadSignColor(newConfig.getString("gates.cosmetic.mainSignColor"),
newConfig.getString("gates.cosmetic.highlightSignColor"));
}
/**
* Loads the correct sign color given a sign color string
*
* @param signColor <p>A string representing a sign color</p>
* @param mainSignColor <p>A string representing the main sign color</p>
*/
private void loadSignColor(String signColor) {
if (signColor != null) {
private void loadSignColor(String mainSignColor, String highlightSignColor) {
if (mainSignColor != null) {
try {
this.signColor = ChatColor.valueOf(signColor.toUpperCase());
PortalSignDrawer.setColors(ChatColor.valueOf(mainSignColor.toUpperCase()),
ChatColor.valueOf(highlightSignColor.toUpperCase()));
return;
} catch (IllegalArgumentException | NullPointerException ignored) {
}
}
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK");
this.signColor = ChatColor.BLACK;
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
PortalSignDrawer.setColors(ChatColor.BLACK, ChatColor.WHITE);
}
}

View File

@ -1,5 +1,6 @@
package net.knarcraft.stargate.listener;
import net.knarcraft.stargate.Stargate;
import net.knarcraft.stargate.container.FromTheEndTeleportation;
import net.knarcraft.stargate.portal.PlayerTeleporter;
import net.knarcraft.stargate.portal.Portal;
@ -8,7 +9,6 @@ import net.knarcraft.stargate.utility.PermissionHelper;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -37,11 +37,14 @@ public class PortalEventListener implements Listener {
if (event.isCancelled()) {
return;
}
//Cancel nether portal creation when the portal is a StarGate portal
for (BlockState block : event.getBlocks()) {
if (PortalHandler.getByBlock(block.getBlock()) != null) {
//Unnecessary nether portal creation is only triggered by nether pairing
if (event.getReason() == PortalCreateEvent.CreateReason.NETHER_PAIR) {
//If an entity is standing in a Stargate entrance, it can be assumed that the creation is a mistake
Entity entity = event.getEntity();
if (entity != null && PortalHandler.getByAdjacentEntrance(entity.getLocation()) != null) {
Stargate.debug("PortalEventListener::onPortalCreation",
"Cancelled nether portal create event");
event.setCancelled(true);
return;
}
}
}

View File

@ -13,9 +13,10 @@ import org.bukkit.block.Sign;
public class PortalSignDrawer {
private final Portal portal;
private final static ChatColor highlightColor = ChatColor.WHITE;
private final static ChatColor errorColor = ChatColor.DARK_RED;
private final static ChatColor freeColor = ChatColor.DARK_GREEN;
private static ChatColor mainColor;
private static ChatColor highlightColor;
/**
* Instantiates a new portal sign drawer
@ -26,6 +27,20 @@ public class PortalSignDrawer {
this.portal = portal;
}
/**
* Sets the main sign color
*
* <p>The main sign color is used for most text on the sign, while the highlighting color is used for the markings
* around portal names and network names ('>','<','-',')','(')</p>
*
* @param newMainColor <p>The new main sign color</p>
* @param newHighlightColor <p>The new highlight color</p>
*/
public static void setColors(ChatColor newMainColor, ChatColor newHighlightColor) {
mainColor = newMainColor;
highlightColor = newHighlightColor;
}
/**
* Draws the sign of the portal this sign drawer is responsible for
*/
@ -47,12 +62,12 @@ public class PortalSignDrawer {
*
* @param sign <p>The sign re-draw</p>
*/
public void drawSign(Sign sign) {
private void drawSign(Sign sign) {
//Clear sign
for (int index = 0; index <= 3; index++) {
sign.setLine(index, "");
}
setLine(sign, 0, highlightColor + "-" + Stargate.getGateConfig().getSignColor() +
setLine(sign, 0, highlightColor + "-" + mainColor +
portal.getName() + highlightColor + "-");
if (!portal.getPortalActivator().isActive()) {
@ -118,11 +133,12 @@ public class PortalSignDrawer {
if (freeGatesGreen) {
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
setLine(sign, signLineIndex, (green ? freeColor : "") + ">" +
portal.getDestinationName() + (green ? freeColor : "") + "<");
ChatColor nameColor = (green ? freeColor : highlightColor);
setLine(sign, signLineIndex, nameColor + ">" + (green ? freeColor : mainColor) +
portal.getDestinationName() + nameColor + "<");
} else {
setLine(sign, signLineIndex, highlightColor + ">" + Stargate.getGateConfig().getSignColor() +
portal.getDestinationName() + highlightColor + "<");
setLine(sign, signLineIndex, highlightColor + ">" + mainColor + portal.getDestinationName() +
highlightColor + "<");
}
}
@ -134,7 +150,7 @@ public class PortalSignDrawer {
* @param text <p>The new text on the sign</p>
*/
public void setLine(Sign sign, int index, String text) {
sign.setLine(index, Stargate.getGateConfig().getSignColor() + text);
sign.setLine(index, mainColor + text);
}
/**
@ -147,14 +163,13 @@ public class PortalSignDrawer {
*/
private void drawNetworkSignLine(boolean freeGatesGreen, Sign sign, int signLineIndex, int destinationIndex) {
PortalActivator destinations = portal.getPortalActivator();
String destinationName = destinations.getDestinations().get(destinationIndex);
if (freeGatesGreen) {
Portal destination = PortalHandler.getByName(destinations.getDestinations().get(destinationIndex),
portal.getNetwork());
Portal destination = PortalHandler.getByName(destinationName, portal.getNetwork());
boolean green = PermissionHelper.isFree(portal.getActivePlayer(), portal, destination);
setLine(sign, signLineIndex, (green ? freeColor : "") +
destinations.getDestinations().get(destinationIndex));
setLine(sign, signLineIndex, (green ? freeColor : mainColor) + destinationName);
} else {
setLine(sign, signLineIndex, destinations.getDestinations().get(destinationIndex));
setLine(sign, signLineIndex, mainColor + destinationName);
}
}
@ -165,8 +180,8 @@ public class PortalSignDrawer {
*/
private void drawBungeeSign(Sign sign) {
setLine(sign, 1, Stargate.getString("bungeeSign"));
setLine(sign, 2, ">" + portal.getDestinationName() + "<");
setLine(sign, 3, "[" + portal.getNetwork() + "]");
setLine(sign, 2, highlightColor + ">" + mainColor + portal.getDestinationName() + highlightColor + "<");
setLine(sign, 3, highlightColor + "[" + mainColor + portal.getNetwork() + highlightColor + "]");
}
/**
@ -178,7 +193,7 @@ public class PortalSignDrawer {
setLine(sign, 1, Stargate.getString("signRightClick"));
setLine(sign, 2, Stargate.getString("signToUse"));
if (!portal.getOptions().isNoNetwork()) {
setLine(sign, 3, "(" + portal.getNetwork() + ")");
setLine(sign, 3, highlightColor + "(" + mainColor + portal.getNetwork() + highlightColor + ")");
} else {
setLine(sign, 3, "");
}
@ -190,15 +205,14 @@ public class PortalSignDrawer {
* @param sign <p>The sign to re-draw</p>
*/
private void drawFixedSign(Sign sign) {
if (portal.getOptions().isRandom()) {
setLine(sign, 1, ">" + Stargate.getString("signRandom") + "<");
} else {
setLine(sign, 1, ">" + portal.getDestinationName() + "<");
}
String destinationName = portal.getOptions().isRandom() ? Stargate.getString("signRandom") :
portal.getDestinationName();
setLine(sign, 1, highlightColor + ">" + mainColor + destinationName + highlightColor + "<");
if (portal.getOptions().isNoNetwork()) {
setLine(sign, 2, "");
} else {
setLine(sign, 2, "(" + portal.getNetwork() + ")");
setLine(sign, 2, highlightColor + "(" + mainColor + portal.getNetwork() + highlightColor + ")");
}
Portal destination = PortalHandler.getByName(portal.getDestinationName(), portal.getNetwork());
if (destination == null && !portal.getOptions().isRandom()) {

View File

@ -13,6 +13,7 @@ protectEntrance=gates.integrity.protectEntrance
enableBungee=gates.functionality.enableBungee
verifyPortals=gates.integrity.verifyPortals
signColor=gates.cosmetic.signColor
gates.cosmetic.signColor=gates.cosmetic.mainSignColor
debug=debugging.debug
permdebug=debugging.permissionDebug
useiconomy=economy.useEconomy

View File

@ -11,7 +11,8 @@
# handleVehicles - Whether to allow vehicles through gates
# sortNetworkDestinations - Whether to sort network lists alphabetically
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material)
# signColor - The color used for drawing signs (Default: BLACK).
# mainSignColor - The color used for drawing signs (Default: BLACK).
# highlightSignColor - The color used for sign markings (Default: WHITE)
# verifyPortals - Whether all the non-sign blocks are checked to match the gate layout when a stargate is loaded.
# I------------I-------------I #
# stargate economy options #
@ -39,7 +40,8 @@ gates:
cosmetic:
rememberDestination: false
sortNetworkDestinations: false
signColor: BLACK
mainSignColor: BLACK
highlightSignColor: WHITE
integrity:
destroyedByExplosion: false
verifyPortals: false

View File

@ -1,10 +1,10 @@
name: Stargate
main: net.knarcraft.stargate.Stargate
version: 0.9.0.0
description: Stargate mod for Bukkit
version: 0.9.0.2
description: Stargate mod for Bukkit Revived
author: EpicKnarvik97
authors: [ Drakia, PseudoKnight, EpicKnarvik97 ]
website: https://knarcraft.net
website: https://git.knarcraft.net/EpicKnarvik97/Stargate
api-version: 1.17
softdepend: [ Vault ]
commands: