-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.9.6 - Make NMS support 1.20.5/6, 1.21
- Loading branch information
Showing
15 changed files
with
578 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package net.danh.bsoul.Commands; | ||
|
||
import org.bukkit.command.*; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @version 1.0 | ||
*/ | ||
public abstract class CMDBase implements CommandExecutor, TabCompleter { | ||
|
||
protected JavaPlugin core; | ||
|
||
/** | ||
* @param core Plugin main class | ||
* @param name label | ||
*/ | ||
public CMDBase(JavaPlugin core, String name) { | ||
this.core = core; | ||
PluginCommand pluginCommand = core.getCommand(name); | ||
Objects.requireNonNull(pluginCommand).setExecutor(this); | ||
pluginCommand.setTabCompleter(this); | ||
} | ||
|
||
/** | ||
* @param p Player | ||
* @param args args | ||
*/ | ||
public abstract void playerexecute(Player p, String[] args); | ||
|
||
/** | ||
* @param c ConsoleCommandSender | ||
* @param args args | ||
*/ | ||
public abstract void consoleexecute(ConsoleCommandSender c, String[] args); | ||
|
||
/** | ||
* @param sender Player/Console | ||
* @param command cmd | ||
* @param label label | ||
* @param args args | ||
* @return /label args ... | ||
*/ | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if (sender instanceof Player) { | ||
playerexecute((Player) sender, args); | ||
} | ||
if (sender instanceof ConsoleCommandSender) { | ||
consoleexecute((ConsoleCommandSender) sender, args); | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* @param sender sender | ||
* @param cmd cmd | ||
* @param label label | ||
* @param args args | ||
* @return tab | ||
*/ | ||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { | ||
return TabComplete(sender, args); | ||
} | ||
|
||
/** | ||
* @param sender sender | ||
* @param args args | ||
* @return tab | ||
*/ | ||
public abstract List<String> TabComplete(CommandSender sender, String[] args); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.danh.bsoul.Manager; | ||
|
||
import org.bukkit.ChatColor; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
/** | ||
* @version 1.0 | ||
*/ | ||
public class Chat { | ||
|
||
public static String colorize(String message) { | ||
Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}"); | ||
Matcher matcher = pattern.matcher(message); | ||
while (matcher.find()) { | ||
String hexCode = message.substring(matcher.start(), matcher.end()); | ||
String replaceSharp = hexCode.replace('#', 'x'); | ||
|
||
char[] ch = replaceSharp.toCharArray(); | ||
StringBuilder builder = new StringBuilder(); | ||
for (char c : ch) { | ||
builder.append("&").append(c); | ||
} | ||
|
||
message = message.replace(hexCode, builder.toString()); | ||
matcher = pattern.matcher(message); | ||
} | ||
return ChatColor.translateAlternateColorCodes('&', message); | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
package net.danh.bsoul.Manager; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.inventory.ItemFlag; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* @version 1.0 | ||
*/ | ||
public class Items { | ||
|
||
/** | ||
* @param input List Lore | ||
* @return input with color code | ||
*/ | ||
public static List<String> Lore(List<String> input) { | ||
List<String> output = new ArrayList<>(); | ||
for (String string : input) { | ||
output.add(Chat.colorize(string)); | ||
} | ||
return output; | ||
} | ||
|
||
/** | ||
* @param material Material | ||
* @param data Data (For legacy version 1.12.x and below) | ||
* @param amount int | ||
* @param glow true/false | ||
* @param HideFlag true/false | ||
* @param Unbreakable true/false | ||
* @param name Item name | ||
* @param lore Item lore | ||
* @return ItemStack | ||
*/ | ||
public static ItemStack makeItem(Material material, Short data, Integer amount, Boolean glow, Boolean HideFlag, Boolean Unbreakable, String name, List<String> lore) { | ||
ItemStack itemStack; | ||
if (data >= 0) { | ||
itemStack = new ItemStack(material, amount); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
Objects.requireNonNull(itemMeta).setDisplayName(Chat.colorize(name)); | ||
if (lore != null) { | ||
itemMeta.setLore(Lore(lore)); | ||
} | ||
if (glow) { | ||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true); | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); | ||
} | ||
if (HideFlag) { | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE); | ||
} | ||
if (Unbreakable) { | ||
itemMeta.setUnbreakable(true); | ||
} | ||
itemStack.setItemMeta(itemMeta); | ||
} else { | ||
itemStack = new ItemStack(material, amount, data); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
Objects.requireNonNull(itemMeta).setDisplayName(Chat.colorize(name)); | ||
if (lore != null) { | ||
itemMeta.setLore(Lore(lore)); | ||
} | ||
if (glow) { | ||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true); | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); | ||
} | ||
if (HideFlag) { | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE); | ||
} | ||
if (Unbreakable) { | ||
itemMeta.setUnbreakable(true); | ||
} | ||
itemStack.setItemMeta(itemMeta); | ||
} | ||
return itemStack; | ||
} | ||
|
||
/** | ||
* @param material Material | ||
* @param data Data (For legacy version 1.13 below), null if you use 1.13+ | ||
* @param amount int | ||
* @param glow true/false | ||
* @param HideFlag true/false | ||
* @param Unbreakable true/false | ||
* @param name Item name | ||
* @param lore Item lore | ||
* @return ItemStack | ||
*/ | ||
public static ItemStack makeItem(Material material, Short data, Integer amount, Boolean glow, Boolean HideFlag, Boolean Unbreakable, String name, String... lore) { | ||
ItemStack itemStack; | ||
if (data == null) { | ||
itemStack = new ItemStack(material, amount); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
Objects.requireNonNull(itemMeta).setDisplayName(Chat.colorize(name)); | ||
if (lore != null) { | ||
List<String> l = new ArrayList<>(); | ||
for (String lores : lore) { | ||
l.add(Chat.colorize(lores)); | ||
} | ||
itemMeta.setLore(Lore(l)); | ||
} | ||
if (glow) { | ||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true); | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); | ||
} | ||
if (HideFlag) { | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE); | ||
} | ||
if (Unbreakable) { | ||
itemMeta.setUnbreakable(true); | ||
} | ||
itemStack.setItemMeta(itemMeta); | ||
} else { | ||
itemStack = new ItemStack(material, amount, data); | ||
ItemMeta itemMeta = itemStack.getItemMeta(); | ||
Objects.requireNonNull(itemMeta).setDisplayName(Chat.colorize(name)); | ||
if (lore != null) { | ||
List<String> l = new ArrayList<>(); | ||
for (String lores : lore) { | ||
l.add(Chat.colorize(lores)); | ||
} | ||
itemMeta.setLore(l); | ||
} | ||
if (glow) { | ||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true); | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS); | ||
} | ||
if (HideFlag) { | ||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_UNBREAKABLE); | ||
} | ||
if (Unbreakable) { | ||
itemMeta.setUnbreakable(true); | ||
} | ||
itemStack.setItemMeta(itemMeta); | ||
} | ||
return itemStack; | ||
} | ||
|
||
} |
Oops, something went wrong.