-
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
Showing
7 changed files
with
270 additions
and
55 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
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
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
90 changes: 90 additions & 0 deletions
90
src/main/java/me/lanzhi/bluestargame/commands/bluestaritem.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,90 @@ | ||
package me.lanzhi.bluestargame.commands; | ||
|
||
import de.tr7zw.nbtapi.NBTItem; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabExecutor; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class bluestaritem implements CommandExecutor, TabExecutor | ||
{ | ||
String messagehead = ChatColor.GOLD+"[BluestarGame]"; | ||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) | ||
{ | ||
if (!(sender instanceof Player)) | ||
{ | ||
sender.sendMessage(ChatColor.RED + "此命令仅允许玩家输入!"); | ||
return false; | ||
} | ||
Player player=(Player) sender; | ||
if ("watersponge".equals(args[0])) | ||
{ | ||
if (player.getInventory().getItemInMainHand().getType().isAir()) | ||
{ | ||
player.sendMessage(messagehead+ChatColor.RED + "请手持任意物品"); | ||
return false; | ||
} | ||
if (!player.getInventory().getItemInMainHand().getType().isBlock()) | ||
{ | ||
player.sendMessage(messagehead+ChatColor.RED + "检测到您手持的物品不是方块,可能无法放置使得超级海绵生效"); | ||
} | ||
NBTItem item = new NBTItem(player.getInventory().getItemInMainHand()); | ||
item.addCompound("BluestarGame").setBoolean("waterSponge",true); | ||
player.getInventory().setItemInMainHand(item.getItem()); | ||
player.sendMessage(messagehead+ChatColor.GREEN+"已为您手持的物品添加\"超级海绵\"属性"); | ||
return true; | ||
} | ||
if ("lavasponge".equals(args[0])) | ||
{ | ||
if (player.getInventory().getItemInMainHand().getType().isAir()) | ||
{ | ||
player.sendMessage(messagehead+ChatColor.RED + "请手持任意物品"); | ||
return false; | ||
} | ||
if (!player.getInventory().getItemInMainHand().getType().isBlock()) | ||
{ | ||
player.sendMessage(messagehead+ChatColor.RED + "检测到您手持的物品不是方块,可能无法放置使得超级海绵生效"); | ||
} | ||
NBTItem item = new NBTItem(player.getInventory().getItemInMainHand()); | ||
item.addCompound("BluestarGame").setBoolean("lavasponge",true); | ||
player.getInventory().setItemInMainHand(item.getItem()); | ||
player.sendMessage(messagehead+ChatColor.GREEN+"已为您手持的物品添加\"岩浆海绵\"属性"); | ||
return true; | ||
} | ||
if ("sword".equals(args[0])) | ||
{ | ||
if (player.getInventory().getItemInMainHand().getType().isAir()) | ||
{ | ||
player.sendMessage(messagehead+ChatColor.RED + "请手持任意物品"); | ||
return false; | ||
} | ||
NBTItem item = new NBTItem(player.getInventory().getItemInMainHand()); | ||
item.addCompound("BluestarGame").setBoolean("sword",true); | ||
player.getInventory().setItemInMainHand(item.getItem()); | ||
player.sendMessage(messagehead+ChatColor.GREEN+"已为您手持的物品添加\"op剑\"属性"); | ||
return true; | ||
} | ||
sender.sendMessage(ChatColor.RED +"格式错误!"); | ||
return false; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) | ||
{ | ||
List<String>tablist =new ArrayList<>(); | ||
tablist.add("watersponge"); | ||
tablist.add("lavasponge"); | ||
tablist.add("sword"); | ||
return tablist; | ||
} | ||
} |
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
Oops, something went wrong.