Skip to content

Commit

Permalink
Merge pull request #12 from xXGunner989Xx/bulk_claim_unclaim
Browse files Browse the repository at this point in the history
implemented auto-unclaim functionality
  • Loading branch information
svgaming234 authored Feb 27, 2025
2 parents f44cdfb + ebc0431 commit f59b8f1
Show file tree
Hide file tree
Showing 11 changed files with 548 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
mvn clean install
- name: Upload artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: JVillage
path: target/*.jar
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>groupId</groupId>
<artifactId>JVillage</artifactId>
<version>1.0.13-SNAPSHOT</version>
<version>1.0.14-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/johnymuffin/jvillage/beta/JVillage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.johnymuffin.jvillage.beta.routes.api.v1.JVillageGetVillageList;
import com.johnymuffin.jvillage.beta.routes.api.v1.JVillageGetVillageRoute;
import com.johnymuffin.jvillage.beta.tasks.AutoClaimingTask;
import com.johnymuffin.jvillage.beta.tasks.AutoUnclaimingTask;
import com.johnymuffin.jvillage.beta.tasks.AutomaticSaving;
import com.johnymuffin.jvillage.beta.tasks.Metrics;
import com.legacyminecraft.poseidon.event.PoseidonCustomListener;
Expand Down Expand Up @@ -211,6 +212,7 @@ public void onEnable() {

//Run auto claim task
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new AutoClaimingTask(plugin), 1, this.getSettings().getConfigInteger("settings.auto-claim.timer") * 20);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new AutoUnclaimingTask(plugin), 1, this.getSettings().getConfigInteger("settings.auto-claim.timer") * 20);
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new AutomaticSaving(plugin), 1, 20 * 60 * 10); //Save every 10 minutes

//bstats metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
message = message.replace("%village%", village.getTownName());
commandSender.sendMessage(message);
} else {
// Disable autounclaim if it is enabled
if (vPlayer.isAutoUnclaimingEnabled()) {
vPlayer.setAutoUnclaimingEnabled(false, false);
}
vPlayer.setAutoClaimingEnabled(true, false);
String message = language.getMessage("command_village_claim_autoclaim_on");
message = message.replace("%village%", village.getTownName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
return true;
}

//Auto unclaiming toggle
if (strings.length > 0 &&
(strings[0].equalsIgnoreCase("auto") || strings[0].equalsIgnoreCase("a") || strings[0].equalsIgnoreCase("ac") || strings[0].equalsIgnoreCase("autoclaim"))
) {
if(!isAuthorized(commandSender, "jvillage.player.unclaim.auto")) {
commandSender.sendMessage(language.getMessage("no_permission"));
return true;
}

if (vPlayer.isAutoUnclaimingEnabled()) {
vPlayer.setAutoUnclaimingEnabled(false, false);
String message = language.getMessage("command_village_claim_autounclaim_off");
message = message.replace("%village%", village.getTownName());
commandSender.sendMessage(message);
} else {
// Disable autoclaim if it is enabled
if (vPlayer.isAutoClaimingEnabled()) {
vPlayer.setAutoClaimingEnabled(false, false);
}
vPlayer.setAutoUnclaimingEnabled(true, false);
String message = language.getMessage("command_village_claim_autounclaim_on");
message = message.replace("%village%", village.getTownName());
commandSender.sendMessage(message);
}
return true;
}

// Player is unclaiming a single chunk (default)

VChunk vChunk = new VChunk(player.getLocation());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ private void loadDefaults() {
"\n&8- &7/village claim auto &8- &7Claim chunks automatically as you walk (run again to disable)" +
"\n&8- &7/village withdraw [village] [amount] &8- &7Withdraw money from village bank" +
"\n&8- &7/village unclaim &8- &7Unclaim the chunk you are standing in" +
"\n&8- &7/village unclaim auto &8- &7Unclaim chunks automatically as you walk" +
"\n&8- &7/village setwarp [name] &8- &7Set a village warp" +
"\n&8- &7/village delwarp [name] &8- &7Delete a village warp");

Expand Down Expand Up @@ -237,6 +238,8 @@ private void loadDefaults() {
map.put("command_village_unclaim_success", "&bUnclaimed the chunk you are standing in. You have been refunded $%refund%");
map.put("command_village_unclaim_not_assistant", "&cSorry, you are not an assistant or owner of &9%village%&c so you can't unclaim chunks");
map.put("command_village_unclaim_spawn_block", "&cSorry, you can't unclaim the chunk that contains the village spawn");
map.put("command_village_claim_autounclaim_on", "&bYou have turned on auto unclaim. You will now automatically unclaim chunks as you walk around");
map.put("command_village_claim_autounclaim_off", "&bYou have turned off auto unclaim. You will no longer automatically unclaim chunks as you walk around");

map.put("command_village_kick_use", "&cSorry, that is invalid. Try /village kick [name]");
map.put("command_village_kick_not_found", "&cSorry, the UUID of &9%player% &cwas not found");
Expand Down Expand Up @@ -330,10 +333,12 @@ private void loadDefaults() {

map.put("autoclaim_selected_village_disabled", "&cSorry, autoclaim has been disabled as your selected village has changed");
map.put("autoclaim_disabled", "&cAutoclaim has been disabled");
map.put("autounclaim_disabled", "&cAuto unclaim has been disabled");
map.put("autoclaim_enter_worldguard_disabled", "&cSorry, autoclaim has been disabled as you have entered a protected World Guard region");
map.put("autoclaim_not_neighbouring_disabled", "&cSorry, autoclaim has been disabled as you are not neighbouring %village%");
map.put("autoclaim_not_enough_money_disabled", "&cSorry, autoclaim has been disabled as you don't have enough money to claim land");
map.put("autoclaim_claim_success", "&bYou have claimed [%chunk%] for &9%village% &bfor &9$%cost%");
map.put("autoclaim_unclaim_success", "&bYou have unclaimed [%chunk%] for &9%village% &bfor a &9$%cost% refund");

}

Expand Down
Loading

0 comments on commit f59b8f1

Please sign in to comment.