mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Add experimental placeholder support
This commit is contained in:
parent
ac761a4b9b
commit
070d7d8944
@ -64,7 +64,7 @@ public ItemsCollector(Minepacks plugin)
|
|||||||
itemFilter = plugin.getItemFilter();
|
itemFilter = plugin.getItemFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canUseAutoPickup(Player player)
|
public boolean canUseAutoPickup(Player player)
|
||||||
{
|
{
|
||||||
// Check if player can use in world
|
// Check if player can use in world
|
||||||
if(plugin.isDisabled(player) != WorldBlacklistMode.None) return false;
|
if(plugin.isDisabled(player) != WorldBlacklistMode.None) return false;
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Language;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Database.Language;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.ItemFilter;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.ItemFilter;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.*;
|
import at.pcgamingfreaks.Minepacks.Bukkit.Listener.*;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Placeholder.PlaceholderManager;
|
||||||
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.NoDatabaseWorker;
|
import at.pcgamingfreaks.Minepacks.Bukkit.SpecialInfoWorker.NoDatabaseWorker;
|
||||||
import at.pcgamingfreaks.Minepacks.MagicValues;
|
import at.pcgamingfreaks.Minepacks.MagicValues;
|
||||||
import at.pcgamingfreaks.Plugin.IPlugin;
|
import at.pcgamingfreaks.Plugin.IPlugin;
|
||||||
@ -79,6 +80,7 @@ public class Minepacks extends JavaPlugin implements MinepacksPlugin, IPlugin
|
|||||||
private ItemFilter itemFilter = null;
|
private ItemFilter itemFilter = null;
|
||||||
private Sound openSound = null;
|
private Sound openSound = null;
|
||||||
private ItemShortcut shortcut = null;
|
private ItemShortcut shortcut = null;
|
||||||
|
@Getter private PlaceholderManager placeholderManager = null;
|
||||||
|
|
||||||
public static Minepacks getInstance()
|
public static Minepacks getInstance()
|
||||||
{
|
{
|
||||||
@ -230,6 +232,8 @@ private void load()
|
|||||||
if(config.getCommandCooldown() > 0) cooldownManager = new CooldownManager(this);
|
if(config.getCommandCooldown() > 0) cooldownManager = new CooldownManager(this);
|
||||||
|
|
||||||
openSound = config.getOpenSound();
|
openSound = config.getOpenSound();
|
||||||
|
|
||||||
|
placeholderManager = new PlaceholderManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unload()
|
private void unload()
|
||||||
@ -240,6 +244,7 @@ private void unload()
|
|||||||
inventoryClearCommand.close();
|
inventoryClearCommand.close();
|
||||||
inventoryClearCommand = null;
|
inventoryClearCommand = null;
|
||||||
}
|
}
|
||||||
|
if (placeholderManager != null) { placeholderManager.close(); placeholderManager = null; }
|
||||||
if(collector != null) collector.close();
|
if(collector != null) collector.close();
|
||||||
if(commandManager != null) commandManager.close();
|
if(commandManager != null) commandManager.close();
|
||||||
if(collector != null) collector.cancel();
|
if(collector != null) collector.cancel();
|
||||||
@ -408,7 +413,8 @@ public boolean isBackpackItem(final @Nullable ItemStack itemStack)
|
|||||||
return shortcut.isItemShortcut(itemStack);
|
return shortcut.isItemShortcut(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemsCollector getItemsCollector() {
|
public ItemsCollector getItemsCollector()
|
||||||
|
{
|
||||||
return collector;
|
return collector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.Placeholder;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Placeholder.Replacer.AutoPickupEnabled;
|
||||||
|
|
||||||
|
public final class PlaceholderManager extends at.pcgamingfreaks.Bukkit.Placeholder.PlaceholderManager
|
||||||
|
{
|
||||||
|
public PlaceholderManager(Minepacks plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void generatePlaceholdersMap()
|
||||||
|
{
|
||||||
|
Minepacks plugin = (Minepacks) getPlugin();
|
||||||
|
registerPlaceholder(new AutoPickupEnabled(plugin));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2023 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.Placeholder.Replacer;
|
||||||
|
|
||||||
|
import at.pcgamingfreaks.Bukkit.Placeholder.PlaceholderName;
|
||||||
|
import at.pcgamingfreaks.Bukkit.Placeholder.PlaceholderReplacerBase;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.ItemsCollector;
|
||||||
|
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||||
|
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@PlaceholderName(aliases = "IsAutoPickupEnabled")
|
||||||
|
public class AutoPickupEnabled extends PlaceholderReplacerBase
|
||||||
|
{
|
||||||
|
private final Minepacks plugin;
|
||||||
|
|
||||||
|
public AutoPickupEnabled(Minepacks mp)
|
||||||
|
{
|
||||||
|
this.plugin = mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable String replace(OfflinePlayer player)
|
||||||
|
{
|
||||||
|
ItemsCollector collector = plugin.getItemsCollector();
|
||||||
|
if (collector != null)
|
||||||
|
{
|
||||||
|
if (player instanceof Player)
|
||||||
|
{
|
||||||
|
return collector.canUseAutoPickup((Player) player) ? "true" : "false";
|
||||||
|
}
|
||||||
|
return "offline";
|
||||||
|
}
|
||||||
|
return "disabled";
|
||||||
|
}
|
||||||
|
}
|
6
pom.xml
6
pom.xml
@ -7,13 +7,13 @@
|
|||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<revision>2.4.21.1</revision>
|
<revision>2.4.22-SNAPSHOT</revision>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
|
||||||
<configFileVersion>34</configFileVersion>
|
<configFileVersion>34</configFileVersion>
|
||||||
<languageFileVersion>20</languageFileVersion>
|
<languageFileVersion>20</languageFileVersion>
|
||||||
<pcgfPluginLibVersion>1.0.39-SNAPSHOT</pcgfPluginLibVersion>
|
<pcgfPluginLibVersion>1.0.39.1-SNAPSHOT</pcgfPluginLibVersion>
|
||||||
|
|
||||||
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
|
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
|
||||||
<mavenShade.version>3.4.1</mavenShade.version>
|
<mavenShade.version>3.4.1</mavenShade.version>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</ciManagement>
|
</ciManagement>
|
||||||
|
|
||||||
<name>Minepacks-Parent</name>
|
<name>Minepacks-Parent</name>
|
||||||
<description>Minepacks is a backpack plugin with different backpack sizes, multi language support and SQLite and MySQL storage support.</description>
|
<description>Minepacks is a backpack plugin with different backpack sizes, multi-language support and SQLite and MySQL storage support.</description>
|
||||||
<url>https://www.spigotmc.org/resources/19286/</url>
|
<url>https://www.spigotmc.org/resources/19286/</url>
|
||||||
<inceptionYear>2014</inceptionYear>
|
<inceptionYear>2014</inceptionYear>
|
||||||
<licenses>
|
<licenses>
|
||||||
|
Loading…
Reference in New Issue
Block a user