Skip to content
Open
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
55 changes: 35 additions & 20 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 All @@ -14,25 +14,25 @@
</properties>

<licenses>
<license>
<name>GPLv3</name>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
</license>
<license>
<name>GPLv3</name>
<url>https://www.gnu.org/licenses/gpl-3.0.en.html</url>
</license>
</licenses>

<developers>
<developer>
<name>Devin Lin</name>
<email>espidev@gmail.com</email>
<organization>EstiNet</organization>
<organizationUrl>https://estinet.net</organizationUrl>
</developer>
<developer>
<name>Devin Lin</name>
<email>espidev@gmail.com</email>
<organization>EstiNet</organization>
<organizationUrl>https://estinet.net</organizationUrl>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/espidev/ProtectionStones.git</connection>
<developerConnection>scm:git:ssh://github.com:espidev/ProtectionStones.git</developerConnection>
<url>https://github.com/espidev/ProtectionStones/tree/master</url>
<connection>scm:git:git://github.com/espidev/ProtectionStones.git</connection>
<developerConnection>scm:git:ssh://github.com:espidev/ProtectionStones.git</developerConnection>
<url>https://github.com/espidev/ProtectionStones/tree/master</url>
</scm>

<profiles>
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>
58 changes: 42 additions & 16 deletions src/main/java/dev/espi/protectionstones/FlagHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,33 @@ public class FlagHandler {
// Custom WorldGuard Flags
public static final Flag<String> GREET_ACTION = new StringFlag("greeting-action");
public static final Flag<String> FAREWELL_ACTION = new StringFlag("farewell-action");
public static final Flag<String> PS_GREETING = new StringFlag("ps-greeting");
public static final Flag<String> PS_FAREWELL = new StringFlag("ps-farewell");

// 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,23 +91,33 @@ 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();
}

// extra custom flag registration
try {
registry.register(GREET_ACTION);
registry.register(FAREWELL_ACTION);
registry.register(PS_GREETING);
registry.register(PS_FAREWELL);
} catch (FlagConflictException ignored) {
// ignore if flag conflict
}
}

static void registerHandlers() {
SessionManager sessionManager = WorldGuard.getInstance().getPlatform().getSessionManager();
sessionManager.registerHandler(GreetingFlagHandler.FACTORY, ExitFlag.FACTORY);
sessionManager.registerHandler(FarewellFlagHandler.FACTORY, ExitFlag.FACTORY);
sessionManager.registerHandler(
new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(GREET_ACTION, true), ExitFlag.FACTORY);
sessionManager.registerHandler(
new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(FAREWELL_ACTION, true),
ExitFlag.FACTORY);
sessionManager.registerHandler(
new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(PS_GREETING, false), ExitFlag.FACTORY);
sessionManager.registerHandler(
new dev.espi.protectionstones.flags.PSMessageFlagHandler.Factory(PS_FAREWELL, false), ExitFlag.FACTORY);
}

// adds flag permissions for ALL registered WorldGuard flags
Expand All @@ -123,12 +141,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", "ps-greeting", "ps-farewell");
}

// 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 +173,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 +212,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 +227,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 +239,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
Loading