It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
#help-development
1 messages · Page 430 of 1
Okay I'll just figure it out on my own you fucking cunts
ok
can you send particle packets async
Yes
We told him
He then said it didn’t work
Without showing what he did
o.O
Then got mad when i asked for code with the macro
well, I was scrolled up so I didn't bother reading the millions of messages since then lmao
but yeah would need to see code to see what they did wrong
Well then he’ll curse you out for not spoonfeeding him
is the Enum#values impl gone?
java.lang.Enum.values() method does not longer seem to exist

ah compiler adds it
O guess
https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/Class.html#getEnumConstants()
declaration: module: java.base, package: java.lang, class: Class
wtf would that even do on the abstract class Enum 
Is there a way to block Villagers with jobs from opening the trade window when you right click? I'm tracking the event and cancelling it but it still opens the trade window when you right click them.
iirc Enum had a field of type E[] but its gone now
Which event
PlayerInteractAtEntityEvent
Try just the PlayerInteractEntityEvent
What do you mean?
@EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
for(String characterId : ConfigService.getConfig().getConfigurationSection("server.characters").getKeys(false)) {
String uid = ConfigService.getConfig().getString("server.characters." + characterId + ".uid");
if (uid.equals(event.getRightClicked().getUniqueId().toString())) {
setFace(event.getPlayer(), (Villager) event.getRightClicked());
event.setCancelled(true);
LOG(LogType.Info, event.getPlayer().getName() + " right clicked " + event.getRightClicked().getCustomName());
String id = CharacterService.getIdByUid(event.getRightClicked().getUniqueId().toString());
SessionService.addSession(id, event.getPlayer());
break;
}
}
}
ick that's long sorry
That's what I'm using though
no
the "at" event is only called for some entities where the client sends the exact position where the player clicked the entity
when will it develop feelings
Ah kk!
ah kinda sucks but Enum#values returns a clone every time
clone of what
Though to be honest it makes sense
How can I copy worlds?
can u somehow change skull texture without reflection?
item or block
item
what version
i just got beat
1.18
I'm sorry, but how can I create a dictionary to use multiple elements?
it's been more than a year
wdym multiple elements?
do you mean a map?
i also forgot enums cannot extend a class 💀
enums already extend Enum
dammit java
I mean jave has some of the best enums out of any language imo
in most its just glorified constants
rust enums are the best
make a new class for that kinda of data
but enums can implement interfaces, ofc
no idea what that's supposed to mean tbh
id rather not make 1000 classes
oh you wanna have a Map that stores Player, a boolean, and an inventory per location
create a data class
Well like a Hashmap, but multiple values to one key
``` This don't work on the latest versions?
Map<K, List<V>>
yeah you would create some data class for it
When you click on a villager with a job and it opens a trade window. The background behind the trade scene gets darker. Is there a way to activate/disable that alpha background for a custom interaction?
or you need to have a list of Objects
just create a data class
private Map<Location, MyDataClass> myMap = new HashMap<>();
class MyDataClass {
private final Player player;
private final boolean myBoolean;
private final Inventory inventory;
// Constructor and getters...
}
there is haha
like what
you can also use a Triplet<Player,Boolean,Inventory> from e.g. javatuples
but tuples suck, better make your own data class
It's all client side
at this point i just want to recreate this whole program
imagine not making use of inline records
Darn, k thank you.
ok guys thanks
I mean yeah but like you need to create new ones everytime you want to change the data
i wish we wouldve just had proper structs instead of records
wat type of comment is that
How to check inventory for empty slots?
if(inv.contains(new ItemStack(Material.AIR))){{}
????
lombok
that’s kinda funny
instead of records
javadoc
@Data
no I know it’s a javadoc, it hs the two stars
I dont mean an annotation, I mean like an actual language feature like class and enum
a comment that humanity will extinct if i rearrange the constants order
there we go
i remember someday some dude self-advertised a weird plugin that shaded lombok
lol
why cant you override a static method lol
😭
Inventory#firstEmpty()
wanted to make an enum parent class that provides an immutable alternative for Enum.values without having to copy that array everytime
and what will be the result if there is no empty slot?
but java is like; you cannot let an enum extend smth 💀
just make an interface
thanks
then use composition
read the javadocs
-1
wait are enum instances/values static?
yes
They’re basically just static finals
Enum constants are just fancy static final fields
ofc, how else would ChatColor.RED work
oh man just by making it private
ugh cant make length static cuz an interface doesnt have its surrounding context
how would that work as static o0
returning Enum.values().length but i cant have the constants cuz im in a interface
if that interface is implemented by an enum, does calling getClass().getEnumConstants() returns the constants of the child class?
interfaces have nothing to do with getClass
getClass will return whatever that enum class it is
ye thats an isue too
uhh ye im fucked up
actually my idea is stupid, cant add static method to that enum through a parent class
toDrop = leftToDrop - amount;
leftToDrop -= amount;
this is identical to
toDrop = leftToDrop -= amount
right?
i've been working for 7 hours straight at this point
this is probably very obvious but i don't want to overthink
i just want to simplify
doesnt that assign leftToDrop to toDrop?
maybe idek
yes
somehow i've never stumbled upon or used such expressions
or at least that's what i recall
but toDrop will always be the same as leftToDrop
nice game that im forking lol
anyone know how to fix 84 out of bounds for length 5
do not call myArray[84] on an array that only has 5 elements
Is there a way to freeze a villager when it's walking and you setAware to false? If it's moving when you do that it gets inertia and slowly keeps moving in the same direction for a while.
Is there like a momentum property?
do you mean velocity?
ya
I'm setting aware to false and making it look at me but then it just keeps walking
villagers are more complicated than other mobs
why can an enum not just be a Iterable smh
they have their weird memory system that does this or sth
That wouldnt make much sense... there is nothing to iterate over when you have an instance of an enum
just want to loop over it without having to clone those constants on every invocation
like Enum.values() returns a clone and id rather not clone 3000 constants
could always have a method that returns a shared copy but thats ugly
ill probably do that then
then just cache the values in some class or sth?
public class EnumInfo<E extends Enum<E>> implements Iterable<E> {
private final Class<E> enumClass;
private final List<E> enumConstants;
private final int size;
public EnumInfo(Class<E> enumClass) {
this.enumClass = enumClass;
this.enumConstants = Collections.unmodifiableList(Arrays.asList(enumClass.getEnumConstants()));
this.size = enumConstants.size();
}
public List<E> getEnumConstants() {
return enumConstants;
}
public int size() {
return size;
}
@Override
public Iterator<E> iterator() {
return enumConstants.iterator();
}
// Whatever else you need
}
and then make that Iterable
Is there a way to hack it like set their gravity to 100000 to stop them before setAware to false?
ye i had that but i wanted to make it possible for an enum to implement it
I mean at this point just make your own Enum class
then cry when you realize you gotta write public static final in front of every constant
How would I approach making a custom Inventory class?
Which class would I need to extend?
none really
For GUIs?
Yes
just make a class that has an inventory
so the short answer is that you don't extend any Inventory class?
yes
exactly
because Bukkit cannot really create your custom inventory class if you had one
which is why you are restricted to the existing types/sizes
I miss the old days when you could make janky 7 row inventories
what do you mean?
would you just add an uuid field to the InventoryHandler class?
let's say you have a menu
no you can compare InventoryHolders
i mean like
or like do you mean the player that opened it?
well when you handle the open inventory event, the player will be given
and administrators can open other player's guis
you'd need to store the uuid of the owner of those cosmetics
could you make a seperate IdentifyableInventoryHandler class?
or
something like that
yes if you had such an inventory I would not store the cosmetic data in the inventoryHandler as that does not make sense
you probably have some data construct you use to build the inventory when the player opens it
the thing i'm struggling with is to keep track of the owner of those cosmetics
like an admin opens the gui of e.g Player_1
man made his own arraydequeue 💀
well idk what the actual system is but it sounds like you want to save your player's cosmetics to permanent storage anyways
so then you store it alongside the player's uuid
This is not a concern for the GUI.
Create a CosmeticsManager and a CosmeticsContainer class.
Inside you have a Map<UUID, CosmeticsContainer> where you map players
to their cosmetics container.
yes and then make an InventoryHandler that can show a CosmeticsContainer when the player opens that inventory
are bungeecord events async?
async relative to what?
the main thread (if bungeecord has one where most operations are done)
Depends on the event
Solved it. I wanted to use the setAI not the setAware
in my case, the chat event
is there any way of finding out which are async and which arnet?
If they extend AsyncEvent then they are async
?
uhh i was just thinking
pls you can make the plugin yourself (if you can) since I can't 😦 (1 16 5)
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
Has anyone else had maven issues since the intelij plugin update on the 19th?
which intellij plugin? wdym with "maven issues"?
hows that lazy? you give it a value immediatly?
the minecraft dev plugin always causes problems, but I never had any problems related to maven
Yeah my maven files are apparently not working in the slightest now. and Im utterly baffled. Its like maven is pretending the pom doesnt even exist and is doing its own thing
im also wondering where my getter is now, i wrote @Getter but where is the getter lmao
And my lbiraries are odd as heck
well it's called "getTransactions()"
wait is that decompiled or actual source? because if it's decompiled, the annotation shouldnt be there, and if its actual source code, the getTransactions() method overrides the getter annotation
what other fancy stuff can lombok do
no cluehttps://www.baeldung.com/intro-to-project-lombok#lazygetter
you can make it use fluent names, e.g. transactions()
you rename the field
well instead of isInlineDescription i want it to be hasInlineDescription but the field is called inlineDescription
if I was you, I'd just rename the private method to getTransactions0() or sth
ah, I don't think that's possible
?conventions
oh wait
@Getter(fluent = true)
private boolean hasInlineDescription;
this would do
oh with lombok
if i add @Builder to a record
does it have to make a SomeThignClassXBuilder
it just creates a static inner class
whut
so how does it make the record stuff
ry this
@Getter
@Accessors(fluent = true)
private boolean hasSomething;
source code:
and me thinking annotations would be a good idea
is that recaf
ignore the auto generated class in the first screenshot, that's bullshit and recaf only added it because it didnt know about the inner class
ah
here's the proper decompiled file (empty record with two fields + builder annotation)
just realized you cannot add javadocs to methods that dont exist 💀
if you e.g. annotate fields with NonNull (a lombok annotation), it looks like this
yes
what do jetbrains or javac ones
im guessing the same
nothing
are those just visual?
they only generate warnings
yeah
huh
epics life has been a lie
im gonna start using lombok ones
yeah I'll also switch to them
i wonder if theres a lombok thing to sysout fields
wdym?
one sec
private static final int integer = 95635;
public static void runSomething(int toCompare) {
@MAGIC integer;
@MAGIC toCompare;
if (toCompare > integer) runOtherMethod();
}
MAGIC being something lombok adds
erm what's that supposed to do, I dont really get it lol
sys out
data doesnt work on fields
it doesnt?
not applicable to fields
oh well then use Getter Setter
lombok is awesome for many things imho
yo can someone help me make a plugin that would simply respond a message when typed in? i have no knowledge of java or plugins
idk why people hate lombok but i've stopped using it recently just because
i just either use kotlin or deal with having IDEA autogenerate getters
then you gotta learn java
?learnjava
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.
this is starting to get messy, do people place them after the access specifier or smth?
any conventions?
Before
Preferably above
You can also @Getter the whole class
Instead of every field
lemme guess, there will be one field that should not be exposed
You can exempt that by making that getter private
how does lombok generate getters at compile time
thers nothing in the class for Getter
I usually do it like this
or if you annotate the whole method, you can use Getter(AccessLevel = ...) exempt certain fields
annotation processor
is there no other way
what's wrong with that?
effort
modify classfile
https://github.com/projectlombok/lombok/blob/master/src/core/lombok/javac/handlers/HandleGetter.java here's how it generates the Getters in javac
thats a lot of words
and here it is for the eclipse compiler: https://github.com/projectlombok/lombok/blob/master/src/core/lombok/eclipse/handlers/HandleGetter.java
which is gradle
javac
their code looks like it could use some lombok too
which field actually generates it
wdym
How do I cast a ray that checks for blocks in its way?
bruh how would i translate this to a getter and setter?
iconTable[u.iconId = lastCid++] = region;
isnt lastCid used as index
so iconTable[lastCid] = region;
idk when setIconId is called
Player#rayTraceBlocks or World#rayTraceBlocks or LivingEntity#getTargetBlock or LivingEntity#getTargetBlockExact
bruh 🤦♂️
i freaking forgot how to apply EnchantmentStorageMeta to a sword
Can anyone help me with this function? Im trying to raycast in the player direction and check if there are blocks in the way. If not ill teleport the player to the final location. If there are blocks in the way send a message to the player.
https://paste.md-5.net/ezajuvimed.coffeescript
Loop enchantments on the meta and add them to the sword
not tested, but I guess this should do like vanilla would do it
/**
* Applies an enchanted book to an item. This will not apply incompatible enchantments (either because the target item type doesn't support it, or because it conflicts with an existing enchantment), unless {@param ignoreRestrictions} is set to true.
* If the target item already has an enchantment of the same type, the higher level will be applied. If both levels are the same, the level will be increased by 1.
*
* @param book Book to apply
* @param target Target item
* @param ignoreRestrictions Whether to ignore restrictions
*/
public static void applyBook(final EnchantmentStorageMeta book, final ItemStack target, final boolean ignoreRestrictions) {
final Map<Enchantment, Integer> existingEnchantments = target.getEnchantments();
final ItemMeta meta = Objects.requireNonNull(target.getItemMeta());
newEnchantments:
for (final Map.Entry<Enchantment, Integer> entry : book.getStoredEnchants().entrySet()) {
Enchantment enchant = entry.getKey();
int level = entry.getValue();
if (!ignoreRestrictions) {
if (!enchant.canEnchantItem(target)) {
continue;
}
existingEnchantments:
for (Enchantment existingEnchant : existingEnchantments.keySet()) {
if (!enchant.conflictsWith(existingEnchant)) {
continue newEnchantments;
}
}
}
final int existingLevel = existingEnchantments.getOrDefault(enchant, 0);
if (existingLevel > level) {
continue;
}
if (existingLevel == level) {
level++;
}
meta.addEnchant(enchant, level, true);
}
target.setItemMeta(meta);
}
why it can be null?
because Location.getWorld() might be null when the world got unloaded after you got that location reference
location can probably be null at that location
o right locations weak reference world
Is it complaining about this line, or because of an error in it, or inside?
@brave sparrow Hello Mr Alex
I think you're probably the best person to ask this question as you worked on something like this in mineplex
Could you give me any directions on how the raid world for witherton was programmed
Like how do you create a new raidworld and how did you manage multiple raids happening at the same time
I want to be able to create a similar system which allows players to be teleported into a dungeon but I can't find any helpful videos online so I figured I'd ask for help
Any info would be greatly appreciated
Thanks Mr alex
is that line 43 in FurnaceQ? If yes, inv is null
yes
then your inv is simply null
those two should be the same right?
no
lastCid++ returns the current lastCid
++lastCid returns the current lastCid + 1
oh wait you do setIconId
yeah well then it should be the same I guess. no idea what your setIconId does
just a simple setter
does anyone got a good hex code translator? I used to have a good one but lost it
ig i could make my own
I just regex replace 𞉀 with &x&1&2&3&4&5&6
but you call it on some u object
while lastCid is in the current class / instance
so no idea
well i made the iconId private instead of public at the bottom
and wrote a getter and setter
what was replaced with .of()?
would anyone know how to go about using aspectJ to make the @Debug thing, i went and asked chatgpt but it just spat out incorrect stuff or not what i asked
Player#hidePlayer(Plugin, Player)
So like a mod can see a owner in /v , yes with permissions
How can I "spawn" a bed normally? I got a location and set it's block to a bed but it only sets the a half of the bed
by passing the correct other player?
player1.hidePlayer(..., otherPlayer) will make player1 not see otherPlayer
tysm
oh man
quick question; What is that weird line in the IDE, that light gray one?
120 chars limit
idk
or whatever is configured
ik there's something similar in... Fortran? Cause screens used to stop there.
yeah it's the "Visual guides" setting, 120 by default
is there anyway to view all your projects in the project sidebar, like in eclipse ?
just open the IdeaProjects folder lol
this also works
wdym
move to intellij
Oh you mean the „recent projects“
it has a sroll bar
no he means the bottom toolbar
yeah that’s throw if so
the new ui is so weird
looks cool but like wtf
hamburger menu for window toolbar
Guh
damn
File is
this looks more like c# than java
what the fuck
have they ever heard of a constructor, or a builder pattern
or kotlin named parameter constructor W
thy also have a Fi class which is basically a File wrapper and does some nonsense with old api
not even a Path
Im having a dumby java moment.
When making an instance of a plugin's api (e.g: The Coreprotect api) but i need it to be utilised in several classes, whats the general solution there?
How could I disable the collision between an entity and a player
Theres my dumb java moment xD
yes
iirc scoreboard teams will work, but that’s roundabout
also you don’t make an instance of the API
I tried that, but I didn't find a method for disabling collision in the Team class
does it make sense to wrap a bufferedreader around a buffered inputstream?
declaration: package: org.bukkit.scoreboard, interface: Team, enum: Option
however that javadoc concerns me, it says how players collide
I'll try it out. Worst case scenario, I could use ingame commands to create teams and disable collisions
tf
that’s definitely the worst case
but then i loose project specific build managers
true
Didn't find any other option
Hello, after a couple of months without coding any plugin, I want to create new things but I got a problem when I'm launching the server.
I got a start.bat with the following code:
@echo off
java -Xms1G -XX:+UseG1GC -jar spigot-1.19.jar nogui
pause
And when I'm launching the the server, I got this error:
Starting server
Unsupported Java detected (63.0). Only up to Java 18 is supported.
By the way, I got Java 19 as I can see when I'm using the command java --version:
java 19.0.2 2023-01-17
Java(TM) SE Runtime Environment (build 19.0.2+7-44)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.2+7-44, mixed mode, sharing)
If someone got the solution, thanks in advance for your help!
1.19 only supports up to Java 18
19 is bigger than 18 and therefore not supported
Just use java 17, this is the standard version now
up to don't means "higher or equal" ?
It means lower or equal
bruh why did this man create his own annotations
he probably has his own annotation processor too
ill be very happy if this thing actually runs
Map<Enchantment, Integer> EnchantmentStorage = null;
if(item.getItemMeta() instanceof EnchantmentStorageMeta) {
EnchantmentStorageMeta = (EnchantmentStorageMeta) item.getItemMeta();
EnchantmentStorage = EnchantmentStorageMeta.getStoredEnchants();
}
i did this ! :))
that is good
i can't take the item 😦
Try in survival
same thing
How are you setting the output
i set result
dammit
e.setResult(resultItem);
gradle is a joke to me
are you cancelling inventoryclickevents somewhere? tried it without any other plugins?
i'm running a fresh dev server locally
and there is only the plugin i'm coding
hm idk then
is it normal that when i delete the build folder in gradle, all code becomes an error?
and when building it goes away
I don't think that this is supposed to happen lol
Can someone help me with configurations? trying to save/copy the config.yml from my plugin file/jar into plugin/<plugin-name> has someone a advice, tutorial or a example code?
@Override
public void onEnable() {
saveDefaultConfig();
}
is that everything?
does that override the saved config after restarting the server
no
yes
okay thx and writing and reading in that file is that possible? i mean with code
getConfig() in ur main class or plugin.getConfig() if you have di
okay thx
don't forget to save the file after changing it
is getConfig() FileConfiguration?
yes
k thx
it's even a YamlConfiguration
Is there any way to have a config.yml file that's not editable
what would the purpose of that be
don't call saveDefaultConfig()
Is there a way that I can get a BlockState from a block or something to represent a snapshot of it?
Can I still access it?
then you can read the included config.yml but you don't have to save it
yes, getConfig() lodas the included config
erm yes?
getState()?
I am so dumb lmfao
lol
i feel you ikevoodoo
it happens for me too
.
I were thinking maybe it is a client side issue idk
my problem
is it possible to modify spigot logger format ?
I want to remove original timestamp
Alex how can I access another yml file that's bundled in the plugin but never saved
JavaPlugin.getResource()
Thanks
should give you an input stream, make that an input stream reader and you can YamlConfig.load() it
Why when selecting a cuboid region between 2 blocks, the borders are not protected, its just protecting the blocks inside the 2 corners
log4j.xml or something like that
hey, im new to minecraft development in general so forgive me if this question's dumb.
i got intelij & im working on a server project along with other devs who have the server project in github, yada yada
it seems like the spigot dependency is missing for me which is making it hard for my highlighting & importing stuff but for others it works completely fine, is there a way i could fix this?
let me know if i can reword this better
InputStream guiFile = plugin.getResource("gui.yml");
YamlConfiguration.loadConfiguration(new InputStreamReader(guiFile));
`java
private YamlConfiguration getIncludedConfig(String filename) {
try (InputStream stream = getResource(filename); InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) {
return YamlConfiguration.loadConfiguration(reader);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
tried but there is no effect
works on paper but not in spigot
I want to create a random spawn using a random x and y. How to get the z coordinate of the ground to make the player not spawn on the air or inside a block ?
Well then just consider it a WONTFIX
World.getHighestBlockAt(int x, int z)
returns a Block
or getHighestBLockYAt returns the Y coordinate
Red represents whats is not being protected and blue represents whats is being claim
fuck mojang. why did they add suspicuous sand, but no brushes yet
hm the wiki says upcoming in 1.20
all existed pre snapshot this week, so would be in datapack
sus sand is also 1.20 preview
hm both sus sand and brushes are included in 1.19.4 and can be obtained with bukkit, but seems like the brush doesn't actually do anything
besides breaking the block like normal
hold left or right click sus sand
right click
i think its right click
right click with brush doesnt do anything
hold it
I did
one moment
no
Yeah that's probably why
theres why
well bullshit then, why do they add things that only work if you install additional stuff lol
I mean, then the brush and the sus sand should go into the datapack as well
if you obtain it via bukkit its not int he game
it is
It is
bump
it is sus sand
suspicuous brushes lets go
Also you aren't meant to be able to get those items without the datapack enabled
Suspicious not Sus lol
same thing
No one will use the fully name
coll go find that video
Do you know Java?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
i just found something
setup a basic maven project for spigot ( https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/ ) then read stuff about spigot api
vanilla mc, no mods /jfr is a command
Ok thx
.... this has to be a joke
Ill read it
Your own plugin or worldguard?
Own cuboid class, works exactly the same as BoundingBox
Then why do you need it...
versioning 😂
Just create a BoundingBox using BoundingBox.of(blockA, blockB);
This creates a BB which includes both corners.
Im not using BoundingBox exactly, thats the problem
Then copy the code of BB
or extend BB
BondingBox doesnt exists on 1.12
ah
ugh why is installing the datapack so fucking complicated wtf o0
bc its probably not the best for servers
even though client and server are identical
also why did they still not finish the bundle? it's been like 4 versions now since they added it without actually adding it
¯_(ツ)_/¯
https://hastebin.com/share/aloyenupod.java
when I execute the command it says that the file doesnt exist
?paste the error
im guessng its file location being wrong, use new File(JavaPlugin.getDataFolder + File.seperator + "plots", file) instead
getDataFolder() is not static ¿?
its an example
so what can I sue
an instance of your plugin
so this wont work?
it will, with an instance of your plugin
Smh epic use # to denote instance methods
brain too smooth rn
Does he has experience with Java ¿?
oh sorry
ask them not me
some, i'm still learning
Right, i wont touch spigot api
Without knowing the lang itself, atleast the importants things, access modifiers, fields, methods, etc
when I run a command to delete a created plot, one of the methods is to delete the yaml file of the plot, but when I run the command, the file doesnt delete and it returns null
each plot has its own file
okay, why using yaml as storage? Its mostly designed for making configurations
yes, but if you want to make good i iwould use a db
But meh its up to you
I would get the file object of the plot you want to delete, and then use File#delete()
well, that's exactly what im doing already xd
File file = new File("plots/" + location.getWorld().getName() + "/" + location.getBlockX() + "," + location.getBlockZ() + ".yml");
what's wrong with this his line
the name of the files are the coords of the plot
-38,-24.yml as an example
the government
don't hardcode slashes
use new File(parent, child)
The file constructor handles slashes anyway
or at least use File.separator()
It's basically different char impl based on os
instead of using / you do File.separator()
that isnt the problem though, I had it to log file name it's meant to delete and I think it's to do with the rounding of the coords?
something like that
the file format is fine,it's the coords trhemselves
The file should be relative to your plugins data folder
What does java default to for the parent directory? Is it the same directory the jar is in
the working dir
Am i being a dumby?
for example:
cd /tmp/
java -jar /Users/mfnalex/mctest/spigot-1.19.4.jar
now the eula.txt will be generated in /tmp/
Well how about you show us the method which threw the exception?
its part of the lads api
The of method
you probably shaded the API
^
<scope>provided
That would be my first guess as well
in pom.xml
?
are you using maven?
yup
set the scope of the lands dependency to provided
OH M OTHER
<dependency>
<artifactId>Lands-Whatever</artifactId>
...
<scope>provided</scope>
Reason I question marked is because I didnt think would be it
earlier today
had issues with maven and whilst fucking around had removed the provided scope
forgot to add back in
if you remove it, it defaults to compile
so your plugin used the included version of lands which of course never got initalized or whatever
I know I did the dumb thing assumed "there is no way ive done that"
Idk what the subject is about or what's going on, but I would recommend putting your prefixes for things, like LandsUtilities into a getter or some variable, so you only have to change that one thing, if you lateron decide to change the prefix.
ok i found the problem
Math.floor(location.getBlockX())) + "," + (Math.floor(location.getBlockZ()))
i found my problem: using gradle, 500 lines build.gradle smh
it's still rounding up
instead of down
even though i'm using math.floor
why is this happening?
figure it out for me then https://paste.md-5.net/jihepaduve.js
that hurts
too much
that is the worst build.gradle I ever saw
oh alex if you want an example gradle multi module thing with nms look at epic spigot lib
jefflib hurts too much
dont blame me
i dont understand a shit of that magic
ill probably rewrite it
dude also using sun internal classes for annotation processing
it has no
- timestamp property to replace in config files
- profiles to change the output directory for the test module with one click
- no maven-checkstyle plugin or similar
- no custom javadoc configs (e.g. custom tags, or links to external javadocs)
- no compiler args for ACF
- no webdav support to deploy javadocs
- ...
I won't spend 29 hours to get it working in gradle if it works just fine in maven
anways its time to sleep
4, it does
i found it from just looking at projects
hm it also has no spigot remapping
paper weight
its the best we get
theres ways to set it up to use special soruce and hand remap stuff
i just let maven do it for spigot
is there a way to save a changed configuration with the code and if so how do i do that?
okay thx
erm you do realize that just copy/pasting MorePersistentDataTypes like that violates its license, right? lol
it does?
ScoreboardManager manager = Bukkit.getScoreboardManager();
assert manager != null;
Scoreboard board = manager.getNewScoreboard();
team = board.registerNewTeam(getPlayer().getName() + " -- " + UUID.randomUUID().toString());
team.addEntry(getPlayer().getUniqueId().toString());
team.setDisplayName("display name");
team.setCanSeeFriendlyInvisibles(true);
team.setAllowFriendlyFire(false);
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.ALWAYS);
I have this code to create a team. When I put another entity in that team, it can still collide and damage the player though. Could you tell me what I'm doing wrong?
why don't you just shade it instead
at least the following things
its an inteface
not that I#d care, just wanted to mention it lol
would it still work how i have it now, with PDT.whatever if i implement it in a class
wdym?
if i implement DatType in PDT, making it a class i would still be able to do PDT.STRING or whatever i feel like at the time
gonna test that rq
gradle kills my cpu
ratio
aand you can easily update by just changing the version :3
instead of having to copy/paste
oh also, i can build my spigot lib using paper weight without needing anything else done (buildtools etc etc) in like 4 min
wait untill you realise i used to have all the classes
Can someone help me? Why am I suddenly getting this error?
then i got lazy and just had the PDT interface and shaded more persistent data
send the full log
I cloned your lib in the minute you sent it, gradle is still not done setting everything up
most builds i have github workflows do take like 5
my pc took like 12
its still quicker than running buildtools
adds like 2 min each version
some dependency is fucked up.
run grep through your .m2 folder and see what it prints
grep -rnw ~/.m2 -e '\u0000'
It caches them, but I think it's per project instead of systemwide
that explains why cloning a gradle repo always takes like half an hour
it's still not done, after 17 minutes now lmao
I could have ran buildtools for every version from 1.16.1 onwards during that time
1.19.4 takes about 1 minute remapped
what the fuck
Yeah it doesn't take me long to build
It's stuck here
(or maybe still working)
Only if it's cached tho
my last build with github workflows takes 6 minutes to build
Idk how much buildtools caches
Does that mean that maven broke up all my dependencies?
cached 30 seconds for 1.19.4 remapped
how can i edit the config file in /plugin/<plugin-name>/?
i should 100% make a bat script to allows me to buildtools ver -flags
fresh run, uncached, less than 50 seconds. 30 seconds when cached
It is called a FileConfiguration and you can get it with JavaPlugin#getConfig()
How do you get this list again, including the prefix? Is there a function for it, or do I have to modify the Material#values array.
modify with YamlConfiguration#set("path", value)
then JavaPlugin#saveConfig()
getTranslationKey
On Material
Or just getKey or getNamespacedKey
Sth like that
The translation key will be eg minecraft:block.dirt or sth
The normal key is just minecraft:dirt
I'm trying to make fist contribution to the Spigot-Server, can anyone help with how I should comment my changes? Right now, I'm patching this
public void stopRiding() {
this.removeVehicle();
}
to this
public boolean stopRiding() {
return this.removeVehicle();
}
first* XD sorry
"you got fisted by mfnalex"
what does it return?
I doubt that this would get merged though, it would break existing plugins
whether or not it actually stopsRiding
Because you can cancel the unmount event
Which leads to a ton of unintended behavior
ah okay. anyway, changing the return type will break compatibility for existing plugins because the method signature has changed, IIRC
not sure though
Theoretically changing from void to boolean really shouldn't have any effect
Except for maybe some reflection stuff
It's also done in a few places in the Spigot/Craftbukkit patches already
it wouldn't work -> https://www.morling.dev/blog/refining-return-type-java-methods-without-breaking-backwards-compatibility/
If you work on any kind of software library,
ensuring backwards-compatibility is a key concern:
if there’s one thing which users really dislike, it is breaking changes in a new version of a library.
The rules of what can (and cannot) be changed in a Java API without breaking existing consumers are well defined in the Java language specification...
the return type of the invoked method is part of the byte code of that invocation, too. As developers writing code in the Java language, this might come at a suprise at first, as we tend to think of just a method’s names and its parameter types as the method signature. For instance, we may not declare two methods which only differ by their return type in the same Java class. But from the perspective of the Java runtime, the return type of a method is part of method signatures as well.
So I'm not an expert on this at all, but this is an nms function and not an API function, so as long as the API's signature doesn't change wouldn't it be fine to change?
well it does. One has no expected return the other does
yeah, if you don't change anything in bukkit, it wouldn't be a problem
Yes
WorldCreator to make a custom world
ChunkGenerator for custom world generation
WorldCreator can also load worlds
Or you can just load it with something like Multiverse
building 10 spigot versions is literally 3 times faster than waiting until gradle setup paperweight for 6 spigot versions lol
Cool, I guess I should have led with it being server code and not API code. Since it wouldn't break plugins, can anyone help with the diff comments?
It was done after 20 minutes or so
But building 10 versions from scratch took only 7 minutes
ig ur pc isnt optimized for gradle
Lol no gradle cpu flag
Diff comments? You generate them automatically
With create-patches.sh
Or however its called
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
Yeah, I get that, just worded it poorly
Specifcally, my guess would be
// Spigot start
public boolean stopRiding() { // PAIL void->boolean
this.removeVehicle();
}
// Spigot end
is that right?
^I'm talking about where to put the start and end comments
I guess. I only ever added stuff to craftbukkit, not nms directly
So i never needed those comments 😄
Looks good to me
Well, I guess someone will tell me if I'm wrong ¯_(ツ)_/¯
True lol
I always forget to run checkstyle
Enable the development profile, then see if throws errors
A tax plugin
make md and choco the tax men
I don't know what stopRiding() is from so I can't really inform you how to comment your code @sterile salmon
Players have to declare their ingame income or they get fined
nah im done
minecraft has a lot of model types for being such a blocky game
Its just the function in Entity.java (and inherited in a few other files) that does what it says
Original
public void stopRiding() {
this.removeVehicle();
}
Modified
public boolean stopRiding() {
return this.removeVehicle();
}
Is this set for Spigot? Or CraftBukkit
Spigot, I'm fixing an issue with EntityUnmountEvent, which isn't in CraftBukkit (I believe)
It isn't, yeah. So comments would be better like this imo
// Spigot start - Change return type from void to boolean (must be done to overriding classes as well)
public boolean stopRiding() {
return this.removeVehicle();
// Spigot end
}
(though the last parenthesis can be ignored if that's not the case)
We use PAIL for access changes and renames
Cool, in just a second can you check another function for me?
Yepyep
🎵 chocos pr confirming service 🎵
Alright,
Original
public void removeVehicle() {
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit
}
}
Modified
public boolean removeVehicle() { // Spigot void->boolean
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
// Spigot start
if (!entity.removePassenger(this)) {
this.vehicle = entity; // CraftBukkit
return false;
}
return true;
}
return false;
// Spigot end
}
Also in Entity,java
I'd adjust your end comments because we're not touching that closing bracket
public boolean removeVehicle() { // Spigot void->boolean
if (this.vehicle != null) {
Entity entity = this.vehicle;
this.vehicle = null;
// Spigot start
if (!entity.removePassenger(this)) {
this.vehicle = entity; // CraftBukkit
return false;
}
return true;
// Spigot end
}
return false; // Spigot
}```
Rest LGTM
Thanks!
inb4 md_5 disagrees 
running gradlew build only gives me a 1kb javadocs jar?
and ofc all the modules have one separate .jar but that's not the idea is it?
yeah but where is the final jar that one would use?
the one that includes core AND the nms stuff?
on my repo
gradlew publish
i make github workflow do that htough
yeah, i dont have gradlew build setup
even when I uncomment the repo and do gradlew publish, there is no .jar anywhere
I mean, it must create it SOMEWHERE?
yeah, it generates it and publishes it
yeah but where does it save it before uploading?
no clue
lmao gradle
my dog just let out a ripper
@worldly ingot I actually have one more
Original
@Override
public void rideTick() {
if (!this.level.isClientSide && this.wantsToStopRiding() && this.isPassenger() && this.stopRiding()) {
this.setShiftKeyDown(false);
} else {
...
}
}
Modified
@Override
public void rideTick() {
if (!this.level.isClientSide && this.wantsToStopRiding() && this.isPassenger() && this.stopRiding()) { // Spigot - moved stopRiding to condition so else statement is called when entity does not dismount
this.setShiftKeyDown(false);
} else {
...
}
}
I think I might need to keep the this.stopRiding() inside the if-statement but commented out
My bad XD
since this is deprecated what else should i use
skull.setDisplayName(player.getName());```
The original is a bit important for context though
what class is that on
Actual original
@Override
public void rideTick() {
if (!this.level.isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
this.stopRiding();
this.setShiftKeyDown(false);
} else {
...
}
}
if its ItemMeta
its a paper issue
I just let it ru npublish until it failed to upload, now I got a .jar but it only has the NMS stuff for 1.17 inside
ItemMeta
oh i see
darfick
@remote swallow where are the ones for 1.19 etc?
you use the same package for all of those so shadow ofc can only include one
is my brain that dumb
im gonna go fix that
Context?
.
Don’t think it has any meaning
so why is it used
I always assumed it was Please Add In Later lol
What does it mean in this context
Sorry I didnt see this discussion, but I'm pretty sure I already fixed it https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/commits/b5714184dbd36a89234e191ff203a7edb008db69
Np, thanks for fixing it though!
No commit credit for you :p
pull and rebase and it should spit out a good jar if you gradlew publishToMavenLocal
Can someone go sanity check getting the LandsAPI initiated as I stg I'm going utterly nuts
the boolean is probably better, but as you saw it means a lot of override changes and also potential hidden breakages
generally if the signature of a method is changing you need to keep the old one as well, which I guess would have been an option here
but given its currently just one spot, the isPassenger check probably suffices
Could we change it so that if the player does not stop riding, it resets the shiftKeyDown value to true?
The current behavior seems like it would mess up my specific use case (I'm making a slide mechanic by mounting the player on an invisible turtle)
Essentially, it would force unshift them as soon as they shift
how so?
Hold Shift->Tries to dismount but cancelled-> server-side isCrouching value set to false (in that code snippet) -> mismatch between isCrouching and whether the player is actually crouching
setShiftKeyDown(false) is only called if they did dismount
+ this.setShiftKeyDown(false);
+ return;
+ }```
You're right, I was looking at the commit diff and missed the minus sign
Thanks again for the fix
no problem
Is there any way to get the players of a scoreboard team or should I keep track of them on my own?
Teams have a getEntries() method which will get all the entries in that team and return them as a Set<String>
I thought that only contains Entries added with addEntry()
It gets all Entries on the team
Ok and how can I cast it to a player?
There is no dedicated getPlayers because teams can have more than just players as entries
if (team.getEntries().contains(<player name>)) {
Player player = Bukkit.getPlayer(<player name>)
}
That's one way, if you know the players name.
ah ok it contains the name thx for the info
can soem one help with this
If you want to cast all players in the team, you could do something like
List<Player> players = new ArrayList<>();
for (String name : team.getEntries()) {
if (Bukkit.getOnlinePlayers().contains(name) {
players.add(Bukkit.getPlayer(name))
}
}
Then just call players whenever you need to get a player from the team.
Probs not the most efficient way, but it would work
You have a malformed json in the log4j2.xml for your plugin
Meaning broken, syntax error
Thx for the code 🙂 but yeah I will probably just track it in a List because I have a Class for Teams anyway
is there any wiki about how to do proparly syntax
some tutorial
?paste the contents of the file or use a json parser
Is there a way of checking if a Material is crafted by wood like is there a method to get the recipe then see if it contains wood
