mirror of
https://github.com/songoda/UltimateKits.git
synced 2025-02-19 21:02:05 +01:00
Merge branch 'development'
This commit is contained in:
commit
71f4614f76
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "UltimateKits"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.4.2"
|
||||
version: "2.4.3"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -27,6 +27,7 @@ import com.songoda.ultimatekits.listeners.BlockListeners;
|
||||
import com.songoda.ultimatekits.listeners.ChatListeners;
|
||||
import com.songoda.ultimatekits.listeners.EntityListeners;
|
||||
import com.songoda.ultimatekits.listeners.InteractListeners;
|
||||
import com.songoda.ultimatekits.listeners.PlayerListeners;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import com.songoda.ultimatekits.utils.ItemSerializer;
|
||||
import com.songoda.ultimatekits.utils.Methods;
|
||||
@ -120,7 +121,8 @@ public class UltimateKits extends SongodaPlugin {
|
||||
.addSubCommand(new CommandEdit(guiManager))
|
||||
.addSubCommand(new CommandKey())
|
||||
.addSubCommand(new CommandSet())
|
||||
.addSubCommand(new CommandRemove());
|
||||
.addSubCommand(new CommandRemove())
|
||||
.addSubCommand(new CommandGive());
|
||||
|
||||
|
||||
// Event registration
|
||||
@ -130,6 +132,7 @@ public class UltimateKits extends SongodaPlugin {
|
||||
pluginManager.registerEvents(new ChatListeners(this), this);
|
||||
pluginManager.registerEvents(new EntityListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this, guiManager), this);
|
||||
pluginManager.registerEvents(new PlayerListeners(), this);
|
||||
|
||||
try {
|
||||
if (Settings.MYSQL_ENABLED.getBoolean()) {
|
||||
|
@ -0,0 +1,85 @@
|
||||
package com.songoda.ultimatekits.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.kit.Kit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
|
||||
final UltimateKits instance;
|
||||
|
||||
public CommandGive() {
|
||||
super(false, "give");
|
||||
instance = UltimateKits.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2) return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
if (!args[0].equalsIgnoreCase("all") && Bukkit.getPlayer(args[0]) == null) {
|
||||
instance.getLocale().newMessage("&cThat username does not exist, or the user is offline!").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (instance.getKitManager().getKit(args[1]) == null) {
|
||||
instance.getLocale().getMessage("command.kit.kitdoesntexist").sendPrefixedMessage(sender);
|
||||
}
|
||||
|
||||
Player player = args[0].equalsIgnoreCase("all") ? null : Bukkit.getPlayer(args[0]);
|
||||
Kit kit = instance.getKitManager().getKit(args[1]);
|
||||
|
||||
if (player != null) {
|
||||
kit.giveKit(player);
|
||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.sendPrefixedMessage(sender);
|
||||
} else {
|
||||
Bukkit.getOnlinePlayers().forEach(onlinePlayer -> {
|
||||
kit.giveKit(onlinePlayer);
|
||||
instance.getLocale().getMessage("event.claim.givesuccess")
|
||||
.processPlaceholder("kit", kit.getShowableName())
|
||||
.sendPrefixedMessage(sender);
|
||||
});
|
||||
}
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
List<String> tab = new ArrayList<>();
|
||||
|
||||
if (!(sender instanceof Player)) return tab;
|
||||
|
||||
if (args.length == 1) {
|
||||
tab.add("all");
|
||||
for (Player player : Bukkit.getOnlinePlayers()) tab.add(player.getName());
|
||||
} else if (args.length == 2) {
|
||||
for (Kit kit : instance.getKitManager().getKits()) tab.add(kit.getName());
|
||||
}
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "ultimatekits.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/KitAdmin give <player/all> <kit>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Give a kit to a player.";
|
||||
}
|
||||
}
|
@ -254,7 +254,7 @@ public class Kit {
|
||||
return stacks;
|
||||
}
|
||||
|
||||
private boolean giveKit(Player player) {
|
||||
public boolean giveKit(Player player) {
|
||||
return giveKit(player, null);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.songoda.ultimatekits.listeners;
|
||||
|
||||
import com.songoda.ultimatekits.UltimateKits;
|
||||
import com.songoda.ultimatekits.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerListeners implements Listener {
|
||||
|
||||
private final UltimateKits instance;
|
||||
|
||||
public PlayerListeners() {
|
||||
instance = UltimateKits.getInstance();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.hasPlayedBefore()) return;
|
||||
|
||||
if (instance.getKitManager().getKit(Settings.STARTER_KIT.getString()) == null
|
||||
|| Settings.STARTER_KIT.getString() == null
|
||||
|| Settings.STARTER_KIT.getString().equalsIgnoreCase("none")) return;
|
||||
|
||||
instance.getKitManager().getKit(Settings.STARTER_KIT.getString()).giveKit(player);
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ public class Settings {
|
||||
public static final ConfigSetting AUTO_EQUIP_ARMOR_ROULETTE = new ConfigSetting(config, "Main.Automatically Equip Armor Given From a Kit with the Roulette Animation", false);
|
||||
public static final ConfigSetting CHANCE_IN_PREVIEW = new ConfigSetting(config, "Main.Display Chance In Preview", true);
|
||||
public static final ConfigSetting CURRENCY_SYMBOL = new ConfigSetting(config, "Main.Currency Symbol", "$");
|
||||
public static final ConfigSetting STARTER_KIT = new ConfigSetting(config, "Main.Starter Kit", "none");
|
||||
|
||||
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
|
||||
"Which economy plugin should be used?",
|
||||
|
Loading…
Reference in New Issue
Block a user