Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b74ef3f
Rankups.yml suggestion
flurbudurbur May 12, 2021
cfa7ec2
suggestion fixes
NicBOMB Oct 26, 2022
7eab157
Merge branch 'master' into new-rankups.yml
NicBOMB Feb 5, 2022
e50f04f
add null checks to prevent log spam when tree is null (failed to build)
NicBOMB Feb 5, 2022
d55e38c
implement getSub for pebble to use getSub already defined in requirement
NicBOMB Feb 6, 2022
cba3736
prevent NaN by checking total and replace duplicate calls with 1 call
NicBOMB Feb 6, 2022
1e49aec
consistency, transparency, and indentation recommendations
NicBOMB Feb 8, 2022
d800cc9
trivialize enabling locales in the future
NicBOMB Feb 8, 2022
04a47fc
printed name fix and cleaner code spacing
NicBOMB Oct 26, 2022
7462dc1
test configs separately from loading
NicBOMB Feb 8, 2022
1daa1a2
remove unnecessary loop and add an else case to stop once adv is found
NicBOMB Feb 9, 2022
3b03645
override getSub for advancement, advancedachievements, and placeholder
NicBOMB Oct 26, 2022
43a9800
Merge remote-tracking branch 'origin/master' into new-rankups.yml
NicBOMB Feb 15, 2022
b1bb10a
Compilation Instructions for Windows and Linux
NicBOMB Apr 17, 2022
709cddf
Merge pull request #74 from okx-code/master
NicBOMB Jun 13, 2022
804fd30
A more enjoyable `rankups.yml`.
Jun 13, 2022
29848d3
Merge remote-tracking branch 'origin/new-rankups.yml' into new-rankup…
Jun 13, 2022
8650e80
A more enjoyable `en.yml`.
Jun 13, 2022
9241c45
Verbose YAML files
Jun 29, 2022
360e48d
fix out of bounds error throwing for ranksgui
NicBOMB Jul 10, 2022
3801db6
Merge branch 'master' into new-rankups.yml
NicBOMB Nov 7, 2022
537562d
Merge branch 'master' into new-rankups.yml
okx-code Nov 8, 2022
6a10100
add /rankup noconfirm
okx-code Jan 18, 2023
8e9112e
add luckperms context
okx-code Jan 19, 2023
abb2a3a
bump version
okx-code Jan 19, 2023
2a88bb5
delete github actions for now
okx-code Jan 19, 2023
8bf5029
3.14.1
okx-code Jun 28, 2023
abd4365
fix papi placeholders when using world or placeholder requirements
okx-code Jul 25, 2023
81a7a8a
Merge branch 'new-rankups.yml'
NicBOMB Aug 22, 2023
d37b1ba
default to empty string instead of `req.value`
NicBOMB Aug 22, 2023
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
28 changes: 0 additions & 28 deletions .github/workflows/pitest.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
# Rankup3
## Compiling
### Prerequisites
Compilation requires the jdk8 (java development kit).
#### Windows
The [Eclipse Foundation](https://www.eclipse.org/org/) releases [the required build tools here](https://adoptium.net/temurin/releases).
It's recommended to select an installer download for simplicity and/or compiling other plugins. Don't select a zip archive.
You can easily clone this repo using the [github desktop app](https://desktop.github.com/).
1. Copy the link provided in the above green `Code` button.
2. In the github desktop app, Select `Clone a repository from the Internet` or `Clone repository...`, then select URL, and paste into the url line.
3. Open the Rankup3 directory you downloaded. The default location is in your user's `\Documents\GitHub\Rankup3` folder.
4. Open a command prompt in the directory and run [`dir`](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/dir) to catalog the directory.
5. When you see the `gradlew` file listed, you can now try the [build command](#building).

## Installation
#### Linux
Add `jdk8` or `jdk8-openjdk` from your package manager.
Add `git` (required) and/or `gh` (optional, for github integration) from your package manager.
After installing packages, clone the repository by running `git clone` on the url provided above in the Code button, or the provided `gh` cloning command, from your shell.
Then try the [build command](#building).

Rankup can be compiled with the `gradlew build` command. The compiled plugin jar will be in the `/build/libs` directory. A gradle wrapper is included, so installation of Gradle is not necessary.
### Building
In the Rankup3 directory, a jar can be compiled with the provided `gradlew` wrapper:
- Command Prompt: `gradlew build`
- Unix/Powershell/Other: `./gradlew build`

#### Known Build Errors
##### `Unsupported class file major version #`
This error indicates you are building with the wrong version of the JDK.
Solution:
- Windows: Correct your `Environment Variables` for `JAVA_HOME` to point to the installation location of the JDK 8. `Environment Variables` is program searchable in the start menu that will prompt you with a list of filepaths to your jvm installations in the `JAVA_HOME` variable. The JDK 8's filepath should be moved to the top of the list before [building](#building).
- Linux: Your package manager may natively support installing multiple JDK versions simultaneously. Consult your package manger's docs for information about managing your jvm's. Here are some examples: [`sudo update-alternatives --config java`](https://help.ubuntu.com/community/Java#Choosing_the_default_Java_to_use) or [`sudo archlinux-java set java-8-openjdk`](https://wiki.archlinux.org/title/Java#Switching_between_JVM). The JDK 8 should be selected before [building](#building).
### Jars
The compiled plugin jar will be in the `/build/libs` directory.
All branches are using the same jar name. Rename your build artifacts.

## Translation

Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pitest {
}

group 'sh.okx'
version '3.13.3'
version '3.14.2'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -46,7 +46,7 @@ dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'

compileOnly 'org.jetbrains:annotations:22.0.0'
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
compileOnly('com.github.Realizedd:TokenManager:3.2.4') {
transitive = false
}
Expand All @@ -62,10 +62,12 @@ dependencies {
compileOnly('com.github.mcMMO-Dev:mcMMO:601297') {
exclude group: 'com.sk89q.worldguard'
}
compileOnly ('com.bencodez:votingplugin:6.9.5') {
compileOnly ('com.bencodez:votingplugin:6.13.1') {
transitive = false
}

compileOnly 'net.luckperms:api:5.4'

compileOnly 'com.github.LlmDl:Towny:25fc18a'
testImplementation 'com.github.LlmDl:Towny:25fc18a'

Expand Down
116 changes: 49 additions & 67 deletions src/main/java/sh/okx/rankup/RankupPlugin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package sh.okx.rankup;

import com.electronwill.nightconfig.toml.TomlFormat;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand All @@ -21,12 +15,7 @@
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import sh.okx.rankup.commands.InfoCommand;
import sh.okx.rankup.commands.MaxRankupCommand;
import sh.okx.rankup.commands.PrestigeCommand;
import sh.okx.rankup.commands.PrestigesCommand;
import sh.okx.rankup.commands.RanksCommand;
import sh.okx.rankup.commands.RankupCommand;
import sh.okx.rankup.commands.*;
import sh.okx.rankup.economy.Economy;
import sh.okx.rankup.economy.EconomyProvider;
import sh.okx.rankup.economy.VaultEconomyProvider;
Expand All @@ -49,37 +38,15 @@
import sh.okx.rankup.ranksgui.RanksGuiListener;
import sh.okx.rankup.requirements.Requirement;
import sh.okx.rankup.requirements.RequirementRegistry;
import sh.okx.rankup.requirements.requirement.AdvancementRequirement;
import sh.okx.rankup.requirements.requirement.BlockBreakRequirement;
import sh.okx.rankup.requirements.requirement.CraftItemRequirement;
import sh.okx.rankup.requirements.requirement.GroupRequirement;
import sh.okx.rankup.requirements.requirement.ItemDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.ItemRequirement;
import sh.okx.rankup.requirements.requirement.MobKillsRequirement;
import sh.okx.rankup.requirements.requirement.MoneyDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.MoneyRequirement;
import sh.okx.rankup.requirements.requirement.PermissionRequirement;
import sh.okx.rankup.requirements.requirement.PlaceholderRequirement;
import sh.okx.rankup.requirements.requirement.PlayerKillsRequirement;
import sh.okx.rankup.requirements.requirement.PlaytimeMinutesRequirement;
import sh.okx.rankup.requirements.requirement.TotalMobKillsRequirement;
import sh.okx.rankup.requirements.requirement.UseItemRequirement;
import sh.okx.rankup.requirements.requirement.WorldRequirement;
import sh.okx.rankup.requirements.requirement.XpLevelDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
import sh.okx.rankup.requirements.requirement.*;
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsAchievementRequirement;
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsTotalRequirement;
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOPowerLevelRequirement;
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOSkillRequirement;
import sh.okx.rankup.requirements.requirement.superbvote.SuperbVoteVotesRequirement;
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberResidentsRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberTownsRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyKingRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyMayorNumberResidentsRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyMayorRequirement;
import sh.okx.rankup.requirements.requirement.towny.TownyResidentRequirement;
import sh.okx.rankup.requirements.requirement.towny.*;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsDeductibleRequirement;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsRequirement;
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequirement;
Expand All @@ -89,6 +56,13 @@
import sh.okx.rankup.util.UpdateNotifier;
import sh.okx.rankup.util.VersionChecker;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RankupPlugin extends JavaPlugin {

public static final int CONFIG_VERSION = 10;
Expand Down Expand Up @@ -327,7 +301,7 @@ public void refreshRanks() {



} catch (Exception e) {
} catch (RuntimeException e) {
this.errorMessage = e.getClass().getName() + ": " + e.getMessage();
e.printStackTrace();
}
Expand Down Expand Up @@ -380,59 +354,67 @@ private void registerRequirements() {
requirements.addRequirements(
new XpLevelRequirement(this, "xp-levelh"),
new XpLevelDeductibleRequirement(this, "xp-level"),
new PlaytimeMinutesRequirement(this),
new AdvancementRequirement(this),
new GroupRequirement(this),
new PermissionRequirement(this),
new PlaceholderRequirement(this),
new WorldRequirement(this),
new BlockBreakRequirement(this),
new PlayerKillsRequirement(this),
new MobKillsRequirement(this),
new PlaytimeMinutesRequirement(this, "playtime-minutes"),
new AdvancementRequirement(this, "advancement"),
new GroupRequirement(this, "group"),
new PermissionRequirement(this, "permission"),
new PlaceholderRequirement(this, "placeholder"),
new WorldRequirement(this, "world"),
new BlockBreakRequirement(this, "block-break"),
new PlayerKillsRequirement(this, "player-kills"),
new MobKillsRequirement(this, "mob-kills"),
new ItemRequirement(this, "itemh"),
new ItemDeductibleRequirement(this, "item"),
new UseItemRequirement(this),
new TotalMobKillsRequirement(this),
new CraftItemRequirement(this));
new UseItemRequirement(this, "use-item"),
new TotalMobKillsRequirement(this, "total-mob-kills"),
new CraftItemRequirement(this, "craft-item"));
if (economy != null) {
requirements.addRequirements(
new MoneyRequirement(this, "moneyh"),
new MoneyDeductibleRequirement(this, "money"));
new MoneyRequirement(this, "moneyh"),
new MoneyDeductibleRequirement(this, "money")
);
}

PluginManager pluginManager = Bukkit.getPluginManager();
if (pluginManager.isPluginEnabled("mcMMO")) {
requirements.addRequirements(
new McMMOSkillRequirement(this),
new McMMOPowerLevelRequirement(this));
new McMMOSkillRequirement(this, "mcmmo"),
new McMMOPowerLevelRequirement(this, "mcmmo-power-level")
);
}
if (pluginManager.isPluginEnabled("AdvancedAchievements")) {
requirements.addRequirements(
new AdvancedAchievementsAchievementRequirement(this),
new AdvancedAchievementsTotalRequirement(this));
new AdvancedAchievementsAchievementRequirement(this, "advancedachievements-achievement"),
new AdvancedAchievementsTotalRequirement(this, "advancedachievements-total")
);
}
if (pluginManager.isPluginEnabled("VotingPlugin")) {
requirements.addRequirements(
new VotingPluginVotesRequirement(this),
new VotingPluginPointsRequirement(this, "votingplugin-pointsh"),
new VotingPluginPointsDeductibleRequirement(this, "votingplugin-points"));
new VotingPluginVotesRequirement(this, "votingplugin-votes"),
new VotingPluginPointsRequirement(this, "votingplugin-pointsh"),
new VotingPluginPointsDeductibleRequirement(this, "votingplugin-points")
);
}
if (Bukkit.getPluginManager().isPluginEnabled("Towny")) {
requirements.addRequirements(
new TownyResidentRequirement(this),
new TownyMayorRequirement(this),
new TownyMayorNumberResidentsRequirement(this),
new TownyKingRequirement(this),
new TownyKingNumberResidentsRequirement(this),
new TownyKingNumberTownsRequirement(this));
new TownyResidentRequirement(this, "towny-resident"),
new TownyMayorRequirement(this, "towny-mayor"),
new TownyMayorNumberResidentsRequirement(this, "towny-mayor-residents"),
new TownyKingRequirement(this, "towny-king"),
new TownyKingNumberResidentsRequirement(this, "towny-king-residents"),
new TownyKingNumberTownsRequirement(this, "towny-king-towns")
);
}
if (Bukkit.getPluginManager().isPluginEnabled("TokenManager")) {
requirements.addRequirements(
new TokensRequirement(this, "tokenmanager-tokensh"),
new TokensDeductibleRequirement(this, "tokenmanager-tokens"));
new TokensRequirement(this, "tokenmanager-tokensh"),
new TokensDeductibleRequirement(this, "tokenmanager-tokens")
);
}
if (Bukkit.getPluginManager().isPluginEnabled("SuperbVote")) {
requirements.addRequirements(new SuperbVoteVotesRequirement(this));
requirements.addRequirements(
new SuperbVoteVotesRequirement(this, "superbvote-votes")
);
}
}
private void setupEconomy() {
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/sh/okx/rankup/commands/RankupCommand.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package sh.okx.rankup.commands;

import java.util.Arrays;
import java.util.Map;
import java.util.WeakHashMap;
import lombok.RequiredArgsConstructor;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand All @@ -29,6 +31,11 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return true;
}

if (plugin.getConfig().getBoolean("enable-noconfirm", true) && args.length > 0 && args[0].equalsIgnoreCase("noconfirm")) {
handleNoConfirm(sender, label, Arrays.copyOfRange(args, 1, args.length));
return true;
}

// check if player
if (!(sender instanceof Player)) {
return false;
Expand All @@ -39,6 +46,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (!plugin.getHelper().checkRankup(player)) {
return true;
}

RankElement<Rank> rankElement = rankups.getByPlayer(player);

FileConfiguration config = plugin.getConfig();
Expand Down Expand Up @@ -79,4 +87,23 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
return true;
}

private void handleNoConfirm(CommandSender sender, String label, String[] args) {
if (sender.hasPermission("rankup.noconfirm.other") && args.length > 0) {
Player player = Bukkit.getPlayer(args[0]);
if (player == null) {
sender.sendMessage(ChatColor.RED + "Player not found: " + args[0]);
} else {
plugin.getHelper().rankup(player);
sender.sendMessage(ChatColor.GREEN + "Triggered no-confirmation rankup for " + player.getName());
}
} else {
if (!(sender instanceof Player)) {
sender.sendMessage("/" + label + " noconfirm <player>");
return;
}

plugin.getHelper().rankup((Player) sender);
}
}
}
Loading