mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-10 19:25:11 +00:00
Add more inventory commands (#3704)
Add more commands to access virtual crafting inventories (on platforms with the required APIs). Closes #3195 and #108.
This commit is contained in:
parent
1bd8d1c85c
commit
af1d068022
13 changed files with 253 additions and 1 deletions
|
@ -47,6 +47,7 @@ import net.ess3.api.ISettings;
|
|||
import net.ess3.nms.refl.providers.ReflServerStateProvider;
|
||||
import net.ess3.nms.refl.providers.ReflSpawnEggProvider;
|
||||
import net.ess3.nms.refl.providers.ReflSpawnerBlockProvider;
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import net.ess3.provider.PotionMetaProvider;
|
||||
import net.ess3.provider.ProviderListener;
|
||||
import net.ess3.provider.ServerStateProvider;
|
||||
|
@ -59,6 +60,7 @@ import net.ess3.provider.providers.BukkitSpawnerBlockProvider;
|
|||
import net.ess3.provider.providers.FlatSpawnEggProvider;
|
||||
import net.ess3.provider.providers.LegacyPotionMetaProvider;
|
||||
import net.ess3.provider.providers.LegacySpawnEggProvider;
|
||||
import net.ess3.provider.providers.PaperContainerProvider;
|
||||
import net.ess3.provider.providers.PaperRecipeBookListener;
|
||||
import net.ess3.provider.providers.PaperServerStateProvider;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -131,6 +133,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||
private transient SpawnEggProvider spawnEggProvider;
|
||||
private transient PotionMetaProvider potionMetaProvider;
|
||||
private transient ServerStateProvider serverStateProvider;
|
||||
private transient ContainerProvider containerProvider;
|
||||
private transient ProviderListener recipeBookEventProvider;
|
||||
private transient Kits kits;
|
||||
private transient RandomTeleport randomTeleport;
|
||||
|
@ -300,8 +303,10 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||
}
|
||||
|
||||
//Server State Provider
|
||||
//Container Provider
|
||||
if (PaperLib.isPaper() && VersionUtil.getServerBukkitVersion().isHigherThanOrEqualTo(VersionUtil.v1_15_2_R01)) {
|
||||
serverStateProvider = new PaperServerStateProvider();
|
||||
containerProvider = new PaperContainerProvider();
|
||||
} else {
|
||||
serverStateProvider = new ReflServerStateProvider(getLogger());
|
||||
}
|
||||
|
@ -1003,6 +1008,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||
return serverStateProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerProvider getContainerProvider() {
|
||||
return containerProvider;
|
||||
}
|
||||
|
||||
private AbstractItemDb getItemDbFromConfig() {
|
||||
final String setting = settings.getItemDbType();
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.earth2me.essentials.api.IItemDb;
|
|||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.api.IWarps;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import net.ess3.provider.ServerStateProvider;
|
||||
import net.ess3.provider.SpawnerBlockProvider;
|
||||
import net.ess3.provider.SpawnerItemProvider;
|
||||
|
@ -112,4 +113,6 @@ public interface IEssentials extends Plugin {
|
|||
SpawnerBlockProvider getSpawnerBlockProvider();
|
||||
|
||||
ServerStateProvider getServerStateProvider();
|
||||
|
||||
ContainerProvider getContainerProvider();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandanvil extends EssentialsCommand {
|
||||
|
||||
public Commandanvil() {
|
||||
super("anvil");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openAnvil(user.getBase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandcartographytable extends EssentialsCommand {
|
||||
|
||||
public Commandcartographytable() {
|
||||
super("cartographytable");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openCartographyTable(user.getBase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandgrindstone extends EssentialsCommand {
|
||||
|
||||
public Commandgrindstone() {
|
||||
super("grindstone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openGrindstone(user.getBase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandloom extends EssentialsCommand {
|
||||
|
||||
public Commandloom() {
|
||||
super("loom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openLoom(user.getBase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandsmithingtable extends EssentialsCommand {
|
||||
|
||||
public Commandsmithingtable() {
|
||||
super("smithingtable");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openSmithingTable(user.getBase());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
|
||||
public class Commandstonecutter extends EssentialsCommand {
|
||||
|
||||
public Commandstonecutter() {
|
||||
super("stonecutter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception {
|
||||
if (ess.getContainerProvider() == null) {
|
||||
user.sendMessage(tl("unsupportedBrand"));
|
||||
return;
|
||||
}
|
||||
|
||||
ess.getContainerProvider().openStonecutter(user.getBase());
|
||||
}
|
||||
}
|
|
@ -21,6 +21,8 @@ antiBuildPlace=\u00a74You are not permitted to place\u00a7c {0} \u00a74here.
|
|||
antiBuildUse=\u00a74You are not permitted to use\u00a7c {0}\u00a74.
|
||||
antiochCommandDescription=A little surprise for operators.
|
||||
antiochCommandUsage=/<command> [message]
|
||||
anvilCommandDescription=Opens up an anvil.
|
||||
anvilCommandUsage=/<command>
|
||||
autoAfkKickReason=You have been kicked for idling more than {0} minutes.
|
||||
autoTeleportDisabled=\u00a76You are no longer automatically approving teleport requests.
|
||||
autoTeleportDisabledFor=\u00a7c{0}\u00a76 is no longer automatically approving teleport requests.
|
||||
|
@ -90,6 +92,8 @@ cantFindGeoIpDB=Can''t find GeoIP database\!
|
|||
cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
cantReadGeoIpDB=Failed to read GeoIP database\!
|
||||
cantSpawnItem=\u00a74You are not allowed to spawn the item\u00a7c {0}\u00a74.
|
||||
cartographytableCommandDescription=Opens up a cartography table.
|
||||
cartographytableCommandUsage=/<command>
|
||||
chatTypeLocal=[L]
|
||||
chatTypeSpy=[Spy]
|
||||
cleaned=Userfiles Cleaned.
|
||||
|
@ -251,6 +255,8 @@ giveSpawnFailure=\u00a74Not enough space, \u00a7c{0} {1} \u00a74was lost.
|
|||
godDisabledFor=\u00a7cdisabled\u00a76 for\u00a7c {0}
|
||||
godEnabledFor=\u00a7aenabled\u00a76 for\u00a7c {0}
|
||||
godMode=\u00a76God mode\u00a7c {0}\u00a76.
|
||||
grindstoneCommandDescription=Opens up a grindstone.
|
||||
grindstoneCommandUsage=/<command>
|
||||
groupDoesNotExist=\u00a74There''s no one online in this group\!
|
||||
groupNumber=\u00a7c{0}\u00a7f online, for the full list\:\u00a7c /{1} {2}
|
||||
hatArmor=\u00a74You cannot use this item as a hat\!
|
||||
|
@ -417,6 +423,8 @@ listHiddenTag=\u00a77[HIDDEN]\u00a7r
|
|||
loadWarpError=\u00a74Failed to load warp {0}.
|
||||
localFormat=[L]<{0}> {1}
|
||||
localNoOne=
|
||||
loomCommandDescription=Opens up a loom.
|
||||
loomCommandUsage=/<command>
|
||||
mailClear=\u00a76To clear your mail, type\u00a7c /mail clear\u00a76.
|
||||
mailCleared=\u00a76Mail cleared\!
|
||||
mailCommandDescription=Manages inter-player, intra-server mail.
|
||||
|
@ -737,6 +745,8 @@ skullChanged=\u00a76Skull changed to \u00a7c{0}\u00a76.
|
|||
skullCommandDescription=Set the owner of a player skull
|
||||
skullCommandUsage=/<command> [owner]
|
||||
slimeMalformedSize=\u00a74Malformed size.
|
||||
smithingtableCommandDescription=Opens up a smithing table.
|
||||
smithingtableCommandUsage=/<command>
|
||||
socialSpy=\u00a76SocialSpy for \u00a7c{0}\u00a76\: \u00a7c{1}
|
||||
socialSpyMsgFormat=\u00a76[\u00a7c{0}\u00a77 -> \u00a7c{1}\u00a76] \u00a77{2}
|
||||
socialSpyMutedPrefix=\u00a7f[\u00a76SS\u00a7f] \u00a77(muted) \u00a7r
|
||||
|
@ -753,6 +763,8 @@ spawnSet=\u00a76Spawn location set for group\u00a7c {0}\u00a76.
|
|||
spectator=spectator
|
||||
speedCommandDescription=Change your speed limits.
|
||||
speedCommandUsage=/<command> [type] <speed> [player]
|
||||
stonecutterCommandDescription=Opens up a stonecutter.
|
||||
stonecutterCommandUsage=/<command>
|
||||
sudoCommandDescription=Make another user perform a command.
|
||||
sudoCommandUsage=/<command> <player> <command [args]>
|
||||
sudoExempt=\u00a74You cannot sudo \u00a7c{0}.
|
||||
|
@ -879,6 +891,7 @@ unlimitedItemPermission=\u00a74No permission for unlimited item \u00a7c{0}\u00a7
|
|||
unlimitedItems=\u00a76Unlimited items\:\u00a7r
|
||||
unmutedPlayer=\u00a76Player\u00a7c {0} \u00a76unmuted.
|
||||
unsafeTeleportDestination=\u00a74The teleport destination is unsafe and teleport-safety is disabled.
|
||||
unsupportedBrand=\u00a74The server platform you are currently running does not provide the capabilities for this feature.
|
||||
unsupportedFeature=\u00a74This feature is not supported on the current server version.
|
||||
unvanishedReload=\u00a74A reload has forced you to become visible.
|
||||
upgradingFilesError=Error while upgrading the files.
|
||||
|
|
|
@ -17,6 +17,10 @@ commands:
|
|||
description: 'A little surprise for operators.'
|
||||
usage: /<command> [message]
|
||||
aliases: [eantioch,grenade,egrenade,tnt,etnt]
|
||||
anvil:
|
||||
description: Opens up an Anvil.
|
||||
usage: /<command>
|
||||
aliases: [eanvil]
|
||||
back:
|
||||
description: Teleports you to your location prior to tp/spawn/warp.
|
||||
usage: /<command> [player]
|
||||
|
@ -69,6 +73,10 @@ commands:
|
|||
description: Set a player on fire.
|
||||
usage: /<command> <player> <seconds>
|
||||
aliases: [eburn]
|
||||
cartographytable:
|
||||
description: Opens up a cartography table.
|
||||
usage: /<command>
|
||||
aliases: [ecartographytable, carttable, ecarttable]
|
||||
clearinventory:
|
||||
description: Clear all items in your inventory.
|
||||
usage: /<command> [player|*] [item[:<data>]|*|**] [amount]
|
||||
|
@ -176,6 +184,10 @@ commands:
|
|||
description: Enables your godly powers.
|
||||
usage: /<command> [player] [on|off]
|
||||
aliases: [egod,godmode,egodmode,tgm,etgm]
|
||||
grindstone:
|
||||
description: Opens up a grindstone.
|
||||
usage: /<command>
|
||||
aliases: [egrindstone]
|
||||
hat:
|
||||
description: Get some cool new headgear.
|
||||
usage: /<command> [remove]
|
||||
|
@ -260,6 +272,10 @@ commands:
|
|||
description: List all online players.
|
||||
usage: /<command> [group]
|
||||
aliases: [elist,online,eonline,playerlist,eplayerlist,plist,eplist,who,ewho]
|
||||
loom:
|
||||
description: Opens up a loom.
|
||||
usage: /<command>
|
||||
aliases: [eloom]
|
||||
mail:
|
||||
description: Manages inter-player, intra-server mail.
|
||||
usage: /<command> [read|clear|send [to] [message]|sendall [message]]
|
||||
|
@ -412,6 +428,10 @@ commands:
|
|||
description: Set the owner of a player skull
|
||||
usage: /<command> [owner]
|
||||
aliases: [eskull, playerskull, eplayerskull, head, ehead]
|
||||
smithingtable:
|
||||
description: Opens up a smithing table.
|
||||
usage: /<command>
|
||||
aliases: [esmithingtable, smithtable, esmithtable]
|
||||
socialspy:
|
||||
description: Toggles if you can see msg/mail commands in chat.
|
||||
usage: /<command> [player] [on|off]
|
||||
|
@ -428,6 +448,10 @@ commands:
|
|||
description: Change your speed limits.
|
||||
usage: /<command> [type] <speed> [player]
|
||||
aliases: [flyspeed,eflyspeed,fspeed,efspeed,espeed,walkspeed,ewalkspeed,wspeed,ewspeed]
|
||||
stonecutter:
|
||||
description: Opens up a stonecutter.
|
||||
usage: /<command>
|
||||
aliases: [estonecutter]
|
||||
sudo:
|
||||
description: Make another user perform a command.
|
||||
usage: /<command> <player> <command [args]>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package net.ess3.provider;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
public interface ContainerProvider extends Provider {
|
||||
|
||||
InventoryView openAnvil(Player player);
|
||||
|
||||
InventoryView openCartographyTable(Player player);
|
||||
|
||||
InventoryView openGrindstone(Player player);
|
||||
|
||||
InventoryView openLoom(Player player);
|
||||
|
||||
InventoryView openSmithingTable(Player player);
|
||||
|
||||
InventoryView openStonecutter(Player player);
|
||||
|
||||
}
|
|
@ -28,7 +28,7 @@
|
|||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package net.ess3.provider.providers;
|
||||
|
||||
import net.ess3.provider.ContainerProvider;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
public class PaperContainerProvider implements ContainerProvider {
|
||||
|
||||
@Override
|
||||
public InventoryView openAnvil(Player player) {
|
||||
return player.openAnvil(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openCartographyTable(Player player) {
|
||||
return player.openCartographyTable(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openGrindstone(Player player) {
|
||||
return player.openGrindstone(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openLoom(Player player) {
|
||||
return player.openLoom(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openSmithingTable(Player player) {
|
||||
return player.openSmithingTable(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openStonecutter(Player player) {
|
||||
return player.openStonecutter(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Paper Container Opening Provider";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue