feat: Add support for 1.8+ and feature to tax active claims only

This commit is contained in:
tjtanjin 2023-12-20 21:38:42 +08:00
parent e40b85a27b
commit 184da3d796
5 changed files with 23 additions and 6 deletions

View File

@ -7,7 +7,7 @@
<groupId>quicktax</groupId>
<artifactId>quicktax</artifactId>
<version>1.4.3</version>
<version>1.5.0</version>
<name>QuickTax</name>

View File

@ -24,7 +24,7 @@ import tk.taverncraft.quicktax.Main;
* Schedule contains all information related to a single schedule required for starting, stopping and viewing.
*/
public class Schedule {
private static final String[] allowedTypes = {"collectrank", "collectbal", "collectall"};
private static final String[] allowedTypes = {"collectrank", "collectbal", "collectactivity", "collectall"};
String name;
boolean enabled;
@ -146,6 +146,8 @@ public class Schedule {
taxManager.collectAll(Bukkit.getConsoleSender());
} else if (this.type.equals("collectrank")) {
taxManager.collectRank(Bukkit.getConsoleSender());
} else if (this.type.equals("collectactivity")) {
taxManager.collectActivity(Bukkit.getConsoleSender());
} else {
taxManager.collectBal(Bukkit.getConsoleSender());
}

View File

@ -376,7 +376,12 @@ public class TaxManager {
try {
PlayerData playerData = GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId());
double playerClaims = playerData.getAccruedClaimBlocks();
double playerClaims;
if (main.getConfig().getBoolean("active-claims-only", false)) {
playerClaims = playerData.getAccruedClaimBlocks() - playerData.getRemainingClaimBlocks();
} else {
playerClaims = playerData.getAccruedClaimBlocks();
}
subtractAmount = getSubtractAmountWithClaims(player, usePercentage, balTaxAmount, playerBal, claimsTaxAmount, playerClaims);
} catch (NoClassDefFoundError e) {
Bukkit.getLogger().warning(e.getMessage());
@ -390,8 +395,11 @@ public class TaxManager {
if (player.isOnline()) {
if (main.getConfig().getBoolean("enable-sound")) {
player.getPlayer().getWorld().playSound(player.getPlayer().getLocation(),
try {
player.getPlayer().getWorld().playSound(player.getPlayer().getLocation(),
Sound.valueOf(main.getConfig().getString("play-sound")), 1, 1);
} catch(Exception ignored) {
}
}
MessageManager.sendMessage(player.getPlayer(), "player-pay-tax-success",
new String[]{"%player%", "%amount%"},
@ -446,8 +454,11 @@ public class TaxManager {
if (player.isOnline()) {
if (main.getConfig().getBoolean("enable-sound")) {
player.getPlayer().getWorld().playSound(player.getPlayer().getLocation(),
try {
player.getPlayer().getWorld().playSound(player.getPlayer().getLocation(),
Sound.valueOf(main.getConfig().getString("play-sound")), 1, 1);
} catch(Exception ignored) {
}
}
MessageManager.sendMessage(player.getPlayer(), "player-pay-tax-success",
new String[]{"%player%", "%amount%"},

View File

@ -4,10 +4,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Scanner;
import java.util.function.Consumer;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Consumer;
public class UpdateChecker {

View File

@ -81,6 +81,10 @@ table-name: quicktax
# if true, additional tax will be imposed on players depending on the total amount of claimblocks they have
tax-claims: false
# whether to tax based on claimblocks that are used only
# applicable only when tax-claims is true as well
active-claims-only: false
# whether to remove all claims belonging to player if player does not have enough money to pay taxes
# requires tax-claims to be true as well
# test and use this with caution since removing player claims is a destructive action!