#help-archived
1 messages · Page 180 of 1
integer division doesn't give you floor
= -1
it "rounds" towards zero
no
yes? (Math.floor(-1.0D / 10.0D)) != (-1 / 100)
floor will give you -1
flooring the result
integer division will get you 0
@pastel nacelle oh yeah for signed values sure
yes.
But how come the signed bit isn't an issue in bitwise operations
Is it ignored?
what the fuck
thing got stuck
thought you'd gone insane
but still, what's the answer to that
huh? answer to what? division and bitshift are 2 different operations
if you are asking why the sign doesn't change in rightshifts
it's because >> pads the leftmost bit with the sign bit
pads it with zero
arithmetic vs logical right shift
So in other words it's ignored, thanks.
use getEquipment().getItemInMainHand()
truncating is not the same as floor
cast -1.6 to int vs flooring it
youll get different values
no
Anyone an idea why this keeps happening? Spigot 1.16.1 with a village with 50 villagers, but every 15 mins or so, the whole village is filled... No plugins...
vanilla bug afaik, basically something goes derp and so you get a nice # of golems
imagine writing competent mob spawning code
I can kill it with /kill, but that's annoying and I don't want to give everybody on this survival server that permission
remove villagers from your server
I'd rather remove golems than villagers
golems are just big gray villagers
why does this not work? https://i.imgur.com/88yAmbg.png when I have this: https://i.imgur.com/Rodn1da.png
Hi, I have a question regarding permissions children (in plugin.yml)
my setup is as follows currently: ```yaml
uhcp.:
description: Grants access to all UHCPlus commands
children:
uhcp.preset.: true
uhcp.preset.*:
description: Grants access to all /uhcp preset <arguments> commands
uhcp.preset.create:
description: Allows the player to create a new preset
if I do it like this, will uhcp.preset.create be a child of uhcp.*?
if I were to add uhcp.preset.create as child of uhcp.preset.* that is
if (e.getView().getTitle().startsWith(ChatColor.DARK_RED + "[ChestSecurity]")) {
try {
switch (e.getCursor().getType()) {
case WRITTEN_BOOK:
e.getView().getPlayer().closeInventory();
break;
}
} catch (NullPointerException ex) {
System.out.println(ex.getCause());
}
e.setCancelled(true);
}
``` I'm trying to make it so when a player click the item with the type as `WRITTEN_BOOK` it closes the inventory, but for some reason the item is going back into place when i click it, but its not closing the inventory
InventoryClickEvent?
yes
I use event.getWhoClicked().closeInventoty();
Syntax might be off, doing it off my head
also for getting the clicked item type, use event.getCurrentItem().getType()
ok
Don't catch NPEs...
and catching that NPE is pretty bad imo, it shouldn't be necessary if you: java if(event.getCurrentItem() == null || event.getCurrentItem().getType().equals (Material.AIR)) return;
ok, thanks
Do any of you know how to overwrite the default restart command?
I tried that though Bukkit/Spigots restart command seemed to overwrite it
CommandPreprocessEvent?
Usually that does work though, not sure why it didn't
Ok and check the command there?
Hmm try unregister the default restart command then?
How so?
So reflect the commandmap and do that.
Likely doesn't work because it's a built in spigot command and takes priority
Ok
Is it?
so probably would need to remove it from the server jar
Though only the default minecraft commands was
Yeah it's built in to spigot
I may just use a PreProcess Command Event then
Let me decompile
Coll last time I checked it's totally possible to do that
These commands are only found in Spigot
/restart
Description: Will tell the server to attempt to perform a restart (You must have "restart-script-location" filled out correctly for this to work)
Permission: bukkit.command.restart
/timings on
Description: Turns server benchmark timings on (on demand - no restart required)
/timings off
Description: Turns server benchmark timings off (on demand - no restart required)
/timings paste
Description: Sends all server benchmark timings to http://paste.ubuntu.com which can then be viewed viahttp://www.aikar.co/timings.php
/tps
Description: Will show a super accurate Ticks Per Second (TPS) of your servers current status.
Permission: bukkit.command.tps```
@light geyser its closing, but now the player can have the book on its inventory how do i fix that?
Cancel the event, then they can't click and take it
i did cancel the event
Cancel inventoryDragEvent too
How do I fix this error?
When I try to run /data get entity @r
Report it and request delete
First check if the gui which was clicked in is your gui, then cancel it and do your stuff then
How long does that usally take?
Coll hmm it's kinda akward because the RestartCommand doesn't seem to be in the setDefaultCommands() as those are the spigot cmds right?
So theoretically it should be possible to override the RestartCommand
Are you trying to override the restart command with your own?
Not me
Ah okay, I think I know how.
Speaking of restarts, any way to restart it without a restart script?
Ie the start.sh
not rly?
Reflection would probably be more efficient than PlayerCommandPreProcessEvent
^
If you know reflection
It's not hard
I am completely lost right now and completely tired and completely stupid what are the values inbetween and how can i calculate them? Can't just do divide by 5 since i want the first character to be 0 and the last one to be 255 Sorry please don't judge im tired and LOST right now
Please do explain conclure, I'm using cmdPreprocessEvent quite a lot
You can replace any command with cmdPreprocessEvent
If reflection is more efficient, I'd love to know
You give the event EventPriority.HIGHEST
And get the first argument, check if it equals restart or spigot:restart or whatever with / and it's ez
It might not be "more efficient" but it does the job.
For cmdPreprocessEvent you need to check the first arg with a /
If you really want to learn reflection, search it up and read about it.
But overall it's how to obtain fields, constructors and methods and invoke them without actually invoking them kind of.
I've used the event to replace /help
@light geyser if the player shift click he can get the book and the inventory closes
Should probably move to reflection
For cmdPreprocessEvent you need to check the first arg with a /
@light geyser Yes.
I'm thinking about releasing my API for replacing commands really. Its just ReplaceAPI.replaceCommand("cmd", with command);
if (event.getMessage().equalsIgnoreCase("/help"))
event.setMessage("/infobook");
}``` Pretty easy to use
@stuck quartz check my repo : https://github.com/TheDutchMC/uhcplus, nl.thedutchmc.uhcplus.gui should have most of your answers :)
I mean reflection is heavily used when it comes to multi compatibility even though multi moduling is little faster.
But the main issue would be that many developers doesn't maintain it right.
I've got a feeling its not really version cross compatible?
it is
i cant find a file that can help me in my problem Dutch
I'm developing for 1.16 only so don't need to check for that much but
You should be able to overbloxed,. I've built quite a complicated gui system, I think the easier gui is under .gui.recipes.subgui
Well as you can run reflection on runtime makes itself being able to support that.
Then you've got the main gui class, and the event listener class
Hello, je configure vos serveurs Faction pour ceux qui souhaitent venez privé 🙂 (c'est pas gratuit)
For french people
English please :)
^
We can't help you in French
oui oui baguette
Oui oui, je ne parle pas le baguette xd
Using reflection doesn't guarantee that it'll work for any version. It just works for versions that have the same fields and methods. And given that it's used mostly for NMS, the method/field names are never guaranteed to stay the same across versions
^
Right, so for cross version you might get multiple different codebases for that element
Though in minecraft most things doesn't change too much and hopefully you'll have your reflection working just fine.
Same idea different method names
yeah
Right shouldn't be too much of an issue
I tend to dev only for the latest version anyways, since I like to use the latest features, e.g my uhc plugin only does 1.16 because I use netherrite upgrades
Don't bully me https://github.com/Conclure/SplendidVouchers but here I did use multi modules mostly which can be considerable solution as well.
Not finished yet though.
Multi modules as in every version has its own module with the correct names for reflection?
No - multi version abstraction does not (generally) use reflection
That's the entire point
If you're going to use reflection, then please cache that reflection :]
That'd be a given, I'd say
Get the github app 😮
But obviously not obvious for everyone
Android too it seems
It doesn't skip empty dirs
hey, I'm new to spigot development but I'd say I'm somewhat experienced in Java, how would you create a plugin that supports multiple versions?
:/
Either abstraction + multi module project
Xmair reflection or multi moduling
Or reflection
If you want to multi module you might wanna look into this. https://github.com/Conclure/SplendidVouchers dont bully lol
Still had that on my clipboard :}
I built the core of my plugin on 1.15, then switched to 1.16 without having to change a single thing lol
Oh yeah
Makes those things possible
It depends on what you're using - there won't be many major changes within the API
wait so basically multi moduling is writing the same plugin for diff versions again and again?
No
Nope
Abstraction + multiple modules
You create an interface and implement it for each version
I see
O.o conclure I need to spit through your build.gradle, it looks interesting
Neat
You basically have a bunch of abstract methods which you declare for each version then in the main plugin you check the nms version and based on that you get the wanted class.
Yeah Dutch I hate multiple build scripts
I've not used nms yet, I need to look at that tio
sry but I am that dude :]
In that sense it doesn't matter whether it's an abstract class that gets extended for each version or an interface that gets implemented for each version
But I've found an interface to work for my use cases so far
Yeah though I kinda use a generic builder I did have to use an abstract class
I can see how that could/would be useful 🙂
Yh though my code is always getting to the spaghetti level
few ways to go about supporting multiple versions
indeed
Knowing your code is spaghetti is better than not knowing 😄
I thought I was good at plugin dev, now I realized I'm still a noob lmao
can even go the route of using enum as well if what you are trying to support isn't very large code wise 😛
true ford
I'll give it a try tomorrow
Dutch me2
like my current project is almost 7k lines, so I thought I must be getting decent, but nope apparently XD
lines do not really show much
True,
You use Enum to hold the appropriate class for your version, and then can use a class that can choose the appropriate enum based on version, use the enum to load said class 😉
Idk but I made a simple core but it took 200kb idk how
mine is like 350kb noe
Frostalf I always do it with the static block
Including paper lib though
Are there some specific practices you guys avoid? For example using some specific functions/events as less as you can?
And apache commons io
Can use a static block, but enum is static already as well
so probably not much different then what you do
True true
Not sure what you're asking, Xmair
If you need to listen to an event, you have to, well... listen to it
@unique barn yes there is certain things that are avoided by some of us developers even though it is in the API. But it really depends on what is being made. Just because it is in the API doesn't mean it is optimal to use.
Exactly, the last line is basically why I asked the question
I'd certainly try and avoid deprecated methods unless you know and understand why they're deprecated
The javadocs is a great start
Other than that, as said above, it really depends on what you're doing
So storing Player objects in lists or hashmaps or some other kind of collection is generally avoided due to how easy it is to not have a correct reference to something involved with it, as well as introducing memory leaks because you forgot to remove it from somewhere when a player left the server
that is one of the more popular ones
@naive goblet hey my dude
Alongside that, you'd want to refer to players using their UUID not their name (nor the Player object like mentioned above)
Got it, thanks for the tips
I changed the kickme message but now it's default?
I need to ude some depricated ones, like the getItem in itempickupevent
Hi Banana
Pseudonames there ^^^
I'd also advise against getting offline players by their name unless you're sure they've joined the server because the existing method will freeze the server while doing a network call if no player by the name has ever joined the server
Here is another one that doesn't seem as obvious. Iterating over chunks can cause some problems. The more optimal way if you really need to iterate a chunk or many chunks, is to grab a copy of said chunk and use a separate thread to get the info you need 😉
API has a method for this specific purpose, but I see many people not use it lol
Banana hmm let me check the plugin
Chunks and efficiency...my chunk generator is not thst xd
Before I optimised it it would eat 20 gb of ram
Now only 500mb :)
Frostalf - when you say "iterating over chunks" you most likely mean iterating over blocks in a chunk 🙂
Even getting entities
Also, people don't know the difference between using BasePlugin and JavaPlugin either. If your plugin is an API for other plugins, it should extend BasePlugin and not JavaPlugin 😉
Well yeah, but my point is you're not iterating over chunks but the contents of one chunk
True
That reminds me, is there any method to load a chunk even though a player isn't near it?
yes
Pretty sure getChunk loads it
There is even some methods that will load a chunk for you without you realizing it too
I'd recommend using paperlib for loading chunks
declaration: package: org.bukkit, interface: World
Way more friendly on ram
Javadocs is a neat place to look for all types of things @unique barn
In my observation at leasy
Javadocs is a neat place to look for all types of things @unique barn
@wraith thicket alright, I'll look it up next time, thanks
You are even free to look at the server source too to see how some things are implemented
quite handy if you need to know if an event is thrown before an action or after
or if whether or not in the event the server accepts your changes without first cancelling it
Yeah, I often end up grep'ing the source for events
Yup same
lol that reminds me of my days in VCMP, had to check the source code of a plugin to find function names because there was no wiki at all (and the language didn't have an IDE)
but yeah, I do wish people would use BasePlugin more often though for their API's
extending JavaPlugin most times prevents your API plugin from being able to be shaded
The worst user experience I have is with RealBasic 2011
lol
I was expecting elaboration as to why that was lol funny
Wait, does translateAlternateColorCodes work on hex codes? Such as: player.sendMessage(ChatColor.translateAlternateColorCodes('#', "#FFFFF Test")); ?
Yeah
dang
The bungee one I think
ye
You'd do something like &x&F&F&F&F&F&F iirc
oh
Yeah because weird format
You could make a function so #XXXXXX would work
translateAlternateColorCodes only does one thing. It replaces the character that you choose to use with the section symbol for you
It can work with Hex but it is more involved since you need to use TextComponents to use Hex
Maybe default minecraft accepts values like §x§f§f§f§f§f§f
I need to get the object that placed a boat
Object cause = event.getCause().getRootCause();```
So this was for BlockPlaceEvent
Hi I am Japanese so I use Google Translate. So English may be strange.
I'm sorry then.
So what I would like to ask today is if you know a Placeholder that displays the total number of people in Minecraft Server.
tenkyou
Why are you getting it as an Object
the other dev did that with another flag and it was for placed waterbuckets
Man, the api hasn't updated my latest version and it's telling all my users there's an update available 😦 https://api.spigotmc.org/legacy/update.php?resource=71355 I deleted the resource "v2.0 Release" and replaced it with "v2.0-Release" But the api is still showing the old version?! Haven't seen this happen before
Thinking of making a colour utility for 1.16 that will allow for hassle free hex code formatting in messages, based on 6bit RGB hex codes.
than what should be done to check what/who placed a vehicle?
Anyone got any idea why that endpoint is showing the wrong version? 🙂
The instance that is retrieved from that method?
The type of it
Packet I mean it's not hard to just make a quick system for handling that but would be awesome
@crimson sandal The version of the plugin is 2.0-Release - the version you've specified is v2.0-Release
Ah man I'm legitimately blind af lmao. Although how come the hyphen gets removed too?
The API simply doesn't update every minute - I believe it's every 6h
So your last version change thus hasn't been taken into account yet
Any idea why I'm still able to connect? event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED, "testing loser"); The event is registered I put println statements before and after and both are printed to the console, but I still connect. I'd rather check on AsyncPlayerPreLoginEvent instead of PlayerJoinEvent
Ahh! So If I reupload now I should beat the 6h refresh hopefully? 😄
The bungee chat api isn't included in legacy versions right?
No, james
Oh it legit is just a 6h wait from the upload? I thought it'd just be a cache thats being updated every 6h?
It's updated every 6h. I don't know when those 6h are up exactly, but they do not depend on whether or not you upload a new version
Yeah that's what I'm saying, there must be around 1-2 hours left on the refresh, since it's been 4 hours since I uploaded the last version
Oh, you said "beat the 6h refresh", I thought you said "bypass the 6h refresh"
But whether or not you'll beat it, I'm not sure, because your last upload hasn't been taken into account and it was 4h ago, therefore there's less than 2h left
Yeah I just deleted the old version and pushed the new one. It would be quite nice if there was a way to edit version numbers haha
You can edit the version number without uploading a new one
facepalm
You could make a function so #XXXXXX would work
@naive goblet i used ChatColor.of("#" + sixDigitHex)
How? 😄
Chatcolor from the bungee apibtw
Then you dont need to worry about odd formatting, and just pass along the hex value
Do tell :) i use hex too in my plugin, love to know more options
It was the other way around - you can upload a new version without changing the version number - my bad @crimson sandal
Sorry for bothering anyone here, but is this the right place to ask for help about spigot.yml? I see a lot of stuff that seems like it's related to development :/
Nah some plugins are open source
The bungee chat api isn't included in legacy versions right? ? ?
It is only shaded in 1.16.1 spigot jar right?
I believe 1.15 too
It's also included in other versions
I've only tried it on 15 and 16
Don't know which ones particularly, but I've imported the wrong one many a time
Does anyone know how the BlockBreakEvent handles cascading block breaks? I have this code
public void onBreak(BlockBreakEvent e){
if(e.isDropItems() && !e.isCancelled() && e.getPlayer().getGameMode()== GameMode.SURVIVAL){
Player player = e.getPlayer();
if(!arrayManager.INSTANCE.autoPickupList.contains(player.getUniqueId())) {
ItemStack mainhand = Objects.requireNonNull(player.getEquipment()).getItemInMainHand();
e.getBlock().getDrops(mainhand).forEach(item -> {
HashMap<Integer,ItemStack> droppedItems = player.getInventory().addItem(item);
if (!droppedItems.isEmpty()) {
e.setDropItems(true);
MessageBuilder.sendBarToPlayer("your inventory is full!", player);
}else{
e.setDropItems(false);
}
});
}
}
}```
And it works in giving the player the item form of whatever block they broke, but if there is something like a torch or redstone attached to the block the items just get deleted.
@crimson sandal Should be standard Xenforo as far ass I'm aware
@lunar swift You'd be fine asking about that here
Hmm well I have no usage for the bungee chat api anyways other than 1.16+
or, you know, hover and click events
Thank you ford. Basically, my question is probably dumb, but I'm trying to get hoppers to transfer more than 1 block (if that's possible). I thought I set it up right, and hoppers are ACCEPTING stacks at a time, but they are still transferring 1 at a time. Here's my hopper file in spigot.yml https://pastebin.com/gLryLx4s. I'm sorry if this isn't possible with spigot, but my players keep complaining about the slow transfer rate
Well Dutch the way I make my stuff compatible is by having a static Function<String, String> which I initialize at runtime and then a static method obviously applying that function on the string.
Works fine for me :]
how do i check if 2 Block variables is representing the same block in the world?
@lunar swift
You can read about the config here:
https://www.spigotmc.org/wiki/spigot-configuration/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i did read that Ford and i thought i did it right, but it still doesn't seem to work? i'm at a loss aha
@stuck quartz - blocks should only have one instance as far as I know, so you should be able to simply compare the references. Failing that, you could always compare their locations
@lunar swift - if you want (up to) 64 items being tranfserred every 2 seconds, that's what should do the trick. I don't really know more
i guess i'll just keep testing until it works haha. thank you Ford! 🙂
@stuck quartz Are you sure they're in the same world?
yes
Does PlayerInteractEvent when left clicking a block not work while the player is in GameMode.ADVENTURE?
@stuck quartz When in doubt, you can always check their location equivilance
ok
@spare frost The event is likely fired as cancelled
@EventHandler
public void onBlockHit(PlayerInteractEvent event) {
Bukkit.broadcastMessage("PLAYER INTERACT");
if (event.getAction() != Action.LEFT_CLICK_BLOCK) return;
Bukkit.broadcastMessage("BLOCK LEFT CLICK");
``` I don't get "PLAYER INTERACT" when I left click a block. I only that message when I right click one.
Is there a way around that?
Well, the default behaviour is to include cancelled events in event handlers so if it was cancelled, you should still see it
So therefore it's possible it's not getting called
Might just be iffy
@balmy sentinel I don't think anyone answered your question. You are limited in what you can do in the pre-login event
Well what should I do?
in most cases you don't have the player name or UUID in that event, just their IP address
the appropriate event to use is the Login event
I’ll look it up Frostalf thanks
for instance, you can't kick during a pre-login event
but you can cancel it to stop it though.
Perhaps the BlockDamageEvent? Although that might not get called either @spare frost
well when I was looking at the docs for AsyncPlayerPreLoginEvent I figured event.disallow would stop the connection but it didn’t I’ll look at PlayerLoginEvent right now
so You won't be able to send a message to the client in that event, but you can still stop them from connecting. If you want them to get a message they are banned, need to do it in the LoginEvent as that is when the server has the UUID of the player which is what the server uses to lookup who is banned lol
Isnt there a Result you can set in the AsyncPlayerPreLoginEvent
I think I should use PlayerAnimationEvent :/
tbh I never actually “banned” the player lmao I just checked if they had an active punishment in my database and if they did I kicked them
@wraith thicket i checked the blocks, i checked the location, i checked the world, and they are exactly the same, yet it doesnt work
Is it possible to get an argument from the command used to launch the server inside a plugin?
Thanks, going to check that out
im going to try .equals
It will give you a list of JVM arguments that was used for the currently running JVM application
for the arguments after the jar name, you need to grab those from the server unfortunately
since those are not JVM arguments usually
https://alvinalexander.com/java/how-see-jvm-parameters-arguments-from-running-java-application/
@undone narwhal an example for you
If you use -D parameter you can just get them with
eg -Dtest="something"
System.getProperty("test");
D parameters are not the same as JVM arguments
but yes you can do that for D parameters
However if you want to get the parameter -nogui you will have to grab those from the server using reflection however or other option specified. What you can specify in the server.properties can be specified on the command line
@wraith thicket I found a solution here https://www.spigotmc.org/threads/left_click_block-doesnt-trigger-in-adventure-mode.188481/
would it be wise to make a new event like PlayerBlockHitEvent because my entire gamemode is in adventure mode and I'll have to be detecting this action a lot?
You're welcome to do that if it'll make your life easier
@wraith thicket i tried var1.getLocation().equals(var2.getLocation())
and it worked
Events are usually used as part of an api. So if you want other plugins to interact with this event or if you fire this event in a library you use for all your plugins its usefull.
Other than that you dont really need to.
.equals does an object value's check == does a reference check IE if both point to the same memory address @stuck quartz to help know when to choose which one 😉
Anyone know of a plugin which allows you to make anvils unbreakable? I know theres a permission node for CMI, cmi.command.unbreakable.player, would this node also work as cmi.command.unbreakable.anvil, or is there any way to set the player paremetre to global?
ok
buildtools not working:(
elaborate
i get it
i run java -jar BuildTools.jar --rev 1.8.8 and I get a spigot thing
but the tutorial says i need to get both bukkit and spigot
You dont. The Spigot jar is your server jar. Write a bat or sh to run it and you are done
ok thx
also i get 1.15
but i want 1.8.8
is there a way to get a universal one
for making a plugin
lol no
:(
That's not how these things work.
But --rev 1.8.8 should be produce 1.8.8 jar - if you ran it without, you should now have both
but i only have 1.15
I just copy pasted your arguments and got a 1.8.8 jar
then idk
Are you sure that build tools actually built a jar when you run it with the --rev 1.8.8 option? Because it won't for java version greater than 8
Well, you'll see from the output whether or not it ran
terminal -> java -version
But java -version
C:\Users\Playe\Downloads\Extreme client>java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
C:\Users\Playe\Downloads\Extreme client>
so i need to downgrade?
No, your version is just fine
java -jar BuildTools.jar --rev 1.8.8 will build 1.8.8
Just like the good old days half a decade ago
6 years by now i think
1.7.10 is 6 years old
1.8 release -> 2. September 2014
technically 5 years, but we are like 2 months away from then
so might as well say 6 😛
Well, 1.8.8 was July 27 2015 - which isn't 5 yet
1.7.10 was released in December if I recall correctly, becuse 1.7.2 was released in October
Sure but i like to shame the ppl who run 1.8 so ill stretch a bit
lol
I really don't mind people who want to run 1.8
I do mind people who want to run legacy software, but don't want to bother maintaining it themselves
or expect there to magically be fixes to bugs they encounter XD
frost i uh dont mean to bother but i just wanna make sure lol
"old" is what i should be looking out for right
old is where objects go when they survive a GC like once or twice
and yea i dont like it when 1.8 users come here with support and get made i shrug at them
so does high old mean potential leak
your old generation shouldn't be very large
👍 it was at like 2/3 the way there before i restarted and looked at the heap
@obtuse dagger
Looking at the error and googling:
Run BuildTools again on a clean folder. Follow the instructions exactly https://www.spigotmc.org/wiki/buildtools/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
How do I get the IP Addresse from a player
your profiling looks good though @wanton delta
your old Gen has space for 2.5G but only 560MB is being used there
Your GC is doing its job like it is supposed to
and not causing drastic pauses
And the timings for each look good too
how do i get the title of the inventory in InventoryMoveItemEvent.getSource()?
getInventory().getTitle(); I think is what it would be
@wraith thicket Do you know if the "Removing entity while ticking" error is meant to be a thing when teleporting players between worlds during an event?
You don't - an inventory doesn't have a title, an inventory view has a title
I get it quite a lot
Ah right, I was confused Drives_a_ford is correct
should listen to them 😛
you can't remove entities that the server is doing things with
@wheat mirage just run the teleport on the next tick
Basically is it an API bug or is it just something be dealt with
it is along the lines of a CME
@wraith thicket that allows players to logout inbetween
I did extensive testing
I have a workaround but it seems like a pretty big issue
Then check for that at teleport time?
@wraith thicket thx but mustang is better
@wraith thicket Yes but then they avoid any delayed behaviour
or the teleport itself
Players can logout inbetween to avoid being tp'd
You can just keep track of them and TP them to the correct location once they join
Would appreciate if there was an officially endorsed way to do it
Seems a little hacky to me
The thing is, when you TP a player during some events, the server is busy "dealing with" that entity so when its location changes abruptly there's issues.
Yeah sadly that's the case
It never used to be a thing in older versions
1.12 I could do this no problem
But if those issues don't really manifest into real problems, you might also get away with just having them in console
Suddenly teleporting between worlds is a huge issue
@wraith thicket They manifest into HUGE issues
ghost players etvc
The player stays in the same dimension, can't send chat
They become detached from their playerentity almost
it's awful
OK, well then you'll need to deal with it
I'm not sure what event you're on exactly
Still, if you think it'd be able to be added or fixed API-side, that would be appreciated for spigot
You don't - an inventory doesn't have a title, an inventory view has a title
@wraith thicket what could i do to check if the inventory that the item is getting moved into is a gui that i created?
@wraith thicket Almost any, most cases, entitydamagebyentityevent
the player being teleported is the victim
@wheat mirage Well, then there's your first issue - if you teleport the target, then they would get hit in their original location after being teleported (unless you cancel the event, but still server runs something else after which obviously seems to be an issue)
@stuck quartz How would an item be moved into a GUI exactly? It's not in the world
nightvison_worlds:
- world_nether
- world
``` So this is my config. I did the whole:
```java
getConfig().options().copyDefaults();
saveDefaultConfig();
However, this bit of code is throwing a NPE at the line that checks if the list contains the current world.
@EventHandler
public void joinServer(PlayerJoinEvent event) {
Player player = event.getPlayer();
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
World world = player.getWorld();
List<String> list = (List<String>) plugin.getConfig().getList("nightvision_worlds");
if (list.contains(world.getName())) {
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 200000000, 0, false, false, false));
}
}```
im trying to stop the player from moving something from a chest inventory (that i created) to a player inventory (the inventory from inventory)
Anyone know why?
@wheat mirage There is no general "fix" for things happening in a certain order on the server (which is what you're asking for)
@winged sparrow You should probably use #getStringList
@wraith thicket It's cancelled.
And it worked in older versions
Which is the strange bit
But anyway, spigot could still implement a workaround in the #teleport function
@stuck quartz That's not what the InventoryMoveEvent is for - read the javadocs. You need the InventoryClickEvent
As a delay of 0 ticks is sometimes too long.
ok
@wheat mirage There is no general "fix" for things happening in a certain order on the server (which is what you're asking for)
@wraith thicket
@wraith thicket The old entityplayer could be hidden and silently maintained in the dimension it's being removed from until safe to do so.
You're welcome to PR
Just proving the point that it is possible to fix, I may PR for the sake of other users, but I can always hack around it
I can guarantee it's not that simple.
It just seems unintuitive that a teleport inside an event, a perfectly valid use of the API can error in such a way.
And of course it isn't simple, but it's not going to be impossible @wraith thicket
Especially for a developer of md_5's talents
If you believe the issues you're having to be a bug, you can also try posting a bug report on jira
that's why I'm asking you as a mod if you think it's worthy of one @wraith thicket
(which would also be needed for a PR, really)
I've done some NMS testing and saving the entityplayer for disposal / killing until the next bukkit task tick seems to work well.
@wraith thicket i'm now using getStringList, and now it doesn't throw a NPE but I can't get anything from it
Is the list empty?
You're not actually copying the defaults, though
The list is not empty.
You need to pass true to #copyDefaults
Right now you're simply "querying" whether or not the config copies defaults
Weird, I didn't have to do all this for this functionality in 1.15
If the list is not empty then i dont understand the "I can't get anything from it" part
The list is empty - that's why he was getting an NPE when using #getList and not one when using #getStringList
They're just expecting the list to be not empty
Thats why i asked
And this is nothing new. You probably had a different situation
I.e if you save the default config and it already has a list, you don't have to copy defaults
I tried doing a System.out on everything in the list, and I'm not getting a NPE I'm not just getting anything at all.
But if you add something to the config, you may want to copy the defaults in, which is what passing true will do
Yes, the list is empty.
It shouldn't be
List<String> list = plugin.getConfig().getStringList("nightvision_worlds");
for (String string : list) {
System.out.println(" - " + string);
}```
nightvison_worlds:
- world_nether```
@Override
public void onEnable() {
getConfig().options().copyDefaults(true);
saveDefaultConfig();```
Is that the context of config.yml in plugins/<plugin name>/ folder?
Yes.
Just proving the point that it is possible to fix, I may PR for the sake of other users, but I can always hack around it
@wheat mirage that doesn't prove it is possible to fix and this is going under the assumption it is broken. This means that something changed between the versions that requires you to use a different method.
If i have my phsycal server, how can i install spigot to my server? Im very new at this (also if here is somebody that speak spanish is better)
As I stated earlier, the Ticking Entity Exception is basically a CME but not quite the same
CME = Concurrent Modification Exception
however it isn't a CME because it isn't occurring Concurrently. Therefore, we have ticking entity exception. Basically the server expected an entity and there wasn't one or you are trying to remove an entity the server is currently doing something with.
not 100% sure what the context is, but there's a good chance that it was just silently broken in a previous version
you're welcome to submit what you think is a fix for review though
@fleet crane When teleporting a player to a different world in an many contexts, the player bugs out horrribly
And it throws an error in console about removing an entity during ticking
because youre doing it in a teleport event no doubt
It's an entitydamagebyentityevent
Actually
Where the player is the victim
Even more strangely
when they're dying?
It happens in a couple other events I notice
The event is cancelled
So I guess not @fleet crane
open a clear bug report or fix it yourself
basically they are trying to teleport the player during certain events
moaning that it used to work and now doesn't won't get anything done
Alright, if you consider it something worth fixing
I wasn't moaning, I was noting, thanks.
in a damage event where the player is not dead I would consider it a bug (probably)
in eg a teleport event I would consider it user error
Alright, I'll file a bug report when I next get chance
?jira
relevant link for you
(probably)

it makes sense to me though why that exception is being thrown
guess it doesn't make sense for some people lol
not saying it can't be changed
Yeah it does make sense, but there are ways around it
And this seems like something not uncommon in the usage of the API
well obviously, otherwise there wouldn't be exceptions
If we're looking for forwards compatibility, it atleast is worth a look obviously
there is going to be times where it is unavoidable to change something's behavior
Thanks Captain Obvious, you have saved the village!
Just saying I know it is spigots goal to maintain consistency
just even though that is the goal it doesn't mean it is unavoidable and it should be expected
?paste
how can i stop the player moving something from their inventories to the chest they opened?
InventoryClickEvent and InventoryDragEvent
i want to let them move inventories in their inventories, but stop them from putting these items in the open chest gui
InventoryClickEvent and InventoryDragEvent
@grim halo
Then you'll need to catch a lot of different things.
There are a lot of cases you need to consider
I'd personally cancel the drag event in the appropriate inventory
And then you'd need to go through https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/ClickType.html and see what else you need to cancel
declaration: package: org.bukkit.event.inventory, enum: ClickType
And keep in mind, there's plenty of times you want to cancel the event even if the click is in the player's own inventory
All in all, this is not trivial. But it's not rocket surgery (™ choco), either
Posted bug report to the best of my ability, let me know if I can improve it @fleet crane https://hub.spigotmc.org/jira/browse/SPIGOT-6002
A workaround of delaying a task to teleport by 0 ticks is decent, but it is possible for the player to logout inbetween and avoid the teleport entirely.
plugin.getConfig().getStringList("nightvision_worlds").add(args[1]);
plugin.saveConfig();
plugin.reloadConfig();
Any glaring reason why this would not add a string to a string list?
I see, how would I do that?
List<String> modifiedList = plugin.getConfig().getStringList("nightvision_worlds");
modifiedList.add(args[1]);
plugin.getConfig().set("nightvision_worlds", modifiedList);
I assume like this?
should pay attention to getters and setters
or more specificly whether the returned collection is a clone or not
whats better for larger projects, reflection or abstraction?
ok
reflection is not that much slower if used right
what do you mean "if used right"
caching it for instance
oh ok
I've seen pretty nasty reflection code blocks reflecting same fields and invoking accessible everytime.
so basically just get a field and store it somewhere so you're not always getting it and making it accessible?
not saying you can't use it, just if you don't need to then don't
^
abstraction seems more efficient but reflection would allow for less copying code
most people who use reflection, really don't need to. You should really evaluate your reasons for using reflection
nah abstraction can be used effectively
Well only make yourself override necessary code
the other downside of using reflection, is it makes debugging that much harder
yeah thats true
you can even introduce memory leaks as well or unintended side affects using reflection
but like I said, I am not saying you can't use it. Just you really need to use for the right purposes or reasons and not just because you want to be lazy
Yeah I see a lot of people who makes malicous memory leaks with reflection.
Is it possible to automatically get the jar from my CI/CD, put it in my plugins folder and restart the server
yes
any existing programs for that or have to write itmyself?
is the server and CI on the same system?
well i guess i would rather copy code 3 times than deal with the side effects of reflection, cons seem worse than abstraction
seperate machines, local network though
you can set in the CI to upload the jar to the second server and the directory it uploads to be the plugins directory
then you can set in the CI at the end to use SSH to run a command on the second machine to restart the server
I assume you are using Jenkins so this is all relatively easy to set up with that CI
you could condense this down to using a custom bash script
so that the CI only invokes the bash script instead
Oh awesome I'll look into that
npc stuff and pathfinding
thankyou
I do it all the time
that must be a nightmare for the people who do...
Yah
Nah
Most stuff doesn't change too much
And I have a plugin that makes it pretty efficient
Is anyone good at ProtocolLib?
I'm trying to disable a specific sound made by the server.
Anyone know how to create an a record to redirect to an ip that doesn't have the port 25565
Oh ok, do I set it up the same way?
as...?
oh
I'm using freenom.com :/
oh ok
I mean i do have a namecheap domain as well, but those don't work well
Well it works fine it just doesn't fit with my server:/
What do you use cloudfare for? Ddos attacks for your website?
Also its just that the name doesn't fit lmao
no i use it for dns records too
Buenas noches, alguien que hable español? Necesito ayuda con un pago
Yo no hablo much espanol
tengo un problema con un pago que realice
Hace 22 horas pague por el plugin BannerBoard y hasta ahora no puedo descargarlo
@frigid ember since you use namecheap: stupid question and not about spigot, but is there a limit to how much activity you can send through your domain(
not sure
Dang
Idk if i want to use my domain since I'm setting up a pretty big minecraft server for someone
There's no limit right
if there is, then they are a very stupid DNS hoster
you're talking about cloudflare right?
public void initializeProtocolListener() {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(
new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Server.NAMED_SOUND_EFFECT) {
Bukkit.broadcastMessage("Sound played");
Bukkit.broadcastMessage(event.getPacket().getStrings().toString());
}
}
});
}```
This is what I'm using to listen to sounds playing, but I'm not getting any output. The only time I was getting errors from this was when I was trying to get a field that didn't exist, but otherwise NOTHING is being put out in either broadcast.
Oh ok
if you want a cheaper alternative as far as dns hosting goes, can always use afraid.org
costs $5 to keep your domain private which is reasonable and you can create any kind of record you want
I use afraid.org for test servers
Yeah
Thing is they take a LONG time to update lmao
costs $5 to keep your domain private which is reasonable and you can create any kind of record you want
Thats insane
is it a one time fee?
odds are your ISP DNS isn't fetching like it is suppose to 😛
@pastel condor no, its a monthly fee
by a kid with no money lmao
but they steal your domian.....
and just never allow people to use a subdomain off your domain 😛
they don't steal it
*they steal subdomians
Oh
@loud kindle Sorry friend, I don't know if you can help me, 22 hours ago I paid for the BannerBoard plugin and I still can't download it.
they don't steal subdomains either
then what do they steal?
at anytime you can revoke someones use of a subdomain
oh fun
I mean it was a .host
You also have no obligation to allow subdomains either
Which isn't the greatest, but an ok one
You also have no obligation to allow subdomains either
Then why pay a $5 fee?
because there is other services I use
ah
such as more domain hosting space
oh I see
also it keeps my domains out of the public searchable area
so I don't have to deal with people wanting subdomains
See people can use subdomains from your domain, but its not automatic unless you set it that way
they have to ask you
what I do for dynamic dns is I use no-ip.com, then I setup a cname record via cloudflare to it
Whats srv priority
they have to ask you
ah okay
Oh... so higher is more priority?
the lower the priority number, the higher the priority in serving it
How about weight
weight has to do with if you have 2 srv records with the same priority because maybe they are for the same service, but the addresses technically point to two different machines
Oh
weight will help determine which of those should be served
@subtle blade Excuse me can you help me please
lower weight is better
generally a weight of 0 is sufficient if you are just creating a single srv record
Thanks
and don't intend to have multiple of the same srv records
you do know you can specify also multiple IP's for a same A records?
this will create what is known as round robin dns
Yes I know you can do that
Wouldn't that just create a tree of a bunch of domains leading to 1 ip?
its not so much a tree, but essentially it just gives out a different ip everytime that A record is served
Oh
so if I query the dns for a particular domain or subdomain and it has 2 ips defined, I will get the first ip, second time I query it I will get the second ip
and then if I do it a third time I will get the first ip again
which ever was defined first
Oh
anyways since round robin load balancing exists in DNS, it extends to almost all the records you can create as well that takes in explicit ip's
so that includes srv records 😉
which is why priority and weight exists lol
O
there is a lot of nifty things you can do with just DNS alone especially if you tack on geoip DNS stuff 😛
Dang, didn't know there was so much to dns
Anyways, tysm for the hel0
Help
I got it, and hopefully it works lol
np, and have fun 🙂
I will :)
case CustomConfig.get().getString("permission_button_name"):
``` why is this showing up 'Constant expression required'
how could i fix that
Hey is there any plugin that creates kit and save contents of the items inside the shulker
You cant have a dynamic expression as case.
what could i do
Depends on what you are doing
if the player click a item with the name as [the variable on the custom config file] then it opens another gui
if statement?
sure, ill try that
lol
So dumb question
I donated to Spigot for the Redstone tier
and it said I can change my name and also my theme
But I am unable to locate these
anyone have an idea how to?
(feel free to @ me)
String colorizedName = ComponentSerializer.toString(new ComponentBuilder(player.getName()).color(color).create());
PacketContainer packet = pm.createPacket(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, player.getEntityId());
WrappedDataWatcher watcher = new WrappedDataWatcher();
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.getChatComponentSerializer();
watcher.setEntity(player);
watcher.setObject(2, serializer, WrappedChatComponent.fromJson(colorizedName).getHandle());
packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
try {
pm.sendServerPacket(player, packet);
} catch (InvocationTargetException ex) {
ex.printStackTrace();
}```
Trying to send an entity metadata packet but when its sent nothing seems to happen?
I don't know how Placeholders work, please, can anyone help me set up luckperms placeholders on a featherboard.
Where are you from? What language?
I just bought a plugin and I don't know where to download it
@timber berry This should occur as soon as you buy the plugin. Sometimes it takes a while.
Did you wait at least 24h
So I just coded a text plugin using eclipse, and I want to know how to get the .jar file from eclipse to my plugins folder (I am using linux)
Compile it and copy it to your plugin folder...
I get the proof of purchase and nothing
No idea then. Spigot has a thread for recruitment
how do I compile it?
@burnt idol is there a target folder in your project directory.
yes
What’s in it?
??
uhh the jar file but it doesn't work
@burnt idol File -> Export
ok
Do you get an error message?
nop
@timber berry Did you wait at least 24h
fuck
just a sec
I'm seeing what the error message is
@timber berry
Did you wait at least 24h
@grim halo no
Probably doesn’t have the resource files, like the plugin.yml
I have the files
main: me.MrEgel.Why.Main
name: Why
version: 1.0
author: MrEgel
Commands:
Why:
Whats the error?
si no llega al toque me mato
well it says it is ignoring plugin.yml
What doesnt work? You copied the jar in your plugin folder and spigot doesnt load the jar?
So can you see any messages in the console or logs? You’re going to need to pastebin the log
?paste paste it here
is there something like PersistentDataType.BOOLEAN
Don’t think so
If you really need a Boolean just set a byte with 0
And then check PersistantDataContainer.has
They’re asking about an unrelated issue, Mr_Egel
Is that all that your log showed?
@burnt idol This log doesnt show anything
@lone fog ill try that, thanks!
The only issue is related to the permissions.yml and I don’t think that’s a problem
@lone fog so byte as 0 would be true and no data would be false?
ok
Is your plugin called Why?
yes
Does your command require any permission to be used?
Then its enabled and works
Pls paste the command code. The whole class if possible
You need to register the command.
how?
https://www.spigotmc.org/wiki/create-a-simple-command/
Scroll down to "Registering the Command"
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
and instead of "new CommandKit" you just use "this"
A reference to the instance you are currently in. this
so .setExecutor(this)
Does spigot have API methods to check if an item is the right tool to break a block or vice versa?
syntax error on token "this", invalid name
paste the code
Uhm i think something like block.getDrops(ItemStack).isEmpty() not sure if it covers all cases
Plus that checks if it can break it, I want to check if it’s the ideal tool
Ie shovel for dirt
Ah wait. I made a plugin that needed this for automatic switching. Ill take a look at it
Pretty sure it’s just getCommand
Actually I don’t think it matters, but you gotta save those bytes
how can I declare any rgb color for chat now? for player.sendMessage I'd normally use ChatColor.RED etc
I'm not using bungee?
Ok i made a Map<Material, ToolType>. I also used some NMS stuff in older versions but if you want to use API methods only, you need to populate a fat map per hand.
oh nvm I see the namespace
Do you think it should be part of the Material Enum?
I created a new Enum ToolType with AXE, PICKAXE etc and then mapped Material to ToolType.
But having the ToolType as a constant in the Enum would be nice.
Would be nice yeah
Or create a new Tag for the tool materials.
Like Tag.PICKAXES containing all pickaxe materials
And a material.isProperToolFor(otherMaterial)
Instead of a new ToolType enum
So if Tags.PICKAXE.contains(material)?
Bukkit Tag with IRON_PICKAXE, WOODEN_PICKAXE etc.
Then an entry for the Material containing the Tag as a collection of proper tools
hmm, net.md_5.bungee.api.ChatColor doesn't have an of method for me. using spigot 1.16.1.
Do you know the Tag class?
Kind of
Just a new Tag for every tool type
So Tag.PICKAXES would essentially be a list of pickaxes
Yes
Do you want to PR this? I have never done one for Spigot and this sounds like a nice first addition i could try.
Ah yeah that’s not bad
Although it would be a bit cumbersome to get the tool tag from an item no?
You’d have to check each tool tag until you got a match
Material itemHandMaterial;
Material blockMaterial;
Tag<Material> optimalToolTag = blockMaterial.getOptimalTools();
if (optimalToolTag.isTagged(itemHandMaterial)) {
// Item is optimal for breaking Block.
}
Ah I see
why is HIDE_POTION_EFFECTS the thing that hides the banner pattern from the lore 🙃
idk its just weird
I’m just happy I figured it out
KM it’s pretty easy to create if you know how to code. If not idk the plugin
😄 ikd how to cde
all good uhh it’s a very specific plugin so your best option is finding someone to code it for you tbh so it’s made to your liking
can u help me removing flower banner pattern lores :3