#help-development
1 messages Β· Page 1454 of 1
So is it possible to get how much a player is suppose to regenerate before being limited by the health bar?
Not easily no
oof
I see
this is was I was planning on doing
calculate the heal potion myself
now I only need to recreate natural regen
oh welp
how do i get an empty map, i mean which material is an empty map
bc both MAP and FILLED_MAP are normal maps instead of empty ones
any ideas? :(
ill try LEGACY_EMPTY_MAP
Hey,
I am working on a Recipe-Addon for my Server.
I created an object called CustomShapedRecipe.class and I serialize it using the ConfigurationSerializable interface.
It saves the object correctly to the config, but when I am trying to get the object back from the config, it cannot even find the stored Keys, even tho they show up in the .yml.
This is the yml-file:
==: customShapedRecipe
name: Test-Recipe
skill: COMBAT
conditions:
==: conditionList
enabled: true
result:
==: org.bukkit.inventory.ItemStack
v: 2586
type: NETHER_GOLD_ORE
ingredients.7:
==: org.bukkit.inventory.ItemStack
v: 2586
type: NETHER_GOLD_ORE
ingredients.8:
==: org.bukkit.inventory.ItemStack
v: 2586
type: NETHER_GOLD_ORE
ingredients.9:
==: org.bukkit.inventory.ItemStack
v: 2586
type: NETHER_GOLD_ORE```
I also registered it using
```registerConfigurationSerializable(CustomShapedRecipe.class, "customShapedRecipe");```
I placed this in my code, but how do I provide the arguments
can't you only listen to 1 event?
That is a utility method you call from your event to get teh Heal level
the legacy compat layer is bullshit
yeah but it asks for PotionSplashEvent, LivingEntity and PotionEffectType?
Yes, you pass those fields to it
wait I can just listen to EntityPotionEffectEvent and I can get them right
you listen to the PotionSplashEvent
wait then what about drunken potion
backwards compatibility measures should be employed by the plugin, not the platform
what about it? This method accepts a PotionEffectType
I'm not writing your plugin for you
Im just confused
listening PotionSplashEvent would only listen to potion splashed onto players right?
so drunken potion won't be managed?
You asked how to get the full heal amount on a splash potion. We answered that one. Do you have another question?
wait did I
my example mentioned splashing a potion but I never specified I only want to handle splash potions tho?
If you want to also cover consumed potions you need to listen to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerItemConsumeEvent.html
how can I start a sub server through the proxy?
sub server?
Like a spigot backend server?
like a lobby
Oh yeah
im not very good at english π
are you trying to be hypickle
no
why do you need to spin up new instances at runtime
so I did this but it didn't do anything, there's so many thing that could've went wrong, can you guys find any obvious mistakes?
https://pastebin.com/PWuw7HKM
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
if not Im gonna start debugging
i want to make a "Player Server / Private Server" System
ok I shall start debugging
Guys who can help particles..
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
it works ty π
anyone?
looks like you're implementing some form of id system to store your data under, make sure that ID stays permanent or that you wipe the file before writing to it again
Or store under the player UUID as that will not change.
^or even better, take the uuid as key and if one uuid can have multiple locations, make it a list
what are we talking about
For some reason this code also calculates damaging potions as positive number? this isn't right
at this point i would need to get the string list and then apply
setup saving is called in the onenable
I like that theme π
thx
Which one is it?
Can you stop the items in a crafting table from being put into a players inventory when the exit it?
my question is why you need to save in your onEnable
its a repeating task
InventoryCloseEvent should be able to help you, no
i use it since in case of a crash it saves the data.
Yeah, but there is no direct method.
Do i just have to remove them manually?
why u spoonfeed me, you could have told me what to do and i would have tried to do it xd
how about you don't persist arbitrary data with the bukkit config api
yeah obviously, but you can check if it's a crafting inventory and remove the result, in theory.. not sure if it's fired before or after the items are returned
yeah its also i really dont get a lot of english i am italian my bad ahah
Just checked, the event is fired before the items are returned, so you can just clear all items of the closed inventory
ok, thanks
dont compare strings with == pls ty
no its not broken
oh I think I know whats happening, my bad
I get a compilation error when trying to compile my plugin (updated to Java 16):
P:\xTag\src\main\java\me\N137\xTag\events\xTagEvent.java:33:44
java: cannot access java.util.function.Consumer
class file for java.util.function.Consumer not found
The xTagEvent file: https://paste.md-5.net/iniyesukok.cs
make sure to use the right java version
16
are you using maven?
Yes?
try include this build configuration
Solved it, thanks π
I don't think food level has an enforced limit
it will be reset to 20 whenever it is updated (if it was above that prior)
Tbh if you are going to dive deeper there isn't much generic help anyone could offer
why are there false Left Click Air events when right clicking sometimes?
left click air events are triggered when the server receives the swing arm packet
nah it registers the item correctly
anything on the client side that procides such behaviour will trigger a left click air event
ah so there's no way to circumvent it
yeah, either the fake ones or no left click air events at all π¦
oh well
U understand finnbon docs?
Crafting Table that retains items π
i need to do serialisation and deserialisation now
but, the concept works
its like the tinkerers crafting bench from modded
Is there a good way to serialise / deserialise ItemStacks?
yes
paper's ItemStack::serializeAsBytes
everything else that i know of is either incomplete or runs into versioning issues
copy the impl i suppose
Bukkit.getUnsafe().serializeItem(itemStack);
assuming that is included in spigot, anyway
java.io.ByteArrayOutputStream outputStream = new java.io.ByteArrayOutputStream();
NBTTagCompound compound = (item instanceof CraftItemStack ? ((CraftItemStack) item).getHandle() : CraftItemStack.asNMSCopy(item)).save(new NBTTagCompound());
compound.setInt("DataVersion", getDataVersion());
try {
net.minecraft.server.NBTCompressedStreamTools.writeNBT(
compound,
outputStream
);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return outputStream.toByteArray();
what version is that for
any
of course you will need to import the NBTTagCompound and other nms classes from different packages depending on the nms version
just be a bit inspired by the paper commit for it xD
someone can link me how to add the APIs of an another plugin in mine custom work (for example add PAPI support and create placeholders)
just add them as a dependency
for addind a placeholder
hi
https://github.com/PaperMC/Paper/pull/3265 implemented it into paper for reference
either in maven or in ur ide
?paste
wat xD
Can blocks have a UUID or something
I need something unique
blocks (which are not tile entities) are just a few bytes representing the material later one
16 bytes for a UUID would be a bit of a yikes
blocks are just a few bits in a chunk's palette somewhere
i guess i will have to use their location then
most likely
what're you trying to do
when i added the plugin on the dependent i can create a placeholder?
idk if you could craft a unique key for a block combining chunk x and z plus the x,y,z of the block
i am making a crafting table that holds the items inside
but i need a 'key' for each crafting table
atm i am just using their location
I mean, then just chunk x,y,z and internal location x,y,z
as your keys
should work out nicely in the database
redlib has some sort of a persistent block data feature
although supposedly it is kind of prone to exploding
private static Field getStaticField0(Class<?> clazz, String field)
{
Class<?> superClass = clazz;
if(superClass == null)
return null;
while(superClass != null)
{
try
{
System.out.println(Arrays.toString(superClass.getDeclaredFields()));
System.out.println(superClass.getDeclaredField(field));
Field reflectedField = superClass.getDeclaredField(field);
System.out.println(reflectedField);
reflectedField.setAccessible(true);
System.out.println(reflectedField);
Field modifiersField = Field.class.getDeclaredField("modifiers");
System.out.println(reflectedField);
modifiersField.setAccessible(true);
System.out.println(reflectedField);
modifiersField.setInt(reflectedField, modifiersField.getInt(reflectedField) - Modifier.FINAL);
System.out.println(reflectedField);
return reflectedField;
}
catch(NoSuchFieldException e)
{
superClass = superClass.getSuperclass();
}
catch(SecurityException e)
{
System.out.println("A security manager may be preventing you from setting this field");
e.printStackTrace();
}
catch(IllegalAccessException | IllegalArgumentException e)
{
e.printStackTrace();
}
}
return null;
}
All prints are printing the good thing, but if I call Field reflectedField = getStaticField0(getClass(className), field); and print reflectedField it is null? Btw getClass works
I realised tho, that i have to listen for every single thing that could happen to the tnt
?paste
please
Ok....
you are spamming the entire chat xD
yeah, you have to listen to like 500 events
can't even read what is said above π¦
and it's still not reliable
yeah
https://paste.md-5.net/oqafecoder.cs (All prints are printing the good thing, but if I call Field reflectedField = getStaticField0(getClass(className), field); and print reflectedField it is null? Btw getClass works)
btw that reflective final bullshit will go rip once 1.17 comes around
π¦
1.17 apparently uses a fairly new version of java which has nerfed reflection into a limp dicked shadow of what it was
Why?
project jigsaw
Is it an good idea to already use Java 16 then?
probably yes
Security
will murder your reflective access to jdk internals
yes and no
you can't reflectively access the fields of propietary classes anymore
Come on
oh my, NNY still alive
f.e modifiersField will throw a NoSuchFieldException
How does reflection work then?
it doesnt lol
you can't do anything
Why is Java so rude?
I mean, unless mojang actually packages their server code into a package
who do you think you are
Btw somebody knows when 1.17 will be released?
you can still modify the server reflectively all you like
afaik projects without their respective modules expose everything
and may still be mutated using reflection
issue is that java 16 reflection can't find a lot of fields from the java base libraries
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/block/BlockPistonExtendEvent.html
Does this get called b4 they move or after the blocks have been moved?
declaration: package: org.bukkit.event.block, class: BlockPistonExtendEvent
oh yeah, java base library is rip
for example the modifiers field he is using to change finality cannot be found via reflection anymore
AARGH why.....
which leaves methodhandles hacks as your only option for fucking with finality
Ok then I have to live with it.....
and that's a pain in the ass
Yes
tbh just mix in some bytecode hacks
tbh we will just live in a world where everyone uses their own fork
and I am happy
like, not too hard to just create a fork off of paper
and patch your way to happiness
forking and maintaining everything you use is also a pain in the ass though
I just found out Java has textblocks since Java13 and I'm happy now π
Haha nice
But 1.17 takes not too long then
Then I have to upgrade everything to java 16...................
Oh
terrain and shit
Haha
Will it work if I now upgrade to 16, and then use the plugin in a java 8 1.16.5 server?
no
Or do I need to run the server on 16?
yeah
Ok, then I will download Java 16
older classes work on newer java but not the other way around
Ok thanks
Can you have one method listen for 2 events
cause they have the same params
BlockPistonRetractEvent && BlockPistonExtendEvent
no
kind of
well some have parent classes
f.e you can listen to EntityDamageEvent
InventoryInteractEvent listeners execute for a bunch too
which will catch both EntityDamageByEntity and EntityDamageByBlock
Ahh, ok
but that only works for classes which have a static getHandlers method declared
you can't f.e listen to Event and catch all events
I just found out I have more than 5800 .java files on my pc....
because Event doesn't have a HandlerList
so this would be BlockPistonEvent
assuming it has a handlerlist, yes
yeah, it wouldn't work in this case but ok thanks
does this logs a player join to the console?
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
event.setJoinMessage(ChatColor.translateAlternateColorCodes('&', "&7[&a&l+&7] &b" + p.getName() + " &7joined the server."));
}
No, you have to listen to Extend and Retract as BlockPistonEvent is Abstract with no handlers
I can't find any download for java 16 jre
Ok, but I also need to run the server?
Yeah, do you use pterodactyl or?
No local pc
What is a vps?
you can have multiple jdk's
Virtual Private Server
Ah
is pterodactyl free?
yes
a jdk is just a directory with a bunch of shit in it
Pterodactyl is an open-source game server management panel built with PHP 7, React, and Go. Designed with security in mind, Pterodactyl runs all game servers in isolated Docker containers while exposing a beautiful and intuitive UI to end users.
ooh
@wraith rapids I need to jre
Oh ok
@quaint mantle you know that I don't have a vps?
Or can't I just create a virtual os?
DM me π
what is the event for endermen picking up blocks
EntityChangeBlockEvent
Ok dmed
too specific
i mean, that could just be a subclass, right?
no need if you make it for Entity, Naming a Mob type is pointless
Fair enough
My servers starts with java 16 but yea the reflection errors started to appear.....
all player messages are logged to the console too
not much of a logger if it doesnt log everything
consider yourself logged
If i want to make a command /<plugin name> reload do i need to make a command with the name <plugin name> and the subcommand reload?
yes
oh okay
what will happen to the uuids when the mojang accounts are completly replaced by microsoft ones?
i don't know anything about that but going by common sense they'd stay
But going by MS logic, they will be completely replaced and break everything
nice π
one more reason to use offline mode
seriously?
I trusted Mojang, up until MS purchased them
MS is all about Money and selling user data, so no trust there.
minecraft is the new skype
rip minecraft π
return to roblox
noo
xD
but is it really getting that bad with microsoft?
I mean, worst case scenario the community opens it's own authserver
wdym with own authserver?
mojang runs an auth server
clients authenticate against that server
and servers check whether their authentication is valid from that server
iirc servers can set their own auth servers now, so it'd be relatively trivial for the community to just set up its own auth server
thx
that is interesting
that said it wouldn't ever actually work and nothing would ever come of it
nobody could agree on which of the dozen auth servers people would invariably start is the right one
So I should do it quick to secure a monopoly then?
then i will just run an offline mode server
did microsoft already bought discord?
tbh microsoft would be almost better than the current people in charge
the new Font π¦
ew
what are the recent changes
advertising friendliness
what
i'm going to plaster my website with distorted and irrelevant fake discord logos out of spite now
how does a goatse discord logo sound
since setDurability is deprecated, what do we use instead of it now
itemmeta
damagable
durablity is no longer stored on the itemstack, it's stored on the itemmeta of the itemstack
and the itemmeta may be an instanceof damageable
What do I put in the brackets then
what brackets
just cast the item meta to a damagable
get the item
get the meta
check and cast to damageable
set damage
set the meta
set the item
*and import the right damagable
Hi, do you know good rtp algorithm? I mean finding safe place to teleport
an important step yes
the Inventory one
not the entity one
am I doing something wrong?
declaration: package: org.bukkit.inventory.meta, interface: Damageable
could you show your code
yes
ItemMeta meta = p.getInventory().getItemInMainHand().getItemMeta();
org.bukkit.inventory.meta.Damageable.s
you are trying to call the method statically
just import it
the item meta may be an instance of damageable
do not call any methods on the damageable class
cast the meta object to the damageable class and then call methods on the object
Damageable damageableMeta = (Damageable) itemMeta;
damageableMeta.setDamage()
so then I can use methods of damagable on it
yes
again, the literal definition of a cast, to treat something as something
of course it will explode if you're trying to treat something as what it is not
which is why you want to check instanceof first
to see if it actually is that something
btw can .getItemMeta() be null?
bc there is .hasItemMeta()
oh now you say that
?paste
kk
you don't want to treat something as something it is not
you don't want to take a Vehicle and threat it as a Car without checking whether it's actually a Car
it could be a Bicycle
What is people's opinion on this:
https://paste.md-5.net/jonoyuleku.cs
my antivirus recognises it as a trojaner
is that a serialization test
Hello, so i have this
if(player.getInventory().getItemInMainHand().getItemMeta().equals(meta)) {
essentially i have a custom item and I don't know what the meta of the item is
how do i find out?
should be fine
nice, thanks
but since bukkit object stream uses the config serializer, it'll run into the versioning shit
so expect it to explode on server upgrades
just .getItemMeta
sure
and after I set damage I just setItemMeta((ItemMeta) damagablemeta) correct?
yeah
you don't need to cast it back to ItemMeta
I think thats automatically
well, you shouldn't need to
Yea but I need a to use a specific itemmeta
i don't actually remember if Damageable extends ItemMeta, but it should
i suppose it doesn't
just cast it
give it the itemmeta you have, it's the same object
basically when a custom bow shoots , i want my code to do stuff. so i added this:
if(player.getInventory().getItemInMainHand().getItemMeta().equals(meta)) {
But I DONT know the itemmeta of this bow, how do i find out?
ItemMeta meta = item.getMeta();
((Damageable) meta).setDamage(10);
item.setMeta(meta);
don't test the entire meta
if you do, it will basically never return true
Ok thanks
meta includes shit like durability, item names and enchants
store a tag in the pdc of the item and check whether that tag is there
what custom bow
that wasnt meant for you I think
ah
I made a custom bow thru a plugins called customcrafting
basically i added some attributes to it
and some lores
and stuff
and now when it hits a player i need to insta kill the player
i did that
Hentai
but i need my plugint o actually check
then juts create a custom Itemmeta with the lores and attributes...
if it's the right bow
add a tag in the pdc of the item
and check for that tag
to see whether it is your custom bow
How?
is that possible with his plugin?
i don't know
and how?
thanks
I would make a debug message so you can see the item meta and then create it by yourself
ah yes thats way esier
again, if you test the entire meta, it will never return true
?
itemmeta contains durability and everything else about an item
How could I do something similar to player.hidePlayer() but still allow armour to be visible?
I would just check the important attributes...
you'll want to open up the itemmeta and look at like the lore or something
potioneffect
invisibility
and disable the particles
is there a way for someone to be invisible for everyone else, but not them self
maybe with nms
any suggestion to how it'd be achieved?
a player can't be invisible to themselves
private static java.lang.String me.tvhee.tvheeapi.core.test.AClass.aMethod(java.lang.String) is listened in Class#getDeclaredMethods, but if I try to do Class#getDeclaredMethod("aMethod") it will throw NoSuchMethodException ?
the best you'll get is the invisibility potion effect
or just use .hidePlayer()
e.getplayer().hideplayer if an event, basically .hideplayer
if you want the inverse, that is, the player is visible to themselves but invisible to everyone else, you can either send the potion effect packet to everyone else
or use the hidePlayer method
keep in mind that the latter hides the player entirely
armor and tablist name and all
show actual code
just use textcomponent
public static Reflection invokeStaticMethod(String className, String method, Object... parameters)
{
Class<?> superClass = getClass(className);
while(superClass != null)
{
try
{
System.out.println(Arrays.toString(superClass.getDeclaredMethods()));
System.out.println(superClass.getDeclaredMethod(method));
Method javaMethod = superClass.getDeclaredMethod(method);
System.out.println(javaMethod);
javaMethod.setAccessible(true);
System.out.println(javaMethod);
return new Reflection(javaMethod.invoke(parameters));
}
catch(NoSuchMethodException e)
{
superClass = superClass.getSuperclass();
}
catch(InvocationTargetException | IllegalAccessException e)
{
e.printStackTrace();
}
}
try
{
throw new NoSuchMethodException("Method '" + method + "' not found!");
}
catch(NoSuchMethodException e)
{
e.printStackTrace();
return null;
}
}```
it returns null
The first thing prints, and the method is inside that array, but System.out.println(superClass.getDeclaredMethod(method)); does not print
-->
catch(NoSuchMethodException e)
{
superClass = superClass.getSuperclass();
}
is called then
then you dont have an item in main hand
i did
??
i tried both hands
javaMethod.invoke(parameters)?
That makes no sense
code?
Oh I understand, thanks
when retrieving a method reflectively, you need to describe the method's signature
the method's signature consists of 3 components
the return type
the method name
and the method parameters
you need to provide both the name and the parameter types to find the method
Yes, thanks
are you still writing your horrible plugin loader shit
Yep
give up already
But I want to test reflection
or rather, do it properly
That is not the point now
i solved it instead i'll just set a custommodeldata for the item and my plugin will read it
nevermind
system.out.println(player.getInventory().getItemInMainHand().getItemMeta());
@EventHandler
public void onHit(ProjectileHitEvent e) {
if (e.getHitEntity() instanceof Player) {
if (e.getEntity() instanceof Firework) {
Firework firework = (Firework) e.getEntity();
Entity shooter = (Entity) firework.getShooter();
Player player = (Player)shooter;
if(player.getInventory().getItemInMainHand().getItemMeta()) {
}
}
} else {
Firework firework = (Firework) e.getEntity();
Entity shooter = (Entity) firework.getShooter();
Player player = (Player)shooter;
System.out.println(player.getInventory().getItemInMainHand().getItemMeta());
}
}
ok
what's the maximum zoom (FoV contraction) you can do and how to do it?
???
try adding the Speed effect at Short.MAX_VALUE - 1
Or Short.MAX_VALUE / 2 - 1, one of those
unfortunately speed and slowness are capped pretty early on, i.e. slowness 10 is the same as 255 and same for speed
then nothing you can do as you cannot alter the settings of the client (duh)
Can i serialise a Location and then use that as a key to multiple ItemStacks?
Cause i have a HashMap<Location,ItemStack[]> which i need to serialise / deserialise
serialize into what? a config?
I need to be able to read from it so that i can store it for the next time the server starts
in a config?
I mean, i guess
Well you decide how you are going to store it and come back for how to do it.
then simply put it in the file. Map, Location and ItemStack are all serializable
yes you can use a Location object as a key
if you add it to a config be sure to save it and always reload your config if you want to access the data again.
i mean, ideally it would be in a separate file from the default config.yml
sorry ><
to store you are simply going to use config.set("path", HashMap);
the soft-depends are kile softwares where the plugin not works well without them, and depend are the plugins required to a plugin?
for example an bw addon has the depend, and PAPI a soft-depend of bw?
Depend = plugin will not start without it. softdepend = would like it but its not essential.
ok thanks
depend will make your plugin load after those it depends on. softdepend will not affect load order. Do NOT use depend and softdepend on the same plugin as it will break the load order of depend.
how do i deal with the fact that it is a ItemStack[]
ok, so i really am kinda lost. this is what i have
private void loadAllBenches() throws IOException, InvalidConfigurationException {
File file = new File(getDataFolder().toString().replaceAll("\\\\", "/") + "/Benches.yml");
if(!file.exists()) file.createNewFile();
FileConfiguration configuration = new YamlConfiguration();
configuration.load(file);
Set<String> keys = configuration.getKeys(false);
for(String key : keys){
this.inventoryContents.put(Location.deserialize(key),configuration.getObject(key,ItemStack[].class))
}
}
for an addon i use depend: [Bedwars]
in the plugin: soft-depend: [PlaceholderAPI, Citizens, SlimeWorldManager]
Thats fine
i use the Intellij plugin named mincraft development, if i add the plugins in that when i start project it generates the dependency?
im able to make a player invisible through packets, not using potion effects, however when they sprint or crouch it resets the invisibility, what could cause this?
oh my, so wrong. new File(getDataFolder(), "Benches.yml");
sorry
i use them
to help me
different environments use \ and / for paths
public static void setStaticField(Class<?> clazz, String field, Object object)
{
Class<?> superClass = clazz;
while(superClass != null)
{
try
{
System.out.println(superClass.getDeclaredField(field));
Field reflectedField = superClass.getDeclaredField(field);
System.out.println(reflectedField);
reflectedField.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(reflectedField, modifiersField.getInt(reflectedField) - Modifier.FINAL);
reflectedField.set(null, object);
return;
}
catch(NoSuchFieldException e)
{
superClass = superClass.getSuperclass();
}
catch(SecurityException e)
{
System.out.println("A security manager may be preventing you from setting this field");
e.printStackTrace();
}
catch(IllegalAccessException | IllegalArgumentException e)
{
e.printStackTrace();
}
}
try
{
throw new NoSuchFieldException("Field '" + field + "' not found!");
}
catch(NoSuchFieldException e)
{
e.printStackTrace();
}
}```
[16:30:28 INFO]: private static final java.lang.String me.tvhee.tvheeapi.core.test.AClass.stringField
[16:30:28 INFO]: private static final java.lang.String me.tvhee.tvheeapi.core.test.AClass.stringField
[16:30:28 WARN]: java.lang.NoSuchFieldException: Field 'stringField' not found!
I do the same thing to get the field and that works
No idea, I'd never recommend anyone use that plugin unless they are already competent at writing plugins
You shoudl not be doing any deserialization, thats all in built
i just saw this:
https://www.spigotmc.org/wiki/serializing-location-objects/
and thought i needed to
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Location is ConfigurationSerializable
i just am not familiar with this at all and am kinda confused
You don;t need anything. Location and ItemStack aer already serializable. You do nothign
hey
although since the config is deserialized all in bulk, you often end up with weird broken location objects when pulling them from the config
anyone knows how to fix a .jar logo
because the worlds they're in aren't loaded yet at the time of deserialization
i downloaded java 8 then it change my icon
you need to jump through a few hoops to get it to work as intended
you know they are locations and ItemStacks, just call config.get("path").getValues(); and it will give you an annoymous Map
or somethgin close to that
this.inventoryContents.put(configuration.get(key));
?
No, that will be a ConfigurationSection, or a MemoryMap
there is no getValues()
hey
do you know how to fix .jar file logo
Take a look at this example of saving and loading inventories https://paste.md-5.net/sogaruraca.java
will do
Hasn't bungee an interface ConfigurationSerializable ?
someone send me a java 15 download link then fucked up my .jar logo
Jar file logos use your system registered logo
who cares about a logo
a file is a file
go into your file association settings and change it there if you don't like it
you will know how bad it is
It will look different for anyone who has a different type
if you see it
The look of a jar file does not persist across machines
i see what you have done, however i am stuck yet again on how you would change:
key -> Location
get(key) -> ItemStack[]
for(String key : keys) {
MemorySection section = (MemorySection) configuration.get(key);
this.inventoryContents.put(key,section.getItemStack(key));
}
The system I showed you eliminates AIR and null slots. but to store that under yours you'd have Map<Location, Map<Integer, ItemStack>>
question, how can i interface with a TOML configuration?
or if you don;t care about storing nulls and AIR, you'd process your Itemstack[]
basically, i am storing the contents of crafting tables.
just feed them into the stream and shit it out as base64
i think for now i iwill just store at ItemStack[]
using yaml to store arbitrary data is dumb
using bukkit config api to do it is even dumber
you should at the very least rig up your serialization so that you don't need to rewrite everything when you inevitably switch to something better
i mean, i have the methods for base64 to itemstack and viceversa
shove all of the itemstacks into the stream
Do craftign tables have TileEntities? I forget
Odd
they aren't designed to hold items ><
they don't really store any data or have any state
they exist solely to open a transient inventory screen
At least they can be moved by pistons
So, i mean, i could store Location : ListOfBase64Strings
no
no?
shove all of the itemstacks into the stream
there is no point in converting them to strings in the intermediate stage
Well to store just as Location, ItemStack[] you just add the map, then to read you use similar code to what I showed you, where the key would be the Location
f.e write the # of itemstacks in the inventory, then for each number read an int representing the slot and an itemstack representing the item in the slot
idk how you get the location from the config that is the whole problem π π©
you are serializing data, you should think serially
like i have the 'key' but idk how to turn that from a string to location
maps aren't serial
Should I make this static:
public void reloadConfig() {
if (this.configFile == null) {
this.configFile = new File(this.plugin.getDataFolder(), "config.yml");
}
this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource("config.yml");
if (defaultStream != null) {
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.dataConfig.setDefaults(defaultConfig);
}
}
why would you make it static
I want to use the reloadConfig() inside a command
that is not a reason to make it static
well It's easier than making an instance and calling a method on it
you never make an instance of your main class
something to keep in mind about static is that it is not an access modifier
you don't make something static because "i need to access it from here"
Location:
- Itemstack1
- ItemStack2
- ItemStack3
- ItemStack4
Why can't it be this easy ><
you make something static because the related function or data is not bound to an instance of the class but rather the class itself
yes
its an instance of my dataManager class not the main
then it's bound to your datamanager instance
what
guys someone hacked my server and later I banned him but the problem is every time I join is that they disconnect as well as my friends and others
imagine paying for this
uhh I'm doing it like this
why are you creating a new data manager each time and then discarding it immediately
that is like going to the grocery store, buying a banana, peeling it, and then throwing it away
well that's why i asked to make reloadConfig() static
private final MagmaBuildNetwork plugin;
private FileConfiguration dataConfig = null;
private File configFile = null;
public void reloadConfig() {
if (this.configFile == null) {
this.configFile = new File(this.plugin.getDataFolder(), "config.yml");
}
this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource("config.yml");
if (defaultStream != null) {
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.dataConfig.setDefaults(defaultConfig);
}
}
those are not static
how would i do it else?
you are creating a new DataManager each time
mmm
each instance of DataManager has its own set of these fields
each DataManager instance has its own configFile
and dataConfig
ow
you are creating an object which has these two fields
then you are telling the object to do some stuff with those fields
then you throw the object away
you are doing nothing
you are repeatedly buying a banana, peeling it, and then throwing it away
construct one singular instance of DataManager and then use that same instance across your entire plugin
do it at startup or whatever
store it in a field in your main class instance or whatever
uh does anyone know how to invert a players vision in 1.16
there's this plugin called UltimateDrugs v2 (which is paid). it implements a negative vision effect
define negative
Do those random shaders still exist in the game
they do yeah
if you mean super secret settings then no
That's the enderman shader
ahhhh
oh yeah
the one on the left is the creeper shader
so this in my main class?
public DataManager data;
oh okay..
what
third time this month that my server.props gets nuked by multicraft on my shitbyte test server
is it possible to tell idea to upload the artifact to an ftp after a successful build?
it's getting annoying to test
Hey everyone ! I have a quick question , how can I get like the type of an item that's on the ground ? Idk if that makes sense
it's an entity
Yeah but how
I have the location where it is and I know it's an item how do I know what it is ?
I did all of that
and check whether it's an Item, then cast to Item
I have the entities
my method is public and i cant access it :/
getItemStack method to get it as an itemstack ?
that's because you're trying to access it statically
how can i read/write TOML files?
you are trying to invoke a method on the class
you need to invoke the method on an object
learn and understand the difference
I want to a leaderboard containing 10 armor stands, now all is fine and dandy however I don't know how to store those mfs across restarts
yea i know so why not making dataManager static?
Oh I can just recreate them on start.
like private static DataManager data;
no
why do you make them static
but what then?
yea i made it like this long ago
private static MagmaBuildNetwork plugin;
yes, you have written a static getter for your plugin instance
this is fine because your plugin is a singleton; only one instance of it exists at a time
uhu
get your plugin instance, call the method
How can i force a player to do the swimming animation?
so normally i can easy do getPlugin() and it returns plugin
packet
oh I thought he wanted a swinging animation as in their arm, mb
You don't need a packet for that
well it cant find the method either i import it statically
brrr
what
theoretically setting a barrier block at player's head would force a player down no
yes
private void saveAllBenches() throws IOException, InvalidConfigurationException {
File file = new File(getDataFolder().toString().replaceAll("\\\\", "/") + "/Benches.yml");
if(!file.exists()) file.createNewFile();
FileConfiguration configuration = new YamlConfiguration();
configuration.load(file);
int i = 1;
for (Map.Entry<Location,ItemStack[]> entry : this.inventoryContents.entrySet()){
configuration.set("Location" + i + ".x", entry.getKey().getX());
configuration.set("Location" + i + ".y", entry.getKey().getY());
configuration.set("Location" + i + ".z", entry.getKey().getZ());
configuration.set("Location" + i + ".world", entry.getKey().getWorld());
for (int x = 0; x <= 9; x++){
configuration.set("Location" + i + ".item" + x, encodeItemStack(entry.getValue()[x]));
}
i += 1;
}
configuration.save(file);
}
``` does this look ok?
its just it doesn't work
i get no errors tho
ok
the heck is a bench
ill just like lag back if somebody steps on the barrier block lol
work bench
god damn it
this is inside the main class
public static MagmaBuildNetwork getPlugin() {
return plugin;
}
nothing gets saved thats all
:/
literally
You aren't in the main class
So you can't just magically call getPlugin with no class prefix
well can't i call public methods in another class then?
look at this
and see if it rings any bells
you can call public methods in another class
but the compiler doesn't know what "getPlugin" refers to
there is no "getPlugin" in this class
you need to tell it what class's getPlugin you mean
learn java
that's because every time you've done it before was in the same class
Is there any difference between Bukkit.getScheduler().scheduleSyncDelayedTask() and Bukkit.getScheduler().runTaskLater()?
the other one might be deprecated
I don't think so
i remember some of them being deprecated because of dumb naming conventions
other than that they do the same thing
the scheduleSync one was around first
but apparently itas async variant, scheduleAsyncTask, was too confusing for people
scheduleX are mostly depreciated
as people thought it meant "schedule a sync task"
rather than "schedule async task"
Also, is it better to construct a new runnable (with the same code) every time I want to schedule the task, or store that runnable statically?
doesn't matter
storing it statically is generally more boilerplate and has negligible benefit if any
lambda expressions are very fast anyway
ok
is there any TOML wrappers to Configuration?
So I should use .runTaskLater()?
instead of scheduleSyncDelayedTask in BukkitScheduler?
you should do whatever
ok
it doesn't matter
What gradle plugin do people use for generating javadocs? (I already typed the shit, I need to turn it into html/css and that stuff)
i mean something to use a TOML file as a Configuration object
not in bukkit no
i don't remember seeing any community made impls of one either, but I haven't really looked for one anyway
hm
anyone knows how can i change the wheat and other seeds growing velocity? i have tried this but I was unsuccessful
Ah legacy data
i would love to be able to use a TOML file with bukkit's Configuratoin api
the event is not called, it is not legacy data
Yes it is
yep
why are you writing 1.8 code but building against 1.13+
because 1.8 is the version that have most players in my country
o_0
yes but why are you building against 1.13+ then
trully, I don't get it
build against 1.8 if you're building for 1.8
you can't use any of the 1.13 features or api anyway
what do I check to know if player is interacting with a crafting table
it's a tile entity so I can't getClickedBlock() == Block.CRAFTING_TABLE
A crafting tables isn't a TileEntity and you use getClickedBlock
ID?
event.getzClickedBlock() == <here>
it's not a tile entity
get clicked block -> get the block's type -> compare to Material.CRAFTING_TABLE
yes, it returns a block
look at the methods a block has
you can get a block's type
which returns a material
hey guys
so i have a chunk like: -6 5 -11
how to know if my player (using getPlayer()) is in this chunk?
I'm new here
divide the players x and z by 16
it will give you the chunk x and z
i can't get the chunk using F3 ?
oh
wait
i can get the location, then get the chunk of the location no?
yes
i tried
and it's retuning a class
but idk how to use it
returning
it says "CraftChunk{x=-5z=6}"
how could i use it
and compare it
https://paste.md-5.net/reyecoyona.cs Read comments
uh
you compare the getX and getZ to the values of your chunk
how do I know when player closes out of an inventory
thanks
can i create a chunk class so i can just compare the 2 classes instead of typing everything?
I want a NPC to open an inventory when I right click it and say: buy what you need
PlayerInteractEvent
and when I cloes it it would say something like goodbye
InventoryCloseEvent
yes I found it
um? return new Reflection(reflectedField.get(null));
Because it's static
but how do I tell it's my inventory he closed
check if the inventory's name equals your npc inventory's name
Oh no
lol
but wouldn't a chest named the same thing also trigger the event?
This can cause issues
This
In what version of minecraft could you name chests?
ever since name tags were added ages ago
so how do you do it the non-dummy way
anvilll
ever since anvils were added
Btw it is about "setStaticField", "getStaticField" works
why are you writing all of this redundant boilerplate
can't you just use reflection
so how do people do it
Because this is plainer so I don't have to use try/catch everywhere
people compare the inventory instance
oh?
if (event.getinventory == myinventory) do stuff
ok so basically Im trying to return all non-GUI thing back to the player when they close the GUI
wait I just realised
I would need a hashmap of inventory right
if I don't want the inventory to be the same for every player
myes
Doing this already (1th answer post) https://stackoverflow.com/questions/3301635/change-private-static-final-field-using-java-reflection
can i give an item to player on join event?
public void onJoinServer(PlayerJoinEvent e)
If removing
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(reflectedField, modifiersField.getInt(reflectedField) - Modifier.FINAL);
I don't get NoSuchFieldException, but now I get java.lang.IllegalAccessException: Can not set static final java.lang.String field me.tvhee.tvheeapi.core.test.AClass.stringField to java.lang.String
setAccessible no longer makes final fields accessible as of some version
e.getPlayer().addItem(new ItemStack(Material));
How could I fix this? Get another method or something?
Oh I forget getInventory my bad
e.getPlayer().getInventory().addItem(new ItemStack(Material));
it's ok
the way you used to do it was to get the root field on the Field object and modify that
can i fix that i can just do getPlugin(). ... instead of MagmaBuildNetwork.getPlugin().
private static MagmaBuildNetwork plugin;
public static MagmaBuildNetwork getPlugin() {
return plugin;
}
since the Field returned by getDeclaredField is just a copy
ok how do I set what the items are in an inventory
it worked before
the copy does however hold a ref to the original backing Field instance
that'd be the Field object you want to modify
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(reflectedField, modifiersField.getInt(reflectedField) - Modifier.FINAL);
If using this, I will get the NoSuchFieldException, and if not using this I will get previous exception
Hey!
How can I check, if an entity exists even tho it is not loaded?
E.g.: An Armorstand in an unloaded Chunk, and I've only got the UUID.
of course the root field is a private field in a propietary class and so you can't actually find it with reflection past like java 8 or something
We are on java 16
yeah get fucked basically
....
how do I create an inventory with like items in it
see the javadocs
how to set the location of the item
public class MagmaBuildNetwork extends JavaPlugin
{
private static MagmaBuildNetwork plugin;
public void onEnable()
{
plugin = this;
}
public static MagmaBuildNetwork getPlugin()
{
return plugin;
}
}
use teh javadocs for Inventories and find the method that allows you to add an item with a slot
setContents
well yea that's exactly what i have and i have to do MagmaBuildNetwork.getPlugin() or it wont find it
try it and see
Bukkit.createInventory, and then you can put your items there and see https://paste.md-5.net/moturaduqu.java
i am not trying to make a GUI
JavaPlugin.getPlugin(MagmaBuildNetwork.class) will also work
ik how to make one
Ok
:/
strange
very strange
there's nothing strange