Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ View the Spigot page (with FAQ and install instructions) [here](https://www.spig
Check the [wiki](https://github.com/espidev/ProtectionStones/wiki) for plugin reference information.

### Dependencies
* ProtectionStones 2.10.6
* ProtectionStones 2.10.7
* Spigot 1.21.6+
* WorldGuard 7.0.9+
* WorldEdit 7.2.6+
Expand Down
29 changes: 22 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>dev.espi</groupId>
<artifactId>protectionstones</artifactId>
<version>2.10.6</version>
<version>2.10.7</version>
<name>ProtectionStones</name>
<description>A grief prevention plugin for Spigot Minecraft servers.</description>
<url>https://github.com/espidev/ProtectionStones</url>
Expand Down Expand Up @@ -89,8 +89,8 @@
<version>3.1</version>
<configuration>

<source>16</source>
<target>16</target>
<source>21</source>
<target>21</target>
<encoding>${project.build.sourceEncoding}</encoding>

</configuration>
Expand All @@ -107,13 +107,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.5.0</version>
<configuration>
<minimizeJar>true</minimizeJar>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>false</minimizeJar>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>dev.espi.protectionstones</shadedPattern>
<shadedPattern>dev.espi.protectionstones.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>dev.espi.protectionstones.lib.kyori</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down Expand Up @@ -201,7 +206,7 @@
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.2</version>
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -272,5 +277,15 @@
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.3</version>
</dependency>
</dependencies>
</project>
55 changes: 41 additions & 14 deletions src/main/java/dev/espi/protectionstones/FlagHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,28 @@ public class FlagHandler {

// Custom WorldGuard Flags used by ProtectionStones
// Added to blocks on BlockPlaceEvent Listener
// When adding flags, you may want to add them to the hidden_flags_from_info config option list
// When adding flags, you may want to add them to the hidden_flags_from_info
// config option list
public static final Flag<String> PS_HOME = new StringFlag("ps-home");
public static final Flag<String> PS_BLOCK_MATERIAL = new StringFlag("ps-block-material");
public static final Flag<String> PS_NAME = new StringFlag("ps-name");
public static final Flag<Set<String>> PS_MERGED_REGIONS = new SetFlag<>("ps-merged-regions", new StringFlag("ps-merged-region"));
public static final Flag<Set<String>> PS_MERGED_REGIONS_TYPES = new SetFlag<>("ps-merged-regions-types", new StringFlag("ps-merged-region-type")); // each entry: "[psID] [type]"
public static final Flag<Set<String>> PS_MERGED_REGIONS = new SetFlag<>("ps-merged-regions",
new StringFlag("ps-merged-region"));
public static final Flag<Set<String>> PS_MERGED_REGIONS_TYPES = new SetFlag<>("ps-merged-regions-types",
new StringFlag("ps-merged-region-type")); // each entry: "[psID] [type]"

public static final Flag<String> PS_LANDLORD = new StringFlag("ps-landlord");
public static final Flag<String> PS_TENANT = new StringFlag("ps-tenant");
public static final Flag<String> PS_RENT_PERIOD = new StringFlag("ps-rent-period");
public static final Flag<Double> PS_PRICE = new DoubleFlag("ps-price");
public static final Flag<Double> PS_RENT_LAST_PAID = new DoubleFlag("ps-rent-last-paid");
public static final Flag<Boolean> PS_FOR_SALE = new BooleanFlag("ps-for-sale");
public static final Flag<Set<String>> PS_RENT_SETTINGS = new SetFlag<>("ps-rent-settings", new StringFlag("ps-rent-setting")); // TODO
public static final Flag<Set<String>> PS_TAX_PAYMENTS_DUE = new SetFlag<>("ps-tax-payments-due", new StringFlag("ps-tax-payment"));
public static final Flag<Set<String>> PS_TAX_LAST_PAYMENT_ADDED = new SetFlag<>("ps-tax-last-payment-added", new StringFlag("ps-tax-last-payment-entry"));
public static final Flag<Set<String>> PS_RENT_SETTINGS = new SetFlag<>("ps-rent-settings",
new StringFlag("ps-rent-setting")); // TODO
public static final Flag<Set<String>> PS_TAX_PAYMENTS_DUE = new SetFlag<>("ps-tax-payments-due",
new StringFlag("ps-tax-payment"));
public static final Flag<Set<String>> PS_TAX_LAST_PAYMENT_ADDED = new SetFlag<>("ps-tax-last-payment-added",
new StringFlag("ps-tax-last-payment-entry"));
public static final Flag<String> PS_TAX_AUTOPAYER = new StringFlag("ps-tax-autopayer");

// called on initial start
Expand All @@ -83,7 +89,8 @@ static void registerFlags() {
registry.register(PS_TAX_LAST_PAYMENT_ADDED);
registry.register(PS_TAX_AUTOPAYER);
} catch (FlagConflictException e) {
Bukkit.getLogger().severe("Flag conflict found! The plugin will not work properly! Please contact the developers of the plugin.");
Bukkit.getLogger().severe(
"Flag conflict found! The plugin will not work properly! Please contact the developers of the plugin.");
e.printStackTrace();
}

Expand All @@ -100,6 +107,18 @@ static void registerHandlers() {
SessionManager sessionManager = WorldGuard.getInstance().getPlatform().getSessionManager();
sessionManager.registerHandler(GreetingFlagHandler.FACTORY, ExitFlag.FACTORY);
sessionManager.registerHandler(FarewellFlagHandler.FACTORY, ExitFlag.FACTORY);

// Register handlers for standard WorldGuard flags to support MiniMessage
try {
sessionManager.registerHandler(new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(
(Flag<String>) dev.espi.protectionstones.utils.WGUtils.getFlagRegistry().get("greeting"), false,
false), ExitFlag.FACTORY);
sessionManager.registerHandler(new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(
(Flag<String>) dev.espi.protectionstones.utils.WGUtils.getFlagRegistry().get("farewell"), true,
false), ExitFlag.FACTORY);
} catch (Exception ignored) {
}

}

// adds flag permissions for ALL registered WorldGuard flags
Expand All @@ -123,12 +142,14 @@ static void initCustomFlagsForPS(ProtectedRegion region, Location l, PSProtectBl
}

public static List<String> getPlayerPlaceholderFlags() {
return Arrays.asList("greeting", "greeting-title", "greeting-action", "farewell", "farewell-title", "farewell-action");
return Arrays.asList("greeting", "greeting-title", "greeting-action", "farewell", "farewell-title",
"farewell-action");
}

// Edit flags that require placeholders (variables)
public static void initDefaultFlagPlaceholders(HashMap<Flag<?>, Object> flags, Player p) {
for (Flag<?> f : getPlayerPlaceholderFlags().stream().map(WGUtils.getFlagRegistry()::get).collect(Collectors.toList())) {
for (Flag<?> f : getPlayerPlaceholderFlags().stream().map(WGUtils.getFlagRegistry()::get)
.collect(Collectors.toList())) {
if (flags.get(f) != null) {
String s = (String) flags.get(f);

Expand All @@ -153,15 +174,17 @@ static void initDefaultFlagsForBlock(PSProtectBlock b) {
String[] splGroups = spl[1].split(",");
List<String> groups = new ArrayList<>();
for (String g : splGroups) {
if (FLAG_GROUPS.contains(g)) groups.add(g);
if (FLAG_GROUPS.contains(g))
groups.add(g);
}

b.allowedFlags.put(spl[2], groups);
} else {
b.allowedFlags.put(f, FLAG_GROUPS);
}
} catch (Exception e) {
ProtectionStones.getInstance().getLogger().warning("Skipping flag " + f + ". Did you configure the allowed_flags section correctly?");
ProtectionStones.getInstance().getLogger()
.warning("Skipping flag " + f + ". Did you configure the allowed_flags section correctly?");
e.printStackTrace();
}
}
Expand Down Expand Up @@ -190,7 +213,8 @@ static void initDefaultFlagsForBlock(PSProtectBlock b) {
}

// get settings (after flag name)
for (int i = startInd; i < split.length; i++) settings += split[i] + " ";
for (int i = startInd; i < split.length; i++)
settings += split[i] + " ";
settings = settings.trim();

// if the setting is set to -e, change to empty flag
Expand All @@ -204,7 +228,9 @@ static void initDefaultFlagsForBlock(PSProtectBlock b) {

// warn if flag setting has already been set
if (b.regionFlags.containsKey(flag)) {
ProtectionStones.getPluginLogger().warning(String.format("Duplicate default flags found (only one flag setting can be applied for each flag)! Overwriting the previous value set for %s with \"%s\" ...", flagName, flagraw));
ProtectionStones.getPluginLogger().warning(String.format(
"Duplicate default flags found (only one flag setting can be applied for each flag)! Overwriting the previous value set for %s with \"%s\" ...",
flagName, flagraw));
}

// apply flag
Expand All @@ -214,7 +240,8 @@ static void initDefaultFlagsForBlock(PSProtectBlock b) {

RegionGroup rGroup = flag.getRegionGroupFlag().detectValue(group);
if (rGroup == null) {
ProtectionStones.getPluginLogger().severe(String.format("Error parsing flag \"%s\", the group value is invalid!", flagraw));
ProtectionStones.getPluginLogger().severe(
String.format("Error parsing flag \"%s\", the group value is invalid!", flagraw));
continue;
}

Expand Down
Loading