#help-development
1 messages · Page 656 of 1
ah
bro calm down
sorry btw if its kinda a noob question, its my first time coding in java i started yesterday lol
I already searched on google if you had read what I said! I usually don't use maven! I need a little help if this is too much for you then stop confusing me
add the maven shade plugin to your maven plugin list
define the dependency as scope compile
run mvn package
voila
thanks !
(as defined on the literal first google result https://maven.apache.org/plugins/maven-shade-plugin/usage.html)
It seems like the updateInventory() method doesn't exist, unless I did something wront
event.getWhoClicked().updateInventory();
I get an error, because "updateInventory() is undefined for the type HumanEntity
I think I need to convert it to a Player
yea human entity isnt a player
But idk how to that
simple
you're done ?
ye 👍
Like this ? ```java
Player player = (Player) event.getWhoClicked();
Sure
That works. I usually use this
if(object1 instanceof class object2){
...do stuff
}
```inside that if, the object 1 is cast onto object2 as an instance of class. Player extends humanEntity so Ido ```
if(event.getWhoClicked() instanceof Player player)```
Im trying to do is if the attackers held item is a stick and if the name contains "STICK" and the lore contains "------", "", "Købt af:" + p.getDisplayName(), "Må kun bruges i a", "", "-----" it should give the attacker blindness
But i dont know how to get the lore
if (attackerPlayer.getItemInHand().getType() == Material.STICK){
if(attackerPlayer.getItemInHand().getType() == Material.STICK.name().equalsIgnoreCase("STICK"){
if(attackerPlayer.getItemInHand().getType() == Material.STICK.name()){
victimPlayer.sendTitle("Hello", "This is a test.");
victimPlayer.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(60, 1));
}
}
}
but yours legit too
Okay thank you, ill try to use updateInventory() then
warning
yours can error
if the class is wrong
thats what instanceof does
it checks if its actually convertible
I'm kinda confused with this, its just a condition, it doesn't actually convert it to player ? Unless i didn't understood
it's one of those summary things
It does convert to Player, object2 will be player
Oh okay sorry , again its my first time in java i still don't understand everything about this language
public void onPistonExtend(BlockPistonExtendEvent event) {
List<Block> movedBlocks = event.getBlocks();
movedBlocks.forEach(b -> {
Location oldLocation = b.getLocation(); // block location before
Location newLocation = b.getRelative(event.getDirection()).getLocation(); // block location after
db.removeBlock(oldLocation.getBlock().getLocation());
db.addBlock(newLocation.getBlock().getLocation());
});
}``` why this event updates only one block()
I'd strongly suggest using PDC to identify custom items
they use 1.8 probably
Yeah i do



"The Java feature 'Pattern Matching in instanceof Expressions' is only available with source level 16 and above"
I think the fact that i'm coding a 1.8 plugin and i'm on java 8 is the issue ?
Well, ItemMeta#getLore()
yields you a list of strings
just split into two lines
java got good around java 9
im so used to it i forget some things dont work in java 8
wdym in two lines?
if(object instanceof Class){ //check class
Class object2 = (Class) object;
}
oh okay its as simple as that
ty !!
Its basically the same as my method but you're checking beforehead if its possible
yea. By the way
some people advertise for keeping your clauses as shallow as possible
which isnt always applicable, sinnce sometimes you need code for both possible outcomes of the condition
essentially, instead of inside if clauses, you negate conditions and return if your code wouldn't run anyways
if(! (object instanceof Class)) return;
Class object2 = (Class) object;
that way your code can be more readable
in most cases it should be fine either way though
That's what i usually do , my "main" language is javascript so i'm kinda used to the main syntax of java
more or less the only thing in common between those is the name lol
It works !!! The item is sent in the trade menu
However is still have it in my inventory, I just need to delete it
Thank you so much for the help 🙂
np
inventories are one of the more finnicky things
just hope nobody finds a dupe glitch
stout shako for 2 refined
no a lot of thing are common, thats why i got used to it so fast
hahaha even if its the case its just a mini game so its not that gamebreaking
I dont have the option
ItemStack attackerWeapon = attackerPlayer.getItemInHand();
Material weaponType = attackerWeapon.getType();
String weaponName = weaponType.name();
ItemStack weaponLore = weaponType. <- ItemMeta dosent exist
its like a bedwars but for french peoples lmao
We need a library that implement PDC for 1.8 somehow
no thanks
if you create more stuff for 1.8 it gives people reason to still use it
Well yeah
But people will use it anyways, so why not
I wish there was like a seperate line of updates that added everything modern minecraft added besides the new pvp mechanics so people would just use "1.20.1-OldPvP"
Maybe also remove shields
Sorry i dont understand so ItemMeta weaponlore = attackerWeapon?
Okay thanks, but how do i check for more lines? i cant do "line1", "line2"
Hey, me again lol
How can I clear an inventory slot ?
I tried inventory.setItem(30, null); and inventory.setItem(30, new ItemStack(Material.AIR))
None of them works, it threw an error
hi bro i have a question for u
im getting player last online date with relative i mean like 10 hours age
this data is constantly changing one day after this will be 1 day 10 hours
if i add this to database is there continuous data updating in the database?
btw i used library for get relative time
save the epoch an convert it to relative as needed
wdym for that
save System.currentTimeMillis() and convert it to relative tiome as you need it
im trying to give a clock a simple new texture when it has a specific custom model data, but this causes vanilla clocks to lose their texture. any way i can avoid this?
I am trying to do if a player is gettig hit and if the attacskers item is a stick and the name contains "STICK" and the lore contains ".." the player should get a title and blindness but the player dosent get anything and it dosent send anything in the console, i think the problem is that in the lore if the stick is the players name but i cant see why it should work when i use contains
This is the lore on the sitck: -----", "", "Købt af: " + p.getDisplayName(), fMå kun bruges i a", "", "-----"
if (weaponName.contains("STICK")) {
String weaponslore = "-----" + "\n" + "\n" + "Købt af: " + "Må kun bruges i a"+ "\n" + "\n" + "-----";
if (weaponlore.getLore().contains(weaponslore)){
System.out.println("19199191");
victimPlayer.sendTitle("Hello!", "This is a test.");
victimPlayer.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(60, 1));
}
}
you shouldnt check names or lore for custom item functionality, i recommend you put a persistent data tag with a string ID on your custom item and check for that data tag instead
look into PersistentDataContainer
their on 1.8
ah
also, your lore detection doesnt work because you have line breaks in your string
lore isnt done with line breaks
its a list of strings
Anyone got an idea?
well what error is thrown? setting a slot to null should be fine
i do it all the time
Could not pass event InventoryClickEvent to rushplugin v0.1
org.bukkit.event.EventException: null
Here is my complete code :
public void onClickEvent(InventoryClickEvent event){
System.out.println("A click event pccured. Here is the raw slot :");
System.out.println(event.getRawSlot());
Inventory inventory = event.getInventory();
System.out.println(inventory);
if (event.getRawSlot() == 0 || event.getRawSlot() == 1 || event.getRawSlot() == 2) return;
if (!event.isShiftClick()) return;
if (!inventory.getType().equals(InventoryType.MERCHANT)) return;
ItemStack cursorItem = event.getCurrentItem();
inventory.setItem(0,cursorItem);
if(event.getWhoClicked() instanceof Player){
Player player = (Player) event.getWhoClicked();
player.updateInventory();
inventory.setItem(30, new ItemStack(Material.AIR, 1));
player.updateInventory();
}
}
I'm basically trying to make the villager trades shift clickable
well what is null
i removed the null rn
ok but that wasnt the issue
but it was giving me the same error
?paste the full error
Not just one line
you're getting a null error, therefore something is null
and such an error is thrown when you try to call a method on null
Okay, sorry
https://paste.md-5.net/befecusuzu.cs
the villager doesnt have 30 slots
Its the line 49, so its the inventory.setItem()
you should really read your errors and not just assume something you think of broke it
they do
no they dont
it says indexoutofboundsexception
I used this https://www.spigotmc.org/wiki/raw-slot-ids/
And when i'm clicking on the first slot of my hotbar, the System.out.println(event.getRawSlot()) return "30" on the console
That’s the raw slot though
Yeah
Your inventory is separate from the villagers
But i'm using raw slot on the inventory.setItem() of the top and it works fine
event.getInventory() returns the villager inventory, so you're limited to slots 0 1 and 2
public void onClickEvent(InventoryClickEvent event){
System.out.println("A click event pccured. Here is the raw slot :");
System.out.println(event.getSlot());
Inventory inventory = event.getInventory();
System.out.println(inventory);
if (event.getRawSlot() == 0 || event.getRawSlot() == 1 || event.getRawSlot() == 2) return;
if (!event.isShiftClick()) return;
if (!inventory.getType().equals(InventoryType.MERCHANT)) return;
ItemStack cursorItem = event.getCurrentItem();
inventory.setItem(0,cursorItem);
if(event.getWhoClicked() instanceof Player){
Player player = (Player) event.getWhoClicked();
player.updateInventory();
int slot = event.getSlot();
player.getInventory().setItem(slot, null);
player.updateInventory();
}
}
Will this work?
So isnt this a list? becuase it is still not working
weaponlore.setLore(Arrays.asList("-----", "", "Købt af: ", "Må kun bruges i a", "", "-----"));
thats a list yes, but when you're checking the lore you're checking if the lore contains that full string
which it doesnt
String weaponslore = "-----" + "\n" + "\n" + "Købt af: " + "Må kun bruges i a"+ "\n" + "\n" + "-----";
this is the problem
update : it doesnt lol
you're checking if the list contains that string
it doesnt contain it
and it seems with that string you just assume line breaks work for lore which they dont
If you want a line break you add another entry to the list
yeah he seems to understand that when he actually creates that custom item of his, i dont know why he uses line breaks to check if the lore actually matches though
anyway does anyone know how this works
Oh okay thanks
use Bukkit.getLogger().info("text) instead of system out println
its fine to use sout for simple debugging
ok
Hi.. I recently decided to try creating plugins, and I needed to create a custom item tag, and for this i need NMS, in all tutorials there are normal methods like .hasTag, .getTag().. And I only have an alphabet...
?nms
here you can view what your methods translate to
oh thanks
you could also just get the mojang mappings
thats recommended yes
Logger can only take strings
Anyone has any ideas to check if the player is clicking in the inventory I created
And that check must happen under InventoryClickEvent
Something other than comparing titles
oh simple
you can internally create a new class that extends inventory
call instanceof on the clicked inventory
Don't have to make class that extends
so ill make my custom gui class just extends inventory pretty much
i mean thats what i did
Just save your inventory and check if (yourInv == event.getClickedInv())
couldnt tell you what for though lol
you can create your own abstract class too, if you want
keep in mind you cant actually make new guis tho
you need to use the layouts in vanilla + the unused storage container layouts
(1...6 x 9 slots)
Why is this if statement false?
player.sendMessage("true");
} else {
player.sendMessage(activeInventories.get(player));
player.sendMessage("rewInvMinenarbeiter");
}```
In the image, you can see the messages sent to the player.
Can you elaborate
what?
extend an already implemented inventory
you can do whatever you want with your abstract class
and create your own inv creator if you want
with all the methods you could dream of
strings arenot compared using ==
they are compared using .equals
I dont understand the system with that
you create an abstract class
You add some methods
Like I just dont understand the sentence
thanks
i can help you
if you create a class through an abstract class, it has all the attributes assigned to the abstract class. All the attributes you think an inventory should have
yes, but no
there are also abstract methods with are not filled with anything (if you want)
Yeah and these are the ones the class that extends the abstract class needs to define
yes, lets say you have a String displayname; and a abstract method called setdisplayname
you can set your displayname in the method
it's a stacktrace
and once you call the method setdisplayname somewhere
it's the textual representation of an exception
why does the server need to know the parts of an ender dragon?
how do i fix ?
Why does Bukkit.unloadWorld(world, false); still try to save raids.dat
to calculate the hits?
ah
read the exception and you'll know
hey alex do u know by chance how long it'll take for the javadoc to be available for 1.20?
wdym
if i run --generate-docs for 1.20 or 1.20.1, neither seems to exist when i enable the maven import for it
like
spigot exists and so does remapped
but it doesnt find the javadoc
oh hm idk. --generate-docs doesn't install them, idk why. you can install them manually or let maven download them
mvn dependency:get -DgroupId=org.spigotmc -DartifactId=spigot-api -Dclassifier=javadoc -Dversion=1.20.1-R0.1-SNAPSHOT -DrepoUrl=https://hub.spigotmc.org/nexus/content/repositories/snapshots/
sth like that
uh
ive never had to deal with maven commands lol
okay so i do have maven on %Path% at least
you can alternatively add that to your pom, let maven download it, then remove it again
can i call that anywhere or do i need it to do in the proper .m2 folder?
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<classifier>javadoc</classifier>
...
anywhere
or just add this to your pom quickly, reload maven, remove it again
i doubt that you are depending on the javadoc
nope
i disabled it cuz it gives a maven error
though your command pasted the javadoc into the spigot api folder
so it should work now
yea seems to work now
any idea why the --generate-docs is broken
int++;
is there something like this too?
int--;
i tried but couldnt get it to work?
both should work
int++ worked
if you use them in an expression, depending if you do ++int or int++ it first adds then reads, or first reads then adds
like
int a = 0;
int b = a++;
// a = 1, b = 0
int a = 0;
int b = ++a;
// a = 1, b = 1
what about int--
same thing but minus
i want it to lose 1
I installed remapped NMS, but after installing remapped NMS NBTTagCompound stopped working
Then - - works
hmm it has red underlines if i try to do it
is this the right symbol '-'
i managed to get it work, i was using a wrong minus
what language is your keyboard on lol
i copied urs
hm
weird how the ender dragon doesn't use pathfinders like most other mobs do
How can I change the name of a player so it also shows this new name in the tablist and death messages and so on?
try pressing alt shift and hold those buttons. It should light up possible keyboard configs on the right, it might help switching to a different layout
with
you know
setPlayerlistname
the correct minus
yeah i changed it too, thank you
So... I installed remapped NMS but NBTTagCompound stopped working.. Idk what i should do now
Oh really, thanks
Where could i find all changes of the names in remapped version?
for some reason the multiple choises don't appear anymore, did i change something?
ah i found the problem
java
r u storing connections in variables or sth?
no im getting uuid from connections and savetostring
the issue talk about the getConnection
in any moment can connect?
wdym
the error is a timeout when try to get the connection to DB.. then with hikary that can be by...
- you can connect but dont close correctly the connection and a new getConnection cannot happen
- you put bad the host or by firewall or another things where is the code cannot connect to the database
is there a way to use maven to send a 'reload' command to a locally running test server?
i dont think you can make this easily...
maybe a ant plugin in maven for run a batch but not sure
How can I get the inventory of a Dispenser from the BlockDispenseEvent?
lol, I learned recently that for (int i = 0; i < 10; ++i) is more efficient than for (int i = 0; i < 10; i++) because while the pre-increment updates the value of the object referentially, the post-increment creates a copy first and returns it, then updates the value of the object referentially. So you can avoid an object copy by pre-incrementing vs post-incrementing unnecessarily
Compilers tend to make this optimization for you so it doesn't really matter, but you'll see ++i in source more often because of it
*in C++, btw. Doubt it makes any meaningful difference in Java
yeah in c++ it makes more sense
it doesn't even make any difference at all in java
i think i figured out why main has to be the last method in the source file
it must be due to how the stack works
it loads all the binary and the main will be right on top
main can be anywhere. It's just that files are processed from top to bottom
interesting. how come that doesnt change the loop count?
i couldn't have main in the middle
So if the method prototype doesn't exist and is called, then y'know, boom
i think i heard a weird compiler
What'cha mean? Those both loop 10 times
well yea
you can have the method declaration above main and the definition below or in a completely separate translation unit
doesn i++ return then increment
what i mean is if it increments first wouldn't it return one loop early?
Because it's a post-increment, right? So int i = 10; int x = i++, i = 11, but x = 10 still
i dislike how in c++ you can't have bodies in classes due to inlining
wut
I'm lost at what you're trying to get at 😅
you had to put it in the main class with class::method
i don't remember that much about c++ so don't expect me to be precise in what i'm saying
you can have a body in the classes but it's not recommended
No it should be fine. Shouldn't be any copying at all there
you are supposed to do it like this
You can definitely still write that in the header file
Especially just simple one-line functions, it's fine
If it's in a header file, #pragma once it and it won't be duplicated
i don't know that much c++, i might go back into it for a refresh
I have a lot of questions about NMS, I'm just starting to figure it out and it's quite difficult for me, I don't want to clutter up this chat so can someone help me in dm?
How can i get the line of the lore?
Thanks
I got an error 'StringTag(java.lang.String)' has private access in 'net.minecraft.nbt.StringTag',
and I do not know how to solve it, could someone help? Please
CompoundTag itemCompound = new CompoundTag();
itemCompound.put("time", new StringTag("foo"));
make a thread, more people could see it
I'm not very good at this and I'm afraid of judgment so I would prefer dm
eh
the linker will optimise those away
We recently learned that inline keyword in cpp is more likely "please compiler, make this inline " then "make this inline !"
Which is kinda funny to me lol
but why is your "time" a string?
Because i was doing something like this https://imgur.com/ASY8vcs
but isn't time a timestamp or sth?
you dont have embed perms, you need to be verified for them
oh, i'm just testing things
ok thanks
How would i be able to translate a title of a gui?
The vanilla way of making translatable things is like this:
[{"translate":"space.-50"},{"text":"Example Name"}]
But how would i do this in a plugin?
I offer 5€ to whoever helps me to make a post request to my website
?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/
you cant yet
?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/
well you can, just not built in
I can't arrive
welp... there goes that idea than lol
Its not allowed here
You'd need nms for that
you could use nms to add it but if its a public plugin its too much
@barren ridge I have the NMS for this do you want it?
nerd
yes please :D
okay give me a minute
Another err "Cannot resolve symbol valueOf"
what version you on
1.20
alr
I only have 1.20.1 but the NMS didn't change between 1.19.4 and 1.20.1 so I doubt theyr will be differences other than the craftbukkit imports
srry meant 1.20.1
?paste
so there is kinda two ways to go about this. One way is to just resend the title packet on open with your custom title or the other is to override the entire custom inventory system I went for the latter because I'm a nerd, but the former should be just fine
y2k why are you in offline mode
forgot
https://paste.md-5.net/ininoneluw.java I'd do this if you want to do what I went with
I abstracted it into an interface like so and my handler looks like this https://paste.md-5.net/eqofoconok.java
skuetto
Well but it exists https://nms.screamingsandals.org/1.20.1/net/minecraft/nbt/StringTag.html
Nah
screamingsandals so deprecated
The new website is weird
no it isnt
it looks the same
you can toggle namespaces before you say it
I know, IDE too thinks that it's exists but something is going wrong https://i.imgur.com/DBW81ex.png
alright thank you!
It looks totally different
screamingsandals' viewer is literally deprecated 
did you add a spigot nms jar through external jars not the maven dep
i'm not sure
It does still work obviously
I mean for now
explain the steps you took to add nms to your plugin
if you want the code for ItemStack components I have that too
but I'll warn you mine is wrapped up in a builder you'd probably want to decouple it
Screaming sandals is better, just compare this
okay who the fook looks at mappings on their phone
Me, right now
why
that would be epic!
i downloaded BuildTools and started it by cmd "java -jar BuildTools.jar --rev 1.19.4 --remapped" then i added <classifier>remapped-mojang</classifier> to dependencies
and that's all i think
did you add the special source plugin
No i didn't i think
?nms walks you through the process
Need help:
How can i set someones compass direction to a specific location? (in skript)
you did most of the steps but it has the special source on here
skript has a discord pretty sure 99% of people here use java highly doubt you'll find help
grab the special source info off the link y2k triggered and change the version to match what you develop for
oh alr, my bad
u good
thx :)
epic what's my next PR :} i"m bored
look at some jira feature requests
or bug reports I suppose
them too
I could probably look at paper feature requests too if they have those

