mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-06 15:41:35 +00:00
Add multiple command support to icons, add MoneyRequirement
This commit is contained in:
@@ -25,10 +25,13 @@ repositories {
|
||||
}
|
||||
|
||||
maven { url = "https://repo.aikar.co/content/groups/aikar/" }
|
||||
|
||||
maven { url = "https://jitpack.io" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT' // spigot
|
||||
implementation "io.papermc:paperlib:1.0.2" // paperlib - async teleport on Paper
|
||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // vault
|
||||
implementation 'io.papermc:paperlib:1.0.2' // paperlib - async teleport on Paper
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.islandearth.rpgregions.requirements;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class MoneyRequirement extends RegionRequirement {
|
||||
|
||||
private final double money;
|
||||
|
||||
public MoneyRequirement(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean meetsRequirements(Player player) {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RegisteredServiceProvider<Economy> economy = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (economy == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return economy.getProvider().getBalance(player) >= money;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Money";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(Player player) {
|
||||
return "money " + money;
|
||||
}
|
||||
}
|
||||
@@ -248,7 +248,9 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
||||
else PaperLib.teleportAsync(player, new Location(configuredRegion.getWorld(), x, y, z));
|
||||
}
|
||||
|
||||
if (!configuredRegion.getIconCommand().isEmpty()) player.performCommand(configuredRegion.getIconCommand().replace("%region%", configuredRegion.getId()));
|
||||
if (!configuredRegion.getIconCommands().isEmpty()) {
|
||||
configuredRegion.getIconCommands().forEach(iconCommand -> player.performCommand(iconCommand.replace("%region%", configuredRegion.getId())));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class ConfiguredRegion {
|
||||
private final Sound sound;
|
||||
private final String icon;
|
||||
private final String undiscoveredIcon;
|
||||
private final String iconCommand;
|
||||
private final List<String> iconCommands;
|
||||
private final boolean showCoords;
|
||||
private int x;
|
||||
private int y;
|
||||
@@ -67,7 +67,7 @@ public class ConfiguredRegion {
|
||||
this.sound = XSound.UI_TOAST_CHALLENGE_COMPLETE.parseSound();
|
||||
this.icon = XMaterial.TOTEM_OF_UNDYING.name();
|
||||
this.undiscoveredIcon = XMaterial.TOTEM_OF_UNDYING.name();
|
||||
this.iconCommand = "";
|
||||
this.iconCommands = new ArrayList<>();
|
||||
this.showCoords = false;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -93,7 +93,7 @@ public class ConfiguredRegion {
|
||||
this.sound = sound;
|
||||
this.icon = icon.name();
|
||||
this.undiscoveredIcon = icon.name();
|
||||
this.iconCommand = "";
|
||||
this.iconCommands = new ArrayList<>();
|
||||
this.showCoords = false;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -142,8 +142,8 @@ public class ConfiguredRegion {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getIconCommand() {
|
||||
return iconCommand == null ? "" : iconCommand;
|
||||
public List<String> getIconCommands() {
|
||||
return iconCommands == null ? new ArrayList<>() : iconCommands;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
|
||||
Reference in New Issue
Block a user