#help-development
1 messages · Page 1584 of 1
I was also wondering, how does one go about having multiple configs for their plugin with different names? I’m assuming it’s something to do with the FileConfiguration class but I’m not sure
I'm pretty sure that question is quite common that you can find multiple solutions on Google
I did try searching but I didn’t get clear answers on it
I would have thought it’d be talked about more
Thanks a bunch mate
Doesnt works
weird thing
i need desc not asc
IntelliJ keeps telling me the .playerConnection isn't resolved
import io.netty.channel.*;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketListener {
public static void start(Player player) {
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
@Override
public void channelRead(ChannelHandlerContext channelHandlerContext, Object packet) throws Exception {
super.channelRead(channelHandlerContext, packet);
}
@Override
public void write(ChannelHandlerContext channelHandlerContext, Object packet, ChannelPromise channelPromise) throws Exception {
super.write(channelHandlerContext, packet, channelPromise);
}
};
ChannelPipeline pipeline = ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel.pipeline();
pipeline.addBefore("packet_handler", player.getName(), channelDuplexHandler);
}
}```
The SQL is fine, you are putting it in some order list
im following a course
for java
i should clarify i have a very mediocre/subpar grasp on whats happening
yeah it was haha
nms was changed in 1.17? :(
There’s no nms field called playerConnection in 1.17
wait
yes ofc it was
bro nms is changed every update shhh
alright is there an alternative or
that is interesting
but yeah i have no clue how to do the packet thing i bet its way out of my league haha
should i wait or just try to tackle it with tutorials
I am pretty sure there is no tutorial for 1.17 specifically
Unless someone is speed running the classic spigot dev
Although this makes me wonder, why packets?
eh
i knew nothing about java when i started coding my plugin
Myes
learned all on the field
and did the packets thing as my second project
oh ok
just try it
Shouldn't be to hard
Isn’t it for right click only? I’ld like to detect left click too
so when you mine it cancels the event and sends the packet that you broke it to only the player that broke it
so to everyone else it looks like the tree is still there
even when you've mined it
There’s a method for that
You can try 🤷♂️
oh?
Like an api method pretty sure
Yeah that's what you would do
declaration: package: org.bukkit.entity, interface: Player
yeah thing is im like super new to java like ive just got my hand on commands on spigot and im coming from skript
OH
the name alone just sounds perfect
I don't understand why you would want that only the player that broke it could see it destroyed though 🤔
good for farming
Oh okay
?jd-s I do suggest looking into this when you want to search for how to do stuff before resorting to packets.
better then the wait and regen method bc of that
it isnt really that much work
hopefully one that wll teach me alot as a dev haha
you can do it in one listener
Yeah, that's basically why i code as well
i like to learn
Represents an event that is called when a player right clicks an entity that also contains the location where the entity was clicked.
That’s from the spigot Java docs
?paste them chad
swag ty
this should be good so far for cancelling the event right?
actually no dont answer that i can just test
😌
something like this?
return Bukkit.getWorlds().size() > 0;
here so you learn it: https://tryitands.ee/
haha
ive seen it used on so many people
ive fallen
oh noooo
haha but yeah i got like half of it working

just != 0 works but yeah
ok
what if its an inception and he has -1 worlds?
oh no
Well then some real wacky shit has gone on
-1 worlds 🤔
throw new AssertionError();
throw new wtfHaveYouDoneError();
never heard of smh
this better discord documentation is pretty shit
Is it?
imagine breaking the ToS
oh
i did it like this
BossBar bar = Bukkit.createBossBar(key, "Vanished", BarColor.BLUE, BarStyle.SEGMENTED_20);
Hey, I'm trying to get a custom head except (https://minecraft-heads.com/custom-heads/alphabet/8902-blue-arrow-left)
I have to set it in a GUI. I can set the owner but the link only offers that :
/give @p minecraft:player_head{display:{Name:"{\"text\":\"Blue Arrow Left\"}"},SkullOwner:{Id:[I;2019808580,1338983880,-1755567695,414268273],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWFlNzg0NTFiZjI2Y2Y0OWZkNWY1NGNkOGYyYjM3Y2QyNWM5MmU1Y2E3NjI5OGIzNjM0Y2I1NDFlOWFkODkifX19"}]}}} 1
How can I get the custom head for my plugin?
The color is immutable yeah
you sure? i remember i did once a plugin which just changed the color continuously
No it probably isn’t lol
^^
look up this https://github.com/deanveloper/SkullCreator/blob/master/src/main/java/dev/dbassett/skullcreator/SkullCreator.java
copy the minecraft URL + the code right under and get the head from that url
Okay but how do I get the url of the head ?
@limpid bronze thats the url you need to use to get the skin
alright so you guys mentioned using protocollib to send packets right
Oh okay
would you mind helping me figure out how to implement that or send a tutorial?
all the tutorials i can find are 2 hours and i was hoping to see if there's a quicker summary haha
Wait
Wtf
Uh 1 sec
you could also just look up their wiki mr. they/them
https://wiki.vg/Protocol
There
yeah you're right i should get used to using wikis now
ill check both out! much appreciated
I didn't understand what should I do with this code
nope i said nothing
you can just click the link
thats the link you need
Not 100% spigot related, but is there a way to call a function when a class gets extended
Idk how to explain this
Yea
I want to extend an abstract class and automatically register it to an command manager
Let the super class call a function in the constructor, an init block or smntg
Ah okay
But do I still need to call super()
if your super class has a constructor your subclasses have to
If it’s not a nullary constructor also
But then comic you’d probably need to call something like super(commandManager);
assuming the superclass requires a CommandManager
So there's not a way to make it automated?
if he wants to register it on the command manager he would need to DI it
so yeah, his subclasses would have to call a super in their constructor
Ah okay
reflections
you could have a static singleton of your CommandManager
Tho it would lead to rigid code
but reflections aren't necressary and overcomplicated
class CmdBase {
{
CmdManager.getInstance().register(this);
}
}
class HelpCmd extends CmdBase {
}
Or smtng
The super of a nullary constructor is inferred which is nice tho
so no matter what he does
there is always a super
in a hidden on runtime created default constructor
any ideas to add to my plugin?
a giant black hole
what plugin are you making
uhh it has alot of functions
like?
a way to view people you've traded with in the past and what got traded
yeah haha
so you can see how you got fucked left and right while getting scammed
"oh this wasnt... the item i thought it was..."
"luckily i can show staff what happened"
and bahm easier resolution
a-giant-black-hole
or replace the minecraft fire with yourself animated particles
i just realized
or or or
i was about to ask why my code wasnt working but i forgot to reference...
ahh lemme make a gui for prefixes
what about the monumental black hole?
the what-
⚫ which do skkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkrrrrrt and sucking everything in
oh
kinda void with cool effects
yeah just a black hole
sucking void
oh i forgot interface methods cant have a body 💀
probably confusing C#
oh
im ngl i have no idea what im doing
ok
i forgot to send my follow up question-
so int he example theres this
fakeExplosion.getDoubles().
write(0, player.getLocation().getX()).
write(1, player.getLocation().getY()).
write(2, player.getLocation().getZ());
fakeExplosion.getFloat().write(0, 3.0F);```
and im confused by
write(0, player.getLocation().getX()).
write(1, player.getLocation().getY()).
write(2, player.getLocation().getZ());
fakeExplosion.getFloat().write(0, 3.0F);```
this
its just getting the location
to send the packet to right?
so i can just change the packet type to BLOCK_BREAK and it should work right?
brr coding in C# and then going back to java goes brrr
also isnt it possible to get the slots of an inventory?
kinda list
update: it didnt work
WAIT
player.sendBlockChange() IS A THING
ok but
someone who has the vault discord?
i dont think that there is one
I saw in the code BlockDispenser.eventFired but I never see it actually being set, any clue where it is being set cause i don't see it
oh sad
good news! it works1
player.getInventory().getContents()?
bad news! no it doesnt
when you break something else it upda
it updates*
any way to prevent this from happening and make players wait the 10 seconds\
OH WAIT
ITS UPDATING
returns an itemstack
and getslot() after it doesnt work
are you trying to get an itemstack in a specific slot index?
i also dont😵💫
happy for you :)
returns an array of the ItemStacks from the inventory
yes iknow
just gotta figure out a way around the block updating
it updates client side
packets?
that isn't packets
oh
or at least i don't think it is
hmm idk what it would be then haha
you could use the protocollib api if you wanted
Do you want it to stop from updating when right clicked?
idk i don't really do packets often
OH SHIT I FORGOT ABOUT THAT TOO
yes
and also when blocks around it are mined
(i.e block above/below)
I can send you the code I'm using give me a min
#Olivoissexyandswag
Ultimate spoon 
He won't be able to directly copy and paste that
So I don't really care and it's easier than explaining it
Alrighty
Olivio is
ing again by let others test his code
so he doesn't have any issues when implementing
I mean that code has been running on quite a few servers so it should be fine 😅
rip those servers
How would I set the slots in an anvil GUI? (1.17.1) I have tried the usual way like how you would set a chest's content, with slots 0, 1 and 2 but that doesn't do anything.
it should. show us the code
Inventory anvil = Bukkit.createInventory(player, InventoryType.ANVIL);
player.openInventory(anvil);
anvil.setItem(0, new ItemStack(Material.PAPER));
open it after setting the item
players.add(this.getServer().getOfflinePlayer(playerUUID));
playerUUID = 1234; // Example

Wait
Player player;
player.getUniqueId().toString() = 5678
It opens the Anvil but no item.
Why the UUID changes, after adding an OfflinePlayer to a list and the get the UUID back , but casted to a Player?
🙃 UUID isn't an int
Anyway it might be offline mode UUID
it doesnt
What do you mean?
I mean it shouldn't change but that would be the only reason
just if you got an offlineplayer who doesnt exist by the name and it couldnt find the uuid
And the UUID of my account is the same as there.
Send your full code
But there. It isn't
The information you're giving doesn't make any sense send all of it
?paste
wow that totally says nothing at all
Send entire classes
What do you mean?
It is the whole code
It literally isn’t
its just a piece of your code
Use another pasting service then
the class is too large
Or push to GitHub
or create a github gist
^
I had!!
never heard of SRP?
Then share it
Link me then
See the links
So where ist it?
Anyone else knows how to set items inside an Inventory GUI? (1.17.1)
It is the whole code you need. What do you need more. Tell me pls.
Inventory#addItem setItem
.
its not. its like taking 5% of a 2000% sized puzzle
Thanks.
Yeah see that's the entire problem, it doesn't do anything, both of those functions.
we need to understand your code to help you.
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.
are you sure that you are not operating on a clone?
It does tho kyllian
Assuming you’re not implementing it yourself or some other stupid shit
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.
its just this:
Inventory anvil = Bukkit.createInventory(player, InventoryType.ANVIL);
anvil.addItem(new ItemStack(Material.DIAMOND));
player.openInventory(anvil);
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.
you need to specify the slot of the item
I think so at least
if you scroll up then thats what I did before, I just changed it to add to test that..
so, and where do we find your function which is causing your confusion?
Are you suppose to create an anvil inventory with the player holder
I am not sure, I can try setting it to null I suppose?
Thought passing Players to inventory creation was only for the PlayerInventories
Yeah try that maybe
its not
RolePlayer.java Line 16 and 17
Just because they do it doesn’t mean it’s suddenly right but I guess. Haven’t looked at implementation so cant tell.
@hybrid spoke
why are you adding the player to the onlineplayer list?
Yeah I don't get it, am I not allowed to create an inventory inside of an event?
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.
it should work fine. its just setting the player as the inventoryholder. makes it easier to identify the inventory
GodCipher.
i am here
In Plugin.java line 37
Idk if it’s intended then sure I guess but really avoid side effects if possible.
is there a way to affect every block in an array list?
Mye
like use player.sendBlockChange for every block in an array
That’s possible totally
i am really not sure what you are trying to do or even doing there. your code is a huge mess. afaik the UUID is immutable so you can't just change it. @rigid hazel
so the uuid of the same player can't just change. it have to be 2 different player instances
arraylist without <> smh
fuck generics
are you saying that to me or someone else-
yes
yes
alright
Raw types is generally a bad idea
okay for the procotol
ahhh alright
you are creating a local arraylist
without generics
adding the block
and throwing it away
also removing them later
yes but im throwing it away after 10 seconds
a hashset might be better here
a bypass for the updating? you are just adding it, never querying it and later removing it
but since you do not invoke #contain nor use the return value of #remove, why would you need to have the arraylist in the first place?
ok so
what i ant to do is
whenever you mine it turns the block into bedrock client side
but when you mine a block below/above/near it
you should completely refactor your code
it updates on the client side completely bypassing the 10 second wait time
you are also defining a local Location variable at the beginning of your function
and never querying it again
because serverside it is still not bedrock
yeah
i want that
so other people can mine during the other person's cooldown
if that makes sense?
why aren't you just canceling the break event for people inside a list?
that would be much easier
uh yes
you shouldn't handle with packets if you just barely know java/spigot
yeah you're right
But if you absolutely need to have it be bedrock, then I think the easiest way would be to spam that packet over and over again
with the cancel break event for people inside a list
can people walk through it
like
the person who's mined
they wouldn't be able to right?
bc serverside its still there
canceling the break event will let them not break that block
oh oh, this sounds complicated
not what im asking
yeah so
it cancels the event for x players right
lets say y player is the person who breaks the block
for the players defined in the list, right.
can y player walk through the block even though on x player's screen its not mined
yeah
But ACs will not be happy with it at all
But I would say no, that should not be possible
this requires protocol stuff
oh so with protocollib i could do that?
I recommend changing your design plans to remove or at least minimise the usage of NMS (and other protocol hackery)
plus this is only part of a demo i'd like to show to my player's before
without any help
You can't have a block exist on one client but not on the other one without packet hackery
sendBlockChange just does it
Well, you could spawn a wall with sendPlayerBlockChange i guess, but that would require you to constantly spam it so the client does not recieve "hey, this is air"
but as soon as you click it its gone
just set an armorstand on the top of the players head
so he can't interact at all
easy
im back sorry
hmmm the issue with that is
they should still be able to mine other parts
just not the part previously mined
which is what i was trying to do with arrays
everytime its mined it'd run through what the player recently mined and make that into bedrock on the player's side
but why if its gone after anyways?
well it goes away after 10 seconds
and i dont want people making a bypass ig
it'd feel weird idk haha
i want the players to move for resources bc it also helps with macros
the less ways people have to cheat the better
i am not sure if i understand you right.
currently you are dropping an extra log for every broken oak log block so there drops 2. 1 tick later you set at the location of the mined block a bedrock block CLIENTSIDE. after 10 seconds you change that clientside bedrock to a clientside oak log. why?
because other players should be able to proceed as usual
ok so
oak log gets mined
- cancel event
- set log to bedrock CLIENT SIDE so player cant mine until
- 10 seconds have passed and player can mine again
uhh?
And that is the issue
the event is cancelled
it works
the block never actually gets mined
because of step 1
ah i see
the issue is that when you click near the block it updates to whats server side
like mining right below the client side bedrock
and thats the oak log
ya never saw the canceling, my bad.
but anyways. just spam it like geol said
you dont have other options
I think NMS has packet transformers that might do the job here, but I have never used those so ¯_(ツ)_/¯
ahhh
no since its clientside
While loop?
if the player is playing on 3 fps normally they will probably have 2 afterwards but other changes shouldnt occur
while loop will crash your server
💀
Call the method every tick
ahhh alright
It'll only be a few dozen bytes per tick per player, so it isn't too much of a deal lag-wise
That being said, it isn't the best solution
Does it require NMS to spawn an armor stand on the player passengers using packet and rotating the armor stand alongside with the player movement?
but not the worst either
its close enough to what i wanted for a small demo
yes or a wrapper like protocollib
oh god nms
I think it should be possible using basic bukkit api
packets?
this does not require packets at all
but he want to do it with packets
no he doesnt
doing it server side
with enough players
can lag the server
so clientside is the best option here
Yeah it is possible, but you cannot teleport If there is passenger.
How would you want to do it clientside?
Which are created by teh server?
yeah but the server just know it created it
spawning an entity is frequently
spawning via packets is onetimer
Worst case scenario the server has 200 players online, so it maintains 200 real entities that are moved every tick, shouldn't be too resource consuming
Well, you can remove or spawn the armor stand whenever you want to basically.
its not
how can I quickly get a list of all plugin resources, so I can save them all to my data directory?
the server doesn't even know that the entity is there
its not moving without sending the packets to let it move
just the user the packet is send to know that the entity is there
So what, bukkit api can do it!
it can, but just serverside.
declaration: package: org.bukkit.entity, interface: Entity
and doing such things serverside is bad
since the server and the client have to manage and handle the extra entity
if you send it via packets just the client have to handle it
Also I have a couple of issues using the api
A single extra entity! How outrageous!
Like when you go in the water, the armor stand will dismount from the player
a single extra entity for every online player on a 200 player server
And I don't want that to happen.
So then it is sealed, packet it is
f.e. a multiline title system with a title over the players nametag.
do you want to have 10 armorstand entities for each player on a 200 players server?
no you don't want to. you want to have them clientside so just the client have to handle them
Either way, the question was the question of possibillity, not whether it makes any sense
yeah we digressed. it is possible.
If I have to use NMS, that means I need to create a module for every version right?
I want it to support 1.14+
if you want to go that way, sure.
Are there any other way?
probably reflections. but i can't recommend that. reflections are bad.
otherwise doing a single plugin for every version
ono
but modules are the best way to go here ig
ok so
@Override
public void run() {
player.sendBlockChange(event.getBlock().getLocation(), Material.BEDROCK.createBlockData());
}
}, 0L, 1L);```
I now have this code but how do I make it only run the amount of times I need it to (200)
use a for loop instead
aight
ah nvm you want the delay
just count up an integer
and if its on 200 cancel the task
Which part that requires the NMS?
packets
Isn't that a really laggy solution?
shouldn't lag at all
Why not use a repeating task?
is there a way to get it to end after x ticks?
Instead of sheduling 200 tasks at once
⬆️
he's using repeating task
I mean
we could get rid of the delay?
wait no
there needs to be a 1 tick delay before starting
but after that it should just be able to loop
Ah I got confused by the code
a for loop would also work but wouldn't change anything since it's changing 200 times at once
I am getting confused here
i think itd be better to use a for loop
why the hell do we need a for loop
you were already given the solution, consider a bukkitrunnable instead since they can self cancel
and I am not too sure whether
int ticksPassed = 0;
BukkitTask task = Bukkit.getServer().getScheduler().runTaskTimer(this, () -> {
player.sendBlockChange(event.getBlock().getLocation(), Material.BEDROCK.createBlockData());
if (++ticksPassed == 200) {
task.cancel();
}
});
is a valid solution
You’ll need to pass the task in the lambda
bukkit runnables can loop?
That is what I have been saying the whole time!
task -> {
Blah blah
task.cancel()
}
Good to know that this is also valid
Alternatively maintain a single task and have some global LinkedHashMap<Player, Location> that is iterated over
then remove/add to this map when time comes
thats what i had earlier haha
decided to do this instead
well
not with hashmaps
i proposed doing it with arrays
GodCipher, how do I keep track of the entity?
Actually, LinkedHashMap<Player, Map.Entry<Location, Integer>> needs to be used since at some point the entry needs to be invalidated
it was just an idea since he said he want to execute it 200 times at once and i forgot that we already agreed on a scheduler
storing/caching it
I think the entities are referenced as integer ids, so storage shouldn't be too much of an issue
Like store the EntityArmorStand?
afaik you can give your fake entity a custom id. store that
I think I'll create another object for that, I want to get the owner of the fake entity too.
guys so
or go functional and use a hashmap
i ended up using the loop and spamming and i think i did it poorly bc it technically worked??? but nothing turns back
Do I need to send the packet again If the player changed world or teleported?
Or the armor stand will stay on the player's passengers?
if you've mined multiple things
most likely
WAIT
ah right, you need to make it turn back manually.
so he doesnt even have to spam it, or am i wrong?
if its not turning back
it could be turning back on the last loop as it turns into a log
ah wait i am dumb
I dont understand
idk if im stupid but how do i make an static getInstance() method on a class
public class YourMain extends JavaPlugin {
private static YourMain instance;
public void onEnable() {instance = this}
public static YourMain getInstance() {return instance;}
}
``` 
or in normal java you can use the (static) constr.
error on my end, i was turning it back to a log on the same tick i think
testing now
is there a way to see someones resource packs?
does clicking the block change anything?
How do I make the armor stand ride player tho?
sending the mount/attach packet
if a player changes his resource packs, will the PlayerResourcePackStatusEvent be fired?
it works
Oh, there is EntityArmorStand#startRiding method
ty guys so much
Called when a player takes action on a resource pack request sent via Player.setResourcePack(java.lang.String).
but theres an error-
not sure if that will work since the packet is probably not sent to the player
add api-version:1.13
You need to define the api-version
aight
ty
i started working on this a while ago thank you everyone who spent so much time to help me
in Player.setResourcePack how can i make it set the default Resource pack?
It works xd
btw, does anyone know what PathfinderGoal.d() does?
void
It could either be the onStart, tick or onStop
from what i know, tick is e() and onStart is c(), but when i tried to put printing to console inside it, it activated before c every tick except the first
What goal are we talking about now
I have custom goal. (and the navigation is also custom, it should set the motion of the entity to aim at the coordinates that are in its params and return true/false based of if the missile reached the target)
public class PathfinderGoalTrackTarget extends PathfinderGoal {
Missile e;
EntityLiving target;
private boolean success = false;
public PathfinderGoalTrackTarget(Missile e) {
this.e = e;
}
@Override
public boolean a() {
target = e.getGoalTarget();
return target != null;
}
@Override
public boolean b() {
return success;
}
@Override
public void c() {
success = e.getNavigation().a(target.locX(), target.locY(), target.locZ(), 2D);
}
@Override
public void d() {
e.setMot(0, 0, 0);
System.out.println(success);
this.e.world.addParticle(Particles.EXPLOSION, e.locX(), e.locY(), e.locZ(), 1.0D, 0.0D, 0.0D);
//e.die();
//target.die();
}
but idk if it is correct, because there are no tutorials on this
d() should be onStop
Hmm yeah obfuscation is ewww
At least it was like it in 1.16.5
You know the difference between a() and b() right?
Anyways it’s canStart vs canContinue iirc
when i try to print both c and d, it starts with c and executes d, c every tick
Anyone know how I could cancel drops while still getting the perks of block#breakNaturally?
i think, that a is shouldStart and b shouldStop, but idk
I am using 1.16, but it will be probably same
And that was valid for 1.16.5
Is there any way to make a command handler
Mojmap warning?
Like not a class for every command
You don't have to make a class for every command
But a class per command is good usually
Really?
Just in case there are any yarn contributors around
It adheres to srp
How do I get the player name from a command args?
Even for tiny commands?
Yeah but like a handler for the commands
And ofc if you have similar commands abstract common code away
So i dont have to repeat getCommand("name").setExecutor(new CommandClass());
is there an asynchronous event for quiting, like Join?
thx btw
If you really want it shorter/simpler: make a HashMap of command names and command executor classes and then just run over that and register it. Can be "simpler" and a bit more dynamic I guess
might impact startup perf slightly
Alternatively: use tools such as ClassGraph
You’re scary
So write your commands in the main class
If you only want to have one instance for all of the commands, just make a static variable with an instance of your commands class
And use it for all of the registering
If you want to totally over engineer command loading:
Use reflections to get every class from your package in which your commands are stored. Have there be a base class, making them all have some property like String name or sth, then load all of them through that.
Or, just write that statement a bunch of times
I do not think that this is possible via reflection, you have to use tools such as ClassGraph for this
At least for obtaining the Class object that is
Anyways why not just provide a stream of commands and then register each one. Just one more line per command, won’t destroy you.
(or just open the jar yourself)
Lol
In the end of the day you’ll hahe to put em on the plugin.yml haha
Hopefully lol
writes gradle plugin to automate it
Not if you access the command map
Hi, I'm making an API for Mini-Games and my APIPlugin has a class called GameManager that has static methods. My game plugin is supposed to call a those methods to add itself to the GamaManager's list.
However my list always seems to be empty for some reason has anyone else had issues with this ?
I think it’s exposed now on spigot
Can we see code
Cant just play guessing games
Yep hold on
the args in a command is string. So how can i change the persistend data container for that player
btw one more question, why isn't the explosion particle effect working (I repaired the rest of the code, co it gets called correctly)?
Why the hell does paper have all the good (and unsafe) features while we do not have them?
This is unfair!
Maybe you are calling another GameManager class
Alright so my Actuel game plugin implements GameAddon
This is my code from my GameAddonManager that handles registering
private static ArrayList<GameAddon> gameAddons = new ArrayList<>();
public static void registerGamePlugin(GameAddon gameAddon){
if(!gameAddons.contains(gameAddon)) {
gameAddons.add(gameAddon);
}
else{
return;
}
}
public static void unregisterGamePlugin(GameAddon gameAddon){
if(gameAddons.contains(gameAddon))
gameAddons.remove(gameAddon);
else{
return;
}
}
I'll grab the code from my game plugin in a sec
Look at the javadocs, there’s methods to get an online player by their name
So basically, my game plugin registers itself during onLoad
then in my api in my onEnable I check the length of the ArrayList which returns 0
and just use a set if you dont want duplicates
then you dont have to check it
um my only thought is its not initializing at the right time
@Singleton
public final class FightOut extends JavaPlugin implements GameAddon {
@Inject
GameManager newGameManager;
@Inject
PlayerManager playerManager;
@Override
public void onLoad(){
GameAddonManager.registerGamePlugin(this);
}
``` this is what happens in my gamePlugin class
Do u use guice?
I do
Or whatever di framework that looks like
But in this case, it isn't the problem because I'm not iniecting GameAddonManager (because it's static)
I'm only using Guice to inject GameManager and PlayerManager
Sounds like it shouldn’t be static
yup
i mean
yup
that's the problem with static
sometimes
Well I guess, I haven’t used guice myself however if you use guice then you’d use it to inject every dependency ideally.
Inject all the guice into your veins
The reason why I'm using static for my addons is so I can tell guice to inject the other stuff into my addon from my api
gamePlugins.forEach((key, value) -> bind(key).toInstance(value));
I haven’t messed with guice a single bit (but dagger) so can’t help you out with the architecture sorry bud
But what was the issue anyways we went too much off topic hehe
Basically GameAddonManager.registerGamePlugin(this); doesn't seem to work
Because my API thinks that the list is empty
Oh right
if you return the class instead of a arraylist?
Use a Set which was already mentioned
sounds better
Okay, will try
Set<E> set = new HashSet<>(); precisely
did you try to register it on enable?
Did I register what ?
to register your game plugin on enable
GameAddonManager.registerGamePlugin(this); this into your onEnable
GameManager.registerGamePlugin
Nope I'll give that a try
also make sure that your GameManager api plugin is loaded before your plugin
yes unless you call onLoad in onEnable
I think it does since it's listed as a dependency if that's how it works
somebody have experience with gameprofiles and packets? more directly, with disguise plugin?
I have an issue, a little one
?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.
still typing faster than me. are you typing with 20 fingers?
So, in my disguise plugin everything goes good, the problem it's in commands. If i use the original nickname of a disguised player it works, so i dont know if i have to send a packet or do something else with the gp
go ask the developer?
That sounds like a #help-server question, if anything
But just read the docs/ask the developer of the plugin
is there any other way of registering an command than getCommand("name").setExector(...);
Or you can use brigadier or some command framework that does it for you
But otherwise, no
Or commandmap
:)
Why would you ever want to do that tho if you aren’t using brigadier or a command framework
Destroys the point
can anyone say me why my uuid on player.getUniqueID() is different then my normal UUID?
Unless you are modifying existing commands
Offline mode?
ok
Maybe you don't want extra size in your plugin?
yes
Then that’s why
but I cant change to online mode
Why not
rip
bungeecord
Oof
bungeecord forwards the correct uuid
^^
I want to create a module for version 1.16.5 and 1.17, does that means I need to use Java 16 for all modules?
Enable bungeecord in the spigot.yml
oh ok thx
?paste
Okay so I tried a few things and my addon system seems to register itself, however when It doesn't seem to be in the list
No
Java 8 code for the most part is compatible with Java 16
might as well just use j16 anyway though
He’s using 1.16
so
So it would depend ig
lol
but seriously 1.16 with java 16 isn't much of a problem anymore and almost anyone can update to it
I have problem with while trying to compile it tho, it's kinda weird.
Hey I have a question, can I update a static variable from plugin A in a plugin B ?
sounds dumb tbh
I have a list from plugin A that handles games and I need plugin B to add itself to that list
uuuh make sure everything is pointed to j16
I mean, that makes the plugin only usable with j16
Yes and it doesn’t even need to be static
Okay cool, would you be able to provide me with an example please ?
Is it possible to fix the issue without making everything compiled with j16?
I still want the plugin work on java version below 16
NMS code is compiled with java 16, and I guess it doesn’t like you referencing that
^
Well you need to add plug-in b as a dependency, make a setter for the variable and then use it in plug-in a after getting an instance of plug-in b
So I'm forced to use j16 basically
I guess I'm gonna create 2 different version of the plugin.
how can I send a plugin message without player?
sounds like making your life harder for no reason
I literally only need a method with craftbukkit.
You can try reflection
yes
Yeah that could work, thanks!
Is there any other way ? Ideally I would like my plugin to add itself to a list onLoad() ?
But the method will be called very often, what's the best way to use the rerlection?
Does this list contain JavaPlugins?
Can't you compile with j16 but still make it produce j8 bytecode?
it's a two-liner in gradle and a 6-liner (or something like that) in maven
just copy & paste
I think you have to define target to be 16 while source is 8, but it could be the other way around
I've tried both, nothing works
what about a source = target = 1.8?
Javac should complain about referencing newer bytecode, but it should work, I think
Same
Not going to lie, im still confused what you mean, how is your gameaddon interface in both plugins without the plugins being linked?
It was teh other way around: https://stackoverflow.com/a/15525251/16138583
So the source will be 16 and target is 8
Is that for the whole project or for just the specific module?
Depends, but usually it should be the whole project
If you disallow a playerloginevent, is playerjoinevent called?
Alright thanks for that, will try it later.
since target is only the Class format version and a class file formatted for java 8 can still reference java 16 features, it doesn't really matter
Source just dictates what features you can use and as such cannot be lower than target (since otherwise it would make no sense)
What was the error again? It just doesn't work?
It just doesn't work :
https://paste.md-5.net/iyopapuhof.md
It registers and then says it has 0 addons
If I make my game log how many addons it has it will say 1 but If I make my game api log how many addons it has, it will say 0
I'm calling the same static method from two plugins, which results in the values being different, so I'm trying to find the correct way of doing this
They both call
public static HashSet<GameAddon> getGamePlugins(){
return gameAddons;
}
could it be that guice is making your second plugin use different classes?
never worked with guice
it shouldn't be, I remember trying without guice and I'm not even using guice to inject this class anyway so probably not
Also GameAddonManager is marked as @Singleton which should stop that from being the case
conclure is just better
how can i use nms using 1.17 spigot api (i use maven)?
Run BuildTools and change spigot-api to spigot in your pom
What the man said
@hybrid spoke Hey, sorry for the time I took to say the problem I encountered. You gave me this link: https://github.com/deanveloper/SkullCreator/blob/4789847930cd68021a95a99d1e16c69b905d420a/src/main/java/dev/dbassett/skullcreator/SkullCreator.java
and I couldn't import these imports:
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
How i can solve this problem ?
Run BuildTools and change spigot-api to spigot (I assume you're using Maven)
I'm using gradle not maven
And where is BuildTools
depending on the server impl is kind of destroying the idea of using reflection in the first place no ? xD
why not just depend on mojangs authlib
Does anyone know why this doesn't create the particles
Explosion explosion = new Explosion(this.e.world, e, e.locX(), e.locY(), e.locZ(), 5, false, Explosion.Effect.NONE);
explosion.a();
explosion.a(true);
but this does (even when these two codes should do exactly the same thing)?
this.e.world.createExplosion(e, null, e.locX(), e.locY(), e.locZ(), 5, false, Explosion.Effect.NONE);
Not much difference import spigot instead of spigot-api and make sure to add mavenLocal() to your repositories
?bt
it is a huge difference what
Not in what steps to follow
one is capable of being compiled without build tools installing the local server into the repo

