mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Testing
This commit is contained in:
parent
a267261c7d
commit
761ab51edc
@ -1,6 +1,6 @@
|
||||
package com.songoda.update.command;
|
||||
package com.songoda.core.command;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -49,9 +49,9 @@ public abstract class AbstractCommand {
|
||||
subCommand.add(command);
|
||||
}
|
||||
|
||||
protected abstract ReturnType runCommand(SongodaUpdate instance, CommandSender sender, String... args);
|
||||
protected abstract ReturnType runCommand(SongodaCore instance, CommandSender sender, String... args);
|
||||
|
||||
protected abstract List<String> onTab(SongodaUpdate instance, CommandSender sender, String... args);
|
||||
protected abstract List<String> onTab(SongodaCore instance, CommandSender sender, String... args);
|
||||
|
||||
public abstract String getPermissionNode();
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
package com.songoda.update.command;
|
||||
package com.songoda.core.command;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.command.commands.CommandDiag;
|
||||
import com.songoda.update.command.commands.CommandSongoda;
|
||||
import com.songoda.update.utils.Methods;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.command.commands.CommandDiag;
|
||||
import com.songoda.core.command.commands.CommandSongoda;
|
||||
import com.songoda.core.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -18,12 +18,12 @@ import java.util.Map;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private SongodaUpdate instance;
|
||||
private SongodaCore instance;
|
||||
private TabManager tabManager;
|
||||
|
||||
private List<AbstractCommand> commands = new ArrayList<>();
|
||||
|
||||
public CommandManager(SongodaUpdate instance) {
|
||||
public CommandManager(SongodaCore instance) {
|
||||
this.instance = instance;
|
||||
this.tabManager = new TabManager(this);
|
||||
|
||||
@ -97,7 +97,7 @@ public class CommandManager implements CommandExecutor {
|
||||
// Construct a new Command object
|
||||
Constructor<PluginCommand> constructorPluginCommand = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class);
|
||||
constructorPluginCommand.setAccessible(true);
|
||||
PluginCommand commandObject = constructorPluginCommand.newInstance(command, SongodaUpdate.getHijackedPlugin());
|
||||
PluginCommand commandObject = constructorPluginCommand.newInstance(command, SongodaCore.getHijackedPlugin());
|
||||
commandObject.setExecutor(executor);
|
||||
|
||||
// Set tab complete
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.update.command;
|
||||
package com.songoda.core.command;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
@ -50,7 +50,7 @@ public class TabManager implements TabCompleter {
|
||||
|
||||
|
||||
private List<String> onCommand(AbstractCommand abstractCommand, String[] strings, CommandSender sender) {
|
||||
List<String> list = abstractCommand.onTab(SongodaUpdate.getInstance(), sender, strings);
|
||||
List<String> list = abstractCommand.onTab(SongodaCore.getInstance(), sender, strings);
|
||||
String str = strings[strings.length - 1];
|
||||
if (list != null && str != null && str.length() >= 1) {
|
||||
try {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.update.command.commands;
|
||||
package com.songoda.core.command.commands;
|
||||
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.command.AbstractCommand;
|
||||
import com.songoda.core.Plugin;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@ -36,7 +36,7 @@ public class CommandDiag extends AbstractCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(SongodaUpdate instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(SongodaCore instance, CommandSender sender, String... args) {
|
||||
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("Songoda Diagnostics Information");
|
||||
@ -64,7 +64,7 @@ public class CommandDiag extends AbstractCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(SongodaUpdate instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(SongodaCore instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.songoda.update.command.commands;
|
||||
package com.songoda.core.command.commands;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.command.AbstractCommand;
|
||||
import com.songoda.update.gui.GUIOverview;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.command.AbstractCommand;
|
||||
import com.songoda.core.gui.GUIOverview;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -16,13 +15,13 @@ public class CommandSongoda extends AbstractCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(SongodaUpdate instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(SongodaCore instance, CommandSender sender, String... args) {
|
||||
new GUIOverview(instance, (Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(SongodaUpdate instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(SongodaCore instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.songoda.update.gui;
|
||||
package com.songoda.core.gui;
|
||||
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.utils.gui.AbstractGUI;
|
||||
import com.songoda.core.Plugin;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -10,9 +10,9 @@ import java.util.List;
|
||||
|
||||
public class GUIOverview extends AbstractGUI {
|
||||
|
||||
private final SongodaUpdate update;
|
||||
private final SongodaCore update;
|
||||
|
||||
public GUIOverview(SongodaUpdate update, Player player) {
|
||||
public GUIOverview(SongodaCore update, Player player) {
|
||||
super(player);
|
||||
this.update = update;
|
||||
|
||||
|
@ -7,12 +7,13 @@ import com.songoda.core.library.economy.economies.VaultEconomy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class EconomyManager {
|
||||
|
||||
private static Map<Economies, Economy> registeredEconomies = new HashMap();
|
||||
private static Set<Economy> registeredEconomies = new HashSet<>();
|
||||
|
||||
public static void load() {
|
||||
if (!registeredEconomies.isEmpty()) return;
|
||||
@ -20,10 +21,19 @@ public class EconomyManager {
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
if (pluginManager.isPluginEnabled("Vault"))
|
||||
registeredEconomies.put(new VaultEconomy());
|
||||
registeredEconomies.add(new VaultEconomy());
|
||||
if (pluginManager.isPluginEnabled("Reserve"))
|
||||
registeredEconomies.add(new ReserveEconomy());
|
||||
if (pluginManager.isPluginEnabled("PlayerPoints"))
|
||||
registeredEconomies.add(new PlayerPointsEconomy());
|
||||
}
|
||||
|
||||
public static Economy getEconomy(String name) {
|
||||
return registeredEconomies.stream().filter(economy -> economy.getName().equalsIgnoreCase(name.trim()))
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static Set<Economy> getRegisteredEconomies() {
|
||||
return Collections.unmodifiableSet(registeredEconomies);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.songoda.ultimateclaims.economy;
|
||||
package com.songoda.core.library.economy.economies;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public interface Economy {
|
||||
|
||||
String getName();
|
||||
|
||||
boolean hasBalance(OfflinePlayer player, double cost);
|
||||
|
||||
boolean withdrawBalance(OfflinePlayer player, double cost);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimateclaims.economy;
|
||||
package com.songoda.core.library.economy.economies;
|
||||
|
||||
import org.black_ixx.playerpoints.PlayerPoints;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -16,6 +16,11 @@ public class PlayerPointsEconomy implements Economy {
|
||||
return (int) Math.ceil(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlayerPoints";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
int amount = convertAmount(cost);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimateclaims.economy;
|
||||
package com.songoda.core.library.economy.economies;
|
||||
|
||||
import net.tnemc.core.Reserve;
|
||||
import net.tnemc.core.economy.EconomyAPI;
|
||||
@ -15,6 +15,11 @@ public class ReserveEconomy implements Economy {
|
||||
economyAPI = Reserve.instance().economy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Reserve";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
return economyAPI.hasHoldings(player.getUniqueId(), new BigDecimal(cost));
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.songoda.ultimateclaims.economy;
|
||||
package com.songoda.core.library.economy.economies;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class VaultEconomy implements Economy {
|
||||
|
||||
private final net.milkbowl.vault.economy.Economy vault;
|
||||
|
||||
public VaultEconomy() {
|
||||
@ -11,6 +12,11 @@ public class VaultEconomy implements Economy {
|
||||
getRegistration(net.milkbowl.vault.economy.Economy.class).getProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Vault";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBalance(OfflinePlayer player, double cost) {
|
||||
return vault.has(player, cost);
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimateclaims.utils.locale;
|
||||
package com.songoda.core.library.locale;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.ultimateclaims.utils.locale;
|
||||
package com.songoda.core.library.locale;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.update.listeners;
|
||||
package com.songoda.core.listeners;
|
||||
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.core.Plugin;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -9,9 +9,9 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class LoginListener implements Listener {
|
||||
|
||||
private SongodaUpdate instance;
|
||||
private SongodaCore instance;
|
||||
|
||||
public LoginListener(SongodaUpdate instance) {
|
||||
public LoginListener(SongodaCore instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.songoda.update.utils.gui;
|
||||
package com.songoda.core.utils.gui;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.utils.Methods;
|
||||
import com.songoda.update.utils.gui.Clickable;
|
||||
import com.songoda.update.utils.gui.OnClose;
|
||||
import com.songoda.update.utils.gui.Range;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -125,7 +122,7 @@ public abstract class AbstractGUI implements Listener {
|
||||
registerOnCloses();
|
||||
}
|
||||
constructGUI();
|
||||
initializeListeners(SongodaUpdate.getHijackedPlugin());
|
||||
initializeListeners(SongodaCore.getHijackedPlugin());
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.update.utils.gui;
|
||||
package com.songoda.core.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.songoda.update.utils.gui;
|
||||
package com.songoda.core.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.songoda.update.utils.gui;
|
||||
package com.songoda.core.utils.gui;
|
||||
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import com.songoda.update.utils.ServerVersion;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.utils.ServerVersion;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -18,7 +18,7 @@ public class Range {
|
||||
this.max = max;
|
||||
this.clickType = clickType;
|
||||
this.bottom = bottom;
|
||||
if (SongodaUpdate.getInstance().isServerVersionAtLeast(ServerVersion.V1_9)) onClickSound = Sound.UI_BUTTON_CLICK;
|
||||
if (SongodaCore.getInstance().isServerVersionAtLeast(ServerVersion.V1_9)) onClickSound = Sound.UI_BUTTON_CLICK;
|
||||
}
|
||||
|
||||
public Range(int min, int max, Sound onClickSound, ClickType clickType, boolean bottom) {
|
||||
|
Loading…
Reference in New Issue
Block a user