52 Commits
Author SHA1 Message Date
Ryder Belserion 9f939649cd [ci-skip] update CHANGELOG.md 2024-10-14 12:24:21 -04:00
Ryder Belserion 4f84911bc2 remove jenkins garbage 2024-10-13 00:58:23 -04:00
Ryder Belserion 269367ad2b add new method 2024-10-13 00:56:52 -04:00
Ryder Belserion 1683cfe940 don't add flag is config option is false 2024-10-13 00:56:47 -04:00
Ryder Belserion f158356044 don't trigger listener if config option is false 2024-10-13 00:56:29 -04:00
Ryder Belserion dd555ef372 remove space 2024-10-13 00:56:11 -04:00
Ryder Belserion 4486d2e08a update imports 2024-10-13 00:56:06 -04:00
Ryder Belserion 252ba2c209 update configmanager 2024-10-13 00:55:53 -04:00
Ryder Belserion 8042692c6a update commands 2024-10-13 00:55:20 -04:00
Ryder Belserion 8653722289 update library loader 2024-10-13 00:54:55 -04:00
Ryder Belserion b7c405fc30 re-work build script 2024-10-13 00:54:49 -04:00
Ryder Belserion 2b6c3867ea update build script 2024-04-05 19:36:45 -04:00
Ryder Belserion c68b99b4f5 Update LICENSE 2024-03-24 10:13:58 -04:00
Ryder Belserion b1152f8f50 Update LICENSE 2024-03-24 10:04:24 -04:00
Ryder Belserion 3b322e71a0 add default command to help menu 2024-03-22 21:21:36 -04:00
Ryder Belserion 5e464897d7 add permission to the base class 2024-03-22 21:19:04 -04:00
Ryder Belserion 4694f1e3d8 Change @NotNull annotation 2024-03-22 21:17:50 -04:00
Ryder Belserion 1b12182cf2 Use sendRichMessage 2024-03-22 21:17:39 -04:00
Ryder Belserion 70234ac910 Don't save configs on stop 2024-03-22 21:17:25 -04:00
Ryder Belserion 310040edba Update dev bundle 2024-03-22 21:17:13 -04:00
Ryder Belserion 298bdc7f65 Remove bstats 2024-03-22 21:17:04 -04:00
Ryder Belserion e79e94539e Add libs.versions.toml 2024-03-22 21:16:01 -04:00
Ryder Belserion e265297e02 refactor library loader 2024-03-22 20:47:34 -04:00
Ryder Belserion 2a4fab9d04 Update changelog 2024-03-12 13:21:00 -04:00
Ryder Belserion 61c1c4cc91 Remove unused import 2024-03-12 12:48:17 -04:00
Ryder Belserion d4bd25f1f9 Fix spawn reason check 2024-03-12 12:48:11 -04:00
Ryder Belserion 20e32fd180 Simplify damage source check 2024-03-12 12:47:59 -04:00
Ryder Belserion cc8bbd411f Add flag to prevent natural spawning in regions 2024-03-11 20:26:18 -04:00
Ryder Belserion d3ced7a57b Make the damage method not abstract 2024-03-11 20:01:21 -04:00
Ryder Belserion bcb3cd7956 add proper permission defaults 2024-03-11 19:51:12 -04:00
Ryder Belserion 4973036378 Remove commit id checks 2024-03-06 20:34:55 -05:00
Ryder Belserion d1e9acc677 Fix assemble task
Update commit id
2024-03-06 20:33:11 -05:00
Ryder Belserion b021ffb03e actually fix deletion of the jars folder 2024-03-06 20:26:48 -05:00
Ryder Belserion 552a442cb4 Delete jars directory 2024-03-06 20:23:55 -05:00
Ryder Belserion 036e793033 Update help-menu path 2024-03-06 20:21:53 -05:00
Ryder Belserion 64fc245d72 Update build script 2024-03-06 20:16:54 -05:00
Ryder Belserion 030c0d81c1 Add everything I just mentioned 2024-03-06 20:16:47 -05:00
Ryder Belserion 5b87b2a823 Add dependency loader 2024-03-06 20:16:40 -05:00
Ryder Belserion 234631d8fc Add command api 2024-03-06 20:16:34 -05:00
Ryder Belserion f1075da09a Add metrics 2024-03-06 20:14:47 -05:00
Ryder Belserion ddf0f60033 Add config files 2024-03-06 20:14:42 -05:00
Ryder Belserion f590186546 [ci-skip] Update commit id 2024-03-06 17:19:37 -05:00
Ryder Belserion 5fafba633f [ci-skip] fix publish task 2024-03-06 17:18:22 -05:00
Ryder Belserion 3db53609e0 add publish task and build number 2024-03-06 17:14:06 -05:00
Ryder Belserion 5d42ed3f19 Merge branch 'main' of github.com:ryderbelserion/SimpleFlags 2024-03-06 17:09:05 -05:00
Ryder Belserion ecd02f3630 Test jenkisn 2024-03-06 17:09:00 -05:00
Ryder Belserion 2ed1e08f5b Update version 2024-03-06 16:59:16 -05:00
Ryder Belserion 774276c9b8 Create README.md 2024-03-06 15:46:01 -05:00
Ryder Belserion 0c2837ddd8 Update load order 2024-03-06 14:02:54 -05:00
Ryder Belserion 40495b6a4e Add drowning flag 2024-03-06 14:02:47 -05:00
Ryder Belserion f82205da3b Update build script 2024-03-06 13:49:17 -05:00
Ryder Belserion 370c37889b Initial commit 2024-03-06 09:16:37 -05:00
16 changed files with 60 additions and 212 deletions

