#help-development
1 messages · Page 1403 of 1
You could synchronise the Class and that will sync everything in it
you mean to synchronized (MyClass.class) {} ?
yea ik, but i can't in this particular situation since thread unsafe code is ran not only from my classes
no
@ elgar
yeah you can't make code that wasn't written with synchronization in mind be synchronized
sad pepe noises
that what i was asking for, but i guess i'll just run that code in the main thread instead
like yeah you can make every method of your class synchronized yes, but he needs to operate on the methods of a class from nms
Not solved yet
he can't exactly modify the source and make all of the related nms methods synchronized
^^
Then he needs to make an access wrapper
an access wrapper is only useful if all of the access is done through that wrapper
Thats the point of an access wrapper
which again would involve making the nms spaghetti use that wrapper
well problem is that its NMS class, its not that the only one plugin uses it
ah, so access beyond his control
yes
Then I suggest you give up
basically yeah
eh
Just uhh
best you can do is sync to main thread
Mixin the NMS stuff
im just gonna run inside the main thread
if i wanna do a plugin in 1.12, do i use JDK ver 13, or 11?
1.8?
Java 8, 1.8, same thing
lots of servers are going to switch to 11 soon and have switched already
Fixed by running code sync
what with the whole paper wanting to move away from 8 thing
I use 11 in all my servers, big perfoemance importvments
they've gotten a bunch of shared hosts up in the arms and changing the default runtime to 11
and apparently paper won't support 8 as of 1.17
which fucking pisses me off because I like my _ variable names
guys its 2021, java 8 is 7 years old.
but 9 and 11 fucked up reflection and made it gay
1.8 is 6 years old
not really
aren't you the JS developer
lmao
can't access the internals of propietary classes anymore
because i've saw these kind of vars thrown around there
I know of a python dev here
f.e the root field of the Field class
The only change I seem to recall is not being able to reflect away final
there are hidden classes and fields now
quite a few of the base library classes now have their fields and internals invisible to reflection
why?
bullshit
for a class to save data would i use an arraylist or a list?
muh "can't let noobs run around tearing the system apart because it might explode"
what do you care if my system explodes
it's my fucking system
if someone modifies the fields via unwanted software you're already fucked
i can blow it up if I want
List is the abstract class
wtf is that
is what
how can i disable it
disable what
whats it called?
the popup?
the purple thing
popup
yea
press esc or something
reference popup
it shows you what the method parameters are
and is very useful in conjunction with auto completion
if you want to hide the box, press esc and it goes away
if you want to bring it back up, press ctrl-p
quite annoying sometime s
it's a life saver once you get used to it
or would you rather flip between your browser and look at the javadocs each time you forget the exact order of the arguments
is there another method to make player chat other than player.chat()?
Yes Bukkit.getPlayer(name).chat 🙂
I still fear people that write Bukkit.getPlayer(player.getName())
I wonder if they know something that I don't
well, it does prevent the use of offline mode servers
No it doesn't 
player.getPlayer.getPlayer.chat
Interestingly if you run this code in the PlayerRespawnEvent it should throw an NPE java Bukkit.getPlayer(event.getPlayer().getname()).chat("test");
oof
yes this is very clever way of getting the instance of a player 👍
More code 😇
More code has to be better.
howdy do, how would i make a random message chooser?
math.random
list.get(ThreadLocalRandom.current().nextInt(list.size()))
hi its me again
String[] arr={"Tip 1", "Tip 2", "Tip 3", "Tip 4", "Tip 5"};
Random r=new Random();
int randomTip=r.nextInt(arr.length);
player.sendMessage("§6§lTip:§7 (arr[randomTip])");
return true;```
how would i add my random tip to the message
why do i get this error?
mc ver 1.12
the second starting doesnt run
the if condition brakes the plugin
use +
player.sendMessage("§6§lTip:§7"+ (arr[randomTip]));
i think
No, just use Random#nextInt
Don't create a new Random instance every time, you can reuse it
how does spigot internally represent rgb color?
https://pastebin.com/r4Pd3w23
here is the code im getting an error in
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.getItem().getType() == Material.COMPASS) {
System.out.println("hi");
}
}
line 31 is the if statement
use bungee's ChatColor class instead of color codes
yes i mean bungee, not the bukkit one
hello its me again again, would it be possible to stop any mobs apart from zombies spawning?
o hi 7smile7
Sure. Listen for the spawn event and cancel it if its not a zombie
Hi ;D
do you still have that color mapping thing?
at this point im just implementing my own RGB color class lol
okay thanks
hey i got this rn
public class ListenerClass implements Listener {
@EventHandler
}
how would I listen for the spawns
declare a method that takes a single parameter, EntitySpawnEvent, and annotate the declaration with @EventHandler
I need devs, admins and mods for my servers dm me if you are capable (Vouluntary job)
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
good luck getting anyone even remotely competent from this discord
Lol
I think i got a pretty good approximation for the distance in the color space
what am i looking at
thats looking pretty sweet
RGB to mc color translation
Mapping from 24bit rgb color space to ChatColor. He wants to support older spigot versions
I think i missed some weights. But that alright so far. I just didnt get it to work in O(log n) so its O(n) for now
i mean if possible ill send RGB regardless
doesn't adventure have that built in though
adventure?
the new ™ text formatting library
it's bundled in with paper now
but you can still use it on splögget if you depend on it as you would with anything else
^
huh..
?paste
Anyways. Here is the code:
https://paste.md-5.net/omaqeqagaf.java
Feel free trying to implement that with a NavigableMap. For me that didnt work. But the calculations are really cheap. So maybe dont bother.
let's take a look see at adventure's impl
@lost matrix wait
your implementation is 100% compatible with my RGBColor class LOL
if i got rid of the function taking the single int
adventure looks like it's using hsv to calculate the distance rather than rgb
i'm not a color guy so i don't know how much of a difference that makes, if any
it uses hue, saturation and brightness instead of red green and blue
yes, i know that
Some users are having the problem that the database.dB file is not generating, would there be any reason why ? Or should I just make a create db file méthode on startup
couldn't you just have put that in a static block
anonymous initializers are haram
its a lookup map
idk its smile's code
Is there a way adding extra Permissions for Arguments in a Command?
imagine if minecraft supported ANSI color syntax
what changed in 1.16.5 that i cant connect to 1.16.3?
the protocol version
in particular, the social interactions menu or whatever the hell it was called
i think the social interaction menu is bs
You handle that in your TabComplete and your onCommand
the "i am a fragile snowflake and my mind will explode if I have to look at mean words on my screen" menu
microsoft™️
ah yeah
thankfully you can pretty much turn it off on the server side
can you?
yeah
since it relies on exact-match usernames and uuids
just have your chat plugin not send the sender uuid of a message
and if you have literally any chat formatting, it won't be blocked by the username filter either
the username has to be like exactly <youSuckBalls>: youSuckBalls' message or whatever the vanilla default is
Scan started!
Exception in thread "main" java.lang.NoClassDefFoundError: net/thearcanebrony/spigotav/FSUtil
at net.thearcanebrony.spigotav.CLI.Scan(CLI.java:30)
at net.thearcanebrony.spigotav.CLI.main(CLI.java:11)
Caused by: java.lang.ClassNotFoundException: net.thearcanebrony.spigotav.FSUtil
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 2 more```
I would add bodies even if its only for one line. I hate those dangling statements.
what are you trying to do here
why am i getting a classnotfound lol
recursively find all jars in a folder @quaint mantle
only case where i don't use the curly fucks is if the if clause and the thing i'm running fit on the same line
as can be seen by the function name
what does hide matched names even do
If its form your own project: Probably an exception during static initialisation.
in the social interactions menu?
Arrays.stream(new File(folderPath).listFiles()).filter(i -> i.endsWith(".jar"))
it tries to block the messages from the players with that name
but 90% of the time it doesn't work because the chat format has to be exactly vanilla
This does not find all jars in a folder.
wym
its from my own project yes
it only finds all files with a .jar file extension
He also wants all files from sub folders
but i dont see how it could be causing an error?
ohhh
cap
if you really want to be thorough you'll have to open up each file and see the first few bytes if it's a zip
no i have it call itself
in a folder, didnt know he wanted sub-dirs
pls... add a body on there.
how do you mean "a body"
nah