just keep away from looking at any prs or their current code
thanks!
I wouldn't wanna copy that anyways
True
paper does quite a bit of impl different from Craftbukkit iirc
don't you guys have your own like utils for some stuff or whatever I forget tbh
add this
what one
gui
yea
Shadow is in charge of that one
smh
I do testing nd shit
im a windows slave
reminds me I need to test latest jar
BuildTools really is a mess lol
the code formatting makes me cry too
completely recode it
no
Hello, in my Logs Unicode is being replaced with "??????" instead of the original Unicode char. Is there an way to display them or maybe display them in there HEX format?
actually, just upvote https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/1230/overview 😏
yeah I would, but I don't know anything about NBT lol
its so annoying because I cannot pull it into paper
otherwise, people cannot go back to spigot 
idk why no one has given it a look
mojangson
paper pr queue isn't better lol
what's the goal of the PR, I don't really get what it is
we don't talk about that
Well, rn spigot tries to map a compound tag completely into a yaml tree
that fails terribly in edge cases because nbt has a lot more datatypes than yaml
e.g. bytes, doubles, ints, float etc
@lone jacinth are you still working on the de-enumification stuff
so it uses some fucked logic to represent the values in a string way to re-construct the type
that falls short in a couple of cases
yeah they are its just a ton of work :P
last commit 28th june
is this like a ConfigSerialization type thing
nah, there is some internal logic to convert it to a Map<String, Object>
thank god nothing on the API level
Any solutions?
but it just fails rn, shit like true is interpreted by the mojang parser as a byte 1
watch it not have been seen bc its a cb only pr
is mojangson mojang modified gson
I read that as Mojang-son lol
no that was just spigot mappings back then xD
mojang-gson
its just their SNBT format
ahh
which is partially used to like, serialise a double to like 3.5d
instead of 3.5
this instead stores the entire PDC as a single, multiline string
of pure SNBT
still editable
why would you need to serialize pdc to yaml anyways?
I mean, that is how half the people serialise them to db too
with the bukkit output stream
I just take the material type and guess the rest when I deserialize
random word generator for the name
random enchantment generator etc etc

