#help-development
1 messages · Page 883 of 1
oh okay
for (String key : plugin.getConfig().getConfigurationSection("mineblocks").getKeys(false)) {
Location location1 = plugin.getConfig().getLocation("mineblocks." + key + ".location");
if (location.getWorld().getName().equals(location1.getWorld().getName()) && location.getBlockY() == location1.getBlockY() && location.getBlockX() == location1.getBlockX() && location.getBlockZ() == location1.getBlockZ()){
return true;
}
}
return false;
}```SOOO this should work?
try it
ye
ok 11 libraries in and it seems to have worked
😭 it still doesnt work
you sure you stored it correctly in the first place?
If youre accessing this often its best to load to ram instead of reading config every time
its already loaded into ram
but it should work
yep
plugin.getConfig().set("mineblocks." + args[1] + ".location", p.getLocation());
plugin.getConfig() is loaded into ram?
yes
Ok I didnt know
but I get what u mean
I thought plugin.getConfig reads the file
yeah, I mean it might be worthwhile storing the locations in a more sophisticated data structure ^^
its just a normal YamlConfiguration instance I believe
i dont know what im doing bad. im just setting and getting the location 😭
I dont know what could go wrong there
args[1]?
/mineblock add <name>
ye well, in this case ur mineblock names
ugh, well it has pros and cons
so it maybe doesnt work bcs of this?
i doubt
😭
im rather unsure tbf, but I mean I would say try to do the command again on a new location and test it
oh thats why
?
yk that getConfig().set(...) doesnt dump it into the config.yml automatically
u need to use plugin.saveConfig() I think
ah alr
why aren't we using the location object
location is serializable
he is using it
im using location
object
Location location1 = plugin.getConfig().getLocation("mineblocks." + key + ".location");
ah sick
and why do you compare x y z then
and not do
configLocation.equals(minedLocation)
that'd yield false even if the block location is the same, but the offsets are different
so i have to just compare the location like (if loc1 == loc2) ? xd
i dont think location.getBlock returns with an offset
rather just the center block location
well they're using p.getLocation() for now
im just saving location to config and than getting it as a location and comparing its blockY, blockZ, blockX
anyway Block basically translates to just the blockX, Y and Z from a Location
yeah that would make it a lot easier
I mean like, Location::getBlock basically calls getBlockX, getBlockY and getBlockZ at some point
yeah so why would you do the logic manually
which logic?
the checking logic
is there a packet so i can show player nick when he is invisible (or hidden)?
i dont think so but u can use armor stands
Under which circumstances will PlayerMoveEvent#getTo() be null?
can i set armor stand a nick?
yeah I think you can, holographic displays does this iirc
can it even be null?
Documentation states so
ah nvm, I was reading
docs
Eww :(
Is there in any way to remove spawn conditions for spawners with spigot api?
i think only that
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/CreatureSpawner.html
based in the wiki https://minecraft.wiki/w/Monster_Spawner#Data_values
declaration: package: org.bukkit.block, interface: CreatureSpawner
A monster spawner is a type of spawner found in a variety of structures. It contains a miniature mob, and constantly spawns instances of that mob as long as a player is nearby and, if applicable for the mob it spawns, if there are valid dark areas nearby. It cannot be obtained as an item in survival mode or moved by a piston, and it only drops e...
what would be the highest recommended about of sqlite connections for an mc server? I'm making multiple plugins for my server and i'm needing about like 4 connections and i was wondering if that could result in any network problems or something?
No
okay, thanks ❤️
I couldn't found any method that clears spawn conditions in CreatureSpawner.
What conditions
Everything, I want all spawners to spawn in all conditions.
Well, most importantly light level condition.
Here's my attempt
// Try to modify the spawn conditions
List<SpawnerEntry> potentialSpawns = new ArrayList<>();
for (SpawnerEntry entry : spawner.getPotentialSpawns()) {
SpawnRule rule = new SpawnRule(0, 15, 0, 15);
potentialSpawns.add(new SpawnerEntry(entry.getSnapshot(), entry.getSpawnWeight(), rule));
}
// Set the potential spawns
spawner.setPotentialSpawns(potentialSpawns);
I've tested it and zombie spawner still act the same.
Look at the spawner and run /data get block (tab complete the coords)
Ooops, I think I forgot to do CreatureSpawner#update
I did the update but zombie still won't spawn in daylight.
I don't really want to create my own spawner system lmao, or do I have to?
Just check if it’s empty and if so use getSpawnedEntity and add that to your spawnPotentials list
It takes EntitySnapshot.
which inventory event is most suitable for dragging an item and clicking it another item
is it possible to have 60 ppl on a server with 4gb of ram?
How can I get EntitySnapshot object from entity type?
getSpawnedEntity should give you a snapshot
that sounds like a no to me
Depends on a lot of factors
Thank you, here's the new data, but the zombie still doesn't get spawned in daylight.
Updated code: https://paste.md-5.net/kujiqizate.cs
Hmm that might be a bit of an oversight
Make it dark and let one spawn, then try it in the light
On dark it spawn the zombie right away.
But after that, the zombie keep spawning even on daylight.
That's weird.
Yeah that’s what I figured
what is the full exaplaination of this?/
Can you explain to me a little bit why it does that?
Before you setSpawnPotentials, try doing setSpawnedType(null)
Hoppers and hopper minecarts call that event when they move items
Would that make getSpawnedType become null after setting the spawn potentials?
Not sure, it might be replaced when you call setSpawnPotentials
It's not replaced, the spawner doesn't have the mob spinning inside the block, and also my plugin really depends on getSpawnedType too.
set spawned type null -> set potential spawns -> set back the spawned type?
Hmm then I’m not sure there is much you can do
I’ll need to add a setSpawnedEntity(SpawnEntry)
Does anyone have experience with Spigot and Paypal IPN?
So basically with this way, the spawner need to at least spawn once?
The current entity it’s trying to spawn is still a standard zombie with no custom spawn rules, once that is spawned it gets replaced with an entry from spawnPotentials, which does have custom spawn rules
Ah that makes sense.
If I don't want this result then I assume I would need to create my own spawner system right?
Or use some nms
Okay for sure I can use a little bit nms lmao.
Think time asking lol:
Is there a good way to check an entire structure for Spawners? I don't want to iterate through every block since it's VERY slow.
Spawners are tile entities
Any guides should I follow?
So you can iterate tile entities instead
I can provide some code in a min
Okay, appreciate it.
CraftCreatureSpawner craftSpawner = (CraftCreatureSpawner) spawner;
NBTTagCompound compoundTag = ((CraftEntitySnapshot) snapshot).getData();
MobSpawnerData.a data = MobSpawnerData.a(new InclusiveRange<>(rule.getMinBlockLight(), rule.getMaxBlockLight()), new InclusiveRange<>(rule.getMinSkyLight(), rule.getMaxSkyLight()));
craftSpawner.getSnapshot().getSpawner().nextSpawnData = new MobSpawnerData(compoundTag, Optional.ofNullable(data);
Something like that, although those aren't Mojmap names so it may be a bit different
How would I loop through every single PDC in a thing, I have the value but I need to find the key?
iirc there is a getKeys
Thank you, will try that.
How to check if item is tools or armor?
or weapons
Thank You
do enchantments work beyond lvl 5? I tried to enchant but did not achieve the effect
what can replace them?
yes
are there any nuances when adding char to an item via bukkit api
I tried to add them but they didn’t work, maybe I needed to add something else as parameters?
char?
He means enchantment
enchantments.
If you are adding overleveled enchantments you need to use addUnsafeEnchantment (ItemStack) or addEnchant(enchantment, level, true) (ItemMeta)
hm ok i will try
no, still doesn't work even if the enchantment sharpness 11 sword kills a pig with only 2 hits
netherite material....
Through the command I can’t enchant an item above the basic standard levels
https://hastebin.skyra.pw/gidopipugu.java
Does this look correct for the intended functionality of the admin command? ie: start / remove a player's cooldown
hmm.. I can't exactly read that XD
Can someone translate the 3 enchantments and the attrubute?
sharp 7... thats all I think I know
hi, i need to code an always burning furnace, so far I manage to only set blockdata to lit, but even seting to Short_MAX the furnace.burnTime but it doesnt cook anything and just shows as lit
The attributes are "when equipped (wherever)": +1.6 attack speed
with shapness 13? in Netherite??
You have added a custom attribute
Which removes the base attack damage of the sword
You need to add it back
I just changed the speed of the attack
not damage
Ew that got formatted kinda ugly... maybe I should go back to 3 space indentation
Yes as I said
You have added a custom attribute
Which removes the base attack damage of the sword
You need to add it back
If anyone would rather a version in discord:
When adding an attribute, the characteristics of the item are reset to the basic ones?
No, it removes them
this minecraft pisses me off....
^ Yeah I thought it was like removed completely ie: 100% customizable item
Here's my code now and the spawner still not spawning.
https://paste.md-5.net/gimayabugu.cs
how would I get the plugin responsible for a namespaced key, getPlugin or something similar doesnt exist
Let's see the /data output
attributes are added first, then enchantments. But it still doesn't work
I’m not 100% on namespacedkeys, but I thought more times than not, your plugin needed a key handler method(s) to return correct values
Im looping through a bunch of namespaced keys rn and I wanna check the plugin responsible for it
like here lemme show you
Im using NBTToolTips mod
see the text before the : is the plugin responsible and after it is the name of the key
Is there a way to get the original block (the block at the creation of the world) at a location ?
?xy
Why do you need that
idk just for fun
what?
I feel like this would require nbt to have a sort of timestamp method that saves that information when a plugin creates a new tag
Nbt is open source eh? You could check there for how this data is stored in nbt and just relay changes based on what you need
I mean, the type of block at a certain location when the world was created
Sorry, I have never used nbt before haha, I know that probably wasn't the most helpful
@young knoll this is the difference between spawner that has spawned before and not.
I'm assuming we just need to add the custom_spawn_rules key to the compound tag?
That's what the code I gave you should handle
hi, i need to code an always burning furnace, so far I manage to only set blockdata to lit, but even seting to Short_MAX the furnace.burnTime but it doesnt cook anything and just shows as lit
I've did the same thing, and the result was shown above.
Weird
ah I see why
You are doing craftSpawner.getTileEntity
You need to use getSnapshot, which may be private
what are some pros and cons of project panama vs jni
Nope getSnapshot is protected just like getTileEntity
Right, it's private yeah, protected to be exact.
getTileEntity is public.
guys how do you add sounds when right click on npc in citizen plugin
i don't think y0ou're in the right channel
Oh yeah I forgot about that, let me change it real quick.
Heya, question again.
I'm trying to add BungeeCord to my pom.xml (Maven) - however as of the Wiki "bungeecord-api" does not exist, only -chat and -parent. What should I do now?
Now it's the same as getTileEntity, both are protected.
hi, i need to code an always burning furnace, so far I manage to only set blockdata to lit, but even seting to Short_MAX the furnace.burnTime but it doesnt cook anything and just shows as lit
What hosting specs do I realistically need to run a REST API + MySQL database + store (a lot of small) images?
Is this enough?
- 2 threads 3.3GHz
- 4GB ram
- 30GB NVME
if its not ressource intensive yes
but its the bare minimum for a small/medium service
What would you recommend to be sure that the performance is fine?
that depends on how many requests you are expecting, how's the cache build up etc. etc.
Well it really depends on how much traction the app will get lol. One user might send like 15-25 requests per minute maybe?
im a fan of seperating services
having an extra database server
one for the REST API
and maybe even an cdn for the images
but all in all if its not some heavy requests which each has to be computed individually you are fine to go
My budget is quite limited. Would it be better to separate things for me then?
you just have to stock up a bit if you gain more users
someone can help? https://www.spigotmc.org/threads/help-with-fixing-mysql-issue.635298/
not yet, dont get too big too fast. take it into account when you need it or feel like it
I'll keep that in mind. Thanks for helping!
i need help with a mysql issue on my plugin
How can I ensure that an entity is deleted even if the server crashes?
you dont, you remove it on startup
it is giving a annoying mysql exception that i cant find out how to fix
Did this and the result is still the same https://paste.md-5.net/uqevejicob.cs
https://www.spigotmc.org/wiki/create-your-first-bungeecord-plugin-proxy-spigotmc/ I think, the repository URL is dead, isn't it? 🧐
hi
you can help me?
wait patiently
no one is gonna help you if you're being annoying
you already posted on the forum too
no
works for me
weird, I can't do anything...
try clearing your cookies
I tried the basics already...
mmm MD probably disabled list viewing then
oh wait that's official sonatype
yeah I doubt they'd have that listing public
they probably have an official listing somewhere that is prettier
@real palm here is the front end https://ossindex.sonatype.org/search
How can I implement EnchantmentTarget
can anyone help, do enchantments work for more than lvl 8?
I was told that yes, but they still don’t work for me
Or How do i check tags
EnchantmentTarget.WHATEVER.includes
They do and if they don't work for you, you fucked something up
~~@young knoll do you know why the code still doesn't work? https://paste.md-5.net/uqevejicob.cs~~
Nevermind it works! Thanks for the help Col, really appreciate it!
(% 16) + 1
Denegative them then
idk why you'd want to +1 them tbh, they go from 0 incl to 16 excl lol
If chunk is 16 blocks, doesn't mean 0 to 15? 🤔
x & 0xF will work
because he said 1-16 not 0-15
btw % 16 also works?
int x = block.getX() % 16; ?
no it doesn't
& for binary and 0xF for 16
& 0xf is the right way
for example -126 is chunk coordinate 2, and -126 mod 16 is 2
Im trying to put it in an array so
also that's for chunks, not the block within the chunk
2d array*
Isn't & 0xF the fastest tho
so I dont see why % 16 should not work. it does work for -126 at least, why shouldnt it work for any other number?
si senior
can you give me an example of any number where it doesnt work?
Sounds like you have something wrong
it's literally just jshell lol
Can confirm -126 % 16 = -14 in jshell
weird
@tender shard apparently it works in math, but ig Java just can't math properly
Math.floorDiv handles it fine
that is not the operation they are asking for
I just tried running it in java and it gave me -14???
that will give you the chunk coord, not the block coord within the chunk which is what they're asking
yeah well then just do this
which is always 0 to 16
oh yeah. I thought thats what they asked for. My bad
ok, so will this put the first block in the chunk at the first values in the array?
Chunk chunk = block.getChunk();
NamespacedKey key = getKey(block.getY());
PersistentDataContainer pdc = chunk.getPersistentDataContainer();
byte[][] currentData = ByteFlattener.unflatten(pdc.get(key, PersistentDataType.BYTE_ARRAY), 16, 16);
byte index = findIndex(chunk, uuid);
currentData[block.getX() & 0xF][block.getZ() & 0xF] = index;
}```
Seems to work
hey what is the best way to change the characteristics of an item if enchantments do not work?
what characteristics ?
Good evening, could I get help with my plugin?
i mean this discord if for that (and talk)
if you wanna help in configuration #help-server if is for code then here.
what
the fuck
who is this fucking alex that he thinks he knows better than me, whose name is alex too?!
thats you
no
you say its profane
noob
i dont even know how to add those shitty checks to IJ
well "more actions" for edit that xd
Thanks I hate it
Thanks, I'll just try to understand the source code D:
Hello guys, any way to detect and cancel the dual wield?
You mean you want to cancel anyone from putting items in their offhand?
wtf who wrote that
?paste
https://paste.md-5.net/ivofomusup.md how i can solve it?
Set<BedWars> bedWars = Lobby.getInstance().getBedWarsManager().getBedWars();
BedWars bw = bedWars.stream()
.filter(b -> b.getType() == type)
.filter(b -> b.getStatus() == Status.LOBBY || b.getStatus() == Status.STARTING)
.filter(b -> {
try {
return Lobby.getInstance().getCommon().getApi().getPlayerCount(b.getName()).get() < b.getType().getMaxPlayers();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
})
.findFirst()
.orElse(null);
Yes, i tried this https://www.spigotmc.org/resources/bextraevents.19622/ but dont see working i think because the huge difference between versions
dont do blocking calls on the main thread
solve what
oh sorry didnt see the paste
You probably have to combine InventoryClickEvent + InventoryDragEvent + PlayerSwapHandItemsEvent
what's JoinCommand onJoin?
Any easy and fast way to do this?
Use the events and check if the offhand slot is involved (for the first two) then cancel them. Shouldn't take too long
yes
Please forgive me for being a complete noob at Eclipse, how do I fix this?
The project was not built since its build path is incomplete. Cannot find the class file for org.jetbrains.annotations.NotNull. Fix the build path then try building this project
ok, thanks
Add teh annotation dependency
are you using maven or gradle?
I believe it's maven.
so you do have a pom.xml file?
I do not
do you have a build.gradle or build.gradle.kts file?
Neither
then you're using neither maven or gradle. then you'll have to add jetbrains annotations manually to the project libraries or however its called in eclipse
throw new RuntimeException(e);
💀
that's what generates automatically when you press a button
I just installed Eclipse because it's free. I looked at JetBrains but it requires some money to use... even for personal use...
not really
intellij is free
Convert to a maven project in Eclipse, it's easier
for community version
https://paste.md-5.net/nupivufata.coffeescript
The prepared statement gets closed in the try with resources and I cant populate the cached row set in the try with resources
Whats the best solution?
intelliJ is free, and imho it's much easier to use. I wrote a small blog post about how to setup a project in IJ using maven (which saves you from a ton of issues in the future): https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
How can i check in inventory click if the inventory is the off hand?
Thank you, I will give it a read now.
https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse) This (not the video) tutorial is a full how to make a Maven plugin for Spigot in Eclipse.
Google and Stackoverflow don't offer much advise regarding Java. I normally code C# and PHP sites. :/
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.
F
Like I said I'm VERY new.... like... 10 minutes new... xD
https://paste.md-5.net/nupivufata.coffeescript
The prepared statement gets closed in the try with resources and I cant populate the cached row set in the try with resources
i think the problem is that you put the CachedRowSet into the (...) resources part of the try / cache
does it really fail while populating it, or when you try to use it later?
Yeah and I added this to the catch Logger.info("Failed to populate");
Thats also with moving the CachedRowSet into the body of the try ^
So I found the pom.xml lol. I was looking in the wrong folder....
If you got a pom.xml file, you have to use maven to compile, not eclipse's builtin biuld system - but idk, I haven't used eclipse in 4 years or so
Try Right click proejct -> Run as -> Maven build
I installed the community edition of intelj
compare the slot or rawslot.
wait, is it even possible to modify an array after its been created?
what im doing might not even work
Yeah?
array[index] = value
Chunk chunk = block.getChunk();
NamespacedKey key = getKey(block.getY());
PersistentDataContainer pdc = chunk.getPersistentDataContainer();
byte[][] currentData = ByteFlattener.unflatten(pdc.get(key, PersistentDataType.BYTE_ARRAY), 16, 16);
byte index = findIndex(chunk, uuid);
if(index != 127) {
currentData[block.getX() & 0xF][block.getZ() & 0xF] = index;
}
if(currentData.length == 0) {
return;
}
pdc.set(getKey(block.getY()), PersistentDataType.BYTE_ARRAY, ByteFlattener.flatten(currentData));
}``` i'm getting the 2d array from the PDC and modifying it
Wait whats the default value for the unused slots, cause ik byte cant have null
0
Ok thats not good I need to rework everything 💀
xd
what are you even trying to do
A system that stores a player's UUID in a block (storage efficiently)
using PDc
wait if I put
byte[0][5] to something, will the below values auto get filled to 0?
k it doesnt matter either way I just fixed it
byte[][] currentData = ByteFlattener.unflatten(pdc.get(key, PersistentDataType.BYTE_ARRAY), 16, 16); lets say the PDC doesnt have anything, will it just return an empty 2d array?
Does anyone have an idea about this? I even tried just using a normal try and closing it in the finally statement and that didnt work
Depends what ByteFlattener.unflatten does
pretty sure array1d is gonna be null
if the pdc doesn't have anything for that key, it'll return null
but I thought primitive data types cant be null
an array is an object
Array isn't a primative data type
PDC computeIfAbsent when
Could not get HEAD Ref, are you sure you have set the dotGitDirectory property of this plugin to a valid path?
So close...
Nevermind commented out the plugin from the pom.xml
ok I found it
I'd greatly appreciate some input from anyone better versed in ProtocolLib than myself here - I'm trying to intercept tab completion packets and send a new one in their place, but I'm not sure how to do that specifically. This is what I've got so far
I'm sorry whats an event?
Please inform me if that's the case, my goal is to intercept the tab complete packets in order to send a separate completion when a player performs /version + tab
?jd-s
TabCompleteEvent for command arguments, and PlayerCommandSendEvent for commands
So you probably want the former, TabCompleteEvent
Is it possible to send custom completions instead of the regular ones with commands, including their arguments?
If I were to attempt to disable /plugins + tab for example
Yeah you can clear the suggestions in that event and add your own. That list is mutable
Or even just setCompletions(new ArrayList<>()); if that's more your cup of tea :p
How would I check if the player attempts to do a list of specific commands though, I don't want to clear all chat completions
getBuffer() gets you the command that is being tab completed
I think it includes /? I don't remember off the top of my head
How does the statement get closed?
I honestly had no idea, thanks for educating me, I appreciate your help
Your prepareStatementWithParameters() method is using a try-with-resources which closes it at the end of the method scope
^ you want to not use try with resources here, but honestly I would reccomend not returning a PreparedStatement instead take one as a parameter
Tis why we don't return result sets / statements
If you remove your try statement in your second method there you'll be fine. You're already assigning the value in a try-with-resources in your executeQuery() method
Alright thanks
Whats the better alternative in my case? I dont to repeat the same code in 2 methods
pass it in as the parameter
you can do this in a static method too
it decouples it from your class
plus would allow you remove the query parameter would also allow you to have a void return type
pass the prepared statement to the executeQuery right?
whut
Oh, yeah, no, you're fine. I'd just keep them as internal utility methods to facilitate creation of other more public methods that don't return an SQL type
I'm making a /sell plugin in version 1.6.4, and all the items sell normally, except the lapis lazuli
In an ideal world, callers of your methods there aren't going to interact with much SQL API at all
private final void addParameters(PreparedStatement statement, List<?> parameters) throws SQLException {
for (int i = 0; i < parameters.size(); i++) {
s.setObject(i + 1, parameters.get(i));
}
}
}
tbh I'd personally do it like this. You really shouldn't be passing around AutoClosables IMHO try with resources is really nice to make sure everything gets shut down I prefer to leverage that
How to detect the movement of an item from an inventory to another inventory? basically i want to block the player from putting fuel into a furnace
InventoryClickEvent
that way i block all kind of clicks, i just want to block the ability of puting an item in a single slot
Or InventoryMoveItemEvent if you're talking about hoppers
i tried InventoryMoveItemEvent, but it doesnt catch the event even with a logger in it
if there is a way to get the position of the clicked item in the inventory using InventoryClickEvent
i could use that but i dont know of such method
Oh alright, since I cant addParameters in the try with resources (..) I would have to do this?
https://paste.md-5.net/lafubusuvu.coffeescript
hey guys can i have a problem where whenever i save my yaml config the formatting gets messed up. below is an example before it gets saved
`settings:
debugMode: 'false'
updateChecking: 'true'
chatFormatting: 'true'
Chat - Moderation
hexChat: 'true'
antiSwear: 'true'
antiChatRepeat: 'true'
chatCooldown: 'true'
chatCooldownTime: '3'
Chat - Customization
joinFormat: 'true'
leaveFormat: 'true'
motdDelayTime: '3'
motd: 'true'
announceFormat: 'GRADIENT:e34034[ANNOUNCEMENT]</GRADIENT:e0af26>GRADIENT:b2de43%message%</GRADIENT:49d1cf>'now here is after it gets saved settings:
debugMode: 'false'
updateChecking: 'true'
chatFormatting: 'true'
Chat - Moderation
hexChat: 'true'
antiSwear: 'true'
antiChatRepeat: 'true'
chatCooldown: 'true'
chatCooldownTime: '3'
Chat - Customization
joinFormat: 'true'
leaveFormat: 'true'
motdDelayTime: '3'
motd: 'true'
announceFormat: GRADIENT:e34034[ANNOUNCEMENT]</GRADIENT:e0af26>GRADIENT:b2de43%message%</GRADIENT:49d1cf>`
you can see that announceFormat gets the single quotation marks removed
this is how i save the messages
`public static void saveMessagesGroups()
{
try
{
groups.save(groupsF);
groups = YamlConfiguration.loadConfiguration(groupsF);
msg.save(msgF);
msg = YamlConfiguration.loadConfiguration(msgF);
words.save(wordsF);
words = YamlConfiguration.loadConfiguration(wordsF);
settings.save(settingsF);
settings = YamlConfiguration.loadConfiguration(settingsF);
}
catch (IOException iOException)
{
console.sendMessage("&4Error Plugin Config Cant Be Saved. The plugin will not work correctly!");
}
}`
getSlot() ? it's return the clicked slot
?paste
@ashen schooner
quotes around string values are optional in yaml no ?
yes but some strings have it others dont
that is whats bothering me
this is the whole yaml
Remove them all then
it then empties out the whole config
if i remove the quotes from around these the whole config breaks
chatFormat: '%prefix%&7%player_name% &b%arrow% &7%message%' noGroupChatFormat: '&7%player_name% &b%arrow% &7%message%'
do you know what can cause that?
Also, true and false don't need to be encased in quotes if those are actually boolean values,
will opening them as a string still work?
Depends on how you setup your code.
so like ConfigManager.settings.getString("settings.updateChecking").equalsIgnoreCase("true")
Yeah that works
It does??
Pretty sure you can just use getBoolean though
^ Would recommend that
why would it not?
If I have a value of section: 'true'
#getBoolean("section") should fail since it's a string right?
Pretty sure spigot's config api will convert it
thank you i will try
okay thanks guys i did not know the % thing
Well if that's the case, then why tf do we not have interchangeable support for String and StringList for config sections like this?
section:
- "String 1"
- "String 2"
# VS swapping it out with
section: "One String"
REEEEEE
i have one more question tho
i switched to maven in idea and now i have this target folder
the files often get placed completely wrong inside of it
and in order for the build to work i have to rearrange it everytime
is there a way to automate this?
show your pom.xml
that's where it compiles your stuff etc
no, you should never touch that folder at all
except to copy out the finished .jar file
didnt i pr that yesterday
No
communism version
You were imagining it
:p
hi, i want to get an advancement so i used:
new NamespacedKey("minecraft", "story/balanced_diet")
but it says it's deprecated, what should i do?
Za Lenina
new NamespacedKey(yourPlugin, "...")
NamespackedKey.minecraft("story/balanced_diet");
but why my plugin if i use minecraft's advancements?
i dont get it
yes yes
ah yeah then do what coll said
can you help me?
add .toString() on titleColor
or insert + "" + between titleCOlor and the next ChatColor
ChatColor.FIRST_COLOR + "" + ChatColor.SECOND_COLOR
? like thi?
yes
thanks
np
Can you help me? where is the problem?
give the book to yourself, take it in the main hand, then enter /data get entity <yourname> SelectedItem, then show the output
I guess for a written book you'll have to set an author and title or sth
yees, i add the autor and is working
Is there a better way to check if a player clicks a specific item in your inventory other than by comparing by item name?
do you mean you wanna detect a custom item you created yourself or sth?
and why text is not in the center?
custom item i created
or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...
because your centerText method adds too many spaces
if its a premade code i guess it was made for chat or motd
and how should it be right?
only a few private players play on this server and no one has their own fonts so I want to centralize it because of that
Centering text isn't the easiest task since each letter is a different width. There is a thread that has a utility class that does this for you, but it isn't 100% perfect. That and it was mostly made for chat centering.
ohh okay
how does your centerText method even look like?
and why hex code dont working?
What method are you using for hex codes?
String serverInfoHexColor = "99B080";
ChatColor serverInfoColor = ChatColor.getByChar(serverInfoHexColor.charAt(0));
meta.addPage(centerText(serverInfoColor + "This book is about server..."));
you're only taking the first char of your hex color (7) into a normal color code
public static final Pattern HEX_PATTERN = Pattern.compile("#[a-fA-F0-9]{6}");
public static String formatHexColorCodes(String string) {
Matcher matcher = HEX_PATTERN.matcher(string);
while (matcher.find()) {
string = string.replace(matcher.group(), "" + ChatColor.of(matcher.group()));
}
return string;
}
ChatColor titleColor = ChatColor.of("#123456");
Any way for me to disable loading/generating the end? I just don't want the end, and I have allow-end: false in the spigot.yml config ):
[20:58:06] [Server thread/INFO]: Preparing start region for dimension minecraft:the_end
[20:58:07] [Worker-Main-2/INFO]: Preparing spawn area: 0%
[20:58:07] [Worker-Main-2/INFO]: Preparing spawn area: 0%
[20:58:07] [Worker-Main-2/INFO]: Preparing spawn area: 0%
[20:58:07] [Worker-Main-2/INFO]: Preparing spawn area: 0%
[20:58:08] [Worker-Main-10/INFO]: Preparing spawn area: 0%
if allow end is false (in bukkit.yml) it won't load; unless you have a multiworld plugin like multiverse also choosing to load it
that's in server.properties, but same
Gotcha, thanks
btw @sullen marlin is nether and the_end always called <default-world-name>_nether and <default-world-name>_the_end?
not if you disable the inbuilt ones and add one via a multiworld plugin
yeah sure, but the builtin ones?
I think so
ok thx
Like this? https://paste.md-5.net/gimubusiya.cs
Hello, with paper there is the method "#setPos" to set the location of an entity with the "ClientboundAddEntityPacket".
How to do it for spigot, so that could be compatible with every forks ?
is that an NMS Display?
Because setPos is a method from Paper I guess
yes
then setPos is an NMS method
Probably because it was added in later versions.
maybe..
what is this website ?
thank you
nop
?mappings
huh why not 🥲
Compare different mappings with this website: https://mappings.cephx.dev
Wait
too hard for me
What's the command for remapping?
?switchmappings
?nms
Ah
well if you use maven or gradle, you only need to add the remapping plugin and then it automatically does it
you just use the mojang names (setPos) in your code, and the remapping plugin turns that into the obfuscated name again (a_, e, ...)
what is this plugin ?
do you use maven or gradle?
gradle
Contribute to patrick-choe/mojang-spigot-remapper development by creating an account on GitHub.
yes but I need BuildTools
plugins {
id "io.github.patrick.remapper" version "1.4.0"
}
dependencies {
id "org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:remapped-mojang"
}
tasks {
remap {
version.set("1.19.4")
}
}
yes. just download and run it and select "1.19.4" and check the "Remapped" option
this is really long
what do you mean?
I don't have a good internet connection
oh yeah well it takes quite a while on first time
In my memories it took me 1h to download a jar
Can I use SynchedEntityData to define location, instead of doing it with setters from Display entity ?
why do you even need packets for this
To avoid using BuildTools
setPos method wasn't in 1.19.4 I guess
setPos is NMS
so my plugin is compatible from 1.20.1 to 1.20.4, but not 1.19.4
you just teleport the bukkit entity
.teleport is how you move entities with the API
why do you need to use NMS for display entities?
using nms is anti version compatibility
I have to use them to prevent entities from remaining after a crash.
.setPersistent(false)
setPersistent(false)
damn
damn
sniped
tree fiddy
Having an odd issue where i can join my "SimpleSMP" but no one else can they get "Already connected to this server"
Wrong place but you are probably not forwarding ports if using Bungee
Line 5 is the problem. I have a CompleteableFuture<Boolean> that returns if the player confirmed in the GUI. The problem is how do I provide a completable future that I can return with the getResult method? If I just initialize it to a constructor then its bad practice?
Class: https://paste.md-5.net/hozewusoca.cs
if you want to return a boolean from your future, just use CompletableFuture.supplyAsync(() -> { ... });
and initialize completeableFuture variable with the constructor?
no
it's a static method
CompletableFuture<Boolean> myFuture = CompletableFuture.supplyAsync(() -> {
Thread.sleep(1000); // Wait some time
return true; // return the boolean
});
Ik but the variable has to be a field so I can also return it in getResult
also why are you creating a new one here? you're supposed to complete the existing one, not create a new one
it looks like what you actually wanna do is to create an "empty" future right?
in that case yeah just use the constructor
yes
alright thanks
and then call complete on it later
make the field final so you don't accidentally change it later lol
I would love any and all notes ❤️
eh
The uh post I'm talking about is something I've been working on for like 3 days so it's now been posted / covered up twice
how does this look
bold the coords perhaps?
okay so I think I'm going insane, I need some help with this
okay so I have a record class like so:
Otherwise I like it but to be fair I think it'd be nice to leave the coloring up to the player
you're mutating the minLocation
stupid records not being immutable by default
oh
nah it's a location kek
stupid locations not being immutable
I'll see once it's working lol
Oh are the placeholders just not doing their placeholding?
Looks
Almost mwash
I would do (Orange color)%home-name% (Gray like |)in (Orange color)%world% tbh
That's why I said leave the coloring up to the player
nah the issue is more like... that I haven't written anything for the command yet besides this lol
would be cool but idk how you would achieve that
Haha gotcha no worries
works great
I get this a SQL syntax exception on this?
DROP TABLE quests;
DROP TABLE quests_rewards;
DROP TABLE quests_rewards_commands;
DROP TABLE quests_rewards_items;
show the exception
Looks perfect
Caused by: java.lang.IllegalStateException: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DROP TABLE quests_rewards;
The tables exist and even when I added "IF EXISTS" it still failed
are you using a separate execute("...") thing for each line?
no
you need to
Does /home (no args) take you to your first home
it takes you to your home called "home", if any
I guess that works
I stole the essentials behaviour
/sethome -> sets home named "home"
/home -> goes to home called "home"
I swear I remember essentials /home just showing a list of homes if you have more than one
Maybe I’m insane
oh yeah true. However /sethome sets a home named "home"
I remember always getting annoyed about having to do /home home
Basics does not have that issue!!!!1111
lol then you only have a list with 1 home and it sells you to specify a home
home-list: "<green>Available homes: <gold><homes></gold></green>"
home-list-entry: "<hover:show_text:'<gold><name></gold>\nX: <gold><x></gold> <gray>|</gray> Y: <gold><y></gold> <gray>|</gray> Z: <gold><z></gold> <gray>|</gray> <gold><world></gold>\n<color:#994499>Click to teleport</color>'><gold><click:suggest_command:'/home <name>'><name></click></gold></hover>"
home-list-separator: "<gray>, </gray>"
yeah that is very easy to read right
html style
do you have a better idea for the placeholders? Currently it uses <name>, <x>, <y> but someone could have declared global tags in custom-tags.yml with those names, so I think maybe module-specific tags should have a special name, e.g. <%name%> - although that is probably something people wouzld use for custom PAPI tags in custom-tags.yml lmao. So maybe <$name> <$x> etc?
<_name>
<$name>
<%name%>
hm...
ok tags must be this
why does IJ complain about this?
yo guys
i'm trying to make EventListener system in a unity game
Currently i have made a class loader on c# inside the project which basically loads all of the mods in game's mods folder
now i need to code degraded spigotmc code for unity game
anybody want to participate(help me understand how to make an event system)?
my first mod basically changed a cube mesh to sphere and applied nicholas cage's face as a texture 🙂
What i currently don't understand is why event needs a handlerlist
and what is PluginManager actually for if it doesn't store a Collection<Listener> or Collection<EventHandler>
or if it does, how is server avoiding bottlenecking when 9999 events happening at the same time are sent to 9999 listeners and processed
and also when some of them are cancellable, listeners process their cancellation 💀
There are also custom events(which i'm gonna implement by adding components which extend AbstractEvent to gameobjects on the scene)
wdym
fun fact
it doesn't
but server is somehow 20tps most of the time
why wouldn't it be
without listeners its just an empty for loop
listeners and their actions make it take time
yeah but what bout internal listeners?
like?
idk some
server sends packets
idk if they are also handled by listeners
some internal ones
iirc packet handling is done by another thread
events (at least many of them) are in the same thread as bukkit
don't mods also use event system?
this may not be correct tho
wdym?
i never made mods but i doubt they do
it's even worse
that is not related to the server
but modded minecraft still doesn't lag much
forge does that i guess
it would work the same way
so that's related not to the server, but to my problem 🙂
shouldn't matter
i have no idea what that is
maybe
not quite sure if that would skip the events from happening or add them in a queue or smth
yeah i would definitely need a queue
tho tickrate should probably be on 50-60 like fps
like in csgo where it's 64
it sucks
don't bother to download
anyways, ticking system should be your go to answer
i think so
this feels kinda cringe
if you got any other ideas just as performant as this is, use it
one list for everything happening in the game
how else would it work tho?
separate list for every type of event xD
Much memory would be used but time is saved
maybe a map with eventtypes, listeners
or table idk whatever its called in c#
dictionary
c#'s hashmap
on every event happening i need to select which listeners to send event to
public void processQuest(Event event) {
for (HandlerWrapper wrapper : registeredHandlers) {
Method handler = wrapper.getHandler();
if (handler.getParameterTypes()[0] != event.getClass()) continue;
Quest quest = wrapper.getQuest();
try {
handler.invoke(quest, event);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}
this is a method i used 2 years ago
it was made for a quest plugin
hashmap is probably a good solution actually
registeredHandlers was a set in this plugin but yeah like i said its old lol
bruh
getting all event types which are not abstract
like this actually
since EventDescription is abstract
defaultBalance: 100
######################################################################################################################
setCoins:
sendSetCoinsMessage: true
setCoinsMessage: "&fYou have just set &c&l%player%&r's balance to &a&l%playerBalance%"
######################################################################################################################
addCoins:
sendAddCoinsMessage: true
addCoinsMessage: "&fYou have just added &c&l%amount% &rto &a&l%player%&r's balance!"
######################################################################################################################
removeCoins:
sendRemoveSuccessMessage: true
removeCoinsSuccessMessage: "&c&l%coins% &rhave just been removed from your account!"
sendRemoveFailMessage: true
removeCoinsFailMessage: "&c&lYou do not have enough coins to perform this action! You currently have %currentCoins%!"
######################################################################################################################
How do we feel about this?
I forgot to add the default removeCoinsFailMessage and removeCoinsSuccessMessage so thats fixed (same with the slight pathing error for removeCoins)
Also I think it's worth mentioning setcoins / addcoins method is for admin command usage hence the notifyTarget object
RemoveCoins I was handling a bit differently functionality wise... however I don't think the notify target is necessary there
private final EconomyManager economyManager = new EconomyManager(this);
@Override
public void onEnable() {
registerCommands();
enableLogInfo();
loadConfig();
}
private void registerCommands(){
getCommand("coin").setExecutor(new CoinCommand(this, economyManager));
}
Also would this be correct initialization of economyManager? or am I just dumb
Changed, working on renaming playeruuid
What do you think of the configurablility options?
public variables icky
mmmm....
public boolean sendSetCoinsMessage;
public String setCoinsMessage;
public boolean sendAddCoinsMessage;
public String addCoinsMessage;
public boolean sendRemoveSuccessMessage;
public String removeCoinsSuccessMessage;
public boolean sendRemoveFailMessage;
public String removeCoinsFailMessage;```

