Skip to content

Commit

Permalink
Rename flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Mar 8, 2024
1 parent c502aa2 commit 4973bb4
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ public RealPortal build() throws TranslatableException, GateConflictException, N
String unformattedMessage = stargateAPI.getLanguageManager().getMessage(TranslatableMessage.CREATE);
msg = TranslatableMessageFormatter.formatNetwork(unformattedMessage, network.getName());
}
if (flags.contains(PortalFlag.FANCY_INTER_SERVER)) {
if (flags.contains(PortalFlag.INTER_SERVER)) {
msg = msg + " " + stargateAPI.getLanguageManager().getString(TranslatableMessage.UNIMPLEMENTED_INTER_SERVER);
}
MessageUtils.sendMessageFromPortal(portal, messageTarget, msg, MessageType.CREATE);
Expand Down Expand Up @@ -356,7 +356,7 @@ private void finalChecks(RealPortal portal, Network network) {
if (SpawnDetectionHelper.isInterferingWithSpawnProtection(gateAPI)) {
MessageUtils.sendMessage(messageTarget, stargateAPI.getLanguageManager().getWarningMessage(TranslatableMessage.SPAWN_CHUNKS_CONFLICTING));
}
if (portal.hasFlag(PortalFlag.FANCY_INTER_SERVER)) {
if (portal.hasFlag(PortalFlag.INTER_SERVER)) {
Network inflictingNetwork = NetworkCreationHelper.getInterServerLocalConflict(network, stargateAPI.getRegistry());
MessageUtils.sendMessage(messageTarget, TranslatableMessageFormatter.formatUnimplementedConflictMessage(network,
inflictingNetwork, stargateAPI.getLanguageManager()));
Expand All @@ -376,7 +376,7 @@ private void economyCheck(RealPortal portal) throws LocalisedMessageException {

private void flagChecks(Set<PortalFlag> flags) throws TranslatableException {
//Display an error if trying to create portals across servers while the feature is disabled
if ((flags.contains(PortalFlag.BUNGEE) || flags.contains(PortalFlag.FANCY_INTER_SERVER))
if ((flags.contains(PortalFlag.BUNGEE) || flags.contains(PortalFlag.INTER_SERVER))
&& !ConfigurationHelper.getBoolean(ConfigurationOption.USING_BUNGEE)) {
MessageUtils.sendMessage(messageTarget, stargateAPI.getLanguageManager().getWarningMessage(TranslatableMessage.BUNGEE_DISABLED));
throw new TranslatableException("Bungee is disabled") {
Expand All @@ -386,7 +386,7 @@ protected TranslatableMessage getTranslatableMessage() {
}
};
}
if (flags.contains(PortalFlag.FANCY_INTER_SERVER) && !ConfigurationHelper.getBoolean(
if (flags.contains(PortalFlag.INTER_SERVER) && !ConfigurationHelper.getBoolean(
ConfigurationOption.USING_REMOTE_DATABASE)) {
MessageUtils.sendMessage(messageTarget, stargateAPI.getLanguageManager().getWarningMessage(TranslatableMessage.INTER_SERVER_DISABLED));
throw new TranslatableException("Bungee networks are disabled") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum PortalFlag {
/**
* An across-server stargate using the new and better protocol
*/
FANCY_INTER_SERVER('I', true, false),
INTER_SERVER('I', true, false),

/**
* A stargate which is always on and always open
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private boolean registerVirtualPortal(StorageType portalType, PortalData portalD
* @return <p>The resulting network, or null if invalid</p>
*/
private Network getNetwork(PortalData portalData, RegistryAPI registry, NetworkManager networkManager) {
StorageType storageType = portalData.flags().contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL;
StorageType storageType = portalData.flags().contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL;
String targetNetwork = portalData.networkName();
if (portalData.flags().contains(PortalFlag.BUNGEE)) {
targetNetwork = ConfigurationHelper.getString(ConfigurationOption.LEGACY_BUNGEE_NETWORK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private String determineTranslatableMessageFromPermission(String permissionNode)
}
if (permissionNode.contains("type")) {
PortalFlag flag = PortalFlag.valueOf(permissionNode.split(".type.")[1].charAt(0));
if (flag == PortalFlag.BUNGEE || flag == PortalFlag.FANCY_INTER_SERVER) {
if (flag == PortalFlag.BUNGEE || flag == PortalFlag.INTER_SERVER) {
return languageManager.getErrorMessage(TranslatableMessage.BUNGEE_DENY);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public StargateNetworkManager(RegistryAPI registryAPI, StorageAPI storageAPI) {
HighlightingStyle highlight = HighlightingStyle.getHighlightType(name);
String unHighlightedName = NameHelper.getNormalizedName(HighlightingStyle.getNameFromHighlightedText(name));
TwoTuple<NetworkType, String> data;
StorageType storageType = flags.contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL;
StorageType storageType = flags.contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL;

if (flags.contains(NetworkType.TERMINAL.getRelatedFlag())) {
data = new TwoTuple<>(NetworkType.TERMINAL, unHighlightedName);
Expand Down Expand Up @@ -185,7 +185,7 @@ public void run() {

@Override
public Network createNetwork(String targetNetwork, Set<PortalFlag> flags, boolean isForced) throws InvalidNameException, NameLengthException, NameConflictException, UnimplementedFlagException {
return this.createNetwork(targetNetwork, NetworkType.getNetworkTypeFromFlags(flags), flags.contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL, isForced);
return this.createNetwork(targetNetwork, NetworkType.getNetworkTypeFromFlags(flags), flags.contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL, isForced);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
import org.sgrewritten.stargate.util.portal.PortalHelper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -558,7 +556,7 @@ public String getMetadata() {

@Override
public StorageType getStorageType() {
return (flags.contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
return (flags.contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public String getServer() {
}

public StorageType getStorageType() {
return (flags.contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
return (flags.contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private ChatColor getFlagColor(Portal portal) {
return null;
}
if (portal instanceof VirtualPortal) {
return ColorRegistry.FLAG_COLORS.get(PortalFlag.FANCY_INTER_SERVER);
return ColorRegistry.FLAG_COLORS.get(PortalFlag.INTER_SERVER);
}
for (PortalFlag flag : flagPriority) {
if (portal.hasFlag(flag)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static Portal readPortal(String line, World world, StargateAPI stargateA
}

Network network = stargateAPI.getRegistry().getNetwork(portalData.networkName(),
portalData.flags().contains(PortalFlag.FANCY_INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
portalData.flags().contains(PortalFlag.INTER_SERVER) ? StorageType.INTER_SERVER : StorageType.LOCAL);
Stargate.log(Level.INFO, "fetched networkName: " + portalData.networkName());

if (network == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public RealPortal build() throws InvalidStructureException, GateConflictExceptio
unrecognisedFlags = new HashSet<>();
}
if (storageType == StorageType.LOCAL) {
flags.remove(PortalFlag.FANCY_INTER_SERVER);
flags.remove(PortalFlag.INTER_SERVER);
} else {
flags.add(PortalFlag.FANCY_INTER_SERVER);
flags.add(PortalFlag.INTER_SERVER);
}
flags.add(network.getType().getRelatedFlag());
if (name == null) {
Expand Down

0 comments on commit 4973bb4

Please sign in to comment.