No files matched your search

-1
View File
@@ -1 +0,0 @@
.gitea/CODEOWNERS linguist-detectable=false
-3
View File
@@ -1,3 +0,0 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
-72
View File
@@ -1,72 +0,0 @@
name: "🐛 Bug Report"
description: "Create a report to help us improve the plugin."
labels: [ "bug" ]
assignees:
- ryderbelserion
body:
- type: markdown
attributes:
value: |
Note: Search to see if an issue already exists for the bug you are reporting.
Add any gif / imgur links if need be. Markdown is supported!
If you have any large stack traces / errors, Please use https://mclo.gs/
Spark > https://spark.lucko.me/download
- type: input
attributes:
label: Spark link
description: We ask that Spark profile are shared through a link, not a screenshot. Screenshots inhibit our ability to figure out the real cause of the issue.
placeholder: Output of /spark profiler --timeout 300
validations:
required: false
- type: input
id: plugin_version
attributes:
label: Plugin Version
description: Type /version plugin-name in-game
validations:
required: true
- type: dropdown
id: version
attributes:
label: Server Version
description: What server version are you on?
options:
- "1.21.1"
- "1.21.2"
validations:
required: true
- type: dropdown
id: platform
attributes:
label: Server Platform
description: What server platform are you using?
options:
- Paper
- Purpur
- Folia
validations:
required: true
- type: textarea
id: bug
attributes:
label: Describe the bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. Go to '...'
2. Change value in placeholder.yml '...'
3. Run command '...'
4. See error
validations:
required: true
-20
View File
@@ -1,20 +0,0 @@
name: "🚩 Suggest a new flag to add"
description: "Missing a worldguard flag you don't have?"
labels: [ "feature" ]
body:
- type: textarea
id: feature
attributes:
label: Pick a name for it
description: "What do you want to name the worldguard flag?"
placeholder: "anti stabby max pro"
validations:
required: true
- type: textarea
attributes:
label: What does the worldguard flag do?
description: Describe what the worldguard flag does
validations:
required: true
+3 -8
View File
@@ -1,8 +1,3 @@
## Changes:
- Updated how flags are handled internally to easily add newer flags.
- Currently working on another flag I am interested in.
## Fixed:
- Added a null check if the flag is not in the registry.
- This only happens if you enable a config option, and do `/simpleflags reload`
- WorldGuard flags can only be added on startup, as any time after that... the registry is frozen.
## New Flags
* Added a worldguard flag that prevents you from drowning.
* Added a worldguard flag that prevents natural mob spawning in regions.
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Ryder Belserion
Copyright (c) 2014-2024 CoreCraft Network
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+1 -1
View File
@@ -7,7 +7,7 @@ plugins {
}
rootProject.group = "com.ryderbelserion.simpleflags"
rootProject.version = "1.0.1"
rootProject.version = "1.0"
rootProject.description = "A plugin that adds simple worldguard flags."
repositories {
@@ -1,26 +1,52 @@
package com.ryderbelserion.simpleflags.flags;
import ch.jalu.configme.SettingsManager;
import com.ryderbelserion.simpleflags.SimpleFlags;
import com.ryderbelserion.simpleflags.config.ConfigManager;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
public abstract class FlagBuilder<T extends Flag> {
public abstract class FlagBuilder {
protected SimpleFlags plugin = JavaPlugin.getPlugin(SimpleFlags.class);
protected SettingsManager config = ConfigManager.getConfig();
public abstract void register();
public abstract String getName();
public abstract T getFlag();
public abstract StateFlag getFlag();
public abstract boolean isEnabled();
/**
* Prevent any type of damage in any region.
*
* @param player the player to prevent damage to.
* @param source the source of the damage.
* @param type the type of the damage to check.
* @return true or false
*/
public boolean preventDamage(Player player, DamageSource source, DamageType type) {
return source.getDamageType() == type && getQuery().testState(BukkitAdapter.adapt(player.getLocation()), WorldGuardPlugin.inst().wrapPlayer(player), getFlag());
}
/**
* Prevent spawning based on a supplied spawn reason.
*
* @param location the location to check.
* @param receivingReason the reason from the event.
* @param reason your reason.
* @return true or false
*/
public boolean preventSpawning(org.bukkit.Location location, CreatureSpawnEvent.SpawnReason receivingReason, CreatureSpawnEvent.SpawnReason reason) {
return receivingReason != reason || getQuery().testState(BukkitAdapter.adapt(location), null, getFlag());
}
/**
* @return A query of regions.
@@ -35,5 +61,4 @@ public abstract class FlagBuilder<T extends Flag> {
protected FlagRegistry getRegistry() {
return this.plugin.getWorldGuard().getFlagRegistry();
}
}
@@ -6,9 +6,9 @@ import java.util.Map;
public class FlagManager {
private final Map<String, FlagBuilder<?>> flags = new HashMap<>();
private final Map<String, FlagBuilder> flags = new HashMap<>();
public <F extends FlagBuilder<?>> void addFlag(F builder) {
public void addFlag(FlagBuilder builder) {
// Register the flag.
builder.register();
@@ -21,7 +21,7 @@ public class FlagManager {
return this.flags.containsKey(name);
}
public FlagBuilder<?> getFlag(String name) {
public FlagBuilder getFlag(String name) {
return this.flags.get(name);
}
@@ -29,7 +29,7 @@ public class FlagManager {
this.flags.remove(name);
}
public Map<String, FlagBuilder<?>> getFlags() {
public Map<String, FlagBuilder> getFlags() {
return Collections.unmodifiableMap(this.flags);
}
}
@@ -1,11 +0,0 @@
package com.ryderbelserion.simpleflags.flags.builders;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.sk89q.worldguard.protection.flags.IntegerFlag;
public abstract class IntegerFlagBuilder extends FlagBuilder<IntegerFlag> {
@Override
public abstract IntegerFlag getFlag();
}
@@ -1,42 +0,0 @@
package com.ryderbelserion.simpleflags.flags.builders;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.StateFlag;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
public abstract class StateFlagBuilder extends FlagBuilder<StateFlag> {
@Override
public abstract StateFlag getFlag();
/**
* Prevent any type of damage in any region.
*
* @param player the player to prevent damage to.
* @param source the source of the damage.
* @param type the type of the damage to check.
* @param flag the flag.
* @return true or false
*/
public boolean preventDamage(Player player, DamageSource source, DamageType type, StateFlag flag) {
return source.getDamageType() == type && getQuery().testState(BukkitAdapter.adapt(player.getLocation()), WorldGuardPlugin.inst().wrapPlayer(player), flag);
}
/**
* Prevent spawning based on a supplied spawn reason.
*
* @param location the location to check.
* @param receivingReason the reason from the event.
* @param reason your reason.
* @param flag the flag.
* @return true or false
*/
public boolean preventSpawning(org.bukkit.Location location, CreatureSpawnEvent.SpawnReason receivingReason, CreatureSpawnEvent.SpawnReason reason, StateFlag flag) {
return receivingReason != reason || getQuery().testState(BukkitAdapter.adapt(location), null, flag);
}
}
@@ -2,9 +2,8 @@ package com.ryderbelserion.simpleflags.flags.enums;
public enum CustomFlags {
NATURAL_FLAG("prevent_natural_spawning"),
DROWN_FLAG("prevent_drowning"),
CAPACITY_FLAG("max_players");
NATURAL_FLAG("prevent_natural_spawning");
private final String name;
@@ -1,20 +1,21 @@
package com.ryderbelserion.simpleflags.flags.types;
import com.ryderbelserion.simpleflags.config.ConfigManager;
import com.ryderbelserion.simpleflags.config.impl.Config;
import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.ryderbelserion.simpleflags.flags.enums.CustomFlags;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import java.util.logging.Level;
public class DrownFlag extends StateFlagBuilder {
public class DrownFlag extends FlagBuilder {
private StateFlag flag;
@Override
public void register() {
if (!isEnabled()) return;
if (!ConfigManager.getConfig().getProperty(Config.drowning_flag)) return;
try {
getRegistry().register(this.flag = new StateFlag("prevent-drowning", true));
@@ -32,17 +33,12 @@ public class DrownFlag extends StateFlagBuilder {
}
@Override
public String getName() {
public final String getName() {
return CustomFlags.DROWN_FLAG.getName();
}
@Override
public StateFlag getFlag() {
public final StateFlag getFlag() {
return this.flag;
}
@Override
public boolean isEnabled() {
return this.config.getProperty(Config.drowning_flag);
}
}
@@ -1,20 +1,21 @@
package com.ryderbelserion.simpleflags.flags.types;
import com.ryderbelserion.simpleflags.config.ConfigManager;
import com.ryderbelserion.simpleflags.config.impl.Config;
import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.ryderbelserion.simpleflags.flags.enums.CustomFlags;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import java.util.logging.Level;
public class NaturalFlag extends StateFlagBuilder {
public class NaturalFlag extends FlagBuilder {
private StateFlag flag;
@Override
public void register() {
if (!isEnabled()) return;
if (!ConfigManager.getConfig().getProperty(Config.natural_spawning_flag)) return;
try {
getRegistry().register(this.flag = new StateFlag("prevent-natural-spawning", true));
@@ -40,9 +41,4 @@ public class NaturalFlag extends StateFlagBuilder {
public StateFlag getFlag() {
return this.flag;
}
@Override
public boolean isEnabled() {
return this.config.getProperty(Config.natural_spawning_flag);
}
}
@@ -1,10 +1,9 @@
package com.ryderbelserion.simpleflags.listeners;
import com.ryderbelserion.simpleflags.SimpleFlags;
import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagManager;
import com.ryderbelserion.simpleflags.flags.enums.CustomFlags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@@ -29,15 +28,9 @@ public class DrowningListener implements Listener {
if (!this.flagManager.hasFlag(flagName)) return;
final StateFlagBuilder flag = (StateFlagBuilder) this.flagManager.getFlag(flagName);
final FlagBuilder flag = this.flagManager.getFlag(flagName);
if (!flag.isEnabled()) return;
final StateFlag stateFlag = flag.getFlag();
if (stateFlag == null) return;
if (!flag.preventDamage(player, event.getDamageSource(), DamageType.DROWN, stateFlag)) {
if (!flag.preventDamage(player, event.getDamageSource(), DamageType.DROWN)) {
event.setCancelled(true);
}
}
@@ -2,10 +2,9 @@ package com.ryderbelserion.simpleflags.listeners;
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
import com.ryderbelserion.simpleflags.SimpleFlags;
import com.ryderbelserion.simpleflags.flags.builders.StateFlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagBuilder;
import com.ryderbelserion.simpleflags.flags.FlagManager;
import com.ryderbelserion.simpleflags.flags.enums.CustomFlags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
@@ -23,15 +22,9 @@ public class NaturalListener implements Listener {
if (!this.flagManager.hasFlag(flagName)) return;
final StateFlagBuilder flag = (StateFlagBuilder) this.flagManager.getFlag(flagName);
final FlagBuilder flag = this.flagManager.getFlag(flagName);
if (!flag.isEnabled()) return;
final StateFlag stateFlag = flag.getFlag();
if (stateFlag == null) return;
if (!flag.preventSpawning(event.getSpawnLocation(), event.getReason(), CreatureSpawnEvent.SpawnReason.NATURAL, stateFlag)) {
if (!flag.preventSpawning(event.getSpawnLocation(), event.getReason(), CreatureSpawnEvent.SpawnReason.NATURAL)) {
event.setCancelled(true);
}
}