[1.15.2.a.6] Added chest opening sound and customizeable GUI
This commit is contained in:
parent
95f105707c
commit
09e7085979
2
.project
2
.project
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Spigot_EnderBank</name>
|
||||
<name>Spigot_EnderBank2</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
||||
63
config.yml
63
config.yml
@ -19,9 +19,70 @@ Must_Look_At_Chest_To_Search: true
|
||||
#the chest" experience despite actually exiting their bank
|
||||
#to enter their search term in the chat.
|
||||
|
||||
Enable_Open_Bank_Noise: true
|
||||
#Enable this to play a noise upon opening a player's bank
|
||||
#It currently plays every time the first page is opened as this
|
||||
#is the only way it can work with the way the backend saves
|
||||
#the inventories and opens other pages.
|
||||
|
||||
Open_Bank_Noise: "BLOCK_ENDER_CHEST_OPEN"
|
||||
#This is the correct name for the noise in 1.15.2
|
||||
#If you'd like to use a different noise or run a different minecraft
|
||||
#version, check documentation for exact sound name.
|
||||
|
||||
Open_Bank_Noise_Global: true
|
||||
#If this is true, then the noise made upon opening a players'
|
||||
#bank will be heard by all nearby players. If false, only
|
||||
#the player opening the bank will hear it.
|
||||
|
||||
##########################################################
|
||||
# GUI Items #
|
||||
##########################################################
|
||||
|
||||
#Syntax:
|
||||
#%eb_pagecost% -> Cost of next page
|
||||
|
||||
GUI:
|
||||
Next_Page:
|
||||
id: PAPER
|
||||
name: "Next Page"
|
||||
Buy_Next_Page:
|
||||
id: PAPER
|
||||
name: "Next Page"
|
||||
lore:
|
||||
- "&rClick to Purchase"
|
||||
- "&rCost: %eb_pagecost%"
|
||||
Confirm_Buy_Next_Page:
|
||||
id: YELLOW_STAINED_GLASS_PANE
|
||||
name: "Confirm Purchase"
|
||||
lore:
|
||||
- "&r&oClick again to confirm purchase!"
|
||||
Previous_Page:
|
||||
id: PAPER
|
||||
name: "Previous Page"
|
||||
Dump_Equipment:
|
||||
id: IRON_HELMET
|
||||
name: "Dump Equipment"
|
||||
flags:
|
||||
- HIDE_ATTRIBUTES
|
||||
Dump_Items:
|
||||
id: CHEST
|
||||
name: "Dump Items"
|
||||
lore:
|
||||
- "&r&7Left click to dump all items in inventory (excluding the hotbar)"
|
||||
- "&r&7Right click to dump all items in inventory (including the hotbar)"
|
||||
Search:
|
||||
id: COMPASS
|
||||
name: "Search"
|
||||
Separator:
|
||||
id: BLACK_STAINED_GLASS_PANE
|
||||
name: " "
|
||||
flags:
|
||||
- HIDE_ATTRIBUTES
|
||||
|
||||
##########################################################
|
||||
# Version #
|
||||
##########################################################
|
||||
|
||||
VERSION: 2
|
||||
VERSION: 3
|
||||
#Do not touch this. No touchy.
|
||||
@ -1,6 +1,6 @@
|
||||
name: "EnderBank"
|
||||
author: TheTealViper
|
||||
version: "1.15.2.a.5"
|
||||
version: "1.15.2.a.6"
|
||||
api-version: 1.13
|
||||
description: "Bank system from popular RPG's."
|
||||
main: me.TheTealViper.enderbank.EnderBank
|
||||
|
||||
@ -7,12 +7,11 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@ -69,6 +68,14 @@ public class BankStorage {
|
||||
}
|
||||
|
||||
public void openPage(int page, Player opener) {
|
||||
if(page == 1 && EnderBank.plugin.getConfig().getBoolean("Enable_Open_Bank_Noise")) {
|
||||
if(EnderBank.plugin.getConfig().getBoolean("Open_Bank_Noise_Global")) {
|
||||
opener.getWorld().playSound(opener.getLocation(), Sound.valueOf(EnderBank.plugin.getConfig().getString("Open_Bank_Noise")), 1, 1);
|
||||
}else {
|
||||
opener.playSound(opener.getLocation(), Sound.valueOf(EnderBank.plugin.getConfig().getString("Open_Bank_Noise")), 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
openBankDatabase.put(opener, this);
|
||||
Inventory inv = Bukkit.createInventory(null, 54, Bukkit.getOfflinePlayer(bankOwnerUUID).getName() + "'s Bank [Pg. " + page + "]");
|
||||
|
||||
@ -87,54 +94,25 @@ public class BankStorage {
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack nextPage = new ItemStack(Material.PAPER);
|
||||
ItemMeta nextPageMeta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
List<String> nextPageLore = new ArrayList<String>();
|
||||
if(unlockedPages > page) {
|
||||
nextPageMeta.setDisplayName("Next Page");
|
||||
nextPage.setItemMeta(nextPageMeta);
|
||||
}else {
|
||||
nextPageMeta.setDisplayName("Next Page");
|
||||
nextPageLore.add(ChatColor.RESET + "Click to Purchase");
|
||||
nextPageLore.add(ChatColor.RESET + "Cost: " + getPageCost(page + 1));
|
||||
nextPageMeta.setLore(nextPageLore);
|
||||
nextPage.setItemMeta(nextPageMeta);
|
||||
}
|
||||
inv.setItem(8, nextPage);
|
||||
|
||||
ItemStack previousPage = new ItemStack(Material.PAPER);
|
||||
ItemMeta previousPageMeta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
previousPageMeta.setDisplayName("Previous Page");
|
||||
previousPage.setItemMeta(previousPageMeta);
|
||||
ItemStack NextPage = null;
|
||||
if(unlockedPages > page) {
|
||||
NextPage = CustomItemHandler.GetNextPage();
|
||||
}else {
|
||||
NextPage = CustomItemHandler.formatLoreSyntax(CustomItemHandler.GetBuyNextPage(), bankOwnerUUID);
|
||||
}
|
||||
inv.setItem(8, NextPage);
|
||||
|
||||
ItemStack previousPage = CustomItemHandler.GetPreviousPage();
|
||||
inv.setItem(17, previousPage);
|
||||
|
||||
ItemStack dumpEquipment = new ItemStack(Material.IRON_HELMET);
|
||||
ItemMeta dumpEquipmentMeta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
List<String> dumpEquipmentLore = new ArrayList<String>();
|
||||
dumpEquipmentLore.add(ChatColor.RESET + "" + ChatColor.GRAY + "Click to dump all equipment");
|
||||
dumpEquipmentMeta.setDisplayName("Dump Equipment");
|
||||
dumpEquipmentMeta.setLore(dumpEquipmentLore);
|
||||
dumpEquipmentMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
dumpEquipment.setItemMeta(dumpEquipmentMeta);
|
||||
ItemStack dumpEquipment = CustomItemHandler.GetDumpEquipment();
|
||||
inv.setItem(35, dumpEquipment);
|
||||
|
||||
ItemStack dumpItems = new ItemStack(Material.CHEST);
|
||||
ItemMeta dumpItemsMeta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
List<String> dumpItemsLore = new ArrayList<String>();
|
||||
dumpItemsLore.add(ChatColor.RESET + "" + ChatColor.GRAY + "Left click to dump all items in inventory (excluding the hotbar)");
|
||||
dumpItemsLore.add(ChatColor.RESET + "" + ChatColor.GRAY + "Right click to dump all items in inventory (including the hotbar)");
|
||||
dumpItemsMeta.setDisplayName("Dump Items");
|
||||
dumpItemsMeta.setLore(dumpItemsLore);
|
||||
dumpItems.setItemMeta(dumpItemsMeta);
|
||||
ItemStack dumpItems = CustomItemHandler.GetDumpItems();
|
||||
inv.setItem(44, dumpItems);
|
||||
|
||||
ItemStack search = new ItemStack(Material.COMPASS);
|
||||
ItemMeta searchMeta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
List<String> searchLore = new ArrayList<String>();
|
||||
searchLore.add(ChatColor.RESET + "" + ChatColor.GRAY + "Click to search your bank");
|
||||
searchMeta.setDisplayName("Search");
|
||||
searchMeta.setLore(searchLore);
|
||||
search.setItemMeta(searchMeta);
|
||||
ItemStack search = CustomItemHandler.GetSearch();
|
||||
inv.setItem(53, search);
|
||||
|
||||
for(int row = 0;row < 6;row++) {
|
||||
|
||||
@ -1,11 +1,17 @@
|
||||
package me.TheTealViper.enderbank;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.TheTealViper.enderbank.utils.ItemCreator;
|
||||
|
||||
public class CustomItemHandler implements Listener{
|
||||
|
||||
public static EnderBank plugin;
|
||||
@ -25,7 +31,107 @@ public class CustomItemHandler implements Listener{
|
||||
customItem.setItemMeta(meta);
|
||||
BankSeparator = customItem;
|
||||
}
|
||||
return BankSeparator;
|
||||
return BankSeparator.clone();
|
||||
}
|
||||
|
||||
static ItemStack NextPage = null;
|
||||
public static ItemStack GetNextPage(){
|
||||
if(NextPage == null) {
|
||||
NextPage = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Next_Page"));
|
||||
}
|
||||
return NextPage.clone();
|
||||
}
|
||||
|
||||
static ItemStack BuyNextPage = null;
|
||||
public static ItemStack GetBuyNextPage(){
|
||||
if(BuyNextPage == null) {
|
||||
BuyNextPage = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Buy_Next_Page"));
|
||||
}
|
||||
return BuyNextPage.clone();
|
||||
}
|
||||
|
||||
static ItemStack ConfirmBuyNextPage = null;
|
||||
public static ItemStack GetConfirmBuyNextPage(){
|
||||
if(ConfirmBuyNextPage == null) {
|
||||
ConfirmBuyNextPage = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Confirm_Buy_Next_Page"));
|
||||
}
|
||||
return ConfirmBuyNextPage.clone();
|
||||
}
|
||||
|
||||
static ItemStack PreviousPage = null;
|
||||
public static ItemStack GetPreviousPage(){
|
||||
if(PreviousPage == null) {
|
||||
PreviousPage = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Previous_Page"));
|
||||
}
|
||||
return PreviousPage.clone();
|
||||
}
|
||||
|
||||
static ItemStack DumpEquipment = null;
|
||||
public static ItemStack GetDumpEquipment(){
|
||||
if(DumpEquipment == null) {
|
||||
DumpEquipment = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Dump_Equipment"));
|
||||
}
|
||||
return DumpEquipment.clone();
|
||||
}
|
||||
|
||||
static ItemStack DumpItems = null;
|
||||
public static ItemStack GetDumpItems(){
|
||||
if(DumpItems == null) {
|
||||
DumpItems = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Dump_Items"));
|
||||
}
|
||||
return DumpItems.clone();
|
||||
}
|
||||
|
||||
static ItemStack Search = null;
|
||||
public static ItemStack GetSearch(){
|
||||
if(Search == null) {
|
||||
Search = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Search"));
|
||||
}
|
||||
return Search.clone();
|
||||
}
|
||||
|
||||
static ItemStack Separator = null;
|
||||
public static ItemStack GetSeparator(){
|
||||
if(Separator == null) {
|
||||
Separator = ItemCreator.createItemFromConfiguration(EnderBank.plugin.getConfig().getConfigurationSection("GUI.Separator"));
|
||||
}
|
||||
return Separator.clone();
|
||||
}
|
||||
|
||||
public static ItemStack formatLoreSyntax(ItemStack item, UUID uuid) {
|
||||
List<String> lore = item.hasItemMeta() && item.getItemMeta().hasLore() ? item.getItemMeta().getLore() : new ArrayList<String>();
|
||||
List<String> dummy = new ArrayList<String> (lore);
|
||||
BankStorage bank = BankStorage.getBank(uuid);
|
||||
for(int i = 0;i < dummy.size();i++) {
|
||||
lore.set(i, dummy.get(i).replace("%eb_pagecost%", BankStorage.getPageCost(bank.unlockedPages + 1) + ""));
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO
|
||||
//- add functions to cache all items here
|
||||
//- make sure itemcreator can pull from config properly
|
||||
//- make sure custom items work properly
|
||||
//- add in sound effect
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -25,8 +25,6 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -46,7 +44,6 @@ public class EnderBank extends JavaPlugin implements Listener {
|
||||
public static Map<Player, List<String>> chatHandlerQueue = new HashMap<Player, List<String>>();
|
||||
|
||||
//plugin specific variables
|
||||
public static ItemStack confirmBuy;
|
||||
public static Map<Player, String> pendingResponseDatabase = new HashMap<Player, String>();
|
||||
public static List<Material> equipmentTypes = new ArrayList<Material>();
|
||||
private static Economy econ = null;
|
||||
@ -67,15 +64,6 @@ public class EnderBank extends JavaPlugin implements Listener {
|
||||
saveDefaultConfig();
|
||||
|
||||
//Set initial values
|
||||
ItemMeta meta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
confirmBuy = new ItemStack(Material.YELLOW_STAINED_GLASS_PANE);
|
||||
meta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
meta.setDisplayName("Confirm Purchase");
|
||||
List<String> lore = new ArrayList<String>();
|
||||
lore.add(ChatColor.RESET + "" + ChatColor.ITALIC + "Click again to confirm purchase!");
|
||||
meta.setLore(lore);
|
||||
confirmBuy.setItemMeta(meta);
|
||||
|
||||
equipmentTypes.add(Material.CHAINMAIL_BOOTS);
|
||||
equipmentTypes.add(Material.CHAINMAIL_CHESTPLATE);
|
||||
equipmentTypes.add(Material.CHAINMAIL_HELMET);
|
||||
@ -198,7 +186,7 @@ public class EnderBank extends JavaPlugin implements Listener {
|
||||
opener.sendMessage(EnderBank.notificationString + " You don't have enough money!");
|
||||
}
|
||||
}else if(bank.lastOpenedPage == bank.unlockedPages) { //If clicking buy ask to confirm
|
||||
e.getInventory().setItem(8, confirmBuy.clone());
|
||||
e.getInventory().setItem(8, CustomItemHandler.GetConfirmBuyNextPage().clone());
|
||||
pendingResponseDatabase.put(opener, "buypage");
|
||||
}else{ //If clicking next page
|
||||
pendingResponseDatabase.remove(opener);
|
||||
@ -316,7 +304,6 @@ public class EnderBank extends JavaPlugin implements Listener {
|
||||
|
||||
if(pendingResponseDatabase.containsKey(opener))
|
||||
pendingResponseDatabase.remove(opener);
|
||||
|
||||
}
|
||||
|
||||
//[1.15.2.a.3] Using "onChestClick()" instead as the method below forces chest animation to stay open
|
||||
|
||||
@ -28,7 +28,7 @@ public class ItemCreator implements Listener{
|
||||
public static Map<ItemStack, Integer> damageInfo = new HashMap<ItemStack, Integer>();
|
||||
public static Map<ItemStack, Integer> forceStackInfo = new HashMap<ItemStack, Integer>();
|
||||
|
||||
public static ItemStack createItemFromConfiguration(String foodName, ConfigurationSection sec){
|
||||
public static ItemStack createItemFromConfiguration(ConfigurationSection sec){
|
||||
if(durMats.isEmpty())
|
||||
loadDurMats();
|
||||
ItemStack item = null;
|
||||
@ -40,7 +40,6 @@ public class ItemCreator implements Listener{
|
||||
}else {
|
||||
item = new ItemStack(Material.getMaterial(sec.getString("id")));
|
||||
}
|
||||
List<String> tags = sec.contains("tags") ? sec.getStringList("tags") : new ArrayList<String>();
|
||||
if(sec.contains("amount"))
|
||||
item.setAmount(sec.getInt("amount"));
|
||||
ItemMeta meta = Bukkit.getItemFactory().getItemMeta(Material.STICK);
|
||||
@ -84,6 +83,7 @@ public class ItemCreator implements Listener{
|
||||
item.addUnsafeEnchantment(Enchantment.SILK_TOUCH, level);
|
||||
}
|
||||
}
|
||||
List<String> tags = sec.contains("tags") ? sec.getStringList("tags") : new ArrayList<String>();
|
||||
for(String s : tags){
|
||||
if(s.startsWith("skullskin") && item.getType().equals(Material.PLAYER_HEAD)){
|
||||
SkullMeta skull = (SkullMeta) item.getData();
|
||||
@ -98,11 +98,6 @@ public class ItemCreator implements Listener{
|
||||
item.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
for(String s : tags) {
|
||||
if(s.startsWith("skulltexture") && item.getType().equals(Material.PLAYER_HEAD)){
|
||||
item = Base64Skull.getSkull(item, s.replace("skulltexture:", "").split(";")[1], "http://textures.minecraft.net/texture/" + s.replace("skulltexture:", "").split(";")[0]);
|
||||
}
|
||||
}
|
||||
List<String> lore = sec.contains("lore") ? sec.getStringList("lore") : new ArrayList<String>();
|
||||
if(!lore.isEmpty()){
|
||||
for(int i = 0;i < lore.size();i++){
|
||||
|
||||
@ -8,21 +8,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class ViperStringUtils {
|
||||
|
||||
// String constants. TODO Change them to something unique to avoid conflict with other plugins!
|
||||
private static final String SEQUENCE_HEADER = "" + ChatColor.RESET + ChatColor.UNDERLINE + ChatColor.RESET;
|
||||
private static final String SEQUENCE_FOOTER = "" + ChatColor.RESET + ChatColor.ITALIC + ChatColor.RESET;
|
||||
|
||||
public static String convertToInvisibleString(String s) {
|
||||
String hidden = "";
|
||||
for (char c : s.toCharArray()) hidden += ChatColor.COLOR_CHAR+""+c;
|
||||
return hidden;
|
||||
}
|
||||
public static String convertBack(String s){
|
||||
//String converted = ChatColor.stripColor(s);
|
||||
String converted = s.replaceAll("<EFBFBD>", "");
|
||||
return converted;
|
||||
}
|
||||
public static String makeColors(String s){
|
||||
String replaced = s
|
||||
.replaceAll("&0", "" + ChatColor.BLACK)
|
||||
@ -97,6 +83,17 @@ public class ViperStringUtils {
|
||||
return new Location(Bukkit.getWorld(s[0]), Double.valueOf(s[1]), Double.valueOf(s[2]), Double.valueOf(s[3]), Float.valueOf(s[4]), Float.valueOf(s[5]));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////
|
||||
// Encode Strings //
|
||||
////////////////////
|
||||
// String constants. TODO Change them to something unique to avoid conflict with other plugins!
|
||||
private static final String SEQUENCE_HEADER = "" + ChatColor.RESET + ChatColor.UNDERLINE + ChatColor.RESET;
|
||||
private static final String SEQUENCE_FOOTER = "" + ChatColor.RESET + ChatColor.ITALIC + ChatColor.RESET;
|
||||
|
||||
public static String encodeString(String hiddenString) {
|
||||
return quote(stringToColors(hiddenString));
|
||||
}
|
||||
@ -124,15 +121,10 @@ public class ViperStringUtils {
|
||||
|
||||
return input.substring(0, start + SEQUENCE_HEADER.length()) + stringToColors(hiddenString) + input.substring(end, input.length());
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal stuff.
|
||||
*/
|
||||
private static String quote(String input) {
|
||||
if (input == null) return null;
|
||||
return SEQUENCE_HEADER + input + SEQUENCE_FOOTER;
|
||||
}
|
||||
|
||||
private static String extract(String input) {
|
||||
if (input == null) return null;
|
||||
|
||||
@ -145,7 +137,6 @@ public class ViperStringUtils {
|
||||
|
||||
return input.substring(start + SEQUENCE_HEADER.length(), end);
|
||||
}
|
||||
|
||||
private static String stringToColors(String normal) {
|
||||
if (normal == null) return null;
|
||||
|
||||
@ -162,7 +153,6 @@ public class ViperStringUtils {
|
||||
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
private static String colorsToString(String colors) {
|
||||
if (colors == null) return null;
|
||||
|
||||
@ -181,7 +171,6 @@ public class ViperStringUtils {
|
||||
|
||||
return new String(bytes, Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
private static int hexToUnsignedInt(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - 48;
|
||||
@ -191,7 +180,6 @@ public class ViperStringUtils {
|
||||
throw new IllegalArgumentException("Invalid hex char: out of range");
|
||||
}
|
||||
}
|
||||
|
||||
private static char unsignedIntToHex(int i) {
|
||||
if (i >= 0 && i <= 9) {
|
||||
return (char) (i + 48);
|
||||
@ -201,11 +189,9 @@ public class ViperStringUtils {
|
||||
throw new IllegalArgumentException("Invalid hex int: out of range");
|
||||
}
|
||||
}
|
||||
|
||||
private static byte hexToByte(char hex1, char hex0) {
|
||||
return (byte) (((hexToUnsignedInt(hex1) << 4) | hexToUnsignedInt(hex0)) + Byte.MIN_VALUE);
|
||||
}
|
||||
|
||||
private static char[] byteToHex(byte b) {
|
||||
int unsignedByte = (int) b - Byte.MIN_VALUE;
|
||||
return new char[]{unsignedIntToHex((unsignedByte >> 4) & 0xf), unsignedIntToHex(unsignedByte & 0xf)};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user