#help-development
1 messages · Page 879 of 1
they do have debug logging in the source, they just strip it from the log4j config
could be useful for us
kek
implying they care
well spigot or cb could re-add it or remove the deleting stuff with a patch
uhhhhhhhh
i have no idea
i mean technically we patch a pom so im guessing its a similar process
i mean you can provide your own log4j config file anywhere on the filesystem and override it with the log4j2.configurationFile system property
does spigots log4j2 config not override it
spigot has a separate log4j config from vanilla?
so wouldnt it override vanillas and re-enable the levels
i don't run a server but i would not like to be spammed with potentially hundreds of meaningless debug messages on a production server tho
used to be able to, before log4j
talking about logging, is there any way to have nicely formatted messages e.g. "test {} log message" where {} is replaced by the first arg and so on? I can only pass a string to most of the methods
the server ships slf4j api, although it's not exposed in bukkit you can include it in maven/gradle and just use it as usual
What is best for making a discord bot? jda? or is there anything else
wtf is wrong with IJ
nothing is
and if I click on "Wrap using Boolean.valueOf()" it comes up with this lmao
change it to boolean instead of Boolean
No.
primitives are not nullable. And also you can set a Boolean object to a primitive boolean because of autoboxing
the code is valid
it's just IJ being stupid
the weirdest thing is that it uses Foo.valueOf like wtf
have you tried just writing Boolean out yourself instead?
I just use the code I sent, it compiles fine
as I said I am aware that it is valid code, but that wont stop your issue.
Boolean.valueOf gives me "cannot access java.lang.Boolean"
as said, it cannot access java.lang.Boolean lol
yeah I'm already waiting for it to finish
This is the first time I see somebody using Boolean instead of boolean
I am more questioning why you don't want a primitive
why would you want a nulled Boolean?
at that point just use an integer and bitwise.
to indicate that neither on nor off was entered as argument
Minecraft components moment
how do you even get to that stage of code if neither of those two were specified?
should just prevent that stage in the first place
anyways, your way of coding. I'll go back to my show on netflix.
why would that be a problem?
/command on -> turn on
/command off -> turn off
/command -> toggle (onOff is null)
isn't there a default state that you keep track of?
if nothing is specified you just invert the default state in memory.
Why
without even jumping to the part that checks for on/off
and how would I pass on to the "toggleWhateverMethod" that nothing was specified if I don't pass null?
Default is not defined
Hey guys, for some reason, non-op players are able to use commands other than create. A month or two ago, only ops could do that. I'm using the latest version of paper and that's the only plugin I have in the server I'm testing. I also haven't really changed my plugin.yml of my mod, can you guys think of reasons why this is the case?
name: HungerGames
version: '${project.version}'
main: me.cantankerousally.hungergames.HungerGames
api-version: '1.20'
commands:
select:
description: "Select an arena in HungerGames"
usage: <command>
create:
description: "Create an arena in HungerGames"
usage: <command>
chestrefill:
description: "Refills Chests an arena in HungerGames"
usage: <command>
supplydrop:
description: "Drops a Supply Crate in HungerGames"
usage: <command>
setspawn:
description: "Sets SpawnPoints for Arenas in HungerGames"
usage: <command>
start:
description: "Starts the game in HungerGames"
usage: <command>
end:
description: "Forcefully Ends the game in HungerGames"
usage: <command>
permissions:
hungergames.select:
description: "Allows you to select an arena in HungerGames"
default: op
hungergames.create:
description: "Allows you to create an arena in HungerGames"
default: op
hungergames.chestrefill:
description: "Allows you to refill chests in HungerGames"
default: op
hungergames.supplydrop:
description: "Allows you to drop a supply crate in HungerGames"
default: op
hungergames.setspawn:
description: "Allows you to set spawnpoints for arenas in HungerGames"
default: op
hungergames.start:
description: "Allows you to start the game in HungerGames"
default: true
hungergames.end:
description: "Allows you to forcefully end the game in HungerGames"
default: op
The command does not need to be on and off
this is the new boolean to allow using "on" and "off" instead of just toggling
before that, the method just had Command, CommandSender as args
where do you call that method, I need to see some more
a cleaner way to avoid a nulled Boolean would be using a byte if you care about extra allocation of 3 bytes compared to an int or not, or an enum which would be an extra class though and a bit overkill.
not really
A nulled boolean should be fine 🤷🏽♂️
of course its fine but theres a reason primitives exist
a boolean represents two states, on or off, and the boolean not being there prepresents neither on nor off was chosen. I really don't see any reason why someone would be so obsessed with looking for problems with that
maybe I rename onOff to "chosenNewState" to make you happy
@tender shard bro fuck you your buildSrc makes my laptop sound like its going to blast off into space
get an apple silicon then
the m2 macbooks don't have fans I think
For me that's how moving an icon on my desktop (as in the main screen) sounds like, not talking about starting an app
Pro does
how does it stay cool
or does it just not 😂
theres jda and d4j
ive only ever used jda so no idea how good d4j is
oh tbh I never heard it
it simply doesnt get warm
meanwhile my laptop
it's more powerful than my desktop (i7 9700K) and stays super silent and cool all the time. no matter whether im compiling basics or rendering a 4k video or whatever
ok tbh I only render 1080p videos
Can you render a 4k video
is that btop
It simply doesn't
I believe it thermal throttles pretty bad
dont apple use those vibrating air coolers
oh well ig that is one way to "solve" the problem
doesnt show temperature for me 🥲
They don't
really?
wonder why
unless you're running through a VM
then in that case its pretty obvious why
if you close your eyes, there is no problem
must be an apple thing
True the max does tho
Heard the m3 max overheTed
oh yeah idk I got the m2
how can i learn making plugins
By first learning java. Then reading the basics https://www.spigotmc.org/wiki/spigot-plugin-development/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Hey there anyone here familiar with Squaremap api?
is there a way to get config locations and loop through them? this is kinda repetetive
you can getKeys for a config section which allows you to easily loop through them and get them all
u can use ConfigurationSection maybe
ConfigurationSection section = this.config.getConfigurationSection("core.blocks");
Set<String> identifiers = section.getKeys(false);
for(String identifier : identifiers ) {
}
ill try thanks
does it need to be strings or can i do locations?
the strings will be the names of the sections, in this case "coal", "wood", "iron"
ohhh thanks
to get the actual location you still have to throw in the result of getKeys(...) into a get method of the config
okay thanks
For anyone who knows siegewar api, this function is essentially on siege start -> create a new flame icon for the squaremap at spawn location of the besieged town, then remove that icon when the siege ends. I wasn't able to figure out how squaremap api works in order to actually add the icon to the map haha so if anyone has some pointers, that would be awesome!
Have you tried asking the devs of said APIs?
https://github.com/jpenilla/squaremap/wiki/API-Basics
I think what I need is the layproviders explanation which doesnt seem to be written out anywhere I can find
This is still holding up
Well to be completely fair with you, I've had an interaction with them before and their support is utterly useless... they just kinda make fun of you for not understanding their api...
Time to switch then, if the devs are evil you really need to switch
Because of they won't provide support for the API they develop I doubt you will find much anywhere else
Yeah that's a good point, dynmap was an option until the guy I'm helping out decided to just go squaremap.... so that also doesn't help
You could try explaining to him the cons of going with squaremap
I have, I believe it's just the fact that squaremap is already setup
I could always see if they would actually be willing to help me as this is somewhat of an addon I suppose... it's got api usage from towny / siegewar / and squaremap so perhaps that might entice them to actually provide support lol
That looks so fun to manage
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
#bot-commands moment?
how can i learn make plugins?
- Learn java
It's one google search away
there only curses for 90$
https://www.spigotmc.org/wiki/spigot-plugin-development/ here, took a singular google search
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
This explains the general project setup. After that you can basically find everything in the javadocs: https://hub.spigotmc.org/javadocs/bukkit/index.html
what are easy plugin ideas
stuff from essentials
Custom commands
join/leave messages, tp, tpa
I'd suggest trying to make functional plugins... meaning something with multiple layers perhaps... tpa system would be good for sure
idk how to make a tpa system no idea
then start with sth simpler?
Just think about it logically... what needs to happen in order for teleport / accept system to work? Firstly you need the command to request the teleport, then you need to response method in order to "accept / deny" that request... and so on
It's not as bad as you think
This blog post for general project setup. ^
Then here's how to make simple commands: https://www.spigotmc.org/wiki/create-a-simple-command/
And here's how to listen to events: https://www.spigotmc.org/wiki/using-the-event-api/
I think I made my first tpa system with like under 100 lines so it's not super complex
can i make it all in 1 class
if you want
Yes but it's recommended to setup a class per function as it were
you mean an class for tpa an class for tpa deny ...
no, a class for a commandexecutor
No, that can all be handled in a single class
can i make an main class and one commadn class
idk if it can work
programming is about trying
okay lets go xD
Function meaning a mechanic I suppose, just write out everything related to the "tpa function" in the tpa class right? if you were to add maybe like an admin usage of the tp command to check permissions and force teleportations instead of a request, you'd probably write that one out in a seperate class than the tpa
@tender shard are you familiar with towny / siegeware api?
Sorry for the ping btw I know a lot of people hate it, just trying to get some quick support
Or perhaps you might be?
If so, I've been made aware that nothing happens when the player joins / leaves a town. The function is supposed to trigger on townjoin / townleave, if the player is on cooldown they are disallowed to do so and both the inviter / player are sent a message notifying them of the cooldown, otherwise they are allowed and put on cooldown.
i haven't used towny's api in 3 years i guess
how can i make if its an online player here? : if (args[0].equalsIgnoreCase())
I'm not sure if my timer system is just busted, or if I'm just not using to correct events? I have no experience with towny / siegewar api other than trying to read through their documentation for about an hour
Probably a for loop iterating through online players
Or perhaps just a null check tbf
if bukkit.getplayer(args[1]) != null would work i think
do you think its smart to ask chatgpt for an tpa system code and look how it works?
Chatgpt can write you anything to be fair, although for learning purposes it'd be best to try and write out the functions yourself
Chatgpt is also very error prone as it doesn't have real time access to api's meaning it can be incorrect about a lot of methods
but idk how to make tpa
it gave me this code : ```java
package com.example.teleportation.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TpaCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Dieser Befehl kann nur von Spielern verwendet werden.");
return true;
}
Player player = (Player) sender;
if (args.length == 0) {
player.sendMessage("Benutzung: /tpa <accept|deny|player>");
return true;
}
if (args[0].equalsIgnoreCase("accept")) {
// Implementiere die Annahme eines TPA-Antrags
player.sendMessage("Du hast den TPA-Antrag angenommen.");
} else if (args[0].equalsIgnoreCase("deny")) {
// Implementiere die Ablehnung eines TPA-Antrags
player.sendMessage("Du hast den TPA-Antrag abgelehnt.");
} else {
// Implementiere das Senden eines TPA-Antrags an einen anderen Spieler
String targetPlayerName = args[0]; // Annahme: Der Name des Ziel-Spielers ist das erste Argument
Player targetPlayer = player.getServer().getPlayer(targetPlayerName);
if (targetPlayer == null) {
player.sendMessage("Spieler nicht online oder nicht gefunden.");
return true;
}
// Implementiere die Logik für das Senden eines TPA-Antrags an den Ziel-Spieler
// Beispiel: targetPlayer.sendMessage(player.getName() + " möchte zu dir teleportieren. /tpa accept oder /tpa deny");
targetPlayer.sendMessage(player.getName() + " möchte zu dir teleportieren. /tpa accept oder /tpa deny");
player.sendMessage("TPA-Antrag an " + targetPlayer.getName() + " gesendet.");
}
return true;
}
}
It's very good to use when you have some experience with spigot api... athough it can still be used to write "skeleton" type kind of syntax as to allow for the filling of code to still allow you to learn
Ehm
Yeah it looks correct to me
okay i try to understand how the code works
Might want to add a permissions check however
if (player.haspermission("permission node of your choice")){
}
This will make sure only people who should be able to tp are allowed to send requests
i wanna undersatnd first how this system even works to make it a bit different by myself
So essentially this is a very basic, command + argument system. When it comes down to it, if args length = 0, it send the command usage message to the player. if args[0] = accept, it sends the player the "du hast den tpa-antrag abgelehnt" message, otherwise if args[0] = deny, it send the deny message, else it gets the player name from args[0] and turns the string into a usable player variable in order to then send them a couple more messages.
i dont understand this part :
Player targetPlayer = player.getServer().getPlayer(targetPlayerName);
if (targetPlayer == null) {
player.sendMessage("Spieler nicht online oder nicht gefunden.");
return true;```
Currently, there is no actual teleporting functionality and this will only send players messages
bruh
This portion takes the "string name" from args[0] and turns it into a usable Player variable. If targetPlayer = null then it will send the message that the player doesnt exist / isnt online
Hey just wanted to ask what the "proper way" now is to create heads with base64 values thats my old code: https://paste.md-5.net/equjupugim.cs, but now in the console it says its wrong
what should I do so I can have a common module, and then have some type of Player type there inside an interface and use it for paper module and spigot module (and maybe if possible bungeecord in the future)
Hello, do someone know how to remove the background of TextDisplay entity ? like this
That might be being done using custom maps. (At least thats how I would do text on a wall like that.)
Hey guys, for some reason, non-op players are able to use commands other than create. A month or two ago, only ops could do that. I tried it on the latest version of paper and spigot and that's the only plugin I have in the server I'm testing. I also haven't really changed my plugin.yml of my mod, can you guys think of reasons why this is the case?
name: HungerGames
version: '${project.version}'
main: me.cantankerousally.hungergames.HungerGames
api-version: '1.20'
commands:
select:
description: "Select an arena in HungerGames"
usage: <command>
create:
description: "Create an arena in HungerGames"
usage: <command>
chestrefill:
description: "Refills Chests an arena in HungerGames"
usage: <command>
supplydrop:
description: "Drops a Supply Crate in HungerGames"
usage: <command>
setspawn:
description: "Sets SpawnPoints for Arenas in HungerGames"
usage: <command>
start:
description: "Starts the game in HungerGames"
usage: <command>
end:
description: "Forcefully Ends the game in HungerGames"
usage: <command>
permissions:
hungergames.select:
description: "Allows you to select an arena in HungerGames"
default: op
hungergames.create:
description: "Allows you to create an arena in HungerGames"
default: op
hungergames.chestrefill:
description: "Allows you to refill chests in HungerGames"
default: op
hungergames.supplydrop:
description: "Allows you to drop a supply crate in HungerGames"
default: op
hungergames.setspawn:
description: "Allows you to set spawnpoints for arenas in HungerGames"
default: op
hungergames.start:
description: "Allows you to start the game in HungerGames"
default: true
hungergames.end:
description: "Allows you to forcefully end the game in HungerGames"
default: op
He's not on a wall
?whereami
Question, what is the best way to store a mapping of strings to integers in Java/Spigot?
I want to give each player their own map of resources, and then store that map, my structure would look roughly like this:
{
SOME_UUID = {
wood = 0
stone = 5
iron = 10
}
}
JSON/GSON maybe?
I'm using the spigot API to develop the plugin, I also tried it on spigot, I still have the same error
you shouldn't call teleport in the consumer action, the entity does not exist in the world (and, besides, you are already spawning it there)
but as for your actual question, you want to change the background colour with setBackgroundColor
^ the background color allows you to specify an alpha value. setDefaultBackground(false) does nothing because that's the default value
Give it an alpha of 0
is there a way to make a plugin for all verions
if it doesnt use nms use the lowest api verison you want to support
or how can i change version in intelyIDE
my plugin is currently for 1.20.1 i want it for other verions too
lower the spigot-api dep version in pom.xml and change api-version in plugin.yml
^
to what version in plugin.yml
whats the lowest version you want to support
no
i want hiher versions
so you want 1.20.1 and up?
yea
leave it as is then
and in pom.xml?
leave as is too
<version>1.20.1-R0.1-SNAPSHOT</version>
yup
there stands 1.20.1
yes
okay ty
you can only do that if you're cheating
so it will wortk for 1.20.4 too?
yes
and how can i change name casue my plugin names SUPERRTP-1.0-SNAPCHOT.jar
i only want SuperRTP.jar is this possible?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<finalName>SuperRTP</finalName>
</configuration>
</plugin>
Add this to your pom.xml inside <build><plugins>
just add at the bottom?
as long as its not inside another plugin section
okay ty
im to dumb to paste it can you explain xD
what dont you get out of copy that
isn't it kinda obvious if you look at the screenshot?
and paste it inside <build> <plugins>
Hey everyone, i am a bit confused why my PlayerJoinEvent never runs?
i never see "SOMEONE JOINED " in my console
do you register it
yup
does it implement Listener
in the same file there is the onPlayerLeave event, which does work
wait hu?, i am so stupid
ignore me
what was the issue lol
kek
but the thing is, i thought i registerd because the "player left: ${name}" logger was super close to an other message that got logged, so i thougth the above playerLeave event worked
but still tankyou haha, cus it saved a lot of time and headacke when you said that :P
which code looks easier to read / understand?
val maxAllowed = player.getPermissionNumberValue(module.permissionSetHomeMultiple.name) ?: 2
val allowUnlimited = player.hasPermission(module.permissionSetHomeUnlimited)
val isOkay = if (allowUnlimited) {
true // Player may set unlimited homes
} else {
if (homeList.homes.size < maxAllowed) {
true // Player may set more homes
} else {
if (homeList.homes.size == maxAllowed && homeList.getHome(homeName) != null) {
true // Player already set his max amount of homes, but this home will replace an existing one
} else {
false // Buy a rank, ffs
}
}
}
if (!isOkay) {
module.msgHomeLimitReached.tagUnparsed("limit", maxAllowed.toString()).sendToSender(player)
return true
}
or this
val maxAllowed = player.getPermissionNumberValue(module.permissionSetHomeMultiple.name) ?: 2
val allowUnlimited = player.hasPermission(module.permissionSetHomeUnlimited)
val isOkay = allowUnlimited || // Player may set unlimited homes
homeList.homes.size < maxAllowed || // Player may set more homes
(homeList.homes.size == maxAllowed && homeList.getHome(homeName) != null) // Player already set his max amount of homes, but this home will replace an existing one
if (!isOkay) {
// Send message if the player cannot set/replace a home
module.msgHomeLimitReached.tagUnparsed("limit", maxAllowed.toString()).sendToSender(player)
return true
}
if (homeList.homes.size == maxAllowed && homeList.getHome(homeName) != null) {
true // Player already set his max amount of homes, but this home will replace an existing one
} else {
false // Buy a rank, ffs
}```
cmon man
thats like doing if x return true else return false
yeah but imho it's easier to understand
i think its clear enough without comments
if limit is reached but one home gets replaced:
-> its okay
otherwise
-> nah
i really don't like to omit the last thing and replace it with just returning the thing I'd test for
val isOkay = when {
allowUnlimited -> true // Player may set unlimited homes
homeList.homes.size < maxAllowed -> true // Player may set more homes
homeList.homes.size == maxAllowed && homeList.getHome(homeName) != null -> true // Player already set max homes, replacing existing one
else -> false // Buy a rank, ffs
}
Doesn't that work?
Could extract the size statement aswell
Anyone got experience with squaremap api by chance?
Or perhaps anyone could help me with understanding the api basics? (https://github.com/jpenilla/squaremap/wiki/API-Basics)
do you have any specific question? the api basics seem quite straightforward
Java
Kotlin
Kotlin is alright
Declined
reason?
how are uuids generated in offline mode? are they generated based on the username or something like that? or is it just random? is it possible to know what the uuid for a username will be, without actually joining the server?
But actually. Alex?
I was gone for a few months but I still remember you hating on kotlin. What happened?
can some1 teach me java
Yes, it uses UUID.nameUuidFromBytes. Basically that turns a string into an UUID. I think it uses "name:<player_name>" or sth like that
I don't like Kotlin
I started to use it and then I realized how great it is lol
you'll be surprised but I also like gradle now
Yes I've got a project I'm working on, I'm a bit slow right now since I had a head injury last week and am on a lot of meds so the logic is just a bit slowed currently haha. This is the original version although I've made some updates that well... haven't worked so far. The point of this project is so that when a siege started against a town, a flame icon is created on squaremap at the spawn location of the town, on siege end the icon gets removed from squaremap... pretty simple although like I said, I'm having a pretty rough time understanding the api usage
That's what I told you months ago - without the gradle part lol. Glad you listened though
ok I haven't looked at your code, I'll just explain what my general idea would be:
- You create one MapWorld for each loaded world and keep that in a Map<UUID, MapWorld> (where UUID is the world UUID - do not store the world itself). Check WorldLoad and WorldUnloadEvent
- You create a SimpleLayerProvider for each of those worlds and add them to each MapWorld. You can use the same key everytime, e.g. "sieges".
- Whenever a siege starts, get the respective MapWorld and add the marker. You later need the key again to remove it, so you gotta use a key for the marker that you can later recreate, e.g. the center location of the siege in x_y_z format or sth like that
actually you don't even need to store the MapWorld, you can just store your SImpleLayerProvider
There's only one world I'm dealing with, does that simplify at all?
in that case, you can simply keep your SimpleLayerProvider in a field
ok let me have a look
I see you're creating an icon, you will only have to register it once and then you can use it again each time you create a marker
Well I also have split the events to different classes now as well
Would it be bad to use a static method to get the icon?
you will always ever only have one flame icon so that's fine
mmm just tried that in javascript, doesnt seem to generate the same uuid, ill try to do this with a plugin first and try to get it working there https://www.spigotmc.org/threads/how-uuid-is-generated-for-offline-mode-nicknames.347835/
oh yeah one second, let me check the code
it's not "name:..." but sth similar
tho i guess i could look at spigot source? unless its done by minecraft itself
Alright so heres the plan I think... on enable call the icon creation method just to get it registered and available to use when my other events are called. eg: siege start / siege end, get the icon and put it on squaremap at the spawn location of sieged town, when the siege ends simply remove the icon from the map.
public static UUID createOfflinePlayerUUID(String s) {
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + s).getBytes(StandardCharsets.UTF_8));
}
@fluid cypress
that's what spigot uses
s is the plain player name
how so? did you already change it to "OfflinePlayer:..."?
yea
Do you think this is solid mfnalex?
but its generating weird stuff depending on the string length
for example i dont think this is a uuid: 6d6973646f63756d656e6f
yes sounds good
Alright let me see what I can come up with real quick
oh yeah are you using nodejs or otherwise got the "crypto" module?
Alright if I can ping you with the results?
sure
@fluid cypress Here I just threw this together, works fine if you got the crypto thingy
const crypto = require('crypto');
function createOfflinePlayerUUID(name) {
const namespace = 'OfflinePlayer:';
const input = namespace + name;
const hash = crypto.createHash('md5').update(input, 'utf8').digest('hex');
return [
hash.substring(0, 8),
hash.substring(8, 12),
'3' + hash.substring(13, 16),
hash.substring(16, 20),
hash.substring(20, 32)
].join('-');
}
console.log(createOfflinePlayerUUID('mfnalex'));
no, i just looked for a library with which i could generate uuids from bytes, i dont really know how uuids work tbh, or the differences between different versions
this is what i did
const encoder = new TextEncoder()
const array = encoder.encode('OfflinePlayer:misdocumeno')
const uuid = new Uuid().fromBytes([...array])
console.log(`uuid for misdocumeno is: ${uuid.toString()}`)
using OfflinePlayer i get 4f66666c-696e-6550-6c61-7965723a6d6973646f63756d656e6f, using name i get 6e616d65-3a6d-6973-646f-63756d656e6f, which is significantly shorter, and the actual uuid on the spigot sv is f62a41ae-4198-391b-ad68-6dbbc530da23
ill trythat
yea, that works
yeah idk how UUIDs in javascript work, it's easiest to simply md5 the string and use that directly lol
mmm, so uuids are just a md5 hash after all?
well, no
or the version that minecraft uses maybe, bc there are a few versions afaik
a UUID is simply a unique identifier, usually generated randomly - however for offline players, yes it creates it from the md5 string of the input
here's openjdk code for nameUUIDFromBytes
so there is no standar algorithm or something for creating a uuid based on something?
A Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. The term Globally Unique Identifier (GUID) is also used, mostly in Microsoft systems.When generated according to the standard methods, UUIDs are, for practical purposes, unique. Their uniqueness does not depend on a central registration authority ...
type 3 is what minecraft / nameUUIDFromBytes uses
so yes, there is a standard algorithm for that
Hey, is there any possibility to set the title of the player Inventory? so this has a other title when the inventory opens
https://prnt.sc/IH-1mRBR579X
cool then, thanks, i thought it would take longer to implement this
you can't even detect when they open it, it's 100% client side
Mojang should send a packet for that plz
Is it?
I thought it was only client side when in creative
well you can detect when they're clicking in their inventory, but you can't detect whether it's open or not
Isn't there the InventoryOpenEvent? Or is that for chests etc. only?
true. Just tested that. They should really add that to the javadoc though
https://prnt.sc/hG7SZHmdjt6g
@tender shard by chaning the lang file you can remove it but then it will me not there in any other inventory
it used to be possible to detect players opening their own inventories through advancements, but that was removed in 1.14 or so I think
yes with resource packs, you can ofc change it
but you can't change it on the fly or anything
ya i just need any why so 😄
you can resend the packet that sets the title with InventoryView#setTitle
under the hood this sends an open container request to the player with the same ID and will trick the client into using your new title
but for the player's own inventory? which the client doesn't even tell the server about when it's being opened?
ahhh I didn't get that part
the best method there would be to use a scheduler tbh
given you want to do it on the fly
otherwise editing the lang file seems good enough
ya like you dont realy need that title in any way 😄
@tender shard How does this look so far? I've been trying to use the api basics for reference...
I haven't registered the listener classes yet either so don't mention that haha
does LivingEntity#addPotionEffect() forcefully add the effect? like do i need to check if the entity has a preexisting effect to not force it
the method has a force overload but that one is deprecated
I mean I'd assume if an entity already has the effect you're trying to add, you wouldn't need to add it correct?
You could also inverse the check to simplify
i mean i would also like the effect to not apply if the entity happens to have the same effect with stronger amplifier
I think if the time is lower and the level is the same it refreshes the time.
If the level is higher it overrides the lower, ignoring the time left
this is what I think I remember - don't take it for granted.
Yeah if that's true just make an inverse check ie: if !entity.haspotioneffect
So I'm trying to push a player downwards, but if they jump, and run the command right after, they will be pushed upwards. I have no idea how to fix it, could anyone help?
...
if(args[0].equalsIgnoreCase("down")) {
double speed = 2;
pushEntity(player, speed);
return;
}
}
private void pushEntity(Entity entity, double speed) {
Vector currentVelocity = entity.getVelocity();
currentVelocity.setY(-speed);
entity.setVelocity(currentVelocity);
}
the deprecation reason is that entities can have multiple of the same potion effect type, but im pretty sure thats not true?
They can't have multiple but like fabsi said, I think it will just overwrite based on what the effect you're trying to add is
it isn't but I think it's the override change that was introduced at some point
Using the /effect command approves what I said. Higher levels override lower levels (ignoring time) and same levels refresh the time if higher
otherwise you get an error. Spigot probably behaves the same
(without an exception)
https://hastebin.skyra.pw/nasoyedure.java
In case you want the hastebin
Btw if anyone has any experience with squaremap / towny / siegewar api, help would be greatly appreciated. The intended function of this plugin is on siege start event / siege end event, create a flame icon for the spawn location of the besieged town adding it to squaremap, when the siege ends simply remove the flame icon. (https://github.com/jpenilla/squaremap/wiki/API-Basics) I was having a pretty rough time understanding the api usage haha
Is there in any way to clear entity's pathfinder with spigot api? Right now I do LivingEntity#setAI, but this option removes the gravity and colission of the entity too and I don't want that.
As of my last knowledge update in January 2022, the Spigot API itself does not provide a direct method to clear an entity's pathfinder while preserving gravity and collision. The setAI method you mentioned is a general-purpose method to enable or disable the entire artificial intelligence (AI) of an entity, and it may affect various behaviors including movement, gravity, and collision.
However, you might consider using more specific methods or workarounds to achieve your goal. Here are a couple of suggestions:
Custom Pathfinder Goals: Instead of disabling the entire AI, you could look into creating custom pathfinder goals using the Pathfinder API. This way, you have more control over the specific behaviors of the entity. You can add and remove goals as needed.
EntityCreature entityCreature = ((CraftCreature) livingEntity).getHandle();
entityCreature.goalSelector.clear(); // Clear existing goals
entityCreature.targetSelector.clear(); // Clear existing targets
// Add your custom pathfinder goals
entityCreature.goalSelector.a(1, new PathfinderGoalYourCustomGoal(entityCreature));
Note: This involves using NMS (net.minecraft.server) classes, and it's generally not recommended as it may lead to compatibility issues between different Minecraft versions.
Packet Modification: You might explore packet modification to achieve more granular control over entity behavior. This approach involves manipulating packets to modify specific aspects of the entity's behavior. It's important to note that this approach is more advanced and might not be suitable for all scenarios.
Keep in mind that the Spigot API is regularly updated, and there might be new features or changes after my last update. Always refer to the latest Spigot API documentation or community resources for the most up-to-date information. Additionally, be cautious when using NMS-related code, as it can lead to compatibility issues and is not officially supported.
Hopefully chatgpt helps 😄
Yeah he asked for a spigot-api way though.
Oh is there methods for that then?
In that case, I'm sorry I provided false information...
Thanks for the help, if there isn't any way to do that with spigot-api, then I should use nms yes.
No. But that means the answer would "No" instead of "use NMS" xD
ah... well I was just trying to help out... I've never messed with entity ai before haha
It's fun, you should try it some time. Can add parrot AI to pigs that attack you
Ooo actually that gives me an idea
They'll fly after you and even dodge fire just to murder you
Have you ever played assassins creed black flag?
Yes it was the last assassins creed I played actually
Oh yeah amazing, yk the whale/shark hunting mechanics? I think it would be awesome to try and implement something of that sort for minecraft
sir this is development help
what
I think I do but it's been a looong time. My pirate gang singing drunken sailor all the time is a lot more present
Well f(0) should be -2 unless I did some doofus, so it probably intercepts y = -2
Fair point, but still as I'm helping out a geopol server right now, that would be something absolutely amazing for this kind of server
What x-intercepts are I have little idea. Probably the result of me only having done german maths
It definitly sounds cool! Pathfinders do require a lot of try and error though. But you'll be fine!
Yeah I'll certainly have to look up some examples of those, it sounds like something that could be very rewarding '
Hm, so y-intercepts are "Y-Achsenabschnitt" (so f(x) = y with x = 0) and x-intecepts are "Nullstellen" (so f(x) = 0)
I guess y-intercepts are all points where fx is 0, yes
I am using Mojang's API to get a player's UUID by name. However, since this request is limited by 200 for every 10 minutes, I get a 429 error from time to time. Is there a way to get a player's UUID by name in an alternative way? I need to get it also if the player hasn't joined the server before
I mean as far as I know no function can have more than a single point for any given x
mfnalex I made some progress I think
okay why on earth are you using AWT in a plugin?
awt is fun
Doesn't that blow up on mac?
You can always directly query the mojang API. However they probably rate limit by IP so you might need more servers
Edit: https://api.mojang.com/users/profiles/minecraft/_jeb
xx+yy=rr :p
Shit on mac servers lol
But, anyways, good question
What is the difference between kotlin's Comparator interface and java's? more importantly why would I ever use kotlin's when it'd cause issues when using java's stdlib
Oh lord, even hardcoding the font name - so that will even blow up on many linux distros unless AWT uses a good replacement
Now that's bad
idk lol
a function from a set X to a set Y assigns to each element of X exactly one element of Y.
Yep, no more than one value for every X
the contract of a function is math is that every input has a distinct output
Why would it?
I don't think that is actually the case
yes it is
wait no
wrong thing
I'm trying to think what the mod was
Idk, I've just been told in the past that mac doesn't like AWT
Though I cannot remember the context, so perhaps there was some loss of context here
help
its because it was f^-1(x) = x^2 not f(x) = x^2
how much is it
google seems to confirm that
6.25 or something? I donno, I cannot do maths (ignore that I am majoring in maths)
it is 6.25
I need it step by step i don't understand
I instinctively wanted to do 4.25 until I was like "hold on, that is wrong" - so 5.25 it was until I was like "hold on, that is too close too to 2 * 2.5"
learn to use a calculator
Hey ImlIIusion have you any experience with siegewar / towny / squaremap api?
dude are you in 3rd grade
uH
I did some squaremap stuff
omg
1st
and reported
Would you be willing to help me?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
i dont think so they can't even help me with the equation
don't expect any help from them

Kinda what I am doing, the point is that on siege start, an icon gets created at the spawnpoint of the besieged town, on siege end, remove that icon... pretty simple but I'm kinda slow and am having a hard time with the api usage.
they aren't tolerate
hey since you are in first grade how old is that?
man needs help doing (1/2 + 2) ^ 2
@echo basalt this is what I have currently
no I need help with (1/2 + 2) ^ 2
actually its only squared 
same shit
That is certainly of much more difficulty
yes 😭
how much is 1/2
@echo basalt I wish we had this guy instead of CMarco tbh
0.5
how much is 1/2 + 2
7
Funny story: My classmates (Q3 - so the semester before the "abitur") which are majoring in maths don't know how to multiply a three digit number with a two digit number without a calculator. After the teacher taught them "schriftliches multiplizieren" (multiply in written form - according to google) they were "this is the hardest thing we have ever done".
I think at this point I should really not be surprised that I am the top of my class by a large margin.
good job alex you get a cookie
I need to be awake in 4.5 hours but instead I'm indulging a circus performance
I slept lik an hour
Let me know if I am just completely off or something like that, I'm just trying to create the icon on enable, then use that static access for the event classes in order to handle marker additions to squaremap
im doing good
q3 is before abitur? o0 where are you from lol
Well there is still Q4, but that is the abitur more or less
for me q1 was 11 grade, q2 was 12th grade, and then i had my abitur
but yeah if they can't multiply on paper theyre a bit stupid lol
What?
We have "G9" here, so E-phase was 11th, Q1/2 12th and Q3/4 is 13th
does it run?
I love how no one here has considered they are a troll
german guys can y'all fuck off to #general
@tender shard are you talking about quarter years or grades?
Well, they were completely blown away once they were taught division on paper
ah ok so you split up the Q thingies into halbjahre basically
Yep
Ahh yes same here in Bavaria
For us it is called Q11, Q12, Q13
I went to school for 12 years. Oberstufe began in 10th grade, when I was 16.
10th grade = EF = Einführungsphase
11th grade = Q1 = Qualifikationsphase 1
and Q2 and then done
Eh have not had a chance to test this updated version yet, the guy I'm making it for is like 8 hrs behind me haha
Well
I don't see you use the flame emoji anywhere
I'd honestly just make a .png file and stick it in the resources folder
and load it
ImageIO.load(file) or whatever
We had 12 years in G8, I am the first generation which has G9 again
Playing with AWT can cause problems in headless environments
Ok that sounds like a fair point
As far as my implementation of the squaremap api goes, am I doing it correctly?
uH
api.getWorldIfEnabled(mapWorld.identifier()).ifPresent(worldMap - >api = (Squaremap) worldMap);
wtf is this
The addon I wrote does it a bit different
To register your LayerProvider to a MapWorld:
api.getWorldIfEnabled(world).ifPresent(mapWorld -> {
Key key = Key.of("my_unique_layer_key");
SimpleLayerProvider provider = SimpleLayerProvider.builder("My Layer")
.showControls(true)
.build();
mapWorld.layerRegistry().register(key, provider);
});
I think its this
Yeah that looks right
an example of why Java Optionals are 
I had to change it slightly for the ide to be happy but still
Well you can see in my project, I'm trying to create a static usage for my flame icon lol
wel lyeah but you don't use the icon anywhere
You just assign it to a field with no getter
I know, currently I wasn't sure how to add the marker to squaremap
@EventHandler
public void onSiegeStart(SiegeWarStartEvent event) {
Siege siege = event.getSiege();
Town siegedTown = siege.getTown();
if (siegedTown != null) {
Key key = Key.of("my_unique_marker_key");
Location spawnPoint = siegedTown.getSpawnOrNull();
if (spawnPoint != null) {
Point point = convertLocationToPoint(spawnPoint);
Icon marker = Marker.icon(point, key, 3);
epirateSiegewarAddon.provider().addMarker(key, marker);
}
}
}
Thats one of the events where I should be getting the icon for use
Oh haha
Basically you want to init the layer provider once and pass it around with DI
How do you guys like to handle databases? Load data on start? Load playerdata in cache when player joins? Real-time?
Add the marker to your layer provider
load data on start = why is there a database in the first place, really bad scaling
Load data on join = good under certain cases but can cause desync
That was the goal with the initialization being in main class, I didn't realize I was doing that haha
real-time = highly complex and latency prone
Okay, so what would you do? Depending on the data
I usually just load it all on player join
like whatever i need
For example this tycoon minigame's a bit more complex
When a player joins I fetch their island id from the database
I then fetch the server that has it on redis
If that server exists, and is not the current server, I don't load the rest of the island
Do I load playerdata on join and if the data isn't there yet let the player wait and freeze them?
You can load it on the async login thread, put it in a 20 second cache
And when the join event fires you take it from the cache and put it in your map
That means the player's the one waiting longer
but it's fool proof
Well but what if some stuff needs longer in general?
Hard preparations?
Strong server lag?
Basically you load the data you need ASAP on login and the data you need later on join?
"Logging in" phase takes longer for the client
The login event is still called async
Hmm ok
Like there are multiple valid solutions, each one with its own compromise
And if the server needs to do some heavy task at boot that is multithreaded tho, may I freeze the whole server or start it and like deny any connections or ticks until it's done
uH that depends
But joining threads on enable is something that certain people see as acceptable
For example "I gotta render this special map and gotta pull 1GB from my db/IO"
I need context
So I know how I can handle different tasks when writing big plugins or systems
Always try to attach your data's lifecycle to some other lifecycle
We can start with that
Hmm ok
So player data is only kept in memory for as long as the player is connected
Thanks for the answers btw.
If you need a minigame world from a template
You fetch the template and create the world when it's needed
If that's too much IO or the latency is too high you can consider caching the template
When the minigame is over, its world is too
Ahh yes, another problem, save data real-time, sync memory with db scheduledly or on playerquit?
on a timer + when the lifecycle ends
Is ideal
Real time depends
Basically real time = more IO & CPU but better resilliency
So like, I change my data in memory and schedule a task syncing the data to the db every now and then?
Sumn like that
I can do that async then
Yeah sure
Or if you don't plan on doing things often
Like uh
Think of luckperms permissions or user data
Well, maybe if it is an important query schedule to save instantly on next tick
That doesn't need a timer because it's low volume
No one cares about server ticks in an async context
But yeah important data is better real time
High volume is better in batches
Make sure to always save when the player quits though
Yeah
And make sure the data is saved before trying to read it
Alright
hi
Well imma read it from mem anyways
In concurrent environments, like in super sharded instances it's nice to keep things synchronized
Even if it means sending an update request to the server that's "owning" that data to tell what data to modify
You either do that or keep all the data in a central cache like redis
But that comes with higher latency
Yeah ofc, stuff needs to get handled differently with a sharded setup or multi-server
yuh
I'd use redis pub/sub for that, sounds good to me
Guys, is there any other method for placing a block (which works when there's no block, as this doesn't work)?
replaceAirBlockPosBug.getBlock().setType(Material.RED_WOOL)
how does anti-ddos/anti-bot works
Do you want to know how it works in the background or how to use it?
I mean you just have to fill the parameters opf the function.
- Class<? extends Event> event, can be any event you'd usually use in a listener
- Listener listener is a class extending listener
- Priority is some priority
- Event executor is a class implementing EventExecutor
- Plugin is your plugin instance
Marco being wholesome right here. Never seen anyone ask that for code that is public in some discord chat.
Yeah I also had to do some weird stuff on my implementation
Yes. Spigot has a contributors section
If you want individual control and the ability to unregister lambdas individually there's this impl -> #1196562355912446094 message
org.bukkit.Bukkit.broadcastMessage(String)
or
org.bukkit.Server.broadcastMessage(String)
?
Same thing
want to know a fun secret
First one is static and calls the second
i swear if you link me docs... xD
public static void broadcastMessage(String message) {
server.broadcastMessage(message);
}
the first one does this ^
Actually everything in org.bukkit.Bukkit is static and calls the server version
oh
PlayerBucketEvent can’t be listened to
not sure if i was supposed my message in here or help-server but if anyone could look at it and help that would b great
It's an Event with subclasses, you can listen to the subclasses
It’s a parent event for the empty and fill event
I ran into this, too
Any that don’t have handler lists
You can however treat them both as a BucketEvents obviously. Therefore you could register BucketEmpty and BucketFill Event and then delegate them to the same handler for BucketEvent if you like to
Hello I am very confused, line 47 only runs 1 time before a stack overflow error happens. To me this makes no sense. Any ideas?
Code: https://paste.md-5.net/akebuxusay.java
Exception: https://paste.md-5.net/apacovufig.cs
how can i turn a vector into an eulerangle?
Are you opening an inventory in the inventory open event
thats what would make sense to me but no, i dont even listen for that event
I only listen for InventoryClick and InventoryClose
I do open an inventory in the inventory close event if that somehow matters
You are meant to delay it a tick iirc
^^
However opening an inventory in the close event is kinda wacky regardless
That fixed it thanks
Its opening a different inventory to continue the setup process of something
I normally just use buttons for that
Rather than waiting for the user to close the inventory
Im doing both
my mc server im using killrewards and if i kill someone in the lobby they get the rewards but not in the actual minigames, do any of you guys know a fix for this
something seems to not be right, i thought the uuid was correct, but actually its not. my uuid in the server is f62a41ae-4198-391b-ad68-6dbbc530da23, but that function returns f62a41ae-4198-391b-6d68-6dbbc530da23, which is the same, except the first character of the fourth piece, the ad68 part, the js function returns 6d68 instead.
ive been trying a few names, and they seem to be correct, except a few, another one i found that has a different character is duketo, ingame is 9c077d67-1ddc-3fcc-b295-d148b4d6cb4f, but the function returns 9c077d67-1ddc-3fcc-3295-d148b4d6cb4f. again the difference is in the first char of the fourth piece.
i guess it has something to do with the variant? whatever that is https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/UUID.java#L174
this channel is for people getting help coding the other one is for getting help using plugins or just general server help
yea, i just changed it a bit, in case you wanna know, now it works fine
export function getPlayerUUID(username: string) {
const buffer = crypto.createHash('md5').update(`OfflinePlayer:${username}`).digest()
buffer[6] = (buffer[6]! & 0x0f) | 0x30
buffer[8] = (buffer[8]! & 0x3f) | 0x80
const hash = buffer.toString('hex')
return [hash.slice(0, 8), hash.slice(8, 12), hash.slice(12, 16), hash.slice(16, 20), hash.slice(20, 32)].join('-')
}
is there a way to get the size that's currently stored inside a SAVE structure block
or to get the structure name that's typed into it
https://hastebin.skyra.pw/saduvenesi.java
If anyone would like to look through this player bounty plugin and give me suggestions or address some concerns perhaps? I know there's no gui listener, currently working on that class, other than that any notes or suggestions would be awesome.
That's intimidating D:
I'm going to get shunned by you guys I swear!
Anybody experienced with PAPI can answer this?
I just updated my papi extension (had to remake it cause i lost project files) but I basically just updated the onRequest function and thats it. Supposedly the end user is testing and only the old placeholder is working and the new one just displays the %% text he typed for the placeholder. Is there anything else needed for the new placeholder other than the onrequest function or is the user just not updating correctly?
i wish i could help idk what it is probably a maven or gradle thing
Yea its a gradel thing
I dont understand gradle but every one uses it so im obviously just out of the loop
How do you mean?
I get a lot of peeps telling me maven is better, but I look at maven and im just like: 😀
Good evening, after a lot of research, I can't find how to achieve what I want and I wonder if you know the answer:
How can we remove knockback from a player when they are attacked like with the iron goleme?
i also dont understand maven
Intercept the EnityAttackEntity event
but ive never researched either so it makes sense
I've never uploaded anything to git in my life haha
This is gradle tho
Yea he's just saying he doesnt understand maven since I was explaining why i use gradle
yall are confusing me i just add the spigot jar in the libraries
Honestly
Idk why people use gradle. Gradle only seems useful for like 1% of all devs here
Just unneccessarily slow and complicated

Hi lynx
I do not know gradle very well, did you run BuildTools with the right version and --remapped flag?
Yea but for some reason it still shows the old mappings but also says they dont exist when I use them
I defined the method, but what should I do now?
Restart IDE, reload project and deps
rq question, anyone knowledgeable about Persistent Data Containers?
Cancel it and deal the damage manually with the player as the dealer. That way no knockback will be done
Ill try
I guess just ask
?ask :3
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
wanted to ask, even tho Vault exists, is it "ok" to try and do economy with PDCs?
I mean do you know what vault is? You could make an economy implementation using PDC with Vault
im asking this cuz im kind off a starter in plugin development and I was just thinking about it
Vault is simply a standardized API most economy plugins implement
its one of the rare cases in spigot's monolithic amount of plugins that do the same we have agreed to atleast just use this one API
It didnt work but then I Assembled it again and it worked. Really confused tbh. Did that like 8 times already
Yeah I know about that, but since I've never worked with extra APIs as Vault, I'm kinda scared to get into it and be very confused abt it idk if it makes sense, srry
but ty
Anyone? 😄
I did haha
I'm just impatient
Are you in the thread?
Should post it there as to not let your response get cluttered by other messages here
don't trust cmarco he's ai generated
I thought the proper way to remove a item from a list during a loop was with an iterator? Still get the same error though
https://paste.md-5.net/bobaroyini.cs
You are not getting a ConcurrentModificationException but a UnsupportedOperationException.
This indicates that the list you are trying to modify is immutable.
didnt even notice the difference
thanks
Fun fact: List.of, Arrays.asList and List.copyOf are your most common sources of immutable lists
immutable lists are not ok
i hate them
They are ok
Any exposed collections should be mutable
.
It prevents all kinds of funky issues
For example
But what’s the overhead of Collections.unmodifiableX!!!111
public class MyManager {
private final Map<UUID, MyData> registry = new HashMap<>();
public MyData getData(UUID id) {
Preconditions.checkNotNull(id);
return registry.get(id);
}
public void insertData(UUID id, MyData data) {
Preconditions.checkNotNull(id);
Preconditions.checkNotNull(data);
data.setDirty(true); // Some random method
registry.put(id, data);
}
public Map<UUID, MyData> getRegistry() {
return this.registry;
}
}
Here's a non-compliant class
The problem arises if I do something like
myManager.getRegistry().put(myId, myData);
It modifies the registry collection while bypassing the insertData method entirely
Which not only hides code flow, it also bypasses all kinds of side effects the method might have
Which in this case is the setDirty(true) call
Basically you're allowing for 2 slightly different ways of doing the same thing
Except one's fully accounted for and the other one is not
How do we fix this? When exposing our collection (if absolutely necessary, it's not always needed to do so), we return a read-only copy
public Map<UUID, MyData> getRegistry() {
return Map.copyOf(this.registry);
}
This way if someone tries to do this operation, an exception is thrown
in that case don't use java 
That’s doesn’t answer the question :(
What sort of mechanics would be fun for a mobcoins plugin? Currently I just have implemented a shop of sorts that will rotate the items every 12 hours (intention for a survival server so I'd want to implement config for the set of items that will be rotated through the shop (also the %chance for items to show up in shop should be configurable as well) and finally how often the shop will rotate)
asList isn't immutable?
it isn't resizeable but it's still mutable
just like an array, it just wraps it in a List
AsyncPreLogin me thinks
If anyone would do this id appreciate it
#1100941063058894868 message
Is it bad practice to do this? I thinks easier to read and looks better this way
private final Map<Inventory, InventoryHandler> activeInventories;
public InventoryManager() {
activeInventories = new HashMap<>();
}```
instead of
private final Map<Inventory, InventoryHandler> activeInventories = new HashMap<>();
not really you don't lose out on anything
Definetly not bad practice
I'm sure someone here has some super ultra bytecode reason that its actually 2 nanoseconds slower
I find the former to be more clean. This is exactly the purpose of the constructor.
but like who the fuck cares
💀
some user is gonna complain abt that prob
it doesn't really matter use the constructor as god intended it 
more importantly
do what makes you happy!
Its actually quite important because field are initialized before explicit constructor if you just init them on their declaration.
This can lead to dependency issues.
It will just create a default constructor and lets explicit ones call it first
Someome mind showing me how to upload a project to git with intellij?
my calculations seem to conclude that initializing your map in the constructor like this slows down your compilation time by 0.5 nanoseconds
Press shift twice. Search for "share project on ..."
In this blog, we're going to look at how to share code that we've written on our local machine to a repository on GitHub. https://youtu.be/4ukhZvOmAtk This blog post covers the same material as the vi
Literally unusable then
Yeah uhh the first one actually compiles to one extra flarp instruction
Which is 26 CPU cycles
It depends
Thank you smile, @fervent robin
hmm @jagged quail
Hi guys
If the map isnt needed right away or it isnt going to persist it may be wise. However if it will persist it is generally better to initialize the the variables you need as early as you can
Is remaking any hypixel gamemode an advanced project?
like skywars but with the kits upgrades etc
I mean yeah
Minigames are generally not beginner projects.
I'm trying to remake a gamemode right now and I'm seriously wondering how some bugs even exist
Minigames are annoying
How would the few nanoseconds change anything? It will be accessible either way when you instantiate the class
https://github.com/NukeCaps/EpirateTownyAddon/tree/master/src/main/java/nuclearkat/epiratetownyaddon
Could I perhaps get some feedback on this? The point of this plugin is to add a configurable cooldown time / messages to townJoin/townLeave events to prevent quick town hopping of sorts.
He is talking about serialization i suppose.
In which case i would strongly argue for the constructor actually. Especially when using Gson.
I see
afaik if you only have one ctor it'll init it between the super call and the rest of your ctor
loadCooldownsFromFile should not take a HashMap but return one instead.
Its not about speed all the time. So if you initialize a variable ahead of time it fits better in memory, the compiler can do some tricks since it already knows what the value is and not doing some kind of guessing. There is many other things then just speed. Also reduces redundant code
which makes sense if you only have one
All your fields should be private. If they dont change, then they should be final as well.
Public fields are simply not acceptable unless they are constants.
Gotcha
another thing is using packages to separate your classes
You are using DI which is nice. Some of the access modifiers of your methods could use some refinement (most of them can be made private).
The cooldowns map should reside in a manager class. "CooldownManager" or something similar.
The general logic and application are ok.
I see
Public fields belong in the craftbukkit
But i can see potential with where you are going. Splitting the logic into several methods with meaningful names is not something
you see from new devs.
lol
If I'm making a big project, should a manager class just take in the main class in the constructor
Using dependency injection or the singleton pattern is a choice you can freely make.
Both are viable.
they aren't mutually exclusive either :D
I was just thinking about either sending a class that holds all the instances or all the instances needed
Like passing in the class MyPlugin
In comparison to passing in MyManagerOne, MyManagerTwo
I'd say inexperienced. I have been learning java for 4 years now although it's been on and off, and I have been learning it through minecraft framework. I'd say I have perhaps a year of experience with spigot api and have been completely self taught through all of it. I've put probably 10 hours into the stephan udemy course haha
Idk how his course teaches but I find it a lot easier to learn through projects
I suppose it's sorta the same thing, I just have been doing it for a while so
just think of something a project you think might be challenging and then try to do it
Well I sorta just load up his lectures for examples to be fair
It's nice to see how a function can be written cuz then you can play with different implementations
yeah im not saying its bad im just saying I would def try your own projects too
Oh well the one I posted is mine, it's something I'm trying to get working for this towny / geopol server
And every other project I'll probably be posting soon has been all things I've wanted to do for quite some time but just never got around to perfecting
Yeah find something challenging but also enjoyable for you.
How I snatch a specific structure from this. Preferably one that a player is standing in. I cant find out how to grab a specific structure from a map
Are you trying to identify what structure the player is standing in?
Pretty much. Then I need to grab the start pos
hence the map
but the map has every structure in the chunk
So it might get the start of the mineshaft underneath and so on
I believe there is a method to get the starts for a specific structure
How would I get that specific structure?
Like I can check if one is there with paper but I cant get a refrence to it
After that, get the individual pieces and grab the first one, which should be the origin
Uhh I think the structures exist as constants in some class
Might be in Structure
Well, the vanilla ones
If you want a custom one you’ll need to get it from the registry
I think he’s asking how he can detect what structure if any he’s in, which he can then use to look at the registries
Loop over the map and check if the structures bounding box contains the players location
I have this to detect what structure hes in but I dont know how to get a refrence to it :P
Yeah you gotta grab all the ones of that type in the chunk and then check via looping
https://github.com/NukeCaps/SilentSkyCore/tree/master
So this is something I have been working on for probably 2 months now? A couple issues: minion functions don't work also in the process of reworking them from zombie spawn egg to a neat looking armor stand, minions just kinda bugged haha. More issues just kinda relate to it being more so half written. Anyone have any suggestions or notes?
Actually wait, it’s a map so you can just do map.get with your structure to get the start
No need to loop
Yea... Problem is I still got no clue how to grab the structure lol
Cant really find a block method, world method or really any method at all
I also cant find out how to remap after build since all the things ive seen use maven and I use gradle.
You grab the structure like this ^
Ah wait that’s Bukkit registry
Well similar idea you just need the NMS registry
Yea I'm using this. I'm thinking of caching player profiles myself in a database table and have the custom dedicated API that the plugin is running on automatically query for updated names within the request limit
What in tarnations is a TagKey
It’s for tags
How in the world does one use this magical thing
Structure struct = (Structure) world.getMinecraftWorld().findNearestMapStructure(TagKey<Registry.STRUCTURE.get(NamespacedKey.fromString("revamp:desert_pyramid"))>, new BlockPos(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), 100, false);
It needs a tag key?
Pretty sure it can just take a structure
Iirc it’s world.getServer().registryAccess().getRegistryOrThrow(Registries.STRUCTURE).get
Or something along those lines
I havent found one :c
Ah it’s in the structure manager of the world
Now of course I cant figure out how to reobfuscate the mojang mappings :L
There are some unofficial grade plugins to replace special source
There is also paperweight userdev
I gotta say, paper is carrying fr
Doesnt that automatically add weird unrelated dependencies?
like what?
paper
it is paper's software for developing against their software so
yeah it's pretty annoying if you want to use spigot api
Is there a way to detect when a player's saturation has changed? Or at least get a player's saturation value after eating?
declaration: package: org.bukkit.event.player, class: PlayerItemConsumeEvent
do textdisplays have any property that make it display like a name tag? in that it rotates to be visible to the players looking at it
BillBoard.CENTER
oh wait, name tags only rotate sideways, not up and down right?
in that case you need BIllBoard.HORIZONTAL or VERTICAL
yep
The billboard setting controls the automatic rotation of the entity to face the player.
i should learn how to read
still asking for a ?learnread command cought @ivory sleet @young knoll
agree
I've been having this discussion with my own community for a while, what is the point in writing something for people who do not read
they still won't read it
then make it a gif
lmao yeah
had a guy insist i explain my shit to him even though there was documentation on exactly what he was asking
smh
how do i deal with inventory update guys
what
I cant properly set meta of an item on inventory
public void eventProcess(Inventory i, ItemStack is, Game g, Player p, InventoryClickEvent e){
p.sendMessage("1");
ItemMeta meta = is.getItemMeta();
System.out.println("A: " + meta.getDisplayName());
System.out.println("B: " + g.getName());
if(is.getItemMeta().getDisplayName().equals(g.getName())) {
p.sendMessage("2");
if(g.getIsEnabled() == 1 || g.getIsEnabled() == 2) {
p.sendMessage("3");
if(!(CaptureTheWool.isPlayerInLobby.get(p))) {
p.sendMessage("4");
addPlayerToGame(p, g);
CaptureTheWool.isPlayerInLobby.put(p, true);
e.setCurrentItem(g.getIs());
p.teleport(new Location(Bukkit.getWorld("world"), 0,78,0));
}else {
p.sendMessage("Şu anda farklı bir lobidesiniz...");
}
}else{
p.sendMessage("Sunucu şuan aktif değil veya dolu..");
}
}
}```
now we're getting somewhere
Please, name your variables descriptively
i, is, g, p and e are terrible
okay i keep that in my mind thanks.
public void quitFromTheGame(Player p, InventoryClickEvent e) {
p = (Player) e.getWhoClicked();
for(Game g: CaptureTheWool.getGames()){
if(g.getPlayers().contains(p)) {
g.getPlayers().remove(p);
ItemMeta meta = g.getIs().getItemMeta();
meta.setDisplayName("Game " + g.getRoomCode() + " || " + g.getPlayers().size() + "/32");
g.getIs().setItemMeta(meta);
g.setName("Game " + g.getRoomCode() + " || " + g.getPlayers().size() + "/32");
e.setCurrentItem(g.getIs());
System.out.println(g.getName());
System.out.println(meta.getDisplayName());
}
}
}```
So at here i call this method on inventory clicking event
and method adds player to room
Use early return as well
if (!is.getItemMeta().getDisplayName().equals(g.getName())) return;
to avoid nesting, it improves code readability
and if player quits i have to remove him from the game's players so i call this method
And what exactly happens that you do not want to happen ?
item itemstack you get from "g.getIs()" (what is "Is") is not updated ?
yes
System.out.println("A: " + meta.getDisplayName());
System.out.println("B: " + g.getName());
this lines
[12:16:26 INFO]: A: Game 1 || 1/32
[12:16:26 INFO]: B: Game 1 || 0/32```
they are returning like this
System.out.println("A: " + meta.getDisplayName());```
this returns 1/32
please, one simple sentence what you are trying to do, what have you tried and at what point you are + what actually happens
I want to create a lobby controller, I have an inventory and I want to perform some actions in InventoryClickEvent when items with meta are clicked in the inventory.
Say I have a custom ban system. Is it good practice to save the bans to a map and saving that map to a file every x minutes instead of reading reading a file every time someone joins? Ig it def makes sense for performance but not really for security since problems with the server could lead to players accidentally being unbanned if the server crashes or sum?
good practice would be to store it in a database
yeah, eventually
you can save bans directly to the database and still keep it cached
is sqlite recommended for this? i want to make this plugin as accessible as possible (also for beginners) and i feel like having to set up an sql server is kinda counter-productive
but for that you have the async prelogin event
When player leaves the game i want the items meta on inventory to be changed the situation where player is not in the game(0/32 eg).
uhm-
where you can just query the database if the player is banned
sqlite is still a file-based thing but tbh that's what I use
so you wont need to hold it in a cache
though sqlite won't work for networked things
arent all databases files in the end?
uhmm
maybe i'll just stick with config.get() lmao
sorry I have already expended this lifetime's discussion on that topic, go ask chatgpt
and still one of the nicer ones
what more do you want
you've been answered
and no, not every database is file based
saying that I don't want to get into the nitty gritty of how databases work and that it's something you can ask chatgpt about is the rudest help you've gotten here?
did you get here yesterday?
well, you could've replied to a message from me lol, i did not realize this was an reply to my question if all databases were file-based
anyway
well let me establish a new rudeness record for you here, I think you're a moron for jumping the gun in the way you did and I think it points to a shocking degree of emotional instability if you thought that was rude, now you for sure have a benchmark to work with
what the fuck are you saying?
if you don't understand what I said copy paste it into chatgpt and have it explain it to you
jeez, how can someone be such a piece of crap? It was a misunderstanding, and I implicitely stated that. So what r you calling me names for?
maybe you shouldn't have called me rude to start with when I was helping you out
as i said- that was a misunderstanding, lol
very self-reflective
you still never said sorry for the finger pointing lmao