[1.18.1.a.1] Bug Fix + 1.18 Update

This commit is contained in:
TheTealViper 2022-04-23 16:17:33 -07:00
parent d2f7c0365c
commit c7f06bdad9
7 changed files with 47 additions and 32 deletions

View File

@ -16,7 +16,22 @@
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.16.5 Plugin Tester/spigot.jar"> <classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/spigot-api-1.18.1-R0.1-SNAPSHOT.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/commons-io-2.11.0.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/gson-2.8.8.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="D:/My Documents/Minecraft Stuff/1.18 Plugin Tester/bundler/libraries/snakeyaml-1.28.jar">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>

View File

@ -133,6 +133,8 @@ Dump_Into_Inventory_Blacklist:
#%eb_pagecost% -> Cost of next page #%eb_pagecost% -> Cost of next page
#%eb_pagecostitemname% -> Name of item required for next page purchase #%eb_pagecostitemname% -> Name of item required for next page purchase
#%eb_pagecostitemamount% -> Amount of item required for next page purchase #%eb_pagecostitemamount% -> Amount of item required for next page purchase
#%eb_playername% -> Name of player
#%eb_currentpage% -> Current page of bank open
GUI: GUI:
Next_Page: Next_Page:
@ -176,5 +178,5 @@ GUI:
# Version # # Version #
########################################################## ##########################################################
VERSION: 9 VERSION: 10
#Do not touch this. No touchy. #Do not touch this. No touchy.

View File

@ -1,7 +1,7 @@
name: "EnderBank" name: "EnderBank"
author: TheTealViper author: TheTealViper
version: "1.16.5.a.1" version: "1.18.1.a.1"
api-version: 1.16 api-version: 1.18
description: "Bank system from popular RPG's." description: "Bank system from popular RPG's."
main: me.TheTealViper.enderbank.EnderBank main: me.TheTealViper.enderbank.EnderBank
commands: commands:

View File

@ -83,6 +83,8 @@ public class BankStorage {
//Set other default values //Set other default values
pf.set("unlockedPages", 1); pf.set("unlockedPages", 1);
pf.save(); pf.save();
new BankStorage(p.getUniqueId());
} }
public BankStorage(UUID bankOwnerUUID) { public BankStorage(UUID bankOwnerUUID) {

View File

@ -382,13 +382,13 @@ public class EnderBank extends JavaPlugin implements Listener {
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && !disabledWorlds.contains(e.getPlayer().getWorld().getName())) { if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && !disabledWorlds.contains(e.getPlayer().getWorld().getName())) {
e.setCancelled(true); e.setCancelled(true);
Player p = (Player) e.getPlayer(); Player p = (Player) e.getPlayer();
if(!BankStorage.hasBank(p.getUniqueId()))
BankStorage.initiateBank(p);
openEnderBank(p); openEnderBank(p);
} }
} }
public void openEnderBank(Player p) { public void openEnderBank(Player p) {
if(!BankStorage.hasBank(p.getUniqueId()))
BankStorage.initiateBank(p);
BankStorage bank = BankStorage.getBank(p.getUniqueId()); BankStorage bank = BankStorage.getBank(p.getUniqueId());
bank.openPage(1, p); bank.openPage(1, p);
} }

View File

@ -59,7 +59,7 @@ public class EnableShit {
if(update){ if(update){
File file = new File("plugins/" + plugin.getDescription().getName() + "/config.yml"); File file = new File("plugins/" + plugin.getDescription().getName() + "/config.yml");
try { try {
com.google.common.io.Files.copy(file, new File("plugins/" + plugin.getDescription().getName() + "/configBACKUP_" + oldVersion + ".yml")); org.apache.commons.io.FileUtils.copyFile(file, new File("plugins/" + plugin.getDescription().getName() + "/configBACKUP_" + oldVersion + ".yml"));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1,25 +1,16 @@
package me.TheTealViper.enderbank.utils; package me.TheTealViper.enderbank.utils;
import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.craftbukkit.libs.org.apache.commons.codec.binary.Base64;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
public class LoadItemstackFromConfig { public class LoadItemstackFromConfig {
/** /**
@ -154,22 +145,27 @@ public class LoadItemstackFromConfig {
String value = tagStringProcessed[1]; String value = tagStringProcessed[1];
switch(tag) { switch(tag) {
case "playerskullskin": case "playerskullskin":
JsonParser parser = new JsonParser(); //TODO
JsonObject o = parser.parse(new String(Base64.decodeBase64(value))).getAsJsonObject(); // JsonParser parser = new JsonParser();
String skinUrl = o.get("textures").getAsJsonObject().get("SKIN").getAsJsonObject().get("url").getAsString(); // JsonObject o = parser.parse(new String(Base64.decodeBase64(value))).getAsJsonObject();
SkullMeta skullMeta = (SkullMeta) meta; // String skinUrl = o.get("textures").getAsJsonObject().get("SKIN").getAsJsonObject().get("url").getAsString();
GameProfile profile = new GameProfile(UUID.randomUUID(), null); // SkullMeta skullMeta = (SkullMeta) meta;
byte[] encodedData = Base64.encodeBase64(("{textures:{SKIN:{url:\"" + skinUrl + "\"}}}").getBytes()); // GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", new String(encodedData))); // byte[] encodedData = Base64.encodeBase64(("{textures:{SKIN:{url:\"" + skinUrl + "\"}}}").getBytes());
Field profileField = null; // profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try { // Field profileField = null;
profileField = skullMeta.getClass().getDeclaredField("profile"); // try {
profileField.setAccessible(true); // profileField = skullMeta.getClass().getDeclaredField("profile");
profileField.set(skullMeta, profile); // profileField.setAccessible(true);
} catch (Exception e) { // profileField.set(skullMeta, profile);
e.printStackTrace(); // } catch (Exception e) {
} // e.printStackTrace();
meta = skullMeta; // }
// meta = skullMeta;
// UUID hashAsId = new UUID(texture.hashCode(), texture.hashCode());
// Bukkit.getUnsafe().modifyItemStack(itemStack, "{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\""
// + texture + "\"}]}}}");
break; break;
case "vanilladurability": case "vanilladurability":
Damageable dam = (Damageable) meta; Damageable dam = (Damageable) meta;