kangarko / foundation Goto Github PK
View Code? Open in Web Editor NEWFoundation™ helps you create highly customized Minecraft plugins (based on Spigot/Paper API) that support multiple MC versions.
Home Page: https://mineacademy.org
Foundation™ helps you create highly customized Minecraft plugins (based on Spigot/Paper API) that support multiple MC versions.
Home Page: https://mineacademy.org
This is something that I've noticed whilst using the Foundation library. I used the library to design a simplified Vanish plugin to teach one of my students.
Basically, these lines make no sense at all:
if (player.hasMetadata("vanished")) {
final Plugin plugin = player.getMetadata("vanished").get(0).getOwningPlugin();
player.removeMetadata("vanished", plugin);
}
for (final Player other : Remain.getOnlinePlayers())
if (!other.getName().equals(player.getName()) && !other.canSee(player))
other.showPlayer(player);
Now while this does "unvanish" players, that is game breaking to most vanish plugins, who keep an internal state of who is vanished so that server-switches and other game events do not break vanish.
It is my opinion that this should be removed from the normalize method. Either that or all metadata should be removed from the player, as that would be "normalizing" them.
Please comment on your thoughts!
Thanks,
Noah
1.16.1-R0.1-SNAPSHOT
Foundation version: 5.6.3
Going through the lesson on creating custom enchantments. If I pass a name into the constructor:
private BlackNovaEnchant() { super("Black Nova", 5); }
It will duplicate the text "Black Nova I" (I = Level) in the item, upon using the custom enchantment command. When I first type the '/ce' command, it will create the sword with "Black Nova I" 3x. It will then duplicate the name a couple more times, every so often.
In addition to this, it will also duplicate the name if you click on the sword, so it's now free to be moved around in your inventory, and then place it again. This results in a massive list of ''Black Nova I" names.
I've copied and pasted the code from your original project in the download button. However, this didn't resolve the issue either.
Below is a screenshot to further demonstrate what I'm referring to.
EDIT
I understand a previous Github issue reported this as well. In issue #71 It might be the exact same issue. It was supposedly fixed in version 5.6.3. However, I'm still experiencing that issue. Could it be that I messed up my POM file?https://pastebin.com/Dp4vBQrv
I ran a few Maven commands to see if there were any build issues, but there weren't.
EDIT 2
Created a blank project. Copied and pasted the (relevant) code from Matej's Orion code. The issue was still there.
I would like to set custom skull for a back button, and with the current setTitle, setMaterial and setLore method, this is not a option. So mu suggestion is you add another method that allows for setting of ItemStacks as well.
This would be nice to you can create nice looking back button with custom heads.
I'm trying to use the getConfig() method from Foundation. I tested the method in two projects. The first project is built with the latest version of Foundation and the Minecraft version is 1.15.2. The second project is one version prior to the current release of Foundation and the Minecraft version is 1.16.3
When I use the method I receive the following error:
https://pastebin.com/AFfZDRev
I'm using the method in a YamlConfig extended class with an Object type property. In my onLoadFinish method, I call it test = getConfig.get("Test");
(test is an Object).
Could be using this method incorrectly but I don't see cause for the error to pop up.
Currently, SimpleEnchantment is registering Enchantment with
private static NamespacedKey toKey(@NonNull String name) {
if (name == null) {
throw new NullPointerException("name is marked non-null but is null");
} else if (!MinecraftVersion.atLeast(V.v1_13)) {
throw new RuntimeException("SimpleEnchantment requires Minecraft 1.13.2 or greater. Cannot make " + name);
} else {
name = new String(name);
name = name.toLowerCase().replace(" ", "_");
name = ChatUtil.replaceDiacritic(name);
Valid.checkBoolean(name != null && VALID_NAMESPACE.matcher(name).matches(), "Enchant name must only contain English alphabet names: " + name, new Object[0]);
return new NamespacedKey(SimplePlugin.getInstance(), name);
}
}
this checks if name is in alphabetic form because it's using name as namespacekey.
Instead doing something like
UUID uuid = UUID.nameUUIDFromBytes(name.getBytes());
return new NamespacedKey(SimplePlugin.getInstance(), uuid.toString());
may be able to store unique key for enchantment while accept non-alphabet Enchantment names
Hey!
I'm facing an issue with loading Maps using getMapList()
method.
The code for loading is bounties... https://pastebin.com/azSKeius
The error... https://pastebin.com/8xZ60MZa
Any ideas, how do I fix it?
Thanks
Ladislav
Hey!
All the builds are getting failed to build. - The latest we can use is 5.5.6.
Are you able to fix it? @kangarko
Thank you
Ladislav
The CompMaterial class does not have a "POTATO_ITEM" entry
minecraft 1.8.8 cannot render the normal "POTATO" item so this will need to be added
the same problem existed with carrots. that was fixed previously though
I am trying to create a player head with custom texture by calling SkullCreator#itemWithBase64(ItemStack, String)
, and makeProfile(String base64)
throws a NoSuchMethodException:
https://pastebin.com/hc8JjWJj
It's because makeProfile
tries to create a new Property with a single String parameter. The Property class only has (String name, String value)
and (String name, String value, String signature)
constructors. From what I've learned, the solution would be to change these lines:
final Class<?> propertyClass = ReflectionUtil.lookupClass("com.mojang.authlib.properties.Property");
final Object property = ReflectionUtil.instantiate(propertyClass.getConstructor(String.class), b64);
to
final Class<?> propertyClass = ReflectionUtil.lookupClass("com.mojang.authlib.properties.Property");
final Object property = ReflectionUtil.instantiate(propertyClass.getConstructor(String.class, String.class), "textures", b64);
because as far as I know, the constructor arguments would be "textures" and the Base64 value.
Feel free to correct me if I'm wrong in any of these!
When Leonhard was with MineAcademy I asked him to add customisation to a few features.
Another small thing is that there are two #setInfoButtonMaterial() and #setInfoButtonTitle() method when the return button only has one(https://i.imgur.com/w8oA0Rt.png). I suggest you do the same thing as the ButtonReturnBack and make the class called ButtonInfo.
All the customisation features above will give developers more freedom and can make their plugin how they want it. I know you have mentioned in the past that you want everything to look the same so users don't get confused and need to learn each plugin. But as a developer I feel like this should be a choice for us, and it should be our job to make the plugin easy for the users, and these customisation feature will allow us to do that while adding a personal design to the plugins we make.
Hello, I wrote a program with Foundations that works fine on 1.14.4 but most of the buttons don't work on 1.15. I tried with spigot and paper, but paper was the only one that actually gave me an error message. This happens when I try to press a button
java.lang.NullPointerException
[15:53:37 INFO]: at org.bukkit.inventory.ItemStack.isSimilar(ItemStack.java:275)
[15:53:37 INFO]: at org.bukkit.inventory.ItemStack.equals(ItemStack.java:256)
[15:53:37 INFO]: at org.mineacademy.fo.menu.Menu.getButton(Menu.java:287)
[15:53:37 INFO]: at org.mineacademy.fo.menu.MenuListener.onMenuClick(MenuListener.java:71)
[15:53:37 INFO]: at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor63.execute(Unknown Source)
[15:53:37 INFO]: at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69)
[15:53:37 INFO]: at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[15:53:37 INFO]: at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[15:53:37 INFO]: at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePlugin
This is for update hopper gui, It works for 1.16.5 But if I´m not wrong use 1.16.4 similar if not same mns version. Has not try it, but should work for any gui (only change enum from Hopper to an other container). You can play show all from 19 to 16 gui too (but are only a "gost gui" ).
I need this in my plugin, so will update for 1.17 and older versions too. now when Foundation not have it for 17.
I dont know it is better way to use IChatBaseComponent, i has not work with BaseComponent so are unfamiliar with it. I have ether way use like this " ' ' " with out ' ' it will only show first world.
Has try add the imports too here (my idea set it to * so have to fix it in manually).
https://pastebin.com/6G3EWPZe
Hello, when I call save() method from a class that extends YamlConfig and implements ConfigSerializable, nothing happens. I have to specify explicitly what I want to save. Here is an example:
public class ArenaSettings extends YamlConfig implements ConfigSerializable {
private Location entranceLocation;
@Override
protected void onLoadFinish() {
this.entranceLocation = getLocation("Entrance_Location");
}
public void setEntrance(final Location entranceLocation) {
this.entranceLocation = entranceLocation;
//save() <-- This doesn't work
save("Entrance_Location", entranceLocation); //this works
}
@Override
public SerializedMap serialize() {
return SerializedMap.ofArray(
"Entrance_Location", entranceLocation
);
}
}
Is it a bug? Or is it supposed to work that way? If so, how to use save() method properly?
CompMaterial.getFromBlock()
returns null for smooth_stone_slabs
I checked the class and discovered that it is missing on the CompMaterial Enum.
I encountered it while getting the material in an BlockPlaceEvent handler, and I did not check it for null.
How to reproduce
final CompMaterial testMaterialOne = CompMaterial.fromString("smooth_stone_slab");
final CompMaterial testMaterialTwo = CompMaterial.fromString("stone_slab");
Valid.checkNotNull(testMaterialTwo, "Stone slab is null"); // Does not Throw
Valid.checkNotNull(testMaterialOne, "Smooth stone slab is null"); // Throws
BLACK_DYE("GRAY_DYE", "INK_SACK", 8), BLAST_FURNACE("FURNACE"), BLUE_DYE("LIGHT_BLUE_DYE", "INK_SACK", 12), BRICK_WALL("COBBLESTONE_WALL"), BROWN_DYE("GRAY_DYE", "INK_SACK", 8), GREEN_DYE("CACTUS_GREEN", "INK_SACK", 2),
should be change to
BLACK_DYE("INK_SACK", "GRAY_DYE", 8), BLAST_FURNACE("FURNACE"), BLUE_DYE("INK_SACK", "LIGHT_BLUE_DYE", 12), BRICK_WALL("COBBLESTONE_WALL"), BROWN_DYE("INK_SACK", "GRAY_DYE", 8), GREEN_DYE("INK_SACK", "CACTUS_GREEN", 2),
INK_SACK should always be legacy name, or it will cause issues while older minecraft version using it.
When i'm trying to use the .unbreakable() method in ItemCreator.of then it just does nothing.
Heres an example code i tried:
ItemStack mysticsword = ItemCreator.of(CompMaterial.GOLDEN_SWORD, "&eMystic Sword").unbreakable(true).build().make();
When i give someone this item in the game it still breaks. Please fix.
When I use CompMaterial.fromItem(ItemStack item)
I get a NullPointerException error. I've tried to use it in a ButtonMenu and a command.
ItemStack item = new ItemStack(Material.DIAMOND_AXE);
CompMaterial material = CompMaterial.fromItem(item);
Common.log(material + " I am material");
Error log (1.15.2): https://pastebin.com/PZYZ2but
I've also tested in 1.16.3 and got the exact same result. Much like my previous Issue (which I believe should be reopened), there seems to be an issue with using these static methods.
Unless I'm doing something incorrectly, but I am fairly confident the above example should work fine.
Hi there! I was having no problem building the project and running it on Minecraft yesterday until the evening. I keep getting this error.
https://pastebin.com/jHaxpUjG
I have made sure in my .m2 that everything is there, and it is. I checked multiple times that my pom is correct. It builds just fine but I get that error when I run in run/debug mode on IntelliJ.
These 2 new methods will return the world you want if exists, passing the name or UUID, otherwise returns null. Added the necessary annotations.
@Nullable
public static World getWorldByName(final @NotNull String worldName) {
return Bukkit.getServer().getWorld(worldName);
}
@Nullable
public static World getWorldByUUID(final @NotNull UUID worldUUID) {
return Bukkit.getServer().getWorld(worldUUID);
}
public static class Jobs {
public static class General {
public static String Butcher;
public static String Digger;
public static String Farmer;
public static String Fighter;
public static String Fisher;
public static String Miner;
public static String Woodcutter;
private static void init() {
pathPrefix("Jobs.General");
Butcher = getString("Butcher");
Digger = getString("Digger");
Farmer = getString("Farmer");
Fighter = getString("Fighter");
Fisher = getString("Fisher");
Miner = getString("Miner");
Woodcutter = getString("Woodcutter");
}
}
and checked with this
Common.tell(getPlayer(), ""+ Localization.Jobs.General.Butcher)
I tried with Korean, you can try with this example
Butcher: "도축"
Thanks
I have an idea for command groups. My idea is a page system to the help message. For example 10 commands per page (this could be customised as well). Please let me hear what you think of this.
This feature will make it so players using plugins with foundation wont get chat spammed if a command group has many commands.
If you're running Foundation on a 1.8 server and update to the latest version, and create an item with unbreakable true, it will not work, and the items will remain breakable.
Whenever I run a server with the most recent official release version of Multiverse-Core (version 4.1.0) or the latest dev build (version 4.1.1) and a plugin that uses the Foundation Library (version 5.6.3) I am given a null pointer exception upon startup that causes Multiverse-Core to disable itself. Here is the error: https://pastebin.com/U2jw60Nu For my server, I have been using an old version of Multiverse-Core (2.5.0) but if a public resource uses the Foundation Library it would be impossible to ask everyone who downloads it to also download an old version. Thank you!
Tolmikarc
I created the Arena and selected the region with /ma tools. Using the function to save arena snapshots it doesn't save the snapshots.
Hello, can you please provide JavaDocs in the API so it will be easier to understand methods/classes? I think it can help many people that are confused by some methods. In the JavaDocs, you can explain what the methods do, etc. It's not a mandatory feature, I will be able to code without it.
I have a SimpleListener registered to listen to the BlockBreakEvent. Whenever I open a furnace and take an item out after it is done smelting, I get this error saying java.lang.ClassCastException: class org.bukkit.event.inventory.FurnaceExtractEvent cannot be cast to class org.bukkit.event.block.BlockBreakEvent (org.bukkit.event.inventory.FurnaceExtractEvent and org.bukkit.event.block.BlockBreakEvent are in unnamed module of loader 'app')
.
EDIT: I am on Foundation 5.7.5, going to try 5.7.6.
EDIT 2: Still occurring on 5.7.6...
because DEFAULT_PERMISSION_SYNTAX doesn't replace the placeholders, so for example if I have a command /testcmd, and I don't give it permission (means foundation gives it permission "{plugin.name}.command.{label}"), when I type /tes, system won't show me "/testcmd" tabcomplete.
Adding the following Common.tellReplaced to SimpleCommand would allow devs to use Common#tellReplaced without needing to specify the command sender.
protected void tellReplaced(final String message, final Object... replacements) { tell(Replacer.replaceArray(message, replacements)); }
Hi!
When I try to export and run my plugin separately and not through IntelliJ and the debug function, I get the error below - I've tried to install the JDK for Java 8 multiple times and nothing, the weird part is that this only happens when I try to export the plugin and run it via a Start.bat.
Foundation version: 5.7.8
Server version: 1.8.8
Error:
[13:33:12 INFO]: [zGangs] JavaScript placeholders will not function!
[13:33:12 INFO]: [zGangs] Your Java version/distribution lacks the
[13:33:12 INFO]: [zGangs] Nashorn library for JavaScript placeholders.
[13:33:12 INFO]: [zGangs] Please install Oracle Java 8 JDK.
[13:33:12 INFO]: [zGangs] Plugin is now disabled.
[13:33:12 INFO]: [zGangs] Disabling zGangs v1.0.0
[13:33:12 INFO]: java.lang.RuntimeException: Script execution failed for ''
[13:33:12 INFO]: java.lang.NullPointerException: Cannot invoke "javax.script.ScriptEngine.getBindings(int)" because "me.Zcamt.zgangs.lib.fo.model.JavaScriptExecutor.engine" is null
Thank you in advance :D
Currently you can only color leather gear basically with the default chat colors which looks very ugly on armor in my opinion. It would be VERY helpful if you could add a way to add custom hex colors to leather armor so you can set them to any color which leaves a LOT more room for custom / special / armor gear than if you only have a few chatcolors available. I believe a lot of people could benefit from it because when you have many custom items in the game especially custom armor then its a lot easier for players to tell them apart if they have a greater and more bright color range. Most chatcolors look rather grayish and ugly on armor, i prefer pure red and other pure colors because it looks a lot better.
I basically can't implement any custom armor for now because there are like 3-4 chatcolors that even look remotely good on armor so theres no point even adding custom armor because its so limited visually.
I'm not sure but it shouldn't be too hard to just add a method that lets you change the hex color of it because thats very easily possible in bukkit/spigot. I would use it myself but then i couldn't use the itemcreator anymore which would be a whole lot more work defining all the items.
Building against the latest version gives me the following error
serializedmap.getMaterial
doesn't work on soul soil. possibly all other 1.16 added and later blocks. please check. thanks.
paper 1.16.5 , foundation 5.9.8
For one of my containers, you can store in theory 1 million or more items of one type.
And int has a max limit ofc, so I use BigInteger and it seams work fine, for Serialized and deserialize.
But your toStringFormatted() method not like BigInteger at all (is say it can't recognize the class).
I solve that problem self and copy over your toString() method to my class :)
I don´t know, perhaps are my need extraordinarily or/and because of the complexity of my plugin.
Multiverse Core plugin is failing to load, when using the latest Foundation version from master branch https://github.com/kangarko/Foundation/tree/master. Version 5.3.9 was working.
After debugging, I found that this 6320235 change is the cause of the problem.
Removing the added line solved the issue for me : cded164.
MV Core Log
https://pastebin.com/r3zxSNxr
This commit is limited to 1 color only, that is the last color: ea1bda5
Steps to reproduce: Call sendJson() on a message containing {test} with SerializedMap.orArray("test", "{#00c792}hello {#5b04b3}world")
There's a lot that goes into developing a plugin. That said, not every plugin needs a database module. And an IP-Geolocation module. And a JSON parsing module. And a web module. And a particle module..
You get the idea.
Please, split this monster of a library into multiple, smaller projects that can individually be released to Maven repos for incorporating into Maven/Gradle projects.
Edit: GitHub (and git) provides a feature called "Submodules" if you'd like this repo to reference and utilize other repos. It's designed for exactly this sort of thing.
GRAY(ReflectionUtil.getEnum("LIGHT_GRAY", "SILVER", DyeColor.class), null, "SILVER"),
(CompColor line 49).
ParticleInternals, line 171
My suggestion isn't really a major feature or improvement to the library, it's more of a change to the library that liberates the developer using it to not force a specific naming style in the settings.yml.
It's great that you're teaching students proper programming practices and showing them how to write fast, readable code, however some things should be left up to the developer. My only real gripe is forcing people to use Version: 1
instead of version: 1
. Doesn't really seem like the library should limit the scheme to just pascal case.
I know this is ridiculous thing to worry over but I would like to see the checker in SimpleSettings ignore casing. Also, because this is a ridiculous thing it doesn't take precedence over other issues, but I would eventually like to see it added.
It can be usefull to have "find" methods for other data types as it is currently for int
(SimpleCommand#findNumber). I do not see any pratical uses for the long or float type, but having find methods for double or boolean values would be useful.
When Leonhard was doing the live calls I ask about custom heads he used in PunishControl, he then gave me this class (https://pastebin.com/C9BcuBKs), But since you have made changes to MineAcademy I cant get this class to work:
So having a class in foundation that gets customs heads would be an excellent addition to foundation as it will 1) solve my issue and 2) allow people to add custom heads with ease
I added few requested but there is more: kangarko/Confiscate#97
I am following Project Orion and when I give myself an item with the enchant it applies it to the item multiple times. I am trying to get it to only apply it once like every enchant. I was told this is a foundation issue.
What I am getting (no errors): https://i.imgur.com/veBbQWw.png, the more times I give myself the sword, the more times the enchant will be on one of them: https://i.imgur.com/MQ9r7Gc.png
What I am supposed to get (picture is from the video): https://i.imgur.com/uSMJKq0.png
The enchant class: https://pastebin.com/hzWTHQfb
The command class that gives me the item: https://pastebin.com/EHcAP50b
Common.log("&aSuccess! "+success)
will be same as Common.logSuccess(success)
Common.log("&eWarning! "+warning)
= Common.logWarning(warning)
Common.log("&cError! "+error)
= Commong.logError(error)
Also, same logic applies to tellSucces
, tellWarning
, and tellError
which use Common.tell(...)
method.
This is not really important, but maybe can be helpful sometimes. I think it's not much and can be easily included in code. :)
So I'm trying to make a linking system between discord and a server.
For that I've imported JDA which I've played around with before when creating a stand-alone discordbot and I know the dependency I've used works.
However, when I try and launch the plugin, I get the error attached below:
Error in console: https://pastebin.com/YLaeMcZi
I then tried to look at the build process and the messages popping up there, and I realized that it seems like the JDA dependency gets excluded from the shaded jar.
"[INFO] Excluding net.dv8tion:JDA:jar:4.3.0_277 from the shaded jar."
I'm guessing this is the issue, but how do I fix this.
My pom looks like this:
https://pastebin.com/kHE1SfyA
I know that I'm using an older version of foundation(5.8.0), I've tried using multiple different versions, also the newest ones(including 5.9.6) and it doesn't seem to fix the issue.
1.17: Getting NullPointerException error
In the latest (5.9.0) Foundation release. No matter what version I use, 1.16.5 or 1.17, I get the same error of hasGsonSupport is null. The line is:
java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "com.cursedplanet.cursedlibrary.lib.fo.remain.nbt.MinecraftVersion.hasGsonSupport" is null
Whilst the entire stacktrace is below:
I will probably work more and fix up the code (but are 100% working).
I have to use instance, in other case I it create new instances every time and I can´t easy access the data. Will clean it up and make it better in future.
For example make it more customized, should move some of the method to own class (but when make it, I was lazy and not create a second class).
This is the core, to create the items inside the paged menu (so it add items on all rows but not last one).
https://pastebin.com/d9uEbynb
and is not 100% my code has be inspired of someone else code, I cold not use your code because that not work well and hard to collect all code you use for your method (is at least 3 different classes you has use for your paged menu and top of that it branch out in other methods and classes).
error.txt of plugin: https://pastebin.ubuntu.com/p/Cn4Dmy2JCt/
Firstly, thank you for the plugin. i can't see plugins like this(awesome) recently.
Problem:
When i execute /boss butcher * test
command manually or from the menu, the console prints error above.
also there are a boss infront of me (so it is in a loaded chunk).
I am having trouble resolving PlaceholderAPI-2.10.8, this is weird as in foundation's pom file you are getting version 2.10.9-DEV-96
My POM File: https://pastebin.com/Q3fhY6zu
Error: https://i.imgur.com/nC0Itpz.png
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.