i'll burn your house down
😂
buildtools made my battery go from 50 to 10 real quick
if u wanna use that, its optional i think it just does what you are doing
seems complicated
intellij you ok?
oh wait nvm
its working fine
anyways
best way to check mc version?
i guess i should be using jsemver?
you could use something like this
🤷🏿♂️
getBukkitVersion
or,
version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
``` works too
well yeah, im already using getBukkitVersion but thats a string
nah
you're gonna have to parse it yourself then
ill just jsemver
do you have a question you want to ask
you dont want to filter but to sort. And then call findFirst() on the sorted stream
yatopia 👀
jsemver can parse the second one lol
calm down i'm getting confused, you mean to use a sorted method and them call findFirst() ??
anyways ill check later
public Optional<Entity> getClosest(final Location loc, final double radius) {
final List<Entity> entities = Arrays.asList(loc.getChunk().getEntities());
return entities.stream().min((e1, e2) -> (int) (e1.getLocation().distanceSquared(loc) - e2.getLocation().distanceSquared(loc)));
}
is there a method for getting the 2 corners of a chunk from .getChunk()?
not directly
what would be the radius?
Yes, Math
but you can calculate them very easily
As in vectors? Blocks?
xyz position of the 2 corners
get the chunk coordinate with Chunk::getX and Y
left-shift by 4
that gets you the min corner
uhhh
no, chunk::GetX is the chunk coordinate
a chunk that spans blocks from 16 -> 31 has a chunk coordinate of 1
a chunk that spans blocks from 0 -> 15 has a chunk coordinate of 0
so big distance
The radius should be used for getting the entities in a radius instead of just getting the entities in a chunk.
Getting them in a chunk wont work in many occasions.
I do not know if you had decreased in the intention to solve the problem between a block being an entity of the chunk
oh right
what doe sthis maen
<< 4
what the fukc
So like this:
public Optional<Entity> getClosest(final Location loc, final double radius) {
final Collection<Entity> entities = loc.getWorld().getNearbyEntities(loc, radius, radius, radius);
return entities.stream().min((e1, e2) -> (int) (e1.getLocation().distanceSquared(loc) - e2.getLocation().distanceSquared(loc)));
}
google bit shifting values in java
e.getEntity().getLocation().getChunk().getX() << 4?
yes, that gets the minimum x border of the chunk
<< is kind of like multiplication
but not really
okay
Think binary and move all the digits left by 4 slots.
the problem i dont have the getNearbyEntities
inb4 what is binary
I mean. For integer values it basically is that. For IEEE 754 numbers not so much.
and i put a small value : Entity suc = getClosest(ping.add(0, -1.5, 0), 0.1).get(); ping is a location
so that gets the x of the minimum
What do you mean by that?
im using 1.12.2 api
That's because the armorstand is inside the block
Make the armor stand small and don't let it be inside a block
i put this on y
look what im trying to do
Yeah I'm aware of what you're trying to do
in case if I made a small stand armor there would be a problem with the euler angle and also the items would be small
muh angel
Fine try using Dinnerbone armor stands
dont work
I'm not even sure that works 🤷
i already tried it xd
I don’t think I’ll connect much if the armor stand is outside the chunk, since most of the time it’s a detection only if it’s inside a block
I mean it would have to be as close as possible to where the player clicked
Then getting them in a chunk is really bad because a player could click on the border of one chunk.
eeh i'm not very good with streams
Then dont use them 😄 You can easily solve this problem with a for loop.
i need being updated
real men use for loops anyway
Like this
public Optional<Entity> getClosest(final Location loc, final double radius) {
final Collection<Entity> entities = loc.getWorld().getNearbyEntities(loc, radius, radius, radius);
double smallestDistance = radius + 1;
Entity closest = null;
for (final Entity entity : entities) {
final double distance = entity.getLocation().distanceSquared(loc);
if (distance < smallestDistance) {
smallestDistance = distance;
closest = entity;
}
}
return Optional.ofNullable(closest);
}
would this be correct?
e.getEntity().getLocation().getChunk().getX()<<4 // gets x of minimum e.getEntity().getLocation().getChunk().getZ()<<4 // gets z of minimum
oh fuck
you have copied and pasted your previous line
lfmao
and changed 1 character
to get the maximum, add 15
But i would def allocate a ton of variables for this. Get less DRY
but cant do that condition in the stream and get ?
This is way cleaner than all those chained method calls:
final Entity entity = event.getEntity();
final Location entityLocation = entity.getLocation();
final Chunk entityChunk = entityLocation.getChunk();
final int chunkX = entityChunk.getX();
final int chunkZ = entityChunk.getZ();
final int minBlockX = chunkX << 4;
final int minBlockZ = chunkZ << 4;
final int maxBlockX = minBlockX + 15;
final int maxBlockZ = minBlockX + 15;
objective reality
well, uh
pretty sure that has more self repetition than the direct call chains tbh
good job making it all final though
What's the best way to set the xp merge radius in a plugin?
7smile7 would final his final if he could
Or disable it
ty
It is more verbose. Makes it really clear what types are used and makes it easier to change or expand.
Imagine if you wanted to do something with the chunk later. Then you would need to chain the calls all over again
or rewrite your code. This keeps the code soft.
World probably has a method for setting it
bratwurst
that is a giant blob of repeated code
^
Set the appropriate path
isn't it configurable per-world though?
I mean without changing the config
Well you can adjust it but not save it, but it will still work in memory
i remember it being in the world-settings
Last i tried it didnt apply until you rebooted the server
Maybe we cache the config there. I'd have to check
how can i give someone night vision for less than 10s without it pulsing?
Apply it for a longer time and remove it in a scheduled task.
Maybe i implemented it wrong
And make sure to remove it when the user disconnects
no, looks like it is per-world and that's not exposed
Maybe you could expose world settings?
Because its interfering with a thing i do in my retro features plugin
Or can i set it with reflection?
and 3 free resources
Once im at my pc ill check the spigot source
nvm I see that it takes a while to update. I just added two step
no wait what the fuck that's the total number of characters
it's like 20 chars per row
yeah i'm not gonna be able to fit my fancy cui shit in it
how very sad
hello i have a problem with bungeecord, i can't go from server to server via npc
[20:46:34 INFO]: ---------------------{CommandNPC Error}---------------------
[20:46:34 INFO]: Topic
[20:46:34 INFO]: BungeeCord Command
[20:46:34 INFO]:
[20:46:34 INFO]: BungeeCord is disabled in config.yml, yet an NPC has the
[20:46:34 INFO]: command /server registered to it.
[20:46:34 INFO]:
[20:46:34 INFO]: Class: NPCListener Method: onClick(Player, NPC,
[20:46:34 INFO]: ClickType)
[20:46:34 INFO]:
[20:46:34 INFO]: ---------------------{CommandNPC Error}---------------------
ok can you tell which setting is responsible for that?
I'm reading now, but I don't see an option responsible for it
99.9% sure you're not
how can i get the world config?
if, lets say, everything were public
((CraftServer) getServer()).getServer().worldServer.values().stream().findFirst().get().spigotConfig.expMerge
would this be a bad way?
ofcourse i wouldnt just get first world
does minecraft server or either spigot save players inside some sort of storage? i am trying to remove a custom entity bound to a player like doing so. Tho i think it will throw a NPE when getting the player. how could i go around this if any of you knows?
Are you editing files?
ok so i have a playerdata, but i need the UUID to access that, so i don't know if Bukkit will throw null upon trying to get a offline player
If you need to store data on a player use the PDC
whats that
im on 1.8.8 i don't think it exists. Persistent Data Container if i got it right
yeah
Nope it won't
so idk have you got any idea?
shoots himself in the foot
ouch! that hurt! help me
if (packet instanceof PacketPlayOutPlayerInfo) {
final Object a = Utils.getField(packet, "a");
final List<Object> b = (List<Object>) Utils.getField(packet, "b");
final Object playerInfoData = b.get(0);
final Object gameProfile = Utils.getField(playerInfoData, "d");
final String name = (String) Utils.getField(gameProfile, "name");
if (name != null) {
final Player pl = Bukkit.getPlayer(name);
if (pl != null) {
if (a.toString().equals("ADD_PLAYER")) {
((CraftPlayer) pl).getHandle().listName = CraftChatMessage.fromString(name)[0];
final PacketPlayOutPlayerInfo nev = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) nev).getHandle());
((CraftPlayer) pl).getHandle().listName = CraftChatMessage.fromString(name)[0];
super.write(context, nev, channelPromise);
return;
}
}
}
}```
whats up
I try translate this to ProtocolLib
yeah?
but I have problem ;/
whats the problem
idk how create new packet with constructor
PacketContainer playerInfo = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
I have but this is null
final PacketPlayOutPlayerInfo nev = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) nev).getHandle());
I want translate PacketPlayOutPlayerInfo to PacketContainer
@alpine urchin you have idea?
hm
i can't remmeber how to use protocollib wrappers lmfao
they have a specific wrapper for that packet
@main dew use https://github.com/retrooper/packetevents
how could i make commands executed by my plugin silent
silent?
how do u mean silent
does this help?
Maybe remove the line that plays the sound to the player?
@pure glacier he wants to use ProtocolLib
this is so dumb but why cant i put Main there?
public class RespawnEvent implements Listener {
@EventHandler
public void onRespawnEvent(PlayerRespawnEvent event) {
System.out.println("test");
Inventory inv = Bukkit.createInventory(null, 54, "test");
Player player = event.getPlayer();
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncDelayedTask(Main, new Runnable() {
@Override
public void run() {
Bukkit.getLogger().info("test1");
}
}, 2L);
}
}
in the delayed task
what do you mean
U need to have a thing to get the instance of main.
Ex. A public static Main instance
yeah so it doesn't get logged in the console
Then in onEnable instance = this @sharp bough
oh
Then make a getter for it.
i have this public static Main get(){
return instance;
}
i just have to add Main.get()
which getconfig do I need to Import for Configs?
thanks that makes sense
Is instance defined? Coz Rather than main use Main.get().
many commands from other plugins like essentials ezblocks etc. etc. etc.
where do you set that
on enable
i need my plugin to not send message in the console when it executes thoose commands
and you don't call Main.get() before setting it right
no
well, i don't think you can
with the bukkit api atleast
might be some hacky way to do it with some reflection
that i don't know of
Aekit let's u do it I believe.
does anyone know why when i replace the .jar from the target to the plugins folder my "replace" file does not popup anymore?
i get the message but i have to click the open files , click the message and then replace
Use a bash/batch script to build it, delete old jar and copy new jar.
i have on idea what a bash script is, i will google it later, thanks
@kind coral which command are you executing? is it a spigot command or custom
cause the easiest solution would be to recreate the action
its a luckyblock plugin and the commands to execute are set by the user in the config
i see
tho i really don't want to silent all my plugin it will be useless.
maybe my boy, homeboy @odd gulch knows
benz basically he wants to use Bukkit to execute a command without having it be visible in the console.
do you have any idea
guys
why isnt this luckperms dependency working
<dependency>
<groupId>net.luckperms</groupId>
<artifactId>api</artifactId>
<version>5.3</version>
<scope>provided</scope>
</dependency>```
did you import the correct repo?
https://mvnrepository.com/artifact/net.luckperms/api/5.3 it's maven central it appears so, so you are right
Can anyone help me for some reason my plugin is showing up in my plugin list
That is intended
It should work, not entirely sure what you messed up; did you try to rebuild your maven application?
could i try sending you the plugin
That is even less useless than the full error message
that is literally all it says
Does it not show which repos it searched?
can anyone help me with spawning in a structure (such as a bastion)? I know structureblockapi exists, but it can only spawn pieces of a bastion?
im very smart
🤨
is there an event for entities looking at players?
Hey, ive never ever used getInstance as a way to access main class from other classes so I ran into this error which im rly not sure why it happened.
Code: https://pastebin.com/qHGerSTi
https://pastebin.com/s0gsrCpL
Error:
https://pastebin.com/eG9CDGgP
So as I understood my Main instance is null, which i dont understand how since I returned the main class. I've always accessed main class with constructors or some other methods so thats pretty new.
Main.main = this; is after the registration of the enchantment
you should put it before, it can't access something that isn't defined yet.
you have your enchanting instruction and then the assignment of the main instance
@vital ridge
just had to move it few lines up
yep
Never used this way to get the main class
since constructors were always my practice
use dependency injection then ( using constructor yes )
looking at? there's https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityTargetLivingEntityEvent.html and EntityTargetEvent
those events stop mobs from targeting the player, but it doesn't stop them from looking at the player
there probably isnt an EntityMoveEvent, but i guess you could check the rotation of nearby entities and set their direction away from the player?
whats the InventoryDragEvent ? if i cancel the inventory click event you cant drag right?
i tried shifting, ctrl click etc
if i cancel the inv click event then inv drag event doesnt run
drag itemstack over 1 or more slots
yea, but to drag you have to click?
if you're cancelling every possible click event sure, but that's probably not the way to go
always safe to check for drag event too
hm aight
there's an entity move event on purpur
inventory click and inventory drag event are two separate events
if you move your mouse pointer even 1 pixel while holding LMB down, it fires a drag event
if it does not move at all, it fires a click event
the click event is not a prerequisite for the drag event
Ummm I am using player.performCommand() to run a command to add a marker to dynmap but it doesnt let me do it saying it can only be run as a player. But player is a player
why are you running a command to add a marker
because i am testing something
you should use the dynmap api to add the marker instead
it could be something fucked with how bukkit handles that, would need to look into what dynmap does with commands for more details though
why
is ther an alternative to performCommand
why are you even testing something like that
because some plugins dont have a good api
firing commands to do shit is literally worse than not doing anything at all
the alternative and the correct choice is to not do it at all
or perhaps better yet go bully the author
or just hooking against not-api internals of the plugin
does inv.addItem stack items if they are the same material?
uh iirc no
How does one work with API's like Dynmap API?
you mean like, web apis?
Hey hey. I'm wondering what would be an efficient way of counting up for everyone who is currently alive on the server? Doing a runnable and looping through all the online players seems really heavy on performance
I just finished coding my plugin and for some reason it's not showing up in my plugin list in game
!logs
Server#getOnlinePlayers#size geri?
.logs
Wasn't that a command? Anyway, can you please send us your latest.log?
As in, every player has their own value counted separately
what? whats the difference
That it'd reset whenever they die
so you mean a timer for how long they have been alive?
@novel hornet your plugin.yml is invalid, can you send that?
Yes, basically
player.getStatistic() and i dunno the statistic for time since last death
I know
But I want to modify this score. For example if they are doing something, it wouldn't go up
why does this https://paste.md-5.net/huqokusoso.cs
always return 0
you import the API as a dependency
either via your dependency manager of choice, like Maven
or through your IDE
you can also modify the statistic using setStatistic()
Just doing random small projects?
Oh hmm so I would store it whenever I want to freeze it and keep resetting it until they leave/stop doing whatever
name:PantsThatPoopTnt
version: 1.0
author: mrpiedot
main: me.mrpiedot.PantsThatPoopTnt.Main
description:||Cock and ball torture (CBT), penis torture or dick torture, is a sexual activity involving application of pain or constriction to the penis or testicles. This may involve directly painful activities, such as genital piercing, wax play, genital spanking, squeezing, ball-busting, genital flogging, urethral play, tickle torture, erotic electrostimulation, kneeing or kicking.[1] The recipient of such activities may receive direct physical pleasure via masochism, or emotional pleasure through erotic humiliation, or knowledge that the play is pleasing to a sadistic dominant. Many of these practices carry significant health risks||
I don't watch such
what the fuck
dont ask
??? wtf
lol
not gonna lie
every config should have that
give a space after 'name'
yeah that isn't valid yaml
im dumb
yaml needs spaces after :
how much for the plugin
yaml never asked for this
hmm
lmao
honestly yeah
survival mods tend to base around the most developed and documented parts of spigot
so making a "acid rain" or "friendly mobs are evil/evil mobs are friendly" plugin is a great first challenge
satisfaction at 2 frames
the best practice is to just directly copy each of his videos and monetize 💰
yeah pc cant handle 4k orbs lol
yeah do that lmao
theyre pretty fun to make
especially with a group of friends to play them with
Does anyone here know how to use the dynmap api?
they have documentation
they dont
i started spigot some years ago and only recently am coming back 😄
in my effort to relearn what I lost I made a dozen or so just really simple plugins
so like Manhunt, acid rain, server sleeping, all sorts of challenges from way back when
Bedwars is a fun one too, so is Capture the Flag but those are a bit bigger in scope.
I used documentation to remind myself how many of the core bits and pieces of spigot work, from there it's just freerunning.
There's plenty of wiki out there to read too, stuff on commands , all the way up to world gen
as if I was in any way talented enough to get any info from that
but thanks
it's pretty straight forward
for some reason crouch events count your first crouch as a crouch and when you stand up as a crouch how do fix that
are you using onPlayerToggleSneakEvent?
there is no "crouch event"
did you try using the #isSneaking()?
it fires if it turns off
from Player
that's what toggle means
oh
hi can anyone of you help i want a player to be charged on his death let me if any plugin can do that or u know how to
yea so to check if the toggle is true
Try grabbing the attribute from the player
you might have to invert the condition
charged? like economy?
most events fire before the actual change occurs
yes
so it's possible that the player isn't sneaking during the event yet
oh right
is there only a toggle for sneak event?
yeah
Sneak event is not spigot
yeah like in hypixel skyblock
where it take the half
of your money
I don't know how to deal with economy so I wouldn't be able to help you, but if you can hook into whatever economy plugin you use and call some removeBalance() (I've never used it so I don't know), from the PlayerDeathEvent, that would maybe do the trick?
ok ill check the config
economy things should be done through vault
look up a guide on how to hook into vault
vault doesnt have a config
oh vault that's what its called
yeah
if you want to charge a player, you'll want to get the vault economy api and call the appropriate method
probably on player death event
ok thanks for the help ill look up for the api
Hey again - theoretically this updates every 1 second but this doesn't reach right event at all. It's quite late, am I not seeing something obvious?
@EventHandler
public void onPlayerStatisticIncrement(PlayerStatisticIncrementEvent e){
Bukkit.broadcastMessage("fired");
if (e.getStatistic() != Statistic.TIME_SINCE_DEATH) return;
Bukkit.broadcastMessage("right event");
}
oh even cancelling the event doesn't stop it from happening
It does
That's quite unfortunate, this would have been so much easier
im stuck on this. ive set playername to item on its displayname which prints out "in red somehow" but when using it on a playerobj its null any reason what i did wrong here ?
are you the guy who we told to use the pdc
yea looked into that one, did not figure out how to use it"yet"
String uuidAsString = item.getItemMeta().getPersitentDataContainer().get(myKey, PersistentDataType.STRING);
UUID uuid = UUID.fromString(uuidAsString);
Since playername is stored on its displayname i did not think it would be a bad way to get its name from that
Player player = Bukkit.getPlayer(uuid);
getting players by name is kind of haram these days, what with players being able to change their names
is there any decent info ? would like to understand prc bit better
thanks!
oh no he's using the inventoryview's name to find his inventory
haram alert
nvm ^^
could armor work with ItemStack
what?
is armor considered a item is what i'm asking
Anything in your Inventory is an ItemStack
Armor slots are a part of the Player Inventory
new ItemStack(Material.DIAMOND_CHESTPLATE) boom armor
anyone have a good way to make a swear filter that blocks out the found with *'s... I cant seem to find a good efficient way to do it...
regex and replaceall
Pattern match cat|dog|horse etc
or StringUtils
message.replaceall("(fuck|you|cunt)", "***")
StringUtils.replaceEach(text, searchList, replacementList)
if you want to make the *** have as many letters as the filtered word, you'll have to look into Matcher and either the java 9 stringbuilder helpers or just plain for loops
StringUtils is Apache Commons and its shaded in Spigot
and like all things shaded in spigot is probably 6 years out of date
How often are databases used when coding plugins?
whenever necessary
more or less
a database is a tool and each tool has a job
some people suffer from trying to use the wrong tools for the wrong jobs
I've never used them
and some stick with shit like the fucking bukkit config api where a database would be better
I use YamlConfiguration
json files to store huge data OP kekw
idk databases
yeah, you belong to the latter category
I'd love to learn them, pretty sure I'd need it for a JDA bot
the main thing to keep in mind with a database is that a database might not be on the same machine and so queries to it might be slow
so unless you're 100% sure you're not working on like a local in-memory database, you want to take that into account
which means not doing queries on the main server thread
you don't want the server to shit bricks and crash when the control connection times out for 30 seconds
Or do I? 
Even if a database is on the same machine queries can be slow
yeah, needs to be an in-memory database at minimum
sqlite has an option to be in-memory iirc
👀
I didn't know that
SQLite is pretty damn performant, I know that much
It's about as fast as you'll get with SQL of any form
Still not something you wanna be querying multiple times per second on the main thread
But I have written plugins that use SQLite sync on servers with hundreds of players without issue, so I can vouch for it
yeah you kind of lose a large fraction of the benefits of having a db if you restrict yourself to an in-memory db on the same system
This is true
I wasn't aware that SQLite had ways of being in-memory, I've always used it as just a file
And that has served my purposes
In general I'd avoid using remote databases on game servers where you can though
I mean, just always code as if you were coding against a database located in the deep jungles of brazil and allow users to just plug in an in-memory alternative to go lightspeed
so your db facing code should still be written with the worst case scenario of it being on a fucking tape drive in china in mind
If you have to, you're probably gonna want in-memory databases to act as caches on other game servers that are querying it
is there a way to give an armorstand velocity but without gravity?
i'm pretty sure disabling gravity completely disables all velocity on an entity
i googled and 2 solutions both included using nms and overriding this function
public void g(float f, float f1) {
if (!hasGravity()) { // hasGravity() actually means hasNoGravity(), probably a mistake in deobfuscating.
super.g(f, f1);
} else {
move(motX, motY, motZ); // Give them some velocity anyways ;3
}
}```
but i dont know how to apply this
I normally set up my SQLites to be in sync with mysql on restarts and what not
probably useless tho

