#help-development
1 messages · Page 1714 of 1
Did you teach them?
they are experienced
Ah ok
were you scared that i was giving out bad quality plugins? lol
No, nonono all good
why do i feel like this could change a bit and then everything will be fixed 🤔
Well, firstly, please format that ;p
oh god eclipse? @-@
Or you do the whole class with Ctrl + Shift + F
Oh, it's Ctrl + I
No shift, sorry lol
If you did Ctrl + Shift + I already, just Ctrl + Z it. Haha
I ALWAYS forget whether or not there's a Shift
Imagine not just doing ctrl shift F
{
String discord = ((String) main.getConfig().getString("Discord"));
player.sendMessage(org.bukkit.ChatColor.BLUE + "Discord: " + org.bukkit.ChatColor.YELLOW + discord);
}
Can just be
String discord = ((String) main.getConfig().getString("Discord"));
player.sendMessage(org.bukkit.ChatColor.BLUE + "Discord: " + org.bukkit.ChatColor.YELLOW + discord);
so am i
A few notes,
(1) That case to Player will cause you issues if you run it from the console. Though you don't even have to cast to Player. CommandSender declares sendMessage()
(2) The check for cmd.getName() is unnecessary. It's an executor, it will probably be the Discord command executor
(3) You're always returning inside of that check, so the code after it is never run
(4) The block above String discord and player.sendMessage() is redundant
Your implementation there can be simplified down to about just 4 lines
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender.hasPermission("store.discord")) {
String discord = main.getConfig().getString("Discord");
sender.sendMessage(ChatColor.BLUE + "Discord: " + ChatColor.YELLOW + discord);
}
return true;
}```
And if you want to be fancy, you can declare permission: store.discord inside of your plugin.yml with your command so you don't even have to make that perm check
commands:
discord:
description: Get a link to the Discord
usage: /<command>
permission: store.discord
well looky here guys, the pickup detector works :D (btw thats 3 of my 4 detectors lol)

Mmmmm, maybe not 100%. At least the first time around you might get it 60% working 
But the fun is getting that extra 40% lol
i love getting help but most of the times when its asking a lil too much they just get annoyed
If you do that trick I mentioned above with the plugin.yml it will send one for you automatically and you don't have to do the permission check yourself, Bukkit will handle it for you
You can even customize that message with a permission-message: "You don't have permission" option as well
i havent did a command in a while, idk what command to add lol
is there an event that like gets mobs when they spawn in a structure
like piglin brutes
cuz the normal spawn event doesnt work with htem
huh
what are you trying to say?
i cant process it
atleast put some commas or anything to say it much better
Not anymore, no. There used to be but now chunks generate with entities within them before they're generated
seeing people asking for help in a not big brain way is funny lol
imagine if a person just asks "how to set mob that attack everything"
how to play a sound from mc?
i mean like how to use the /playsound feature but in the plugin
well basically what i want to know is how to play the sound lol
how to use it in a commandexecutor class?
just use the method? You can check if the sender is a player and play the sound there if you want to play a sound for a player
can you show me how?
do you guys have a plugin that allows server members to send a message on discord and turn that message into the minecraft server's MOTD?
how do I make a player argument for a command? I have seen plugins have you be able to tab complete player names, I would like to know how to do this.
Implement TabCompleter
how to I implement two things?
you implement that instead of CommandExecutor
ooh
Huh, I normally implement both
TabExecutor is just a wrapper for both
nope
you either implement TabExecutor, or you implement CommandExecutor, TabCompleter
how can i setup a discord channel like this?
?
You can implement as many interfaces as you want
u are breaking discords TOS
Well, I'm sure there is a limit somewhere
me?
BetterDiscord is against discords TOS
nah, i just use it to make the discord's gui look better
not a big deal
btw someone pls answer my question
i need this for my smp server
its still against discords TOS You must not copy, adapt, modify, prepare derivative works based upon, distribute, license, sell, transfer, publicly display, publicly perform, transmit, stream, broadcast, attempt to discover any source code, reverse engineer, decompile, disassemble, or otherwise exploit the Service or any portion of the Service, except as expressly permitted in these Terms
also this is #help-development
for plugins
dude
discord default gui is boring
https://cdn.discordapp.com/attachments/853900636428304394/893264752430678106/2021-10-01_11-33-00.mp4
Does anyone know why the inventory doesn't update the first time I open the GUI, but all the times after that it does update?
if (chatSettings != null && event.getInventory().getName().equalsIgnoreCase(chatSettings.getName())) {
event.setCancelled(true);
if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Party Message Sounds")) {
settings.setPartyMessageSounds(!settings.getPartyMessageSounds());
chatSettings.setItem(1, ItemUtils.createGuiItem(Material.NOTE_BLOCK, Common.colour(settings.getPartyMessageSounds() ? "&aParty Message Sounds" : "&cParty Message Sounds"), Common.colour("&7Toggle hearing a ding for party messages.")));
chatSettings.setItem(10, settings.getPartyMessageSounds() ? ItemUtils.createDye(DyeColor.LIME, Common.colour("&aParty Message Sounds"), Common.colour("&7Click to disable!")) : ItemUtils.createDye(DyeColor.RED, Common.colour("&cParty Message Sounds"), Common.colour("&7Click to enable!")));
((Player) event.getWhoClicked()).updateInventory();
return;
}
thats not an excuse
fine
you can get banned
idc
What version are you on?
1.8.8-R0.1-SNAPSHOT
Well... too bad
Why?
1.8 support was dropped almost half a decade ago. This version contains bugs that will never be fixed and lacks a ton of API features.
Almost nobody gives support for such an outdated piece of software.
Also only a minority still runs 1.8
what if he is trying to write a plugin for a pvp server
Then he has to live with the handicaps that come with such old software.
how do I use onTabComplete?
return a List of tab complete options depending on which arg.length
?
sorry\
if I want to give them all of the players, would I use Bukkit.getOnlinePlayers().toArray();?
make that a variable, and return that?
look at the return type of the method
say it to everyone that put 1.8 in the tested versions
That is their choice
I know, just idk what else to do...
what would I do?
Anyone know how long https://api.spigotmc.org/legacy/update.php?resource=96521 takes to update when a new version is posted?
cause i've posted version 1.0.1 of my plugin and it doesnt seem to be updating....
Could be cached, try adding &bust or something to the end to cache bust it
@quaint mantle thank you very much sir, that worked 🙂
why did nobody tell me this
without &bust prints 1.0
yayyy updatechecker class completed haha
like a config reload command?
look at the tabcomplete wiki]
in commands
wiki
then just get the plugin and do plugin.reloadConfig()
what do i put here (plugin.yml)
name: Launch
api: <-------- here
version: 1.0.0
main: net.j4c0b3y.launch.Main
1.17
Isn't it api-version
yeah
when i put 1.16 in there it underlines red
and api-version is different
its telling me to add api:
Don't see that on the plugin.yml page
It's different in the sense that api-version actually exists
api-version
the available are 1.13 1.14 1.15 1.1 and 1.17
1.1
1.1 
yes
do plugins by default support multiple versions unless there's an enum discrepency?
would my 1.8 plugin work on 1.17 basically?
It depends on what you're doing
it says expedcted array or string
should i surround it in ""
api: "1.16"
If you stick to the API, then there is a good chance it will
alrighty
If you use new features it can break, and if you use NMS at all it'll break
hey so im trying to purchase a hosting server for mc and spigot is one of the options on there. Is it the option i should pick?
oh so i gotta write api-version in my plugin.yml?
If you want to run pluigns, pick Spigot.
and since it's written in 1.8.9, i do api-version: 1.8.9?
Better suited for #help-server also
ok thanks. i can use geyser right?
No
Yeah
api-version only exists post 1.13
name: Launch
api-version: 1.16
version: 1.0.0
main: net.j4c0b3y.launch.Main
it still shows an error asking for api:
o alr
thanks for the help
Missing property "api".
What are you writing your plugin.yml in anyway
I just write mine in Notepad++
wot
Why would I use a fancy IDE for a small yml file
I do
Whatever works I guess
But I'd rather use notepad++ then the plain text editor in my IDE
Does your IDE not have YML support...?
Not without an addon I assume
Are you using Eclipse 
Yes
i would imagine that eclipse probably has an add-on for yaml
Probably
Probably does but Notepad++ is pretty good
With the mcdev plugin it event helps you with the plugin.yml content and syntax
G'day everyone- working on a new API, if you have any feedback on it, I would highly appreciate your input. 😄
Thread: https://www.spigotmc.org/threads/new-economy-api-looking-for-your-feedback.527805/
why this instead of vault
Will be hard to kick vault of its throne
^
Absolutely. I've tried to address that in the thread.
Although vault does not support async interections which is really bad if you have a DB backend.
Here's an opportunity to remedy that :)
Haven’t stopped them yet
I imagine most servers with a database backend have their own solution
I personally dont use vault anymore
Usually a cache in the economy provider helps a lot. Unfortunately there are occasions where plugins want a player's balance as they join the server which means.. synchronous call. 😣
BigDecimals are really big and sluggish btw.
Should I revert to just using doubles?
You could build a generic abstraction so that you can implement BigDecimal, Double, Long and so on.
public interface CurrencyValue<T> {
T getRawValue();
double getDoubleValue();
BigDecimal getBigDecimalValue();
long getLongValue();
}
Probably not, enum set time :p
D:
I dont think so
I'm leaning towards just going for doubles. Converting BigDecimals to other types does take a while as well.
What would you prefer for your use? The CurrencyValue interface or just double values?
I'm unsure if databases even support storing BigDecimals properly. I'm very inexperienced with databases so I'm still learning things.
Really depends on the API implementation. With the interface you need a really clean design and also a way to make it intuitive.
Maybe even provide a trivialised alternative.
Sure
A simple interface extending the more advanced one with automatic conversion?
🤷
?paste
Not trying to hate on you or anything, but.... IntelliJ is so much better I could keep listing things
also the text is so much nicer on your eyes... I'd make the switch if I were you :)
If they're used to Eclipse and know how to use it, and it's not hindering their performance, there's really no reason to switch.
The choice of your IDE is a preference. Also: You can change the style of your IDE as you like.
What would be the best way to go about creating a public API for a premium plugin?
I'm not really familiar with the process, not sure how to go about doing it
If you dont want to expose the src then just provide an API layer using a bunch of interfaces.
Can't they still find the implementation classes
Yeah that's true
If you use the spigot-api only, then you have no idea what the actual implementation will be later on.
One way might be to make a RESTful api
So like, for example, if theres an interface called Server, the actual implementation could be CraftServer or PaperServer or TacoServer, etc etc
Obviously PaperServer and TacoServer aren't real but as an example
No especially in spigot
look at the source code it's all interfaces
That's what I was thinking, write an interface using the plugin itself as a dependency
I still never really have understood how spigot hides the implementation classes
The implementation classes are usually just the same name with Craft at the start
Implementation of Server is CraftServer
Yeah ig
I've always wanted to make my own server implementation but never had the time
using ChunkData, how do you get the center block of a chunk and get its bukkit location?
im trying to spawn in a schematic every chunk
Is there a Chunk class in the spigot api? I'm assuming there is
yes but i cant access it
probably getBlock#getChunk
i only have access to ChunkData
Why are you overriding getDefaultPopulators tho
here we are in a interesting question
you aren't using it
ill remove that
Very
thats not the point tho
Yeah your best bet is to check the spigot api for ChunkGenerator
how would you make it possible for the dev to test the plugin?
ive already done that
they deprecated some stuff
yeah but how do i get the bukkit location from that?
oh are the coordinates relative to the chunk?
yeah
Yeah
i'm stumped
spigot should probably provide implementations for coordinates of chunks
but oh well
this code might help
oh
wait nvm
You need chunk coords?
Yeah
from chunkdata
i need to extract a block object from a chunk
So you want to go from chunk coords to world coords?
yes
Multiple x and z by 16
that wouldn't do anything
that wouldnt work
thats also gonna create it in the same place every time but just x16
^
What’s the exact goal here
spawning strongholds in every chunk
To get the Location of the center block of the chunk
but yes that ^
yea
So you have the coordinates of the chunk itself
And you want to get the centre block coordinate
Multiple the x and z of the chunk by 16
And then add 8
What
i know how to get the center BlockData of the chunk
theres no method within ChunkData or BlockData to get a block
There is in world
i dont have world either
thats Chunk, not ChunkData
You have a getType to get the material of a block
yes and then what do i do
What do you want to do
Why do you need a block instance
Action bar is quite old now
Added the same time as titles
my method for spawning in strongholds requires org.bukkit.Location
Ah
so i need a bukkit location
how am i getting a block fro mthat
You have a world now
And you have an x y and z
So you can construct a location
You need a comma
It’s 2 arguments
i dont have an x and y and z tho
Also you need a component, not a string
where am i getting that from
that will not do anything
Sure it will
that will just give me the same location every time
those x and z's are chunk relative
The javadocs say they are chunk coordinates
Can you confirm they only output 0-15?
That method takes a component, not a string
alright @young knoll i tried your thing but its not working
debugging it
to be clear
this goes in the bukikt.yml right
generator being the plugin name
turns out the method isnt being called
wtf does this mean
could they be any less specific
I imagine it’s one of the build methods now
Can anyone tell me what's the format for FileConfiguration#getItemStack(path, def)? Like, should the key be a material like "WOODEN_SWORD" orrr?
The key would be an arbitrary string that you used when saving it
ItemStacks aren’t really something that is easily edited manually
Ah, so it's meant for when an itemstack is set to it, rather than being edited manually?
Generally yes
Parsing a material from a config isn’t hard if that is your goal
Yea, that's my goal. How would you go about it?
Use a standard getString and pass it into Material.matchMaterial
You will either get a material or null
Oh gdi
Was trying to find a "fromString" equivalent for material, thought it doesn't exist
it was matchMaterial all along
isn't it valueOf?
https://cdn.discordapp.com/attachments/853900636428304394/893264752430678106/2021-10-01_11-33-00.mp4
Does anyone know why the inventory doesn't update the first time I open the GUI, but all the times after that it does update?
if (chatSettings != null && event.getInventory().getName().equalsIgnoreCase(chatSettings.getName())) {
event.setCancelled(true);
if (event.getCurrentItem().getItemMeta().getDisplayName().contains("Party Message Sounds")) {
settings.setPartyMessageSounds(!settings.getPartyMessageSounds());
chatSettings.setItem(1, ItemUtils.createGuiItem(Material.NOTE_BLOCK, Common.colour(settings.getPartyMessageSounds() ? "&aParty Message Sounds" : "&cParty Message Sounds"), Common.colour("&7Toggle hearing a ding for party messages.")));
chatSettings.setItem(10, settings.getPartyMessageSounds() ? ItemUtils.createDye(DyeColor.LIME, Common.colour("&aParty Message Sounds"), Common.colour("&7Click to disable!")) : ItemUtils.createDye(DyeColor.RED, Common.colour("&cParty Message Sounds"), Common.colour("&7Click to enable!")));
((Player) event.getWhoClicked()).updateInventory();
return;
}
Possible as well. Only difference is it won't parse the string to uppercase, so input's gotta be exact
matchMaterial can handle other formats, and deals with the exception
I believe it can parse minecraft:material for example
String#toUpperCase?
Still gotta handle the exception
how to get the time of the BukkitRunable (like the remain delay) when the server stop to put it in the configuration?
Like i have a bukkitrunnable
it goes half of the time i set
then the server shut down
i want it to continue the remain time of the last one
i have no idea what keyword to search on spigotmc tho
in ondisable
just get the Task
so BukkitTask task = new BukkitRunnable
dependency inject it into main class
then use task#cancel in onDisable
@quaint mantle btw in case you weren't aware, for that cache-busting thing from earlier you can cheat like this "&bust" + System.currentTimeMillis();
&bust will obv only work first time so that will give you a different bust everytime
so
I want to make an addon to a plugin
so I want to use their command prefix
how would I go about allowing both our plugins to use the same prefix?
get their plugin's instance and theirplugin.getCommand("...").setExecutor(...
Alright guys im having a serious brain fart here.. so im trying to have a system that gets the highest even number, so like.. if I have 9 of an item, and I want to take items in multiples of 2.. how would I take ONLY 8 and leave the 1?
ive tried doing things with modulo but cant figure it out
leaveAmount = 9%2
9/2*2 will give 8 for integer multiplication
wat
Block block = (event.getPlayer().rayTraceBlocks(50)).getHitBlock();
How make no give null
btw i tried
Block block = (Objects.requireNonNull(event.getPlayer().rayTraceBlocks(50))).getHitBlock();
Just do a null check
?
Hi
i want to serialize some values to an config.yml
but idk how to deserialize the content
public class SerializeHolos implements ConfigurationSerializable {
World world;
String name;
String displayName;
double x;
double y;
double z;
public SerializeHolos(World world, String name, String displayName, double x, double y, double z, CTHolos instance){
//Hologram hologram = new Hologram(world, format(name), x, y, z, instance);
this.world = world;
this.name = name;
this.displayName = displayName;
this.x = x;
this.y = y;
this.z = z;
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> serialized = new HashMap<>();
serialized.put("world", this.world);
serialized.put("name", this.name);
serialized.put("displayName", this.displayName);
serialized.put("x", this.x);
serialized.put("y", this.y);
serialized.put("z", this.z);
return serialized;
}
public static SerializeHolos deserialize(Map<String, Object> deserialize) {
return new SerializeHolos(deserialize.get("world"), deserialize.get("name"),deserialize.get("displayName"));
}
deserialize.get("world"), deserialize.get("name"),deserialize.get("displayName") //this returns objects and i need strings then doubles for x,y,z
i mean in world i need a world type
is there any particular reason you are using the x y z & world rather than a Location
because Location#serialize and Location.deserialize are a thing
Probably avoiding yaw and pitch 
meh ig
although they arent required by the constructor but will be serialised ig
im not a fan of this class name
seems like you are using it for any Holo - dont need to put Serialize in the name just cause it implements serializable
Hey I'm trying to make an inventory similar to this https://gyazo.com/accd6125294fa962bb94c878916cdac3
But I can't figure out how they are making an item invisible?
I've tried using air but that has no metadata so I can't add a description
U can use glass pane in all of the slots
if i want to hide all NPCs with the name Click!,
i know i do that with teams, and by adding the entry by name and setting the visibility, but who do i apply the team to? or wha. i just want Click! to be invisible to all players, but players would be able to see one another
team.addEntry("Click!");
team.setNameTagVisibility(NameTagVisibility.NEVER);
using citizens
idk, but im messing up somehow. im applying this team to everyone when i'm not sure what i should be doing, it does make npc nametags invisible, which removes the hearts thing i have under their nameplates, and the only way to do that.
This is probably a question to ask the devs
(the cititzens one)
i imagine there must be a method to remove them
Hey is there a way i can replace a item from someone's hand?
Player#SetItemInHand
This is probably a question to ask the devs
(the cititzens one)
i imagine there must be a method to remove them
somebody here's gotta know, if anything, this channel is what gave me the idea or the fact that teams would be the only way to remove NPC nameplates
k thx 🙂
I think that may be deprecated tho 🤔
Have a look
okay 🙂
aa will it work for spigot 1.8.8?
for 1.8, Player#setItemInHand(ItemStack)
1.9 brought that
what i thought
i think Player#setItemInHand dafaults to main hand beyond 1.8 - but dont use it anyways
you need to send scoreboard packet for team color
I need all of the online players in a list of strings, how would I do this?
you mean the names of the players?
yes
you get a list of the online players by using server#getOnlinePlayers and make a String list you put all the names from the onlinePlayers list into that
its 4 lines of code
Streams
or that
List<String> players = Bukkit.getOnlinePlayers().stream().map(player -> player.getName()).collect(Collectors.toList());```
I believe you can use a method reference there
yeah
Player::getName
even then, why use streams? they're slightly more inefficient than just writing out a foreach, y'know
if you're truly poggers, make your own functional lib with monadic lists :) (or use Kotlin)
bc y'know, the above in Kotlin is just
val players = Bukkit.onlinePlayers.map(Player::getName)/map { it.name }
ez
probably
List<String> players = Bukkit.getOnlinePlayers().map(Player::getName)
which is the Java representation of what it would compile to
List in Kotlin is completely different from List in Java.
For one, Kotlin's List is not an interface and instead represents an immutable list (while MutableList is a mutable list)
And it contains a large amount of utility methods.
(Which may or may not be extension functions, I'd have to check)
But the benefit is that you're applying that function to the list instead of applying it to a Stream (or Sequence in Kotlin)
the #map() function is missing in java, would make things a lot cleaner sometimes
which has significantly less overhead as you don't have to instantiate a new stream pipeline, although the immutable list may make it slightly less efficient
damn right
hell, they only added List.of and such in like, Java 9 or later iirc
and that goes to show that the standard library designers don't know what they're doing :)
well, they do to an extent lol
(I jest, of course)
also..
I'm way to tired to be coding so I'm drawing a blank since i don't have anything i can copy paste anymore
private boolean inRange(int value) {
return (value >= minArgLength) && (value <= maxArgLength);
}
What would this be if -1 were to be taken into account?
I've been up way too long 👀
well
the value on the right would be true
but the one on the left would be false
so it would return false
e.g.
a min of 2 but max of -1 being infinite in this case
hmm
Guava has something similar apparently, just called it transform
that.. would make things more complicated that it should be
i know I did it before but i don't have the code anymore 👀
Don't remember what i yoinked it from either 😐
see you have to represent 3 possibilities in this
- not in range
- in range
- infinite range
which means you need a bit of a tristate-esque enum
return value == -1 || checkRange?
damn I just cracked my knuckles so hard they fucking echoed
oh wait you mean unbound low/high
I believe for -1 it would just consider anything above min true, yea?
minArgs = 3
maxArgs = -1
so as long as it's 3 or above it's true
minArgs = 3
maxArgs = 6
must be between 3-6 args
you could just add the -1 check inside each condition then
That is what I'm blanking on
due to sleepiness
basically lol
well
that method is for checking the bounds
and checking if the value is in the bounds
oh
Yea, if the args are clamped to 1 and 5 for example it must be between 1 and 5 however if it's between 1 and -1 then as long as it's 1 or above it's true
return (min == -1 || checkMin) && (max == -1 || checkMax);
I'm gonna gist this shit, i swear to god
how does what work?
Discord to minecraft chat
SRV?
Can you tell me how
I bet there's a tutorial on their page
also this is the wrong channel, you should've asked in #help-server
Do I need to make a bot
They have a support discord and the installation process is explained on the resource page
guys how to fix .setExecutor being null?
Also doesn't help i think the previous code was more complicated.... and that I've been up for probably 10+ hours again
a method cannot be null, the thing you're calling it on is
Is the command in your plugin.yml
that's probably getCommand(), so you're missing the command in plugin.yml
or misspelled it in getCommand(String)
TECHNICALLY
that would throw a NoSuchMethod!
IF THE METHOD USES DYNAMIC LOOKUP AND DOES NOT EXIST AT RUNTIME, IT IS THEORETICALLY NULL
chill
No need to yell 😋
I'm not yelling, I'm just speaking very loudly
trying to be nice to the hard-of-hearing people in chat
(is that the term? who cares)
Yelling would be IF THE METHOD USES DYNAMIC LOOKUP AND DOES NOT EXIST AT RUNTIME, IT IS THEORETICALLY NULL
or an image of it
all caps 100 font size, bolded
Nah thats another level. Thats screaming
this is the null thing btw
that is a warning
if it is only 2 getcommand its fine and it runs the plugin but when i add a third one, it doesnt want to enable the plugin
hover over it, what does it say?
it is showing up bc getCommand is probably annotated with @Nullable
which means it may return null
but not that it does return null, just that it may
is that IntelliJ? 🤔
yes
Alt + Enter, insert Objecs.requireNonNull
yeah don't do that 😂
also don't use assert, or even a null check in this situation
why wouldn't you
as I said, it's unclean
^^
then what do i do to stop it being null?
if you have multiple commands, you have multiple Objects.requireNonNull
oh yeh my bad i meant might be null
won't be null
it might be null
but when i add a third command it wont enable the plugin
Able to call? I'll help you out... Much easier
private PluginCommand commandNonNull(String name) {
return Objects.requireNonNull(getCommand(name));
}
uh yeh sure
you can also do that
and then use commandNonNull instead of getCommand
Which is much cleaner, as you type less code overall.
Just use a simple rule for yourself. as soon as you have duplicated code. Extract it and make a method out of it
DRY ftw
guys
getCommand will only return null if you don’t have the command in your plugin.yml
Not much DRY when you do it once.
You ram out of memory
if you had a single command, it would end up the same.
Also that isn’t eve spigot
Still a good idea to check it, never know when you might accidentally leave one out.
That’s when you fix it?
Not really any point in handling the null
therefore letting you know you need to fix it lmao
which is why you should check it
so you don't have to wonder why your code isn't executing
before figuring out it's bc you didn't define your command
the only pro of doing this is shutting up the IDE
that too ^
DRY probably broken in at least one of my resources or github repos lol
he meant the NPE if the command was null
fair but
help me
and i'd say he's right as long as you're doing a plugin and not a command library or something.
I prefer handling it myself
I can barely help myself
that's why you're not a helper
you mean ran?
I'm a resource staff UwU
@terse zodiac how much RAM do you have allocated for the server in total?
2GB I think?
that's prob the issue then
maybe 4?
breaks if the args are 0
“The default values for Xmx is based on the physical memory of the machine. The Xmx value is 25% of the available memory with a maximum of 25 GB. However, where there is 2 GB or less of physical memory, the value set is 50% of available memory with a minimum value of 16 MB and a maximum value of 512 MB”
Memory: 48129320 bytes (45 MB) / 2147483648 bytes (2048 MB) up to 2147483648 bytes (2048 MB)
KB?
MB?
GB?
TB?
hmmm
what
for minecraft 4gb
if (!inRange(args.length)) {
sendMessage(player, messagesConfig.getString("not-enough-arguments"));
return true;
}
private boolean inRange(int value) {
return (value >= minArgLength) && (maxArgLength == -1 || value <= maxArgLength);
}
Looks like 0 gets passed the check, unless I'm being dumb again lol
which is likely seeing as I've been up longer than i should be 👀
what values are min & max
wait...hmm...lemme double check something...i might just be dumb
#AlsoFuck0length
how did you know?
what's that first one?
first one pinned or IUS
yes
IUS is a google doc with notes from a lecture
I sleep at 9 or 10 nowadays, I understand
Intro to software engineering
I sleep at whenever the fuck i sleep.
My GF is in germany lol
My BF is non-existent.
I don't have one anymore.
hand could count
Eh he doesn't fall asleep very often tbh.
xD
But yeah my ex is in WV so we never had that problem.
In fact, he typically stayed up really late talking to me.
Istg we were in a call for like 14-16 hours one day.
Actually that happened 3 times in the span of a week.
#help-emotional-development
#relationship-help
okay yea @analog ore I'm too tired to code. Time to sleep.
The classes don't handle 0 arg properly now, so they need rewritten lol
closed, if you want https://www.github.com/OpticFusion1
wait I have class in 10 never mind
I have open src stuff lol
how do i detect when a player is jumping? PlayerMoveEvent?
mods are not spigot and wrong channel. This is for plugin development
sure if you want to you can use real teams
yeah since scoreboard entries are all strings
for players their name and for entities their uuid
yes, uuid as the string entry
Database Library
Is it possible to know with spigot api if a player is affected by a scoreboard displayed for a team (/scoreboard objectives setdisplay sidebar.team.*** teamName) ?
With scoreboard#getEntries() i can get all players referenced manually (by /scoreboard players add) but not with teams
how tf do I debug this issue with no stack trace being printed and the server just shutting down?
it can;t be terminating with no logs at all, not unless you are force closing teh jre
how should i load everything that a command needs to work (f.e. warp files, locations) to objects? Should i just make one class for it?
tried with JDK 16.0.2 and JDK 17
When you set a static field to null, is it eligible for GC
It is right
The object is unreachable
Thanks
how to move blocks (like hole in the wall in minecraft chamionship event )
Only if the class its in is up for GC
Static variables are referenced by the Class object which is referenced by the class loader. unless the class is unloaded the static variables are permanent
Which is not safe because every single hard reference to the class and the classloader needs to go away
Okay so.
Class Loader -> Class -> Field -> Object
And I set the field value to null, hence killing the Field -> Object reference. The object would then end up unreachable in heap memory right?
There would be no reference to it, hence it would be eligible for GC?
But why?
this seems to be happening because of an empty switch.... weird
Why what
Why set it to null
If its static, no.
I could accept you saying simply no, but I'm interested in what's the reason behind it.
Sure the value of the field would be gone and gc’d if isn’t referenced somewhere else
So it would
Be gc'd
But then using your static variable is pointless
If it isn’t going to be referenced from somewhere else
Its a static field so its referenced by the Class. Setting it to null, its still referenced by the class.
Just by assigning a variable null does not mean its current instance it was holding will be gc’d
if it is referenced it can't be put up for GC
And obv if you’d have a static final variable of a primitive type the value is going to be inlined so there you don’t even have to be worried.
Not sure what I should've found out there
I understand how classes & interfaces are unloaded
I'm interested in the field referencing another object in heap
static variables are covered under those rules too
Just because you set it to null does not remove all references to it.
I understand that
a static field is referenced by the class its in. So unless you can unload that class your field is held by the class reference
But you're still talking about fields, not their values
You already got the answer of their values
^ that was your question. The field.
Okay okay
He asked if the instance the field was referencing to would be gc’d tho if he would mutate the variable with null.
Yup
um, an interesting question
And the answer is yes and no
Thanks for rephrasing
I don't know but I would assume yes, however it could be reassigned
If some other variable references that object, then it by convention cannot be gc’d unless some very specific circumstances I’m not going to talk about, but if that field is the only strong reference to that object then yes, it’d be enqueued for gc.
Thank you
How would you make a YAML database?
there is really no point in making a yaml database
if you need unstructured data, use json based dbs like mongodb
Can't I just store stuff in a yaml file though?
Well yea sure but that is not a database
Oh
Do you know how I would make a mongodb?
Well you can still store things in plain yaml files
which might be a lot easier
just because it isn't a remote database maintained by its own process etc
doesn't mean it is unusuable
True
Do you know how I would make that then?
I just need to store only a few lines of information
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
spigot has this
Ty
which allows you to work with config files
you can however create other files besides the config.yml using the same system
Maybe put the yml storage behind some sort of boundary in case you wanna switch in the future it wouldn't be too big of a hassle
Like having an interface to talk with the persistent storage implementation whatever that might be
Just making a small plugin rn
Nothing public or useful
I guess but you never really know what it might grow into in the future
But ye that would be a good idea to do that
If it grows in the future then I would have to rewrite everything
I have the least efficient code ever rn
can i load an Set<UUID> in string format from config?
ah ok
gotta get somet working first lmao
loop through the strings, if a string can be validly turned into a uuid, convert and add to the set basically
Yeah ofc, but don't forget to clean your code after wards!!!
yea i got it thanks
but uhh this is the format
vanished_players: '[9558961c-bc19-4820-9f75-5d486448c2d5]'
then fix it. Don;t use an array, use a Set/List
its a set.toString()
or maybe i can just do
new HashSet<String>(Arrays.asList(file.getString("vanished-players").replaceAll("[]", "").split(", ")))
smh
what can i use instead?
add it as a List and getStringList
but i saved it with file.set("vanished-players", hashset)
bukkits yaml parser doesn;t understand Set use a List and it will.
but if i just use file.set(..., list) will it be save as
- uuid1
- uuid2
etc?
just write a wrapper method to save and load
build a string List, put in config, read String List from config and return yoru Set<UUID>
uhh lemme search that up
i hope this will
btw saving all the lists etc to the files, should i do that async?
teh actual saving to disc yes
adding to teh config, no
thats just in memory
just remember to save/load lock
you could write a deserializer for that
yep
or simply
there is a get method you can provide teh class
new HashSet<>(getList())
with the saving you mean FileConfiguration#save(file)?
If i create a inventory using a command e.g. Inventory trashCan = Bukkit.createInventory(player, 36, "Trash Can"); and want to detect when it's opened in an event, how do i do that?
yes
save and load (if you can) async
i tried using InventoryOpenEvent but cant figure out how to reference that specific inventory that i created.
if (inventory == trashCan)
You are only instance checking an Inventory, no need for a Holder
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> ConfigManager.saveConfig(ConfigManager.FileType.DATA));
lock it
i've never used locks
then strange things would happen
i know the concept of locks but i never found it useful to use it
lets say you do indeed save to a file async
they're not in the same class
the event and the created inventory
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
normally if you coded spigot plugins you should have realized everything you write gets executed linearly fourteenbrush
When we work with async, that is not the case
One is a command class where it creates the inventory and the other is in a event class
code declared above other code can be executed after that other code
or at the same time
yes
Read the link, you need to learn it
and yes exactly at the same time
so the problem here with files comes down to that you might be writing to the same file twice under the same time
and then you would end up with a corrupt file
or well
sort of corrupt
corrupt data at least
It actually happened I believe in LP early days
oh
but lucko fixed it sophisticatedly
what is dependency injection?
passing a reference of a variable to another class
oh
anyways locking is when we ensure across multiple threads only one thread can at the moment do something
and every code executed passed to a single thread must run linearly
so then you'd be safe
bbl but I will send you an example of how locking can be done
isnt there an easier way to do this
isnt this just something like synchronized {}?
the rough way, yes.
and what is that?
soryr that was to fourteen
oh
is there?
i read a book about operating systems
I'd though avoid using synchronized
it has no fairness policy
and it doesn't provide a read write mechanism
i dont even know what it does exactly do
oh maybe elgar could explain that then
take your time i havent wifi the whole weekend 😳
yep, synchronized is not realy relevant in thsi case
onEntityChangeChunk?
You could make it work by simply sync locking your data access class
but thats rough and basic
Why is <Player>.getTargetBlockExact() when i'm looking at a sign not return an Block that is an instance of Sign?
not performant when you are trying to run things async
?
is that relevant for me or no
You could use a public static variable, however that could be abusing it which isn't a good thing.
no
Is there a way to detect if a scoreboard objective is displayed to a player with spigot api?
what are you doing exactly anyways, Killer?
I'm trying to make an plugin that caches and copies the content of a sign and pastes it
Player player = (Player) sender;
Block looking = player.getTargetBlockExact(10);
System.out.println((looking instanceof Sign));
if(!(looking instanceof Sign)) return false;```always returns false. Any idea why?
someone posted a really nice save/load lock class the other week
have you tried googling it?
also, would probably have been better to make this a thread.
It's more likely you'd have your messages seen easier
?paste
Take a look at this. Its one I've used before. It will not work for you as it uses custom bungee stuff, but you can use most of it. https://paste.md-5.net/neqemiyako.java
The save/load locks will though. It uses a ReentrantReadWriteLock to prevent collisions
static
sing cacher
public static void addLine(String holo, String text) {
ConfigurationSection section =
data.getConfig().getConfigurationSection(holo);
List<String> lines = section.getStringList("lines");
lines.add(text);
section.set("lines", lines);
data.saveConfig();
}
is there anything wrong about this ?
Yeah, static shoudl not be there. It was when I was messing about with abstraction

Hey, how can I put rgb text into a TextComponent in Bungee?
use a rgb pc
Is there a way to read the real code behind a spigot method? I would like to see Player#getScoreboard()
Like deobfuscated
well
just depend on the server jar rather on the api
use mojmaps in case you want to "unobfuscate" it
not for mojang code but spigot one
