-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7179f3
commit a25edff
Showing
3 changed files
with
51 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/com/rathserver/event/invisible/command/InvToolCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.rathserver.event.invisible.command; | ||
|
||
import com.rathserver.event.invisible.InvisiblePlugin; | ||
import com.rathserver.event.invisible.Items; | ||
import org.bukkit.Sound; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.PlayerInventory; | ||
|
||
/** | ||
* Created by Nekoneko on 2020/06/17. | ||
*/ | ||
public class InvToolCommand implements CommandExecutor { | ||
private final InvisiblePlugin plugin; | ||
|
||
public InvToolCommand(InvisiblePlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if (!(sender instanceof Player)) { | ||
return false; | ||
} | ||
|
||
Player player = (Player) sender; | ||
PlayerInventory inventory = player.getInventory(); | ||
if (player.hasMetadata(InvisiblePlugin.METADATA_KEY)) { | ||
inventory.addItem(Items.getInvisibleDeActiveItem().clone()); | ||
} else { | ||
inventory.addItem(Items.getInvisibleActiveItem().clone()); | ||
} | ||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1.6F, 0.5F); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters