9
0
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:
Sam
2020-06-25 12:32:04 +01:00
parent cf891f77a8
commit a56cfe5c00
4 changed files with 51 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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;
}
}

View File

@@ -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);
}));
}

View File

@@ -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() {