9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2025-12-28 19:29:16 +00:00
This commit is contained in:
SamB440
2020-06-25 18:50:52 +01:00
8 changed files with 89 additions and 9 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

@@ -45,10 +45,14 @@ repositories {
name = 'bintray'
url = 'https://dl.bintray.com/rsl1122/Plan-repository'
}
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'junit', name: 'junit', version: '4.5'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.15:0.3.0-SNAPSHOT'
testImplementation 'org.reflections:reflections:0.9.12'
compileOnly 'org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT' // spigot
compileOnly 'me.clip:placeholderapi:2.10.4' // PAPI

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

View File

@@ -3,7 +3,7 @@ version: @version@
main: net.islandearth.rpgregions.RPGRegions
api-version: '1.13'
depend: [Languagy]
softdepend: [WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention]
softdepend: [WorldGuard, PlaceholderAPI, HeadDatabase, Residence, Plan, GriefPrevention, Vault]
authors: [SamB440]
description: Discoverable regions
website: https://fortitude.islandearth.net

View File

@@ -0,0 +1,32 @@
package net.islandearth.rpgregions.translation;
import org.bukkit.configuration.file.YamlConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.reflections.Reflections;
import org.reflections.scanners.ResourcesScanner;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.regex.Pattern;
public class TranslationsTest {
@Test
public void translationTest() {
Reflections reflections = new Reflections("lang/", new ResourcesScanner());
Set<String> fileNames = reflections.getResources(Pattern.compile(".*\\.yml"));
fileNames.forEach(fileName -> {
InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
YamlConfiguration config = YamlConfiguration.loadConfiguration(reader);
for (Translations translation : Translations.values()) {
if (config.get(translation.toString().toLowerCase()) == null) {
Assert.fail(translation.toString() + " not found");
}
}
});
}
}