The PR it itself is feature complete and will only receive bug fixes and merge commits from master, if no other feedback is given.
You can even test it with java -jar BuildTools.jar --experimental, on that point some more testers are welcomed.
crunchy
but yea, single SNBT string imo is just cleaner
and future proof
compared to the hacky solution
so were waiting for md smh
I mean, we are waiting for 1.21
I mean given the tests work (which I believe u
) I think it looks like a better serialization and deserialization solution
shit like this cannot be pulled mid version lol
ofc it can
you break things
spigots not affraid of a few breakages here or there 😆

md_5 is waiting on more feedback and testers, even if it is just a "I like it" or "I run my plugins with it and they work"
why cant we pull it on 1.20.2
what does the new stuff look like serialized just like a SNBT string?
iirc a test should include how it looks ?
or not ?
maybe I only have a test with external yml for the legacy shit
you only have a test external with legacy
that's legacy
where is the PR? I can't find it
thx
yeah maybe would like to see an external non-legacy test too I suppose
just realized config.set("test", stack); you just read the legacy
but I agree, knowing how the output looks would help reviewers
maybe at minimum add an adition to your PR description
Yee exactly
Is there a way to link an object to a player? I'd rather not have to deal with serialization
{name1:123,name2:"sometext1",name3:{subname1:456,subname2:"sometext2"}} this is SNBT though it just looks like json with tweaks
Yea
so I'm assuming the output would just be a one liner like this
Well
it should be multiline
I looked at it before
while coding it
it looks pretty sexy honestly 
I'll only approve If I get to see sexy ItemStack Ouput 😡
Wasnt there an EnumMap in java
Yes
Or is there only enumset
There is EnumMap
declaration: module: java.base, package: java.util, class: EnumMap
invaldating caches fixed it, once again
testpath:
==: org.bukkit.inventory.ItemStack
v: 3465
type: DIAMOND
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: '{"extra":[{"text":"Item Display Name"}],"text":""}'
PublicBukkitValues: |-
{
"test-plugin:custom-byte-array": [B; 0B, 1B, 2B, 10B],
"test-plugin:custom-double": 3.123d,
"test-plugin:custom-inner-compound": {
"test:validkey": 5L
},
"test-plugin:custom-int": 3,
"test-plugin:custom-long": 4L,
"test-plugin:custom-string": "Hello there world"
}
@river oracle
could be sexier
I'm ready for the "no enums" pull request now
actually, why did I not make it generic
stupid me
given how fucking giant material enum is
I'd be surprised if EnumMap isn't larger than HashMap