Yeah that's not great
What you should do instead is just have a sendMessage method
Where you pass a message identifier
And if that message exists, it gets send
It it doesn't, whatever
Hmm yeah that sounds a lot better haha
How does the structure look so far?
Other than the addressed issues ofc
Give me a second I'm dealing with a plugin that decided to nuke all of its player data in a production server
How lovely
I am having a problem with my plugin where on server shutdown it isnt reliably removing entities from the world. I need them to be deleted when the server shutdowns, and I am doing so by the onDisable event. Should I be doing it based off an EventHandler for world unload or something similar? Or is my issue elsewhere?
You should probably move this logic to another helper method and call that method onDisable
well yeah
I was not talking about my code structure
I was talking about how I listened for server shutdown
I'm also not sure if running a slight delay might help
I think that the world would be unloaded by then though no?
this isn't going to work, you would need to remove your entities on next startup. In order to delete entities you need to load chunks, the server is unloading chunks when it is shutting down
I'm not sure if that's detectable, since onDisable means your plugins disable
thats the issue, if the only way to delete the entities is on startup, how does someone with my plugin ever get rid of the entities?
reloading the plugin
if they want to remove the plugin*
or when you run the entity cleanup logic
perhaps you provide a command or something for the clear entitys
ig I could add some extra logic to allow a cleanup command or what not
but that would be a pain for both me and the consumer
the plugin handles everything automatically (by deleting on startup) so the consumer never sees the issue until they go to delete the plugin. its not something they would regularly need to do
so I guess I will just make a "disable" command which just disables the entirety of the plugin so that it can be removed without the left over entities
(the entities are the plugin)
"its not something they would regularly need to do" I think this answers your question, you just simply need to make cases for when this function needs to come into play
hmm
Entity.setPersistent(false)?
does that make it not able to save?
yes
thats exactly what I need, I didnt realize that existed
by doing it on startup, they record where their entities were at
on startup you take those locations, load the relevant chunks, remove your entities if you need them removed
I already do that, the plugin functions fine except for deleting it
but now I can just delete all of that code
and just do what md said
I mean
You could leave what you have and implement extra functionality... just keep expanding it
wdym
As in every single case for when a user needs to clear entities
It's really just extra user functionality benefit ya know?
in my plugin the entities are text displays that are passengers to entities and show their health, they should never need to be cleared (their visibility and what not is handled elsewhere, dont worry about that)
the only reason they should ever be deleted is on shutdown
ah gotcha
yeah
always pops outa the woodworks too
Sucks being self taught over spigot api and not knowing all the solutions D:
not sure there is any other way to learn spigot
pretty sure everyone, including the tutorial makers are self taught, there are not really "docs" from the developers of spigot themselves, just the community in the forums
the javadocs are a lifeline
Well I just meant that my experience is not as extensive as others, and to just have this information on command is impressive. I get the docs are easily available but it's hard to sometimes search for what you need
ah yeah, I just let github copilot tell me what it thinks is best, half the time it has a brilliant solution, the other half it leads to me to the right answer through some javadoc digging
Plus they can just take "what your function does" and be like oh you gotta do it like this or this and it's pretty cool imo
I sent my towny addon to the head dev guy of towny advanced, and he liked it, put it through some ai thing and it gave me an a+ haha
Javadocs are not hard to understand. The part that can't really be conveyed is how everything is implemented. Implementation of an API can be different even if the API itself is the same. IE, order of events are not necessarily guaranteed for example. So an event coming before another is sometimes just a coincedence and can't be relied that in the future to not change. Some of us here have been doing programming long before MC came around 😛
ie: when you don't know what you need, its hard to search for it,
sometimes yeah
I also hate looking through docs for long periods of times
As for the entities problem you can do what MD said, but I would still implement a method that checks on startup that they didn't stick around
this isn't a new problem
well yeah, I meant something more like: I just found spigot 30s ago, how do I make a command?
it will take a while before you figure out how to even register the command, or how the syntax works and all that stuff
if you don't know how to read the documentation sure
even though the javadocs outline the actual methods and classes, it doesnt really help with the true implementation of it
Oh that's why I got stephans udemy course haha
just for the spigot basics pretty much... I should probably finish that course because there are still a lot of concepts I have to come back to
I would have never found this.getServer().getPluginManager().registerEvents() in the javadocs, but maybe I am just bad at looking through them
Once you understand a language, IE java for example. Its not hard to read API documentation and it isn't all that more difficult to devle into the implementation yourself to see how it was implemented or not implemented
so someone who actually has been programming in Java for a long time, can indeed pick up something like spigot and code something within the first few minutes
without all that much difficulty because Java code isn't suddenly different
my exact process over the last 4 years
Though to be fair, I learned everything I know about java through minecraft framework / spigot api so
that isn't a bad thing
And about 14 pages of java 8 bible
what is bad and kind of annoying is those new to both come here pestering with a million questions
you should first attempt to learn it yourself and do the work yourself before coming here
Yeah like I said, I got the udemy course for that exact reason. Learn the damn basics and then you can start to learn by yourself
by yourself as in without guide from others
ie:
I started programming by first learning web development, then I moved to VB and then it was onto C and C++
thats the other hard part. its difficult to learn a programming language period. I get its not really that hard, but it takes a lot of hours, a lot of practice, and there is always something more to learn. it takes a pretty big amount of information to be able to even make something useful out of a programming language, and that for most people is too much effort. They would rather make something before understanding how its made. That is how I learned, I just didnt ask others questions I just googled until I understood it, or I just ignored it until I eventually leanred about it elsewhere
and somewhere in there, Java as well
Is js easy to learn
Well another large part of my learning java was also that when it came to spigot, pretty much everything you know from player experience can be related to the api
js is a lot different than Java
just imagine like python, but Java syntax