i have a question
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.getItem().getType() == Material.COMPASS) {
System.out.println("hi");
}
when i check for a compass
the if statement line returns null
but
if i check for something else
it works perfectly fine
https://pastebin.com/r4Pd3w23
thats the error
the held item may be null
you are not testign the item in your hand
a second one for the main hand
so i should use player.getItemInMainHand?
i don't remember
use hasItem() before you test getItem()
ok
PlayerInteractEvent::getHand
how can i force someone to sneak in order for them to go under like a 1.5 block high thing
^ that too
otherwise, you will notice that your logic will fire twice with each click
and if the player holds a compass in both hands, all of your shit runs twice
ok
i want it to work with both the main and off hands
then just test hasItem and getItem
ok
or
you'll have to like mark the player for 1 tick
otherwise, if they hold a compass in both hands, your code runs twice
set a lastFired Long. so you can check that value and only run your code if its not fired for 1 second.
if (e.getHand() == EquipmentSlot.HAND) {
} else if (e.getHand() == EquipmentSlot.OFF_HAND) {
}
or i guess you could check if the event was fired for the off hand, and return if the player has a compass in the main hand
kind of nasty as well but that's bukkit
if you want to be able to use a compass in either hand you can;t check the Hand
ok
ill just do the main then
wait
i have one question
what will e.getItem() return if a player clicks and they have something in both their main and off hands?
it returns the item in the hand the event was fired for
the item in the main hand for the first event
oh ok
the item in the off hand for the second event
so the event will run twice
yes
once for each hand
ohh ok
i mean thats fine for my plugin, idc
but whats that have to do with the compass thing
it returns null
Long triggered = System.currentTimeMillis();
event {
if (e.hasItem() && e.getItem().getType() == Material.COMPASS) {
if (System.currentTimeMillis() > triggered + 1000) {
triggered = System.currentTimeMillis();
//do whatever here```
your other hand is probably empty
your other hand's content is null
thats why
ok thx
so ill check if e.getItem is not null
that way when it sees the off hand is null it wont run
check if it's air*
ok
air is nasty
and check if it's null
yes that too
chaos
The code above will work for either hand and you can set how long before it will work again
i dont think hand ever returns null?
it might not
so it will only work on the hand with a compass and then ignore the other hand
but best practice when working with inventories and anything related is to check both
if (e.getItem().getType() == Material.AIR && e.getItem() == null) {
return;
}
yes
ok
even the fucking nullability annotations are wrong from time to time
check null first
k
e.getItem().getType() will explode
yeah i mean this doesnt make sense lol
oh ok
ill use e.getmaterial
check the craftbukit source 🤷♂️
and AIR throws NPE often
exp when you try to do things with it
and make sure you use or not and operator
hi! i'm a new developer
if (c.getBlockInventory().getHolder() instanceof DoubleChestInventory) I'm trying to check if a clicked chest is double or not, this method doesn't seem to be working. c is a Chest.
try the instanceof on the block inventory itself
getHolder is most likely an InventoryHolder
which is different from an Inventory; it's the thing that holds the Inventory
getting an error there
if (Bukkit.getOnlinePlayers().toString().contains(args[i])) {
stalkers.add(Bukkit.getPlayer(args[i]).getUniqueId());
Main.main().tracker = new ItemStack(Material.COMPASS);
Bukkit.getPlayer(args[1]).getInventory().addItem(Main.main().tracker);
} else {
invalidPlayers.add(ChatColor.RED + args[i]);
}
line 44 is where i give the player args 1 the itemstack tracker
Worked, thanks! Although it stops working if one side of the chest has a solid block above it 🤔, curious if there's still a way to get around that
args[1] is not a valid player name
its a string
so Bukkit.getPlayer(args[1]) returns null
oh
and .getInventory throws a null pointer exception
ok
but ik that args 1 is a valid player
the player reference whose uuid you're adding to a list isn't null
oh ok
can i force a player to crouch?
you put a player in it
can i cast it to a player?
basically
you can cast it yes
but it will still be null
oh
wdym
if Bukkit.getPlayer(args[1]) returns null, that means bukkit did not find a player for that name
if (Bukkit.getOnlinePlayers().toString().contains(args[i]))
well
then this if statement has to be wrong right?
"my player variable is null"
and
"my box is empty"
are the same
if you get an empty box
the only way to make it not empty
is to put something in it
you can't make an empty box have something in it by twisting it around or shaking it or bouncing around with it
you can't make a null reference have a value by casting it or renaming it or sending it to the moon
null is null
empty is empty
also you are checking if the list contains args[i] and not args[1]
oh
ohhhhhh ik what i did wrong
im supposed to do Bukkit.getPlayer(args[i])
k it works now
also that is not a good way of checking if a player name is valid
how do i then
Player player = Bukkit.getPlayer(name);
if (player == null)
if the player name is not valid, bukkit returns null
if it is valid, it returns the player
for (ItemStack slot : c.getInventory().getContents())
{
if (slot.getType() == Material.AIR)
{
spaceNeeded -= i.getMaxStackSize();
}
}```
This code causes weird exceptions (null pointer i think?). what do? (i = ItemStack, c = Chest)
changing it to if (slot.getType() == null) still causes null pointer exception
easy solution
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
for (Player player : Bukkit.getOnlinePlayers()) {
for (ItemStack item : player.getInventory()) {
if (item == null) item = new ItemStack(Material.AIR);
}
}
}, 0, 1);```
(this is a very good idea and will not hinder performance in any way)
doesn't that default back to null
No
not worth it imo
also
what happens when you right click on interact an empty slot
?
i bet it's null 🤔
Easy solution: fork spigot and solve the issue there
it's a sad overseeing
i'm pretty sure 1/100 plugins will not preemptively check for null
and get their plugin harshly screwed
easier solution: write your code to work with null values 🤔 🤔
i don't understand if it will throw null if the key and value don't exist.
not entirely sure what you mean
hey
how would i make a plugin
that puts people in the lobby
if they get kicked from a server
cuz if i restart survival
they get kicked
instead of going to the lobby
@EventHandler
public void kick(ServerKickEvent e) {
ProxiedPlayer p = e.getPlayer();
if (!e.getKickedFrom().getName().equals("lobby1")) {
p.connect(GlobalMessage.getPlugin().getProxy().getServerInfo("lobby1"));
p.sendMessage(ChatColor.RED + "You have been kicked from " + e.getKickedFrom().getName() + " for reason: " + e.getKickReasonComponent()[0]);
}
}```
i have this so far
do it on the on disable method
ah for bungee
I suggest having something that overrides the spigot restart / stop command and sends players to lobby and then restarting the server
that's what I do and it works very very well
and this is built for spigot^
Hello !
I'm messing around with little things to pass the time, and I'm trying to make a system that allows you to choose a command in the config, but I have a problem ...
How to do ?
I tried to get a string in the config and put it in the line "getCommand ()" etc but I have a small problem: the plugin does not recognize the command if it is modified because of the plugin.yml file. ..
How do you go about fixing this?
Thank you for your time.
Use a command api like helper by lucko which Automatically registers commands

It other good stuff
Hey anyone here who has a good Update Notifier script? The one i use doesn't work.
Make ur own
I am very new to Java and plugin development so i was told to ask around.
i am new to java too
Lie
I just don't know how to check if the version string is the same as the newest version.
try (Scanner scanner = new Scanner(new URL(url).openStream())) {
version = new gson().FromJson(scanner.nextLine(), JsonElement.class).getAsJsonObject().get("current_version").getAsDouble();
scanner.Close();
} catch (IOException ignored) { }```
cap
People aren’t going to spoon feed you