#help-development
1 messages · Page 265 of 1
ahh okay
i was using it since i started
but thats not the thing, im struggling with these null message in the title
i bet if you use ChatColor the issues will be gone
you just do ChatColor.translateBlablabla('&', text) and instead of using that weird character you just use & for color codes
probably want to make an utility method for that lol
ughhh
``player.sendMessage(translate("&aHello there"))`
i have german keyboard, almost every german coder uses § too, but i will try
thanks
i guess & is on a german keyboard too
is anyone here familiar with protocollib?
yes of course, but you cant use & for a color code in a string if you dont translate
i am just using a lang system where messages come from a lang.yml file and get automatically translated
to more predefined messages
okay i understand
but i am not supposed to upload that plugin so i wont need a lang.yml file, its just for me
that plugin was just for me too, just makes it a little easier changing messages without having to reload the server
i get your point
but once ive all done, i wont have to change anything yk
but back to topic, ive never had any problems with using §, so i bet it wouldnt change anything if i would translate
maybe something with my enum class?
idk
debug that field
You didnt assign color
this.color = color; inside the constructor of the enum is needed
Additionally, this is why final sometimes helps having, since it’d have yielded a compile time error
yeah i get it
@AllArgsConstructor \🤔

i believe at some point i might use lombok
Im leaving the scene before it goes too far… 
how can I cancel a player changed world event
what are you trying to accomplish? Preventing a player from entering another Multiverse World or from going to the end/nether?
Cancel changing world, without a portal (plugin executed world switch)
I guess just don't give them the option to switch with your plugin if you don't want them to.
It's handled in another way, basically it's two parts that can't communicate between eachother, and then there's another part that can cancel the switch event, it's a bit complicated to explain lmao
You can try EntityAddToWorldEvent
check if it is a player.
That's a paper event
PlayerChangedWorldEvent?
oh wait that doesn't implement cancellable
you can try cancel PlayerTeleportEvent
yeah changing to that
I wish
if (event.getCause() != PlayerTeleportEvent.TeleportCause.PLUGIN) return;
var from = event.getFrom();
var to = event.getTo();
if(to == null) return;
var fromWorld = from.getWorld();
var toWorld = to.getWorld();
if (fromWorld == null || toWorld == null) return;
if (fromWorld.getUID().equals(toWorld.getUID())) return;
```lmao
why tf
if(event.getFrom().getWorld() == event.getTo().getWorld()) return;
im wondering how to can be null too, i saw it in the javadoc
player#teleport(null)
what does that do?
throw an exception
lmao
Var 
let better
Ideas for designing a command framework?
wdym
Yeah i need ideas for doing it, because i some kind of command framework which allow me to make something like simple command, argument, sub command, childs, etc command based
Also if allow to do luckperms similar structure would be great
anyway to make arrow damage more the who the person is shooting to? i tried using projectile launch event.
like if they shoot themselves?
check for entity damage event
if damager is a projectile and the owner is equal to the damagee then apply more
no like if a specfice player shoots another player i want that specific player to deal more damage using the arrow
ive already setup the specific palyer part by using a hashmap
oh yeah just do the same thing
so is there like a method called get damager in entity damage evnt
declaration: package: org.bukkit.event.entity, class: EntityDamageByEntityEvent
oh i was uysing the wrong event
I built one, but its really really simplier hahaa
How would you recommend cancelling putting items on second hand, but knowing that the plugin can be put on 1.19 or older versions?
Should I just ditch custom entities and publish the NMS tutorial now 🤔
but then half of nms ain't there
I only spoke about packets 💀
300 lines of packets grr
Is there way how to give priority for listners, in some casses there is to listeners running, but I need only one 😄
Eventhandler annotation has a priority thing
declaration: package: org.bukkit.event, annotation type: EventHandler
also you can make a fast search and you will find more than what you expect
I think that websites are free to read
keep in mind the higher the priority, the later it fires
yup
Going to search something.
Am writing a tutorial, wanna help?
thanks, that important detail
i would but dont have time atm sorry
gotta release it by xmas
Is possible make something like this: https://www.spigotmc.org/resources/toast-announcements.106479/
But will read text to annouce from command ex.?
Or just send notification to advancmed area if somehting happend.
My booty ich
How do i get all players that are not vanished
List through all players online, then check each player if they are isVanished then if they aren't. Add them to another list.
I could absolutely be wrong, but I seem to remember most vanish plugins setting a metadata called "vanished"
in an old project (I dont use or maintain it anymore, so it could be outdated), I used Player.hasMetadata("vanished") to check if a player is vanished
then just iterate through online players, and if they're not, add them to your notVanished players list
?paste
like this
List<Player> onlineplayers = Bukkit.getOnlinePlayers().stream().filter(player -> !player.isInvisible()).collect(Collectors.toList());
Sure but Player#isInvisible() isn't a method
Are you handling the vanishing? If so, throw in your own method. If you want to check the vanished state of another plugin, most vanish plugins make use of metadata so you can check that instead.
https://github.com/mbax/VanishNoPacket/blob/master/src/main/java/org/kitteh/vanish/VanishPlugin.java#L290
it is
and essx would use this
Oh it is, lol. Though it doesn't apply to players. They just inherit it from entities
It does. They inherit isInvisible() from Entity, but Players don't respect that NBT tag
Vanish status is determined by plugins
You can check this. I believe EssentialsX uses the same vanish metadata
LivingEntity
public static boolean isVanished(Player player) {
for (MetadataValue value : player.getMetadata("vanished")) {
if (value.getAsBoolean()) {
return true;
}
}
return false;
}```
Or something like that. I can't remember exactly what it is
so use List<Player> onlineplayers = Bukkit.getOnlinePlayers().stream().filter(player -> !player.getMetadata("vanished").get(0).asBoolean()).collect(Collectors.toList());
if i do smth like this
its a different runnable for each player, right?
runnableList is a HashMap
am I the only one who thinks streams ugly
they are
no
you're just putting the same instance returned by Bukkit.getScheduler every time
so what i should do
your suppose to do them like this
Bukkit.getOnlinePlayers()
.stream()
.filter(
player -> !player.getMetadata("vanished").get(0).asBoolean())
.collect(Collectors.toList());
still ugly
ik waste of lines
there's a very crappy way of making it a 2-liner
Stream() very easy way to to make a 1 liner
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
players.removeIf(player -> !player.hasMetadata("vanished") || !player.getMetadata("vanished").get(0).getAsBoolean());
ImIllusion
That's a data structure issue that you need to figure out
I see a bunch of other mistakes in that tiny screenshot you sent
am I able to set the player's inventory contents in an PlayerQuitEvent?
it seems you can
you cannn
It would look nice if they had the invisible check in another method, then they could just do SomeClass::isNotInvisible
Does anyone have a sample pom.xml with Specialsource?
just need it to finalize my nms tutorial
I'm trying to loop through a list of commands in a config, and execute them in order. However when I run the plugin, it sends them in a random order. Any ideas how i can fix this?
for (String command : config.getStringList("startup.commands")) {
new DelayedTask(() -> {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}, 10);
}
It seems to now wait 10 seconds and then send them both at the same time.
no way will it be 10 seconds. thats in ticks
yes
ah
ah custom task
for(int index = 0; index < list.size(); index++) {
String command = list.get(index);
new DelayedTask(() -> ..., (index+1) * 10);
}
type deal
elgar
Mind giving a quick look at my NMS guide before I post it?
eh whatev imma just post it
Can i C?
How would I get my config list into this script?
you'll see it on the front page
List<String> list = config.getStringList("whatever");
F
Rip
gotem
give me the clout ktnxbye
Thanks a lot! Also, would it be possible to exempt the first item in the list from having the send delay?
remove the +1
Legend, thank you so much!
this https://paste.md-5.net/ibijukehev.java throws this error https://paste.md-5.net/bomejucuwu.rb i have no idea what what is
yup
it's because youre casting to HashMap
give me one sec
dont save the map like that
im just doing this java public static void saveBlocksStore(HashMap<Location, Integer> blocks) { //set the blocks store file to the hashmap blocksStore.set("blocks-store", blocks); //save the blocks store file try { blocksStore.save(blocksStoreFile); } catch (IOException e) { e.printStackTrace(); } }
how else can i do it?
Map<Location, Integer> locationIntegerMap = getMap();
int counter = 0;
locationIntegerMap.forEach((location, integer) -> {
config.set("blocks-store." + counter + ".location", location);
config.set("blocks-store." + counter + ".blocks", integer);
});
like this @near night
tysm
and you get like this
ConfigurationSection section = config.getConfigurationSection("blocks-store");
if (section == null)
return new HashMap<>();
Map<Location, Integer> map = new HashMap<>();
for (String key : section.getKeys(false)) {
map.put(section.getLocation(key + ".location"), section.getInt(key + ".blocks"));
}
thx
Do i use .equals or == for uuids?
.equals
kk
.equals because it's a string technically.
Uh it's not because it's a string, it's because it's an object
== compares references, .equals() compares the actual values of objects
Does anyone know the event for when a structure block is used?
and don't forget === does both
:)
You can always do the ol' PlayerInteractEvent and check if its a structure interaction?
I need to know the blocks being placed though
In what language lol
javascript
declaration: package: org.bukkit.block, interface: Structure
That’s not what === does
oh he probs meant as a joke then
I’ll take a look at that thanks, I don’t know much about how structure blocks work so I didn’t realize it keeps track of the structure after it is placed
would you guys recommend i use eco to create my plugin
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
You might want to add another reserved reply. With that to-do list you will surely exceed what you've currently got 😁
Thanks a lot for the guide, been meaning to get into NMS lately, wanting to play around with the entity metadata packets.
what do you need out of it?
if you're going to use someone else's library, make sure you really need to use it, you are able to fork it and maintain it yourself if it changes into a bad direction or gets discontinued, etc
i just heard it was good for developing lol
also nice name :P
I would have changed it to my Spigot username but
eco seems like a library that a plugin would heavily depend on if written for it, though you would get outstanding integration with eco plugins if you used it
you should ask in their Discord if your plugin would be suited for it
Why do teams only use ChatColor in 1.19? Couldn't they use a Color class since we have hex support now?
Teams have always used normal ChatColor and not supported hex. I'm not exactly sure of the reason, but I know it's always been that way.
Kinda dumb imho
Mojank

fun
can an entity with a custom name and a pdc get removed naturally?
not by plugins etc..
just to be sure im pretty sure you can do entity.setPersistent(true)
but i dont think it will
if you do want it to do it manually
on chunk unload or something
Can be remived naturally by dying 😂
invulnurable
and creative damage cancelled
no gravity
index "-57" lol
dunno how that happened
It would seem that you put it there
Hi somene help please how can i get DIAMOND value or normal value using getconfig()?
Generator:
normal:
- STONE:60
- COAL_ORE:10
- IRON_ORE:8
- GOLD_ORE:5
- REDSTONE_ORE:7
- LAPIS_ORE:7
- EMERALD_ORE:2.5
- DIAMOND_ORE:2.0
DIAMOND:
- DIAMOND_ORE:100
you mean converting a string to a Material?
are there any good analogues to std::deque in java?
no i only want to get normal String here
or DIAMOND string
like get list Generator have string value:
- DIAMOND
- normal
I'm kind of confused do you want to get the path Generator.DIAMOND as a List<String>?
not sure what you mean by normal string
use Map type
i tried but it not work
it return value null when i using getconfig.getMapList
It should be List< Map< String, Object > > according to the snippet u provided earlier
do you have an example?
uh can you help please
I'm still having trouble understanding what you're trying to achieve
if you want the Generator section I guess you could do
ConfigurationSection generatorSection = getConfig().getConfigurationSection("Generator")
that would return the Generator section and calling getKeys() on it will return a Set<String> of normal, DIAMOND since they are part of the Generator section.
again, I don't know if that's what you're looking for
The guide is at around 25k characters, I have 60k reserved
thank tou so much it worked
np
love how splitting my guide into 3 posts made me get 3x the positive ratings 
Stonks
Hey, for some reason my code is not working properly. I'm trying to create something called alliances(like clans, guilds), and everything stores fine in the local yml file when creating the alliance itself.
But then I'm making a command to store in an arraylist used names/tags and a command to list every alliance and it's not working, it keeps returning null(from doing yml.getString...) even tho when speaking on chat it puts my alliance tag fine and when doing /alliance command it opens fine my alliance info.
The code right now is after 5 seconds(a scheduler) the server opens it checks the alliances on yml and loads them. (Beforehand it wasn't working even without the 5 second scheduler so I added it to maybe load it when server was "fine" opened)
current YML file:
alliance:
total: 2
'1':
status: 1
leader: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
tag: Test
name: Testing Alliance
members: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
level: 0
xp: 0
totalxp: 0
reputation: 0
'2':
status: 1
leader: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
tag: Abcd
name: ABCDEFGH
members: bad38249-dea9-32bb-84ae-6ec0eb26a3d9
level: 0
xp: 0
totalxp: 0
reputation: 0
But then when I get the total alliances and then a for to check the alliances names, all return null names and tags...
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {
@Override
public void run() {
allowToJoin = true;
int totalAlliances = alliancesYML.getInt("alliance.total");
for (int i = 0; i < totalAlliances; i++) {
String path = "alliance.'" + i + "'.";
if (alliancesYML.getInt(path + "status") == 0) {
Alliance alliance = new Alliance(i);
if (alliance.getChunks() != null && alliance.getChunks().size() > 0) {
for (String chunk : alliance.getChunks()) {
allianceChunks.put(chunk, i);
}
}
}
}
}
}, 20L * 5);```
oh god the nesting
this is the code to load them when they start
?paste
Does someone has an issue with onClickBlock firing twice ?
public Alliance(int id) {
this.id = id;
setup();
}
public void setup() {
Bukkit.broadcastMessage("Starting setup of an alliance...");
String path = "alliance.'" + id + "'.";
if (Main.getInstance().alliancesYML.getInt(path + "status") == 1) {
setStatus(STATUS.DELETED);
Bukkit.broadcastMessage("- Alliance deleted.");
} else {
setStatus(STATUS.ACTIVE);
this.leader = Main.getInstance().alliancesYML.getString(path + "leader");
String membersData = Main.getInstance().alliancesYML.getString(path + "members");
ArrayList<String> members = new ArrayList<>();
if (membersData != null) {
members.addAll(Arrays.asList(membersData.split("#")));
} else {
members.add(this.leader);
}
this.members = members;
this.tag = Main.getInstance().alliancesYML.getString(path + "tag");
this.name = Main.getInstance().alliancesYML.getString(path + "name");```
smth like this, then there's more below
🤔
?interact
idk the command
there is one
It fires for main and offhand. Check something like event.gethand
it keeps returning null from the YML file tho, even tho it stores fine and gets it fine when i do /alliance
So when a click is emitted it emits for both ?
Both events get fired
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
this one
if (event.getHand() == EquipmentSlot.OFF_HAND) {
return;
}```
Thanks copilot xd
Thank you too ^^
😔 alright, was worth a try
?arrowcode
Is this not called spaghetti code ?
no
it does a for per alliance on yml and then checks their status and loads them.
and then it checks if they have any chunks claimed as an alliance and stores them in the hashmap to use for checking when someone else tries to break into their chunks
not really
just been stuck on this for past 2 days and really dont know what else to change and try to fix
I'm telling you that your code looks unreadable, and it can be more legible
you're telling me what it does
bet it's some small thing i'm not seeing so I'm giving my shot here
also no point in looping through your aliances like that
Just a side note making your code more readable/making it a habit will save you a lot of trouble
It will save your life
I can put my chunks loading inside the Alliance class but the problem is the thing before where it's not loading the YML correctly.
it does correctly in the command, but not there
😔 It turned into a mess when trying to fix the bug
That's why I like to commit before starting to fix, then get it to work, and rollback and put the fix without messing up more code. Might work for you
ConfigurationSection alliancesSection = config.getConfigurationSection("alliances");
for(String key : alliancesSection.getKeys(false)) {
if(key.equalsIgnoreCase("total") {
continue; // this is not an alliance
}
parseAliance(alliancesSection.getConfigurationSection(key));
}
public void parseAlliance(ConfigurationSection section) {
Status[] statuses = Status.values();
Status status = statuses[section.getInt("status", 1)];
String leader = section.getString("leader");
List<String> members = new ArrayList<>(List.of(section.getString("members").split("#")));
if(members.isEmpty()) {
members.add(leader);
}
String tag = section.getString("tag");
String name = section.getString("name");
Alliance alliance = new Alliance(status, leader, members, tag, name);
// register the alliance
}
no need to overcomplicate it
oh yeah the configurationsection thing
i saw it few months ago but never got to use it or learn it
this is why you're struggling
so over there u changed the Alliance to receive all the arguments right away on it. is there a reason for it? why not the way i have where i put the ID and the class itself loads them? (or is this a problem?)
Alliance is a data class
passing the loading logic to it breaks the single responsibility principle
you can just make 2 constructors
or you can make a constructor with the section and parse it there, bit stupid but still
I will try to change my alliance code into being like that first(the class) and then if doesnt work i will look into learning and testing ConfigurationSections
i will move to configurationsections later on if not needed yet but feels like i really need to learn them soon🤔
FYI
thank you for the time
a FileConfiguration extends ConfigurationSection
pretty sure the only difference is that it has the save(File) and save(OutputStream) methods
It's just that I been using that forever and been working fine for me to store something that only the server needs(for more global data i use mysql)
weird how it's returning null for the first time, hella annoying
ty again, I will get back to fixing it
I'm trying to check that if the user has enabled the players-needed module, and then check that if the current online player count is above the specified threshold in the config.
That all works fine, however I need it so if "loop" is equal to true in the config, that it will go back and wait the specified amount of time and then try again.
I'm not sure how to properly implement this, any ideas?
if (config.getBoolean("startup.enabled")) {
// If wait length is above 0
if (config.getInt("startup.wait-length") >= 0 && config.getInt("startup.command-interval") >= 0) {
int seconds = config.getInt("startup.wait-length");
// Wait specified time
new DelayedTask(() -> {
// Check if there is enough players
if (config.getBoolean("startup.players-needed.enabled")) {
if (config.getInt("startup.players-needed.amount") >= 0) {
if (Bukkit.getServer().getOnlinePlayers().size() < config.getInt("startup.players-needed.amount")) {
getLogger().severe("Couldn't send command as there aren't enough players online!");
getLogger().severe("Check your config.yml if you think this is a mistake!");
return;
}
}
}
// For command in commands code
}, seconds);
} else {
getLogger().severe("Couldn't send command as config.yml is invalid!");
}
}
My config:
startup:
enabled: true
players-needed:
enabled: false
amount: 1
loop: true
wait-length: 5
command-interval: 2
commands:
- "say [AutoCommand] Thanks for using me!"
Ok first off go invert some if statements so theres not so much indentation. Make a seperate method to check the option, and then you can loop that method
so instead of ```java
if (config.getBoolean("startup.players-needed.enabled")) {
do
```java
if !(config.getBoolean("startup.players-needed.enabled")) {
return;
}
That way you can keep most code on one level, keeping it readable.
there's a bug on that code you sent me btw, says this:
didnt know there was a diff version of such thing
i have latest releases almost, like from 2 months ago on everything, is it an option I have to change somewhere?
you're coding your project in java 8
I clicked to update to 9 over there
and running it on like java 17
i didn't know, i thought downloading latest jdk would put me with latest
where do i change this? is it project or on the IDE? :susthink:
either Project Structure or on your build.gradle/pom.xml
this?
ye
or this "9" now?
since i updated to 9
or is it correct right now?
i checked online something from a month ago and they using same versions as mine for those options
i guess now is fully updated?
exists place ender crystal event?
block place event probably
end_crystal block
otherwise entityspawnevent
pretty sure end crystals just work like spawn eggs
playerinteractevent
Using this config how would I make it so:
- if loop is enabled, it continues to loop through the code until the player-needed.amount is met
- If loop is disabled, it goes through the code only once
What's Total for
yo fourteen
Yo
check my bio and give me clout
still needs a lot of work
Everything was Hidden in the spoilers lol
how can I have the user select a region (like in worledit) and then when someone tries to go outside that specified region they are pushed back?
(this is for a minigame so I'd need it to work efficiently and only when some variables are true)
Learn the worldguard API ig
time to die
Correct
I was really wishing that there was an easy way to just do it myself
The worldguard api is a horrible pain in the ass good luck
Worldedit too
WorldPain Collective™️
And their support server is a bunch of idiots that ban you for whatzver reason
Got kicked a few times
all I need is to allow a user to select 2 regions in a map (for 2 teams) and then not let the team members exit their respective regions
And then banned cuz i helped People and im not supposed to do that
cubecraft discord be like
From someone who designed such a terrible api I'm not surprised they designed the discord in such a terrible way
Lol
Hello guys any of you has any idea of what happens if I set the amount of an item to 0?
It goes away doesnt it?
yeah I think so
Or is the amount indicator gone?
yea that's my doubt
Try it
Pretty sure it removes the item.
Alr I'll try it for science
I currently have 2 options
either I scrap my minigame idea (which is a pretty OG idea and I dont think anyones made it before)
or I literally kill myself trying to learn the worldedit/worldguard API
it becomes a red 0 below 1.9
above 1.9 it just becomes air
is there a "crash course" for the worldedit/worldguard api?
I am kinda in the mood to make this minigame without killing myself in the process
lol
so first I discover that I have to learn WorldGuard API
and then the repo is offline
?jd-s
I want to make a general class ‘Move’ which stores a list of projectiles and has a method ‘Run’ which then just returns the result of a method for each of its extensions
Sigh this sounds so ugly
I just wish I knew how to do it
It seems so much like something that should be obvious
Do inventory slots start at the number 0 or 1?
if i would guess i would say 0
alright
what event do I use to look to see if the inventory that is clicked on has a certain name?
inventoryclickevent ?
Don't check for inventories like that
Make a wrapper object and save the inventory object. Use Dependency Injection to pass it around
Guys, how can I display a list of players but in a normal way?
https://ibb.co/341ZBjt
sender.sendMessage("§ePlayers online: §2" + getServer().getOnlinePlayers().length + "/" + getServer().getMaxPlayers());
sender.sendMessage("§eList: " + Arrays.toString(getServer().getOnlinePlayers()));
sender.sendMessage("§6================§e[§2TAB§e]§6================");```
A loop
?
Use a string builder in a for loop and append the name and what you want in between each name
Thx
for (Player player : Bukkit.getOnlinePlayers()) {
players.append(player).append(" ");
}```
Its right?
players.stream().collect(Collectors.joining(", ")) or smth
players must be a collection
me when String.join
Hey guys. i wanted to ask, how much more/less efficient is PDC compared to sqlite? In my case i wanna store a list of string ids for each player
Uhm i dont know how to use Collection
k, thanks for the info
Bukkit.getOnlinePlayers is collection
🥹
how would i do that?
Wacky, why is paper not finding io.papermc.paper:paper-api:1.16.5-R0.1-SNAPSHOT
it only has 1.17 as the oldest API version on their repo
?paperdev
Make sure to ask in the appropriate server concerning development towards different JAR types such as PaperMC. (Tip: Google them!)
Arrays.stream(Bukkit.getOnlinePlayers()).collect(String.join(", "));?
It gives me an error
Bukkit.getOnlineblabla.stream().collect() blablabla
Lmfao he did
might wanna use smth else if this is too complicated
Idea Intellij replace stream().collect() to Arrays.stream(...).collect()
idk why it does that
ultimately does the same thing
🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹 🥹
Can the playerinteractevent cancel block breaking and block placing
Yes
I think...
omg it can
?tryandsee
bro thats so annoying
whats annoying
i thought only blockbreeakevent and blockplaceevent canceled block place and break
afaik block place and break event are a child of the interact event
ahh
I just decided to steal the method from the server core 😎
if (cmd.equalsIgnoreCase("online")) {
String players = "";
Player[] var5 = Bukkit.getOnlinePlayers();
int var6 = var5.length;
for (int var7 = 0; var7 < var6; ++var7) {
Player player = var5[var7];
if (!(sender instanceof Player) || ((Player) sender).canSee(player)) {
if (players.length() > 0) {
players = players + ", ";
}
players = players + player.getDisplayName();
}
}
sender.sendMessage("§6================§e[§2TAB§e]§6================");
sender.sendMessage("§ePlayers online: §2" + getServer().getOnlinePlayers().length + "/" + getServer().getMaxPlayers());
sender.sendMessage("§eList: " + players);
sender.sendMessage("§6================§e[§2TAB§e]§6================");
return true;
}
bruh cant longer sent smth to chatgpt, whenever i press enter it gives me a new line
sometimes it works sometimes it doesnt
how an entity like this (with custom name, pdc and damage cancelled) can be despawned?
players report it disapearing
and i view the log and they didn't removed it themselves its just not there
is there a way for me to check to see what the name of the gui inventory that is being opened is?
Is it recommended to do dependency injection with Guice or pass the plugin instance to constructors? I'm currently passing my plugin instance to the necessary constructors but I've been reading using Guice is a better practice
Well, wouldn't you still pass your plugin instance through the constructor?
guice has field injection sure, but iirc thats discouraged
Field injection is what I meant yeah
^, mainly field injection sort of advocates mutability
which is discouraged unless reasoned for
and yeah for reference reybot, https://github.com/google/guice/wiki/MinimizeMutability
nothing?
I just started using sql for player stats. Is this way better than just getting and changing from sql everytime
How do ppl usually use sql for player stats
Do you crete object for each player where an instance is stored and save it onto sql sometimes
uuid
Ye uuid is my primary key but
all of the plugins use uuid
Yes, one design choice regarding saving data is to sync with the database with a given interval
Should i make object player stats for each player and keep an instance
a sync buffer or whatever u wna call it
Or just keep pulling data from sql
but yes demopro
if you save it async there should be no problem
and you can pull it once joined
and store it in a hashmap
apply all the edits you want to the PlayerData object
no need of pulling
i do this
fetch on join, save on leave or/and after changing the data
how an entity like this (with custom name, pdc and damage cancelled) can be despawned?
https://cdn.discordapp.com/attachments/741875863271899136/1054470078005006396/image.png
players report it disapearing
and i view the log and they didn't removed it themselves its just not the
Ye so I would keep an instance of each players playerStats object right
Ok but looping through the hashmap wouldnt be suboptimal right to find the player each time
yeaz
Ok ty boys
what event do you use to place particles at a certain block?
when you want to spawn the particle?
on a command
or like when the block is broken?
nvm i figured it out thanks though
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
nothing wrong with it
does worldedit hook it?
it uses it, yes
ok
i mean does it intercept the call?
intercept? you seem to be using the vernacular incorrectly.
Worldedit probably just uses nms for fast setting
by writing into the palette directly
intercept == hook
well there's actually nothing wrong with it
there is no hook, you use it or you don't
location is obviously location of a block
oof someone comes from python 
i checked the world and coords and they're correct
cpp*
mans got the md_5 formatting style
yes
Not block_locatoon 
You are doing something wrong in your code.
?conventions
i realy need help with this
how an entity like this (with custom name, pdc and damage cancelled) can be despawned?
https://cdn.discordapp.com/attachments/741875863271899136/1054470078005006396/image.png
players report it disapearing
and i view the log and they didn't removed it themselves its just not the
i have to fix it in like 10 minutes
i added material diff check and it seems to be working fine
but settype still fails in the same loop lol
the actual part of code
ik int ids are deprecated i use em only for debugging
aaaaa
hey, i have a quiestion, i wanted to start making plugins again, i did this a prob half a year ago. but since stopped
i though i used to have the build (artifacts) button somewhere on top of there
but i cant find how. if anyone knows, this would make my life 10 times easier
Also on player kick need to save it too, because i think that PlayerQuitEvent is not run on server kicks
That is a maven project, so you have to build with maven
This way you are using, is building the project via ant, which would not be okay because its a maven project
yeah
I would either suggest using maven or gradle for projects, because they will keep you faster and dependencies are easier to manage
getting this error, problem is with my constructor here:
though i do not understand what is wrong
implement commandexecutor
your command is not in your plugin.yml
it does
im just switching up constructor stuff, it was all fine before this lol
your class should be implementing CommandExecutor

always that 1 lil stupid thing that messed you up
when a chunk gets unloaded all mobs disapear
tf?
it bugs my plugin
what does this
makes sense?
Why does it bug your plugin?
How I can make a custom recipe with custom items?
I know about exactChoice but this requires the Item properties to be fully the same like Name, Enchants, etc.
But vault is loaded and working. And plugin.yml includes depend: [Vault]
I wanna make it possible just for a custom item unique ID so just compare Item's NBT data
this is my code
and i name it a little later in the code
ahh i dont wanna use packet entities ffs
But vault is loaded and working. And plugin.yml includes depend: [Vault]
rsp seems to be null. Why would this happen
show code
Disregard, fixed
duck bukkit entities
i will use packets
aaaa databases
it used to be a simple pdc thing
bleh
I can't understand what it means by component. Can it be just a string? How could I tell if it presents again
All this because setPlayerPrefix is deprecated :/
paper?
Yes
?whereami
Paper uses components everywhere. This is Spigot, we use Strings
Does that mean I can just use a string and it'll be fine?
yes... kinda
it lacks many nice featues of components
Component.text(String)
Player does not exist in PreLogin event
Fair enough. Thanks
Build against Spigot and your code will always work on Paper. Not vice versa
Hmmmm
Any alternatives then
if they have logged in before use OfflinePlayer
but you can;t access their inventory before they have logged in
ah aight
Is that < arrow mandatory now?
No matter what I change the prefix to the arrow stays
< is in teh chat format not the name
Exactly but I never changed the chat format so I shouldn't be getting that
i kind of ran in to a problem, the problem being that I am alone XD
how do I easily test multi user plugins without a alt account (and only a local server)
for example tick tack toe
i already thought about:
- bringing friends over, but thats to hard to do for simply testing
- buying a alt account, but... no...
- making a public server, have no idea how, i remember it beeing hard and not knowing the password of my routers
(i mean, if a public server is the only way i need to take a look at that again :( )
Exactly
the <> is there by default
oH
You need to remove it
get a free alt
you can use game pass to get alts for like 1$
free trial
WHAT!?!
some kind of weird launcher
Get cracked minecraft and disable server protection
Just for testing
i used to do that but they removed that functionality
and suddenly the conversation stopped
or get friends
where would i do that, only thing i can find are websites that sell them for like 12$, but they all have full username and skins and stuff
not sure if thats totally legal or just stolen, anyway, its 10$ to much XD
game pass literally gives you the game for free
you just buy the game pass trial for 1$
under a new microsoft account
and profit
I did it during my hypixel developer interviews to have a nice account name with no bans
then they asked for all my account names
on another ip so i dont really care
but it didn't really matter, watchdog bans don't influence your development skills
I had some weak points during my interviews that I've been working on
and some weird scheduling conflicts like school
Hello! I have a question, my antivirus show me popup (Virus: Java.Trojan.GenericGBA.31552). But problem is with this because that is plugin"ExploitFixer.jar". Sorry if i ask here, but i know here i find good people for resolve my stress...
link to page for plugin?
I use this plugin long time... and i naver have this. My antyvirus: G data.
Thats from spigot
We need the link
i have this plugin on my computer
This plugin is corrupted. Don't use it anymore and remove it from your computer. Download a new one on spigotmc.org
i download this plugin 2021-05-06
okey but i download this from official site spigotmc this is reason why i ask
link the spigot page or we can do nothing
really i use my computer yester day 2 days ago but this popup kmy antyvirus show me today
its this plugin but give 5 sec i try check version
send your jar to @vagrant stratus
i try open my jar file using winrar but i have also popup about virus
idk whis plugin now works becouse maybe my antyvris remove some file
Antimalware >>>>
Game pass takes it away tho lol
Oh wait this is about alts
ye tru
oh, minecarft wont even let me open a new launcher, cus this one already occupied
hi, i'm new in here so if i'm breaking any rules please warn me!
well, i've got an yml file that is given data in this structure:
bbbdcbc1-996c-435d-9297-9898b419dadc:
Name: George
Staff: Yes
Rank: Begginer
bbbdcbc1-996c-435d-9297-9898b419dadc:
Name: Bob
Staff: No
Rank: Master
how can i go through every key, find the one that has the value 'Bob' and get his UUID?
^
I already told you, You can't get a player in teh pre login event
you can't
:|
there is NO Player in the pre login event
Is there another event I can use instead?
join event
ah right, cheeres
you can read your sql data in pre login and then give the item in the join event
What does it say when you hover the yellow error?
nullable
I can see it from here
giveReward doesn't take into account that the player might be null
use event.getPlayer() not Bukkit.getPlayer
Also that
Oh and new bug; It keeps giving me tokens every time I rejoin
Player player = event.getPlayer();
try {
if(hasReferral(player.getUniqueId())) {
giveReward(player);
removeReferral(player.getUniqueId());
}
} catch(SQLException e) {
e.printStackTrace();
// Kick player optionally
}
Right
Edited it btw
Mhm
reason I was making my own referral plugin is because other ones are either crap or don't support 1.19
UUID referrer = removeReferral(player.getUniqueId());
if(referrer == null) {
return;
}
giveReward(player);
// Give a reward to the referrer
Something like that in the try-catch
because then you can get the referrer, check for referral and remove the referral at once
This is my addReferral function
Yeah
I'll just modify it so it removes it
Remove has referral, then make remove referral get & remove (there is a way to do this in sql, forgot how) and make it return the referral if any
otherwise null
ah yes
you can do
DELETE from table where this = that RETURNING *;
why does this happen? I can build the jar without a problem but IJ keeps saying this
using the latest version, of course
the return type of your y() is not the same as the superclass'
the EntitySlime is from the nms
don't have nms ready rn
DELETE from referrals (referring_player_uuid) RETURNING *?
DELETE from referrals WHERE referring_player_uuid = '?' RETURNING *;
something like that
though you should delete by referred_player_uuid
otherwise if that player refers two players it will also remove the other referral
mhm yeah
So in pseudocode
When a player joins
go into database, Check if any players have typed /refer Ryzanite
If there is, then execute /givetoken Ryzanite 2
basically yes
then delete list of players who did /refer Ryzanite for ryzanite
well not exactly
?
this should run the delete
so you make one SQL request
and not two
ah right
RETURNING * already gives you the output
Ah right
should be referred_player_uuid
got it
otherwise if playerA refers playerB and playerC, if playerB joins it removes playerC's referral
Right
Wait how do I reference to the result?
hm?
executeQuery
it returns a ResultSet
you probs want to use ResultStatement#getString for the UUID
so like
myStatement.executeQuery().getString(0);
gtg
guys, can i have some help?
You don't even mention what you need help with. So how are people meant to help you.
check messages above
They mean this, I assume
yes
it'd be best if you'd provide the message link or reply to the message, rather than saying "check above", since that's very vague
You can?
WOW
?
should've checked the 3 dots
To answer this:
You can get your file as a FileConfiguration object, from which you can use the method #getKeys(bool deep), the boolean stands for, if you'll get every possible key in the case of true or just the next keys in the case of false.
In your case you probably want to set it to false. And when you got the keys you can loop over them and find where "Bob" is
doesnt false get only the highest level keys?
Here's some stuff to read, if you need to specifically know what the methods do
https://helpch.at/docs/1.11/index.html?org/bukkit/configuration/file/FileConfiguration.html
it does, but those are all you need
ok
also, which path do i give? since i haven't got any paths
is it ok if it is is only ""?
use the getKeys() method just on the plain FileConfiguration object
if I want to use CompleteableFuture how many threads should I put in the Executor?
Executor executor = Executors.newFixedThreadPool(10); Is in the example I am looking at, but I don't want to hog resources or possibly cause a server crash from running these tasks
If you do small io tasks, just use cached thread pool
I'm just doing database queries with callbacks
whats wrong with the common pool?
doesn't that not work unless you set the system property I wasn't sure if spigot had it set or what
what
might just use the bukkit scheduler to complete cfs
does Bukkit Scheduler have callbacks? I feel stupid for not knowing
no
just do
var future = new CompletableFuture<>();
scheduler.async(() -> {
// some heavy stuff
future.complete(result);
});
future.thenAccept(System.out::println);```
or use the common pool
might wanna specify the bukkit scheduler as executor tho as a lambda
task -> scheduler.async(plugin, task) whatever
then do CF.supplyAsync(stuff, task -> blablabla)
going to sleep now anyways
Hello. Does anyone have an idea how to set a limit of people who can access protection. The plugin in question is StoneProtect
Hi guys, I got a "funny" (💀) problem
Basically I am creating a plugin (called sSkills) that uses a H2 database, that I relocated because I like relocating 👍
Another plugin (ajLeaderboards) uses the same library but with a different version
My plugin somehow ends up loading ajLeaderboards' H2 Driver class even tho I have no link to this plugin since I'm registering the driver using the following:
Class.forName("fr.stellarfx.sskills.libs.h2.Driver");
And it still produces this cute message:
[sSkills] Loaded class us.ajg0702.leaderboards.libs.h2.Driver from ajLeaderboards v2.6.3 which is not a depend or softdepend of this plugin.
It ends up in my database getting corrupted since it doesn't use the same version
Note that my plugin works perfectly fine with no other plugin on the server, I can even reload it, do coffee with it and everything
Idk maybe I just implemented it badly but I searched Google, and I feel like I can't do any better
Thanks 👍
i've got a bit of an annoying issue, where every time i try to save an ItemStack to a config file it's changed ever so slightly in that supposedly identical items no longer match after being loaded in.
as example, this item:
ItemStack{STONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"italic":false,"color":"white","text":"Not Stone"}],"text":""}}}
turns into
ItemStack{STONE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Not Stone"}],"text":""}}}
causing them to stop stacking and just stop being identical when needed. visually the item looks the exact same, but saving an item to a config file seems to just add this extra nonsense. how can i get around this issue
I've never really messed around with files, but maybe you could "serialize" the item into a string that you can later decode?
The Bukkit system does a full load of the item into their API
And that conversation sadly is not guaranteed to maintain the exact same nbt
As seen here
serialize it

I'm still a bit confused on how I should wrap my brain around this. I'm using a Guava's LoadingCache
@Override
public SlayedPlayer load(UUID key) throws Exception {
// heavy database call
return this.database.select(key);
}
now I want to get the value of the cache but a call to LoadingCache#get or LoadingCache#getUnchecked would block main thread. Now I would just supply async to the retrieval method, but that seems unecessarily heavy. As in most cases its likely the value will be there. So i'd end up creating an asynchronous thread for pretty much no reason and it'd almost immediately close rather than just retrieving sync since the value is there
** solved **
public static Future<SlayedPlayer> get(final UUID uuid) {
if (cache.getIfPresent(uuid) != null) {
return CompletableFuture.completedFuture(cache.getIfPresent(uuid));
}
return CompletableFuture.supplyAsync(() -> {
return cache.getUnchecked(uuid);
});
}```
iim making a shop plugin and if people want to make a spawner shop how would they do that since theres only a material of the spawner not the individual mob spawners
[20:37:28] [Server thread/WARN]: (
[20:37:28] [Server thread/WARN]: `Unique` int default 0,
[20:37:28] [Server thread/WARN]: Total int default 0
[20:37:28] [Server thread/WARN]: )' at line 1
[20:37:28] [Server thread/WARN]: at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
(
`Unique` int default 0,
Total int default 0
);
How is this wrong
Spawners have BlockStateMeta
Spawner Blocks have CreatureSpawner BlockSTate
you can do BlockStateMeta#setBlockState
and BlockStateMeta#getBlockState
to change the block states
I don't think domainlogs.? is a valid table name
Unless .? is some weird SQL operator I'm unaware of
it is not - you're right, that's invalid
my guess is they're trying to fill the table name via a prepared statement variable injection but that isn't valid for a table name. that makes me extra sus as well because that would almost imply the table name is coming from user input...
event.getPlayer().hasPlayedBefore()
Always returns false. why
are you in offline mode
Negative
Where are you running it? ;p
(is that still a thing? it breaks in offline right)
PlayerLoginEvent
I believe the player has not been fully loaded yet, right?
And I have to use PlayerJoinEvent
Hmmmm alright
If you want to get the player before the player logs in, there is the AsyncPlayerPreLoginEvent
Oh
Doesn't help me @jagged monolith
I need access to getHostname()
Only available in PlayerLoginEvent
AsyncPlayerPreLoginEvent gives you the InetAddress, which has getHostName
Yeah I just openned the docs and found it
Let me give that a try
But then how do I access hasPlayedBefore?
Get UUID and use getUniqueID()?
Just get the player from the uuid and check the hasPlayedBefore
can you get the player from uuid if they're not joined yet? are they in the player list that early?
Wouldnt it just return false if its not in thr list
Player player = Bukkit.getPlayer(event.getUniqueId)
Or something like that. On mobile so... lol
oh
That won't work if they're not in the server playerlist yet
we're talking about prelogin
Forgot about that one let me try
Wait
But we're checking about hasPlayedBefore()
but try it i guess
Dunno. You can try. I haven't checked.
Checking rn
But methinks no
If it doesn't work, instead of getPlayer use getOfflinePlayer
getOfflinePlayer may work yes
Ok and lastly before I actually finish my small project with sql injection
How can I set a placeholder to make a table
```CREATE TABLE IF NOT EXISTS domainlogs." + hostname + "\n" +
"(\n" +
" Unique int default 0 null,\n" +
" Total int default 0 null\n" +
");
I wish I could do
CREATE TABLE IF NOT EXISTS domainlogs.?
"(`Unique` int default 0 null,
"Total int default 0 null
");
It is really questionable to create a dynamic table name like that.
Something like that
But...sanitize it properly, and use String.format
Yeah Im aware but it's the functionality of my program
Isn't string.format also not safe?
Technically?
I'm aware xd
But String.format is the cleaner way to do it
I wanted placeholder but not possible
Just sanitize the input.
Alright will do that thanks
Run it through a regex replace to ensure no special chars are in there and stuff, I guess. then I guess it's ok
yeah
Flawless
So clean
And so helpfull for single line, it's prediction is out of this world
it stands on the shoulders of everyone who commits to github
Anyone knows whats wrong there?
Hover your mouse over the red underlined area and it will tell you.
it says remove invalid modifiers on "shortInteger" and Syntax error on token "String", record expected
I need to see the surrounding code
I think that's eclips being eclipse
Paste the file please
ughhh eclipse on her days again
?paste
of cours
Like why is the semicolon underlined at int seconds =0;
Oh fuck
ohhh
Why is the method in a method😂