no
Material will stile be an enum
you forget it
forget material ever existed
you have Items and Blocks
or something along the lines
I'd put this in your PR Overview if possible and say like
before change:
Insert ugly yaml here
after hcange:
insert sexy snbt string
no i know I just enjoy hating on yaml

D:
I think its bad at its sole purpose which is configuration files
barely functional and easily breaks because of indentation errors
I do :P
in your yml files
oh no I just write my configs in json
looks good, nice PR and fixes things. I'd say my only devils advocate with this would be its not "User Editable" but I'd argue thats not even the point of serializing an item stack into a config with bukkit
I mean, it remains user editable
yeah its just not the nice yaml whatever
The fact that it's plain text just makes it easier to edit. Compared to it being encoded.
Editing serialized anything from bukkit is hardly the point though. If you're doing that you need some serious help there are way more user friendly ways to achieve that
That do be true
I should have no room to complain about yaml I'm writing my new Inventory Framework with XML
<item item-type="DIAMOND">
<name>"[Example Diamond](color=#fff-#666)"</name>
<lore>
<line>"[Example Lore Line](color=#111-#222)"</line>
<line>"[Example Next Lore Line](color=#333-#444)</line>
</lore>
</item>
I wonder if this works
BlockGrowEvent IIRC
won't compile
thats not even formatted correctly
LOL
uh what? yes it is
That doesn't matter.
good for you
shush npc
its discord
Ok?
XML is fancy
fun fact: this only compiles when removing the empty <> diamond operator at new EnumMap<> although it doesn't show any error in IJ
i cannot declare abstract static methods
oh well methods, ofc not
an abstract method means that an "inheriting" class has to implement it
well yes thats the idea
static methods are members of the class itself
they cannot be overriden or anything
abstracts don't belong to an instance they belong to a class so how would inheriting those methods even work?
i think you can remove the warnings with T extends Enum
but T might not extend enum, that's the point of the method
T might be Material which is an enum now but not tomorrow
abstract static methods would be cool though. Just to enforce them being implemented when extending a class
yeah I'd also love it if you could declare constructors in interfaces
lright then here's my problem. I have a bunch of different sets of effects. I want to have one class (here named EffectClass) that contains the 'applyEffects' method, but i don't want to have a massive switch and all the effects in there, hard to read, hard to maintain, so the idea was to have classes extend this class, so that i can just call EffectClass' applyEffects method.
Issue here is... static methods cant apparantly be overridden, but i dont want to instantiate an object just to run a basically static method
material will still be an enum
the pr is splitting the class
ItemType and BlockType
the material enum just becomes deprecated
check for deprecation I suppose would be more effective in this case
the 1.18 notes say "enums which implement Keyed"
so material too
this is definitely a better aproach
someone here said something to do with commodo
which probably is a runtime editor
look at the pr
@kind hatch I finalized my data structure this is what the end XML looks like. I like it personally think the one-liner itemstacks are cool hopefully the way I did it allows for it to take name in in the one liner too
https://paste.md-5.net/finofizoti.xml
what's the purpose of splitting it though
it makes more sense
u mean me?
you can currently set an item to a block only material
also more closely follows what nms does
or vise versa
^ this
yeah but most things are both an item and a block
not everythimg is
it'd be weird to have Item.DIRT and Block.DIRT
theres loads of item only stuff
and then how would I check if Item.DIRT and Block.DIRT are the same
What's the column="7" supposed to do to that one item?
It is more convenient for item only and block only methods
it would have been in column 6 but it skips column 6 and proceeds counting upwords from 7 at that point forward
so everything counts up by ones, but once I define column 7 it'll count up from that in the future
Ohhh.
because the current implementation of #isBlock() and #isItem() is garbo
could you send current code?
i havent written any except trying to make a method static abstract
im asking how i should design this
now to write the parser for this bad boy
this is going to be insane especially once I factor in json linking for configuration
if you need an abstract static you're doing something wrong design wise
see here
no clue, most i know is that its being split up
well It sounds like usecase for decorator desing pattern. I wound make Interface Effect with method apply(EffectData data)
alex do u by chance have a blog about this
/**
* Returns the corresponding {@link BlockType} for the given ItemType.
* <p>
* If there is no corresponding {@link BlockType} an error will be thrown.
*
* @return the corresponding BlockType
* @see #hasBlockType()
*/
@NotNull
BlockType<?> getBlockType();```
fuck
yikers, someone pr this so no errors and no manditory hasblocktype check, wrap that shit in an optional
do you not have stash access?
I'd just comment on it on stash if you do
no it's on my list of todos kekw
tbh there's rarely a moment I feel like I need to pr something
there's a spigot thread
comment on that
I dont know what the error is but its never comming sending "b1" on the console and i cant see what's wrong with if(itemName.equalsIgnoreCase("§bSTICK")) {
code: https://paste.md-5.net/lemipiduvo.cs
you really should learn java
you only need 1 item meta variable
you should also have 1 List<String> variable that equals itemMeta.getlore
then you check that
no 5 identical item meta variables calling.getLore on all of them
Okay thanks
A recomendation never compare items by name or description, always add a custom identifier by the use of PDC or even NBT depending on what api version you are using
Im using 1.8
So you will have to use NBT that why i mention it, i cant server everything i mean
If it returns the correct data type.
I have fixed the same 5 lines now but that hasnt fixed it tho
Is there change item in offhand event?
PlayerSwapHandItemsEvent
Only applies when they use the hotkey though.
You'd have to check the InventoryClickEvent if they manually move items.
But if i change item through inventory it won't work
Refer to the message above.
oh yes ok
Hey, some time ago mfnalex (I think) created a wiki for basic minigame framework
I can't seem to find it, does anybody have the link?
Don't think that was alex. @echo basalt This you? ^
Does anyone know whats the error with if(itemName.equalsIgnoreCase("§bSTICK")) {?
ItemStack attackerWeapon = attackerPlayer.getItemInHand();
Material weaponType = attackerWeapon.getType();
ItemMeta itemMetaList = attackerWeapon.getItemMeta();
String world = attackerPlayer.getWorld().getName();
String itemName = attackerPlayer.getItemInHand().getType().name();
if(attackerPlayer.hasPermission("vagt")){
System.out.println(1);
if (weaponType != Material.STICK) return;
if (world.equalsIgnoreCase("B")) {
if(itemName.equalsIgnoreCase("§bSTICK")) {
System.out.println("b1");
if (!itemMetaList.getLore().get(0).contains("-----")) return;
if (!itemMetaList.getLore().get(1).contains(" ")) return;
if (!itemMetaList.getLore().get(2).contains("Købt af: ")) return;
if (!itemMetaList.getLore().get(3).contains("Må kun bruges i b")) return;
if (!itemMetaList.getLore().get(4).contains(" ")) return;
if (!itemMetaList.getLore().get(5).contains("-----")) return;
victimPlayer.sendTitle("Hello!", "This is a test.");
victimPlayer.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(60, 1));
}
}
yep, it was him, found it
tysm
most likely the formatting
if (ChatColor.stripColors(itemName).equalsIgnoreCase("stick")
Okay i will try it, but what does stripColors do?
remove all colors and formatting
imagine just adding an nbt tag to identify the item so you can use any formatting, name, lore, enchants, item flags, item type you want
Still not working tho
Psshhh, that'd be too easy.
well im pretty sure ur lore checks are the ones failing you add an entry of "" not " " as an empty line
That's because your comparing the Material name with a custom color code that you shouldn't even be using.
getItemInHand().getType().name(); will return STICK or DIAMOND since it's an Enum.
You're basically saying
If "STICK" equals "&bSTICK"
Which will never be true.
It was illusion
Maybe that'll help your search
yep, already found it

Nerd
tell you what, I understand it's very basic framework for this but it could at least compile XD
would do PR but idk how wikis work
smerch smindex
public abstract class AbilityHandler {
final TypeEnum type;
public AbilityHandler(){
type = TypeEnum.NONE;
}
}
So
apparantly
abstract classes
have to instantiate
final variables
im so done
I wrote it without an ide
its not a static variable
this class CANNOT be instantiated
why would you need a fcking instanciation
you call super
point
if anything you can inline that init
well you did one hell of a job in making this then
It's decent apart from like 2 small errors
ty for taking your time on this, I would not have any idea where to start were I to do this by myself XD
Fixed that tiny thing
Material.CARROT and Material.CARROTS would like a word
POTATO and POTATOES
these are items and blocks, but have 2 separate enum constants
wasn't that a thing in like 1.8
Key word is most
I'll write something about maps later
This works
it also looks awful on my 2nd monitor wtf sharex
Smh not namedspaced key?
tf you think I am? bukkit?
yeah
built-in minigame lib when
lul
But yeah I'm not concerned about using namespaced keys
very unnerd of you
Because I don't account for idiots trying to register bedwars in 2 different plugins using the same name
Use an interface instead
Don't see the reason of abstraction here
"get fucked bozo, read the docs" should be the error
i need a final identificator thats part of the class it extends from and can change depending on the class that extends it
more like "are you an idiot? who's trying to register %template% twice?"
Okay.. but i dont know how to check the name on other ways
This is the only way i know: if(attackerPlayer.getItemInHand().getType().name().equalsIgnoreCase("§aSTICK")){
?pdc
you are checking if an enum has formatting
which will always be full caps no formatting
is there a way to create and ItemStack that consists of 100 items AND displays the number correctly instead of saying 64?
you should check if the item hasDisplayName() and use get DisplayName
It's a bit hacky
Oh well, in that case, an abstract class stills a class, but one you can extend from and create new instances of with a defined usage (I'm not really good explaining it)
What I mean is that, as a class, stills need to initialize variables (even though it would be really cool to make java auto-generate constructor methods based on fields)
with server patches and client side mods probably
But you can
well even if it would be an interface the variable would still need to be initialized
hmm, can you guys tell me more about it, or send materials that i can use?
oh wait
make a default getter
yea
and move on
just realized that
you can still do it with an abstract class
well
no reason to have one
Plus right, in this case abstraction is not actually needed
If it can be replaced by an interface and it doesn't really need to be an abstract class, do it
I'm not arguing for abstract classes btw just stating the possibility
I have that now but its still not working
if (attackerPlayer.getItemInHand().getItemMeta().hasDisplayName()) {
if (attackerPlayer.getItemInHand().getItemMeta ().getDisplayName().equalsIgnoreCase("§aSTICK")) {
sys out the result of them
Check both in the same if statement
System.out.println(attackerPlayer.getItemInHand().getItemMeta().hasDisplayName()) same for getDisplayName
For maps you use SWM (Slime World Manager) ?
Nah
getDisplayName returns null if none btw, maybe store the value on a field, and check if null
no point
I mean I could probably make an impl with cosmos
thats what hasDisplayName is for
but for now worldedit and a world pool does the job
oh weird, but then dont you have issues related to map loading?
I was doing some profiling and it isn't that bad
But if he's going to use the getDisplayName later, it will be "faster" to directly obtain and null check manually
Okay so its sending true in the console
so sysout the display name
oh right, i thought the "lag" (i dont remember apropiate word) let call it like that was really bad
see if its actually what you think it is
Well
It is if you aren't doing things right
In my case I always have worlds on standby to minimize that stuff
yeah true
How do you leave a world in stand-by?

you put it to sleep?
You have a world pool where you leave worlds loaded but with spawn chunks disabled and that kind of stuff
when did mojang add a sleep function for worlds
Oh
And when you need a world, you fetch it from the pool
fetch it from the poo
Works like a SQL pool
anyways
Doesn't it?
If you start fetching too much it creates new worlds
theres just a poo pile out back you run and grab a usb from
If you use too few it unloads and eventually deletes them
That's what SWM do?
Nah that's what I do
SWM just does its own chunk and world logic instead of relying on bukkit's
nothing related, but for some reason your name sounds too much on my head. Did we talk or seen before
Do you have an API for it? Like a public API you allow to use
Also, isnt done by packets directly which improvees a lot?
oh you sweet summer child
Configurability looks like this
i cant tell if this is normal verano or drunk/high verano
im 0.0% right now, but in night i dont think so
Thanks
oh you sweet summer child what means that? 🤔
Urugay no existe
polite for youve seen nothing
Im trying to do so when you get hit by a player and the attacker has permission "vagt" and his held item is a stick named "§aSTICK" and his lore is .... you will get blindness and send a title but its not working, when im doing this -> System.out.println(attackerPlayer.getItemInHand().getItemMeta().hasDisplayName()); its sending true in the console
if (attackerPlayer.hasPermission("vagt")) {
System.out.println(1);
if (weaponType != Material.STICK) return;
if (world.equalsIgnoreCase("A")) {
System.out.println("a");
if (attackerPlayer.getItemInHand().getItemMeta().hasDisplayName() && attackerPlayer.getItemInHand().getItemMeta()
.getDisplayName().equalsIgnoreCase("§aSTICK")) {
if (!itemMetaList.getLore().get(0).contains("-----")) return;
if (!itemMetaList.getLore().get(1).contains(" ")) return;
if (!itemMetaList.getLore().get(2).contains("Købt af: ")) return;
if (!itemMetaList.getLore().get(3).contains("Må kun bruges i a")) return;
if (!itemMetaList.getLore().get(4).contains(" ")) return;
if (!itemMetaList.getLore().get(5).contains("-----")) return;
victimPlayer.sendTitle("Hello!", "This is a test.");
victimPlayer.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(60, 1));
}
i said this before, sysout the displayname
System.out.println(attackerPlayer.getItemInHand().getItemMeta().getDisplayName())
Try checking the item name stripping colors
ChatColor.stripColors() I think it was
yeah
told them that earlier but no reaction
you wanna see what they had earlier
1.8
My thoughts exactly.
Its not sending anything, only 1 and "a"
add the code i sent you
System.out.println(attackerPlayer.getItemInHand().getItemMeta().getDisplayName())
https://paste.md-5.net/lemipiduvo.cs they sent this earlier
Why!! With this code you are creating 6 variables for the same thing
who knows, they fixed it quite quickly atleast
Its not sending anything if its after i check if the name is "§aSTICK" nothing is getting send and its the same if im tring to do it before i check the name
do it before the if
its not hard to debug this yourself
i shouldnt have to hold your hand the entire way
?? i have, its not sending anything if its before and after
I wont be rude, but have you learnt plain java before coding plugins?
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
they havent, they ignore us sending the ?learnjava command
The apparently don't listen to what has been said. Or at the very least understand what they've been told the issue is.
oh okay, huge issue there
lmao
show ur code for it
lmao how much patiently you have, you should get paid
Your a bit late tho, its an hour ago
🤔
im watching youtube while doing this and if i see enough basic java issues i just give up
oh haha, sorry tagging you. But discord till didnt add a shity option for automatic disabling reply tags
?paste
Hold shift when you press reply.
oh dont worry, makes sure i actually see it
You're welcome.
sharex copycat
How? How did you revert back to the same code that I already told you what the issue was?
Hmmmm
Iam smart 😁
I spended alot of time finding a solution then realized I didn't register the event
And thats where i didnt know how to check it on other ways
oh haha, it happen to me many times that
you didnt update the jar then
I have but i will just do it again
now im gonna eat my dinner, you should go and learn basic java before making plugins . good luck
Okay i think i did something wrong before but now it sends true and ´┐¢a´┐¢lSTICK in the console
I told you to check the name stripping colors
I did that earlier but that didnt work, but i will try again now
How are you stripping colors?
if (ChatColor.stripColors(itemName).equalsIgnoreCase("stick")
if you add the ending bracket yeah
How can i spawn particle and make him go only up?
Im using Particle.CAMPFIRE_SIGNAL_SMOKE
Sorry but im probally doing this wrong but if im doing this:
if (itemName.equalsIgnoreCase("&aSTICK")) {
if (ChatColor.stripColor(itemName).equalsIgnoreCase("stick")) {
Its still sending ´┐¢a´┐¢lSTICK
why would the item name equal &aSTICK ?
why are you checking the item name in the first place?
no shit, you sysout the display name pre strip color
and even if the itemName would equal &aSTICK, then why are you checking if it equals "stick" in the next line again?
you ONLY need the 2nd if
what even is the purpose of checking the item's name?
Becuase i have 3 world c, b and a, and if you are in a and the stick isnt named §aSTICK its not working becuase blue is for the world b and red is for c so you cant use one from world c in world a
their on 1. 8
this would be way easier just to use nbt tags
Okay i will try to do that
No, it would be easier using the latest MC version
every plugin dev should listen to NewMcVersionReleasedEvent and handle it properly
so i just print out every 30 min " new mc server version realsed update will come out in the nxt few days "
exactly
I have tried to do it with the nbt but i dont think its right, im getting some warning about it too
ItemMeta itemMeta = attackerPlayer.getItemInHand().getItemMeta();
itemMeta.setDisplayName("§aSTICK");
itemMeta.getLore().contains(Arrays.asList("§8§m---------------------------", "", "§fKøbt af: §a", "§fMå kun bruges i §aA", "", "§8§m---------------------------"));
use nbt api
I cant find out how do it
are you signed in
yes
== for enum constants
a block is rarely equal to a material
