mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-02-07 00:12:24 +01:00
Move the API into it's own branch and depend on it via maven
This commit is contained in:
parent
1cdc17eb6a
commit
6aca1cbbb5
62
pom.xml
62
pom.xml
@ -1,20 +1,3 @@
|
||||
<!--
|
||||
~ Copyright (C) 2019 GeorgH93
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation, either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ This program is distributed in the hope that it will be useful,
|
||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
~ GNU General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@ -56,7 +39,7 @@
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>pcgf-repo</id>
|
||||
<url>https://repo.pcgamingfreaks.at/repository/everything/</url>
|
||||
<url>https://repo.pcgamingfreaks.at/repository/maven-everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-nexus</id>
|
||||
@ -65,12 +48,30 @@
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- Minepacks API -->
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>Minepacks-API</artifactId>
|
||||
<version>2.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>PluginLib</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Bukkit -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- PCGF Plugin Lib -->
|
||||
<dependency>
|
||||
<groupId>at.pcgamingfreaks</groupId>
|
||||
<artifactId>PluginLib</artifactId>
|
||||
@ -79,7 +80,7 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
@ -105,6 +106,29 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- Bundle the API into the JAR -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>false</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>at.pcgamingfreaks:Minepacks-API</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016, 2017 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Backpack extends InventoryHolder
|
||||
{
|
||||
/**
|
||||
* Gets the owner of the backpack.
|
||||
*
|
||||
* @return The owner of the backpack;
|
||||
*/
|
||||
@NotNull OfflinePlayer getOwner();
|
||||
|
||||
/**
|
||||
* Let a given player open this backpack.
|
||||
*
|
||||
* @param player The player who opens the backpack.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
*/
|
||||
void open(@NotNull Player player, boolean editable);
|
||||
|
||||
/**
|
||||
* Let a given player open this backpack.
|
||||
*
|
||||
* @param player The player who opens the backpack.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
* @param title Custom title for the backpack (will be shown to the player who opened the backpack.
|
||||
*/
|
||||
void open(@NotNull Player player, boolean editable, @Nullable String title);
|
||||
|
||||
/**
|
||||
* Checks if the backpack is currently opened by a player.
|
||||
*
|
||||
* @return True if the backpack is open, false if not.
|
||||
*/
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Checks if a player can change the content of the backpack.
|
||||
*
|
||||
* @param player The player to be checked.
|
||||
* @return True if he can change the content, false if not.
|
||||
*/
|
||||
boolean canEdit(@NotNull Player player);
|
||||
|
||||
/**
|
||||
* Gets the size of the backpack.
|
||||
*
|
||||
* @return The size of the backpack.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* Checks if the backpack has changed since it was last saved.
|
||||
*
|
||||
* @return True if it has been changed, false if not.
|
||||
*/
|
||||
boolean hasChanged();
|
||||
|
||||
/**
|
||||
* Marks that the content of the backpack a changed. It will be saved when the next player closes the backpack or before it gets removed from the cache.
|
||||
*/
|
||||
void setChanged();
|
||||
|
||||
/**
|
||||
* Forces the backpack to be saved
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Removes all items from the backpack.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Drops the content of the backpack to the ground on a given location.
|
||||
*
|
||||
* @param location The location the content of the backpack should be dropped to.
|
||||
*/
|
||||
void drop(Location location);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||
|
||||
public interface Callback<T>
|
||||
{
|
||||
void onResult(T done);
|
||||
|
||||
void onFail();
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||
|
||||
import at.pcgamingfreaks.Bukkit.Command.SubCommand;
|
||||
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||
import at.pcgamingfreaks.Command.HelpData;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class MinepacksCommand extends SubCommand
|
||||
{
|
||||
private static MinepacksPlugin minepacksPlugin = null;
|
||||
private static Method showHelp = null;
|
||||
private static Message messageNoPermission = new Message(ChatColor.RED + "You don't have the permission to do that.");
|
||||
private static Message messageNotFromConsole = new Message(ChatColor.RED + "This command can't be used from console!");
|
||||
protected final JavaPlugin plugin;
|
||||
private final boolean playerOnly;
|
||||
|
||||
//region Constructors
|
||||
/**
|
||||
* Creates a new command instance.
|
||||
*
|
||||
* @param plugin The plugin owning the command.
|
||||
* @param name The command used.
|
||||
* @param description The description of the command.
|
||||
* @param aliases List of aliases for that command.
|
||||
*/
|
||||
public MinepacksCommand(@NotNull JavaPlugin plugin, @NotNull String name, @NotNull String description, @Nullable String... aliases)
|
||||
{
|
||||
this(plugin, name, description, null, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new command instance.
|
||||
*
|
||||
* @param plugin The plugin owning the command.
|
||||
* @param name The command used.
|
||||
* @param description The description of the command.
|
||||
* @param permission The permission to be checked for this command. Players without the permission neither can use the command nor will they see it in help.
|
||||
* @param aliases List of aliases for that command.
|
||||
*/
|
||||
public MinepacksCommand(@NotNull JavaPlugin plugin, @NotNull String name, @NotNull String description, @Nullable String permission, @Nullable String... aliases)
|
||||
{
|
||||
this(plugin, name, description, permission, false, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new command instance.
|
||||
*
|
||||
* @param plugin The plugin owning the command.
|
||||
* @param name The command used.
|
||||
* @param description The description of the command.
|
||||
* @param permission The permission to be checked for this command. Players without the permission neither can use the command nor will they see it in help.
|
||||
* @param playerOnly Limits the command to players, console can't use and can't see the command.
|
||||
* @param aliases List of aliases for that command.
|
||||
*/
|
||||
public MinepacksCommand(@NotNull JavaPlugin plugin, @NotNull String name, @NotNull String description, @Nullable String permission, boolean playerOnly, @Nullable String... aliases)
|
||||
{
|
||||
super(name, description, permission, aliases);
|
||||
this.plugin = plugin;
|
||||
this.playerOnly = playerOnly;
|
||||
}
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Gets the instance of the marriage master plugin.
|
||||
*
|
||||
* @return The instance of the marriage master plugin.
|
||||
*/
|
||||
protected @NotNull MinepacksPlugin getMinepacksPlugin()
|
||||
{
|
||||
return minepacksPlugin;
|
||||
}
|
||||
|
||||
//region Command Stuff
|
||||
/**
|
||||
* Executes some basic checks and runs the command afterwards.
|
||||
*
|
||||
* @param sender Source of the command.
|
||||
* @param mainCommandAlias Alias of the plugins main command which was used.
|
||||
* @param alias Alias of the command which has been used.
|
||||
* @param args Passed command arguments.
|
||||
*/
|
||||
@Override
|
||||
public void doExecute(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String... args)
|
||||
{
|
||||
if(playerOnly && !(sender instanceof Player))
|
||||
{
|
||||
messageNotFromConsole.send(sender);
|
||||
}
|
||||
else if(getPermission() != null && !sender.hasPermission(getPermission()))
|
||||
{
|
||||
messageNoPermission.send(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
execute(sender, mainCommandAlias, alias, args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes some basic checks and generates list for tab completion.
|
||||
*
|
||||
* @param sender Source of the command.
|
||||
* @param mainCommandAlias Alias of the plugins main command which has been used.
|
||||
* @param alias The alias used.
|
||||
* @param args The arguments passed to the command, including final partial argument to be completed and command label.
|
||||
* @return A List of possible completions for the final argument, or null to default to the command executor.
|
||||
*/
|
||||
@Override
|
||||
public List<String> doTabComplete(@NotNull CommandSender sender, @NotNull String mainCommandAlias, @NotNull String alias, @NotNull String... args)
|
||||
{
|
||||
if(playerOnly && !(sender instanceof Player))
|
||||
{
|
||||
messageNotFromConsole.send(sender);
|
||||
}
|
||||
else if(getPermission() != null && !sender.hasPermission(getPermission()))
|
||||
{
|
||||
messageNoPermission.send(sender);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tabComplete(sender, mainCommandAlias, alias, args);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the help for a given {@link CommandSender}.
|
||||
*
|
||||
* @param requester The {@link CommandSender} that requested help.
|
||||
* @return All the help data for this command.
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<HelpData> getHelp(@NotNull CommandSender requester)
|
||||
{
|
||||
List<HelpData> help = new LinkedList<>();
|
||||
help.add(new HelpData(getTranslatedName(), null, getDescription()));
|
||||
return help;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the help to a given command sender.
|
||||
*
|
||||
* @param sendTo The command sender that requested help.
|
||||
* @param usedMainCommandAlias The used backpack alias to replace the /backpack with the used alias.
|
||||
*/
|
||||
@Override
|
||||
public void showHelp(@NotNull CommandSender sendTo, @NotNull String usedMainCommandAlias)
|
||||
{
|
||||
try
|
||||
{
|
||||
showHelp.invoke(getMinepacksPlugin().getCommandManager(), sendTo, usedMainCommandAlias, doGetHelp(sendTo));
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user can use the command. Checks permission, marriage status and player/console.
|
||||
*
|
||||
* @param sender The player/console that should be checked.
|
||||
* @return True if it can use the command, false if not.
|
||||
*/
|
||||
@Override
|
||||
public boolean canUse(@NotNull CommandSender sender)
|
||||
{
|
||||
return (!playerOnly || sender instanceof Player) && (getPermission() == null || sender.hasPermission(getPermission()));
|
||||
}
|
||||
//endregion
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface MinepacksCommandManager
|
||||
{
|
||||
/**
|
||||
* Registers a new sub-command for /backpack.
|
||||
*
|
||||
* @param command The command that should be registered.
|
||||
*/
|
||||
void registerSubCommand(@NotNull MinepacksCommand command);
|
||||
|
||||
/**
|
||||
* Unregisters a sub-command for /backpack.
|
||||
*
|
||||
* @param command The command that should be unregistered.
|
||||
*/
|
||||
void unRegisterSubCommand(@NotNull MinepacksCommand command);
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2018 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.API;
|
||||
|
||||
import at.pcgamingfreaks.Version;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public interface MinepacksPlugin
|
||||
{
|
||||
/**
|
||||
* Gets the instance of the minepacks plugin.
|
||||
* WARNING use this function at your own risk! If the plugin is not installed the MinepacksPlugin class will be unknown!
|
||||
*
|
||||
* @return The instance of the minepacks plugin.
|
||||
*/
|
||||
static @Nullable MinepacksPlugin getInstance()
|
||||
{
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Minepacks");
|
||||
return (plugin instanceof MinepacksPlugin && plugin.isEnabled()) ? (MinepacksPlugin) plugin : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the currently running {@link Version} of the plugin.
|
||||
* Version 0.0 if plugin is not loaded or enabled.
|
||||
*
|
||||
* @return The currently running version of the plugin.
|
||||
*/
|
||||
static @NotNull Version getVersion()
|
||||
{
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Minepacks");
|
||||
if(plugin instanceof MinepacksPlugin && plugin.isEnabled())
|
||||
{
|
||||
return new Version(plugin.getDescription().getVersion());
|
||||
}
|
||||
return new Version("0.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* Let a given player open the backpack of an other player.
|
||||
*
|
||||
* @param opener The player who opens the backpack.
|
||||
* @param owner The owner of the backpack that should be opened.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
*/
|
||||
void openBackpack(@NotNull final Player opener, @NotNull final OfflinePlayer owner, final boolean editable);
|
||||
|
||||
/**
|
||||
* Let a given player open a given {@link Backpack}.
|
||||
*
|
||||
* @param opener The player who opens the backpack.
|
||||
* @param backpack The backpack to be opened. null will result in an error message for the player.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
*/
|
||||
void openBackpack(@NotNull final Player opener, @Nullable final Backpack backpack, boolean editable);
|
||||
|
||||
/**
|
||||
* Let a given player open the backpack of an other player.
|
||||
*
|
||||
* @param opener The player who opens the backpack.
|
||||
* @param owner The owner of the backpack that should be opened.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
* @param title Custom title for the backpack (will be shown to the player who opened the backpack.
|
||||
*/
|
||||
void openBackpack(@NotNull final Player opener, @NotNull final OfflinePlayer owner, final boolean editable, @Nullable String title);
|
||||
|
||||
/**
|
||||
* Let a given player open a given {@link Backpack}.
|
||||
*
|
||||
* @param opener The player who opens the backpack.
|
||||
* @param backpack The backpack to be opened. null will result in an error message for the player.
|
||||
* @param editable Defines if the player who has opened the backpack can change the items inside.
|
||||
* @param title Custom title for the backpack (will be shown to the player who opened the backpack.
|
||||
*/
|
||||
void openBackpack(@NotNull final Player opener, @Nullable final Backpack backpack, boolean editable, @Nullable String title);
|
||||
|
||||
/**
|
||||
* Retrieves the backpack for a given player.
|
||||
* This method only returns a backpack if it is in the cache.
|
||||
*
|
||||
* @param owner The player who's backpack should be retrieved.
|
||||
* @return The backpack of the given player. null if the backpack is in the cache.
|
||||
*/
|
||||
@Nullable Backpack getBackpackCachedOnly(@NotNull final OfflinePlayer owner);
|
||||
|
||||
/**
|
||||
* Retrieves the backpack for a given player.
|
||||
* This method runs async! The result will be delivered with a callback.
|
||||
* If no backpack exists a new one will be created.
|
||||
*
|
||||
* @param owner The player who's backpack should be retrieved.
|
||||
* @param callback The callback delivering the result of the request.
|
||||
*/
|
||||
void getBackpack(@NotNull final OfflinePlayer owner, @NotNull final Callback<at.pcgamingfreaks.Minepacks.Bukkit.Backpack> callback);
|
||||
|
||||
/**
|
||||
* Retrieves the backpack for a given player.
|
||||
* This method runs async! The result will be delivered with a callback.
|
||||
*
|
||||
* @param owner The player who's backpack should be retrieved.
|
||||
* @param callback The callback delivering the result of the request.
|
||||
* @param createNewIfNotExists If set to true, a new backpack will be created if there currently is no backpack for this player.
|
||||
*/
|
||||
void getBackpack(@NotNull final OfflinePlayer owner, @NotNull final Callback<at.pcgamingfreaks.Minepacks.Bukkit.Backpack> callback, boolean createNewIfNotExists);
|
||||
|
||||
/**
|
||||
* Gets the command manager of the Minepacks plugin.
|
||||
*
|
||||
* @return The command manager instance.
|
||||
*/
|
||||
MinepacksCommandManager getCommandManager();
|
||||
|
||||
/**
|
||||
* Checks if the player is allowed to open a backpack based on is permissions and current game-mode.
|
||||
*
|
||||
* @param player The player to be checked.
|
||||
* @return True if the player can use a backpack. False if not.
|
||||
*/
|
||||
boolean isPlayerGameModeAllowed(Player player);
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
|
||||
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||
import at.pcgamingfreaks.Command.HelpData;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Callback;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -53,7 +53,7 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String m
|
||||
@Override
|
||||
public void onResult(Backpack backpack)
|
||||
{
|
||||
backpack.backup();
|
||||
((at.pcgamingfreaks.Minepacks.Bukkit.Backpack) backpack).backup();
|
||||
messageCreated.send(sender);
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||
import at.pcgamingfreaks.Command.HelpData;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Callback;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -20,9 +20,9 @@
|
||||
import at.pcgamingfreaks.Bukkit.Message.Message;
|
||||
import at.pcgamingfreaks.Command.HelpData;
|
||||
import at.pcgamingfreaks.Message.MessageClickEvent;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Callback;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksCommand;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
import at.pcgamingfreaks.StringUtils;
|
||||
|
||||
|
@ -198,7 +198,7 @@ protected String getPlayerFormattedUUID(OfflinePlayer player)
|
||||
return (player == null) ? null : backpacks.get(player);
|
||||
}
|
||||
|
||||
public void getBackpack(final OfflinePlayer player, final Callback<Backpack> callback, final boolean createNewOnFail)
|
||||
public void getBackpack(final OfflinePlayer player, final Callback<at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack> callback, final boolean createNewOnFail)
|
||||
{
|
||||
if(player == null)
|
||||
{
|
||||
@ -238,7 +238,7 @@ public void onFail()
|
||||
}
|
||||
}
|
||||
|
||||
public void getBackpack(final OfflinePlayer player, final Callback<Backpack> callback)
|
||||
public void getBackpack(final OfflinePlayer player, final Callback<at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack> callback)
|
||||
{
|
||||
getBackpack(player, callback, true);
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ public void saveBackpack(Backpack backpack)
|
||||
|
||||
@Override
|
||||
protected void loadBackpack(final OfflinePlayer player, final Callback<Backpack> callback)
|
||||
{
|
||||
{ //TODO this needs to be done async!
|
||||
File save = new File(saveFolder, getFileName(player));
|
||||
ItemStack[] itemStacks = readFile(itsSerializer, save, plugin.getLogger());
|
||||
if(itemStacks != null)
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
package at.pcgamingfreaks.Minepacks.Bukkit.Listener;
|
||||
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.API.Callback;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Backpack;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Helper.WorldBlacklistMode;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
|
||||
|
@ -247,10 +247,10 @@ public void openBackpack(@NotNull final Player opener, @Nullable final Backpack
|
||||
public void openBackpack(@NotNull Player opener, @NotNull OfflinePlayer owner, boolean editable, @Nullable String title)
|
||||
{
|
||||
Validate.notNull(owner);
|
||||
database.getBackpack(owner, new Callback<at.pcgamingfreaks.Minepacks.Bukkit.Backpack>()
|
||||
database.getBackpack(owner, new Callback<Backpack>()
|
||||
{
|
||||
@Override
|
||||
public void onResult(at.pcgamingfreaks.Minepacks.Bukkit.Backpack backpack)
|
||||
public void onResult(Backpack backpack)
|
||||
{
|
||||
openBackpack(opener, backpack, editable, title);
|
||||
}
|
||||
@ -289,13 +289,13 @@ public void openBackpack(@NotNull Player opener, @Nullable Backpack backpack, bo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBackpack(@NotNull OfflinePlayer owner, @NotNull Callback<at.pcgamingfreaks.Minepacks.Bukkit.Backpack> callback)
|
||||
public void getBackpack(@NotNull OfflinePlayer owner, @NotNull Callback<Backpack> callback)
|
||||
{
|
||||
database.getBackpack(owner, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getBackpack(@NotNull final OfflinePlayer owner, @NotNull final Callback<at.pcgamingfreaks.Minepacks.Bukkit.Backpack> callback, boolean createNewIfNotExists)
|
||||
public void getBackpack(@NotNull final OfflinePlayer owner, @NotNull final Callback<Backpack> callback, boolean createNewIfNotExists)
|
||||
{
|
||||
database.getBackpack(owner, callback, createNewIfNotExists);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user