@@ -20,14 +20,15 @@ public class BukkitDupePlusCommand {
2020 public BukkitDupePlusCommand () {
2121 getPlugin ().getCommandManager ().command (
2222 getPlugin ().getCommandManager ().commandBuilder ("dupeplus" , Description .of ("DupePlus Command" ))
23+ .permission ("dupeplus.admin" )
2324 .senderType (Player .class )
2425 .handler (this ::executeHelpCommand )
2526 );
2627
2728 getPlugin ().getCommandManager ().command (
2829 getPlugin ().getCommandManager ().commandBuilder ("dupeplus" , Description .of ("DupePlus Command" ))
2930 .literal ("reload" )
30- .permission ("dupeplus.reload" )
31+ .permission ("dupeplus.admin. reload" )
3132 .senderType (Player .class )
3233 .handler (this ::executeReloadCommand )
3334 );
@@ -43,22 +44,23 @@ public BukkitDupePlusCommand() {
4344 getPlugin ().getCommandManager ().command (
4445 getPlugin ().getCommandManager ().commandBuilder ("dupeplus" , Description .of ("DupePlus Command" ))
4546 .literal ("block" )
47+ .permission ("dupeplus.block" )
4648 .senderType (Player .class )
4749 .handler (this ::executeBlockCommand )
4850 );
4951 }
5052
5153 private void executeGUICommand (CommandContext <Player > context ) {
5254 Player player = context .sender ();
53- if (player .hasPermission ("dupeplus.blocklist.gui " )) {
55+ if (player .hasPermission ("dupeplus.blocklist" )) {
5456 new BlocklistMenu ().getMenu (player ).open (player );
5557 }
5658 }
5759
5860 private void executeReloadCommand (CommandContext <Player > context ) {
5961 Player player = context .sender ();
6062 Audience p = getPlugin ().adventure ().player (player );
61- if (player .hasPermission ("dupeplus.reload" )) {
63+ if (player .hasPermission ("dupeplus.admin. reload" )) {
6264 BukkitConfigyml .reloadConfig ();
6365 p .sendMessage (MiniMessage .miniMessage ().deserialize ("<green>DupePlus</green> <dark_gray>|</dark_gray> <white>Successfully reloaded! (if command name is changed, then players will need to rejoin to see the dupe command in tab complete)</white>" ));
6466 }
@@ -81,38 +83,41 @@ private void executeHelpCommand(CommandContext<Player> context) {
8183 private void executeBlockCommand (CommandContext <Player > context ) {
8284 Player player = context .sender ();
8385 Audience p = getPlugin ().adventure ().player (player );
84-
85- if (getPlugin ().getConfig ().getString ("dupe.dupe-on" , "MainHand" ).equals ("MainHand" )) {
86- if (player .getInventory ().getItemInMainHand ().getType () == Material .AIR ) {
87- return ;
88- }
89- ItemStack itemStack = player .getInventory ().getItemInMainHand ();
90- if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
91- itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
86+ if (player .hasPermission ("dupeplus.block" )) {
87+ if (getPlugin ().getConfig ().getString ("dupe.dupe-on" , "MainHand" ).equals ("MainHand" )) {
88+ if (player .getInventory ().getItemInMainHand ().getType () == Material .AIR ) {
89+ return ;
90+ }
91+ ItemStack itemStack = player .getInventory ().getItemInMainHand ();
92+ if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
93+ itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
94+ }
95+ player .getInventory ().setItemInMainHand (itemStack );
96+
97+
98+ } else if (getPlugin ().getConfig ().getString ("dupe.dupe-on" , "MainHand" ).equals ("OffHand" )) {
99+ if (player .getInventory ().getItemInOffHand ().getType () == Material .AIR ) {
100+ return ;
101+ }
102+ ItemStack itemStack = player .getInventory ().getItemInOffHand ();
103+ if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
104+ itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
105+ }
106+ player .getInventory ().setItemInOffHand (itemStack );
107+ } else {
108+ if (player .getInventory ().getItemInMainHand ().getType () == Material .AIR ) {
109+ return ;
110+ }
111+ ItemStack itemStack = player .getInventory ().getItemInMainHand ();
112+ if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
113+ itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
114+ }
115+ player .getInventory ().setItemInMainHand (itemStack );
92116 }
93- player .getInventory ().setItemInMainHand (itemStack );
94117
95-
96- } else if (getPlugin ().getConfig ().getString ("dupe.dupe-on" , "MainHand" ).equals ("OffHand" )) {
97- if (player .getInventory ().getItemInOffHand ().getType () == Material .AIR ) {
98- return ;
99- }
100- ItemStack itemStack = player .getInventory ().getItemInOffHand ();
101- if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
102- itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
103- }
104- player .getInventory ().setItemInOffHand (itemStack );
118+ p .sendMessage (MiniMessage .miniMessage ().deserialize ("<green>DupePlus</green> <dark_gray>|</dark_gray> <white>Successfully made your item undupeable!</white>" ));
105119 } else {
106- if (player .getInventory ().getItemInMainHand ().getType () == Material .AIR ) {
107- return ;
108- }
109- ItemStack itemStack = player .getInventory ().getItemInMainHand ();
110- if (!NBTEditor .contains (itemStack , NBTEditor .CUSTOM_DATA , "dupenotallowed" )) {
111- itemStack = NBTEditor .set (itemStack , true , NBTEditor .CUSTOM_DATA , "dupenotallowed" );
112- }
113- player .getInventory ().setItemInMainHand (itemStack );
120+ p .sendMessage (MiniMessage .miniMessage ().deserialize ("<green>DupePlus</green> <dark_gray>|</dark_gray> <red>You are not allowed to use this command</red>" ));
114121 }
115-
116- p .sendMessage (MiniMessage .miniMessage ().deserialize ("<green>DupePlus</green> <dark_gray>|</dark_gray> <white>Successfully made your item undupeable!</white>" ));
117122 }
118123}
0 commit comments