#help-development
1 messages · Page 1801 of 1
dont forget that static getInstance ruins re-usability and unit testing
But every constructor of my classes need at least 3 other classes so i feel so lmao
im sorry but not even assigning it to a local variable and just having those static variables in every single class
dont even start on mockbukkit
I don't need unit tests for my plugins. Because I don't even understand how they work lol
anyway, I'm wondering: how is passing the instance better for unit testing?
you still need the main instance
In some cases you dont need entire plugin
in those cases, I just don't declare that variable then
of course I am not using it for data classes etc
I still wonder why it's better for unit tests to use DI
I really wonder, I'm not being ironical
I don't know much things about unit tests
Well repeated testing, every new test runs the setup again which usually instantiates all the instances, however static would persist each test making them impure and un-unit-based as the name hints
I wonder how you'd create a class instance extending javaplugin without running spigot
Mocks
have u heard of mockbukkit?
My constructor always has something like this:
public Constructor(Main class, LocationConfig config, LangUtil konke) {
this.main = main;
this.config = config;
this.lang = konke;
}
No, I haven't
Exactly
To isolate dependencies we mock them
Mhm
as said, I don't know much things about unit testing 😄
Yeah
Well anyways whether you use a singleton or pass your instance probably doesn’t matter
but ofc I'm always up to learning new things
And if it’s just an internal project refactoring won’t be the hardest thing to do
I tried unit testing but i got stuck
You cant just think abt what you are doing rn that may seem easy. I encourage to switch cause u prolly will have to unit testing eventually as a coder
🍬
Conclure you can use mockbukkit and Junit at the same time
right
is that what u do
The biggest benefit with automated testing, is that you can prove your code is not wrong
Hmm Pulse not at the same time
But I have used them hand in hand
yeah but I still don't really get it. I can test whether my code is doing fine by just running it. For all things that actually depend on the game, I have to run it on a real server anyway, Mockbukkit won't help. Did I get this right?
oh
And it has certain api methods like fireEvent(event) which can emulate certain actions being made
so yeah
OwO?
Fully automated
what exactly can it simulate though? it can't emulate a player right-clicking a block at XYZ with COAL_BLOCK at that location, can it?
Yes
I think it’s even capable of such stuff yeah lol
same
Birds can’t read tho so no worries Adele
lol
can someone teach me how to get started with mockbukkit?
Pulse
then first get rid of your static singletons 🥲
No!
why? Conclure said it's no problem
can u read on THIS though
its fine i guess.. for now
yeah it say ZANCO
I know that people say it's bad OOP
Oop my b
but I also think it doesn't make any difference because I'll always have a main instance
otherwise - what else should instantiate my other classes?
I think im dong bad oop too if my constructor always like that…
Anyways mfnalex if you’re serious about getting into testing, just trying something like JUnit on its own first might be insightful. Also might wanna go and learn about the techniques like mocking and such.
tbh I'm not a friend of all those conventions. some are good, no doubt. But when you ever worked in a company that used things like AbstractPluginFactoryFactory, you want to get rid of all this stupid enterprise stuff as soon as possible lol
Lmao
Tried looking into it, but only for a few minutes
Hmm I’m a bit tired today although I guess I could rant it through in a thread some day soon.
that would be awesome. I'd love to learn new things but tbh I need real life examples for it, otherwise I'll just think "ugh, how useless" lol
KISS is cool
Yeah understandable
I dreamt that i was lazy so i used that one dependency whose name evade me, to put @Getter annotations and it was pog

It’s nice when it works
it always worked for me 😄
For instance on GitHub
only thing I dislike about it is javadocs
My github copilot was being overly aggressive so i had to turn it off 😔
Does CB use mockbukkit for testing?
You can’t jump between variables and classes if someone decided to inject those Lombok annots
Actually no clue
yeah but tbh that's not lombok's fault
Don’t think so tho
I wasnt saying anything related to lombok thonk
mspaint ide? 😄
spigot doesn'T support it too
so
fuck spigot
Lombonk
I was just complaining abt copilot
would someone happen to know how to make a player fully invis, but they still show up in tab.
cant figure it out 😳
what even is mspaint ide lmao
Draw
An ide based on paint
you can now use Player#hideEntity
oh that exists now?
sounds very useful lol
I prefer Photoshop IDE though
yep
md_5 pointed it out to me today
however it wasn't useful to me because I needed it for "fake"/NMS entitites
but yeah you can now hide "real"/bukkit entities through the API
idk if it's 1.17+ or 1.18+ though
1.18
i am on 1.18
i just turned off my antivirus
get a proper OS and you won't need any 😛
becuz im too lazy to select excluded apps and files
doesnt seem to exist 🤨
um
Do u have latest of the latest build installed 
here ^
Actually he might have forgotten to push it
PacketPlayOutEntityDestroy KEKW
Gg
seems to be deprecated though
no
Yes
it's a draft API
It’s draft API
ah
deprecated'nt
"not finished yet, might change"
The commit was days ago
Thanks discord
🌝
🌞
ugh wekan sucks hard
Who
Hey there, please tell me if I'm stupid, how can you get a player's persistent data container?
via their MetaData
And how can you get that?
player.getPersistentDataContainer()
oh was it the items you needed metadata for?
yes
goddamnit. always getting those confused
😄
al entities implement the PDC stuff
and yes, for itemstacks you need the itemmeta
yo this mockbukkit thing is cool
i'll check it out soon :3
hmmm idk bout that one
why does the hideEntity method need "plugin - Plugin that wants to hide the entity"
🤨
look at the show method
Let's say I wanted to add "hunter":"1b" to the player nbt. How would I do that?
why not? you probably have a plugin that you can use as parameter 😄
show method must have all plugins who hid the entity
it porbably works like chunktickets
to unhid it
right
yeah it's basically to avoid plugin conflicts
imagine two plugins want to hide an entity
and one wants to show it again
makes sense
sadly it will make plenty of conflicts i hink
that would destroy the "hide" feature from the other plugin
like this:
mans preparing the spoon👀
player.getPersistentDataContainer().set(new NamespacedKey(yourPlugin,"hunter"),PersistentDataType.BYTE,1b);
might contain typos
I wrote that by hand
tab complete is a friend
but not when you're submitting java code inside discord
yet
jetbrains x discord collab
@finite brook
If I have the player as org.bukkit.entity.player, will it work?
welp, hideEntity didnt help with this
yes
oh yeah
you'll have to send a packet to all remaining online players that this player who you've now hidden, has joined again
really didnt want to mess with packets but here we go again
you'll have to though :/
seems like it
but don't worry. If you use mojang mappings and got a proper maven module setup, NMS will work for all future versions too with only minor adjustments
@tender shard hi sorry for distrubing you again, but i tried and tested your way now and it doesn't work...It doesn't throw any error or smth just nothing
hi, np. please explain again what it's about, I don't remember 😄
So, i am trying to read data from a config.yml file and then put it into a HashMap<String,String>
for(Map.Entry<String, String> entry : chunks.entrySet()) {
hash.getHash().set("claims."+ entry.getKey(), entry.getValue());
}
hash.saveHash();
}
public void restoreClaims() {
for(String key : getConfig().getKeys(true)) {
chunks.put(key,hash.getHash().getString(key));
}
}```
The above thing is mine to put it into the yml file
and hash is my custom yml file
public void saveClaims() {
for(Map.Entry<String, String> entry : chunks.entrySet()) {
System.out.println("Setting claims." + entry.getKey() + " to " + entry.getValue);
hash.getHash().set("claims."+ entry.getKey(), entry.getValue());
}
hash.saveHash();
}
public void restoreClaims() {
for(String key : getConfig().getKeys(true)) {
chunks.put(key,hash.getHash().getString(key));
}
}
try this
this feels like over complicating tho
I just added a debug statement
you got a better idea?
try this and tell me what it prints to console
hash.getHash is like config.getConfig
but ur getting keys
true, but I wasn't worrying about that. The actual problem was to load a YAML into a HashMap<String,String>
without specifying the claims path?
just my own yml so i don't get confused because i am using 3 of them
for(Strings key : getConfig().getConfigurationSection("claims").getKeys(false))
or i guess ur using the hashmap way not serializing it by hand
private HashMap<String, UUID> trusted;
int claims;
double coins;
public void addChunk(String chunk, String owner) {
chunks.put(chunk, owner);
}
public boolean isChunk(String chunk) {
return chunks.containsKey(chunk);
}
public String getOwner(String chunk) {
return chunks.get(chunk);
}
public void remChunk(String chunk, String owner) {
chunks.remove(chunk, owner);
}
public void addTrust(String chunk, UUID trust) {
trusted.put(chunk, trust);
}
public UUID getTrusted(String chunk) {
return trusted.get(chunk);
}
public void remTrust(String chunk, UUID trust) {
trusted.remove(chunk, trust);
}
``` this is all my code for the hashmaps
chunks is the one for the claims, i want to put it into it
also i see something strange
you never clean the config file
if there is an old chunk deleted from the memory
the save wont overwrite it
it will load it back again after the restart or reload
good thing to know that xD
how do i do that?
okay, so on save up hash.getHash().set("claims.", null);
and after that the rest of the code
okay
@onyx shale like this public void saveClaims() { for(Map.Entry<String, String> entry : chunks.entrySet()) { hash.getHash().set("claims.", null); System.out.println("Setting claims." + entry.getKey() + " to " + entry.getValue()); hash.getHash().set("claims."+ entry.getKey(), entry.getValue()); } hash.saveHash(); }?
How can i make my anonymous function get the right subclass?
I want r to be a RectangleObject
(without implementing the addEventListener on every subclass)
well it doesn't work but it puts it into the config file, it prints "Setting claims.-14.-2 to fe41bddb-1f29-48ac-b093-24344a5f00ed"
this is my config rn:
'-14':
'-2': fe41bddb-1f29-48ac-b093-24344a5f00ed
You can do this only on interfaces
Oh wait
looks correct
so what's the problem exactly? Your yaml is fine, and the hashmap is fine too
Quick question: What is the preferred Java SDK version for developing an plugin?
java 8
depends
for MC 1.18+: java 17
for MC 1.17+: Java 16
depends on wether you want to develop for 1.17
for older MC: java 8
I can also send the code for those 3 classes if that helps
okay so i do the command /claim which puts the data into the hashmap. On server stop it will save the data into the config and on start put it again into the Hashmap. But now i can claim the same chunk again.. Normally i couldn't because it checks if the chunk is contained in the hasmap
Well, my plugin is not really depended on the newest MC versions
cant rlly use an interface as i cant have variables in that
It can run on 1.13 aswelll
if you want 1.13 users to use it: compile and code it with/for java 8
Floskatler your design is strange
:(
So that means I should set the SDK to 1.8?
yeah but i dont wanna manipulate the original one on hover
yes
thats why i clone it
np 🙂
make them immutable maybe?
whats them?
I still need to get used to all these SDK versions ahaha
you must use the lowest version for compiling that you want to support
and noone is using anything older than java 8 anymore
so just use 1.8
RectangleObject
HashMap#contains(Object o)
where is 1.18 download?
What about the Spigot version?
i always use the newest
can 1.17 and 1.18 servers use plugins developed with 1.8?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
depends
yes
yeah i got that, but issue is when it loads it again it is not contained anymore, even if it should be
essens?
If I use the 1.17 spigot jar. It works on 1.13 aswell right?
Unless i use newer features ofcourse
it's not contained in what?
Alright got it
EssentialsX
Gracias again amigo
But youll need to run a 1.13 server on java 16 atleast
@quaint mantle
So i have a rectangleobject and it has different attributes like width,hight,text etc.
On Hover, i want some properties to be changed, for example the text or width.
rect.addEventListener("hover", r -> {
r.setText("newText");
r.setWidth(30);
});
When you dont hover anymore, the properties should change back to what they were before.
My approach is to simply copy the original rectangleobject on hover start, change the copy as specified in the Event, and display that changed copy when the user hovers. and when he doesnt hover anymore, show the original again.
i need EssentialsX for 1.18
no. only 1.17+ requires java 16
yeah. so go to that channel
you're in the wrong channel
ok
@tender shard okay so i do the command /claim which puts the data into the hashmap. On server stop it will save the data into the config and on start put it again into the Hashmap. But now i can claim the same chunk again.. Normally i couldn't because it checks if the chunk is contained in the hasmap
if you use a plugin compiled with java 16 on a 1.13 server, you have to.
is there a better apprach to it?
of course, but we weren't talking about that
the question was whether a plugin developed for 1.17 will also work in 1.13
if you dont answer i cant help you
It will, but if you develop against 1.17, java 16 is required on the server. If you develop against 1.13,you can use java 8
that's what I said
p.sendMessage("§4Dieser Chunk is schon geclaimt!");
```
```public boolean isChunk(String chunk) {
return chunks.containsKey(chunk);
}```
it checks it
Does anyone know a better approach?
also brb
is there also an else part that executes when the chunk is no claimed?
hover over it? wdym?
im making a gui
or an early return
what framework?
my own
then you should know that yourself, how should we know how your own framework works?
you dont need to know how my framework works
i am trying to figure out HOW to make it work
🎉
damn
auto text-centering, borderradius, canvas to draw stuff (f.e. the cube), ...
and hover events. but what u see in the gif is hardcoded. i could like to do the hover as specified above.
but yeah, i need help with how to do this
im not that deep into OOP
Wym get the right subclass?
well, u see how it returns this.clone() (simply returning this gives the same result)
this should be a rectangleobject when i call addEventListener on a rectangleobject
but it returns a windowobject (superclass)
therefore intellij doesnt show the functions and attributes of rectangleobject unless i cast windowobject to it
get the problem?
if addEventListener is called on RectangleObject, r should be a RectangleObject (and not a WindowObject (which is the superclass))
not sure if you forgot me or smth and i also don't want to come off as impatient, but you didn't respond to me anymore 😦 Also sorry to disturb you again XD
@ivory sleet get what i mean?
changing my interface to this also didnt help
now it just says T, and not RectangleObject :/
Well
One way would be to parameterize the class
what does that mean xD
interface EventFunction<T extends Blah> {
void on(T t);
}
As of now, there is no type of argument which can conform T to whatever you want
how do i change this then?
intellij marks it, but doesnt know what to do
xD
and i dont either xD
<T extends Blah> void addEventListener(String event, Class<T> eventType, EventFunction<? super T> function) {
}
xD Chain!!!

but then i have to pass the class when doing addEventListener, right?
Yep
well that sucks
so no simple way to get r to be RectangleObject when i call it on a rectangleobject?
Does RectangleObject extends something?
yeah, WindowObject
and this is in WindowObject
is it possible to get the amount of players any server has?
example: hypixel, mineplex....
Could have
class WindowObject<T extends WindowObject<T>> {
void addEventListener(String name, EventFunction<? super T> function) {
}
}
Then in your subclass
class SubObject extends WindowObject<SubObject> {
}
Hmm yeah in principle
With the assumption that the server doesn’t lie about it
@ivory sleet now r is of type WindowObject<RectangleObject>, which still doesnt allow me to use methods from rectangleobject
ah wait, i can use T to cast right
wait nah i cant
ok mightve got it to work, ty!
how to check when player is rotating inside vehicle?
get moveevent and check the yaw?
maybe gotta check it on vehiclemoveevent, not sure
then vehicle move event
dooesnt work too
how
i meant
how do i do t
u get the yaw from the getTo location, right, @graceful turret
check
ok no
use e.getTo().getYaw()
thats the new yaw of the player if im correct
p getLocation getYaw should be his old one
im not entirely sure, but try it
@graceful turret
ok
LMFAO the message i sent above this wasnt me
xd chain!!!!
i left my laptop in history class
lmfao
@ember estuary there's a problem because this event even not triggers
if i am just rotating
how do i add the API to IntelliJ again? I tried adding it via the context menu and it shows up in the 'External Libraries' tab and the project shows the bukkit symbol but it still says 'Dependency not found'. I'm building using Maven
Could not find artifact org.spigotmc:spigot-api:pom:spigot-api-1.18-R0.1-SNAPSHOT in spigot-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
7.6$ per month for singapore host 8gb ram with Xeon E 2276G cpu
Is it worth it?
nevermind i found it
ok pls someone help me to start up a 1.16.5 after i installed java 17, i still have the java 1.8 tho
then your only option might be a bukkitscheduler that checks the players yaw
but lets ask the other people, maybe they know a better way
guys, how?
@ember estuary i figured it out - i just have to create new location and teleport entity to it
Hey folks, working on porting my NMS work to 1.18, I'm looking for the new name of isDebugWorld() and isFlatWorld() defined in net.minecraft.world.level.World and WorldServer, what are the new names for these? I cannot find the World class on Mini's mappings viewer to try and find it myself 😅
Or rather, the obfuscated names
the girls now know you're a nerd
Hey ! Is it possible to make the slime faces the ground ? (eyes down)
You could try modifying the rotation, but I'm not sure this is possible
Texture pack
Possible as in, possible at all server side, or possible with the Spigot API, you might have to reach for NMS
Yes I tried slime.setRotation(0, 90); but the rotation seems only possible for the yaw not the pitch
You could try working with NMS, but I doubt thatll solve it, so you'll likely have to reach for a texture pack I'm afraid
An option would be, but this is quite a lot more complicated, is to spawn a custom player with a custom slime skin
would require a lot of NMS too
Thank you for your answers
Remapped the official 1.18 server from Mojang, it does not have net.minecraft.world.level.World 🤔
https://paste.gg/p/anonymous/3ca7c698ecca43d08f9c09da969440c5
it feels like it needs decomposition
Try Level
There indeed is a Level class! Odd that that is renamed in the Spigot jar
Yeah feels like some of those methods belong to the Clan interface instead
Then I am also looking for the Mojang variant of WorldServer 🤔
can you make custom ores with plugins
Found that one, it's net.minecraft.server.level.ServerLevel
Not really, no. You can only customize existing stuff, excluding the texture
deadass tho
im scared lmfao cause they probably looked at my grades
having a LoL pfp is already enough
Yeah lol
tbh i havent changed my pfp for a while now (months)
too lazy to find smthing better
i havent changed my pfp for 4 years smh
F
lied, 3 years but still
pog
Does anyone know a good method for sending a redstone pulse with proper block updating and whatnot?
I attempted it in the past and wasn’t getting very good results, I’m trying to pulse a redstone signal just like a button would
shouldnt why does the first one should null, it should say stick right?
shouldnt why does the first one should null
ok i realise that does not make sense xd
why does the first one show null shouldnt it show first stick?
label is the alias of the command used @hoary pawn
yeah
args[0] does that get the first thing in it or is that python
first_item in this case
hmm maybe fuck efficient updates and just save the entire clan all the time
What would you say is the best way to search a y-coordinate from top to bottom in the nether for a safe spawn point? I was thinking of doing a binary search and even getting it down to O(1). Though the nether can be deceiving and not get the exact results needed with this type of search (but this can be overcome).
can you make certain blocks spawn underground
that already exists in the game
And is there any tuturials for it i cant see anything about it
binary search is probably the "only" way
it depends how much you are calling it
even if you were looping over every block but only when a player spawns that is "fine"
Wdym?
like from bottom to top
I think I linear search would work fine too
IS THAT BETTER
Maybe give the two a test (doing linear from bottom) and see which one does better
thanks
For now just once, but in the long run doing it a ton
It has really good runtime
Could someone help? My first IntelliJ with maven experience. Maven compiles plugin not to jar, but to folder (files are .class). How i can fix it, so files will be compiled to jar?
<build>
<finalName>${project.name}-${project.version}</finalName>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>E:\NTD Studios\intelli-test</outputDirectory>
</build>
what are you running to build it?
you should at least use maven package
that's wrong
you want to use maven
in the top right, there should be a maven tab
open that, go to lifecycle
then double click install
or package
Why doesn't it work?
System.out.println(event.getClickedBlock());
System.out.println(event.getClickedBlock() instanceof BlockInventoryHolder);
[15:29:43] [Server thread/INFO]: CraftBlock{pos=BlockPosition{x=141, y=66, z=96},type=FURNACE,data=Block{minecraft:furnace}[facing=west,lit=false],fluid=net.minecraft.world.level.material.FluidTypeEmpty@6af5bbd0}
[15:29:43] [Server thread/INFO]: false
Do you mean "M Maven"?
yes
what doesn't work? do you expect it to return true?
yes
cause Furnace extends this class
if so: a block will never be instanceof BlockInventoryHolder. You want to compare the BlockState instead
Furnace does, but your block is not instanceof Furnace. It's state will however, be
System.out.println(event.getClickedBlock().getState() instanceof BlockInventoryHolder);
ty, I'll try it now
Yes, it works. Thanks. But file is generating with name plugin-1.0-SNAPSHOT and at /target/ path. Is there any way to change building path?
do you already have maven-jar-plugin in your pom?
inside <build><plugins> ?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>/my/path</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
Now it generated splited per module
show your pom pls
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.DenBeKKer</groupId>
<artifactId>MavenTest</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>plugin</module>
<module>nms-base</module>
<module>nms-1_18_R1</module>
<module>nms-1_17_R1</module>
</modules>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<defaultGoal>clean package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>E:\NTD Studios\intelli-test</outputDirectory>
</configuration>
</plugin>
</plugins>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
yeah it's normal that it creates one jar per module. doesn't your final jar contain all modules?
tysm, it works
you're welcome 🙂
There is only module jars
I cannot find final jar. Or is it located at another path than <outputDirectory>?
java.lang.IllegalArgumentException: No enum constant org.bukkit.Material.RAW_FISH
api-version: 1.16
I don't think raw fish is a modern material
yeah what are you expecting?
declaration: package: org.bukkit, enum: Material
RAW_MISH might have been a thing 10 years ago, but definitely not in recent versions
wait raw mish, i havent heard of that
hi im trying to use buildtool but it is saying i dont have PortableGit when i do
?
what am i doing wrong aaa
dffffffff
Hi, I just ran buildtools to start updating some plugins and all the imports have vanished.
Read the update post
aaahhh i see, thanks
where do i download the 1.18 spigot api
i dont think its out yet
i'm creating a wrapper class around a player which loads and saves data, manages chatchannels, etc should i store a player instance internal or just an uuid as it is easier to get the actual player object rather than calling Bukkit.getplayer(uuid) every time
Separate your User class and Player one
wdym separating? the user class needs player stuff to work with
someone link me a java tutorial
UUID, NEVER store a Player
store a player in a weak ref hash map :>
Fetch it from a UUID when you need it and thers no need to Weak maps nor validating anything
true that 😂
dont make a wrapper. If you need to sendMessage, use player. If you want to set channel, use your User Object
i've been doing it just because I do it
i didnt know it was that important
or i knew but i forgot
and i just got used to do it
?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.
ty
how does Bukkit.getPlayer(uuid) even works internal? just a for loop?
how long does it take adding a pr or md5 and so on?
Depends on the size
I'm having trouble reading the library from 1.17 in eclipse! Can someone help me?
No not a for loop
It uses a HashMap afaik
Read the post on the forums about API changes and Bootstrap.jar #announcements message
CraftServer is the implementation
wasnt the new Bootstrap a 1.18 feature ?
I am not using Bootstrap! And yes the version of spigot + API
ah I saw 1.18 in the pick and didn;t notice yoru question was about 1.17
show some actual errors then
I started having this problem after I upgraded to 1.18
The stranger who cannot understand the problem!
OK, if you don't want to give us any information to help you with
All you have shown is a red cross warning, with zero information
Fun after adding a new library that was 1.18
OK we are getting closer. You are using 1.18 in that code and NMS
it no longer has getId()
new ArrayList<>(entityarmorstands).get(0) :/
entityarmorstands.iterator().next() :)
is it an array?
This NMS is from 1.17!
I'm also using the library from 1.17
How do you rotate a rectangle like this?
how can i make my plugin compatible with both spigot and bungeecord? like this, but when i load the plugin on the proxy it says me
java.lang.NoClassDefFoundError: org/bukkit/plugin/java/JavaPlugin
Please ping in case.
given you have x,y,width,height and a rotation in degrees
and a grid you paint pixels on
how do i calc where the pixels go?
or better: how do you rotate anything? (triangle, ellipse, ...). is there a formula?
player give function
xD
Get their inventory and addItem
^
Anyone?
You need a class for bungee and a class for spigot
And bungee can't touch spigot imports, and vice versa
hehe
is there a way to only generate worlds that do not have the spawn as an ocean
cuz i make 100x100 worlds generate
in spigot?
yes
oh
well i use paper as software
basically my minigame has 100x100 random worlds, but when it is an ocean world, it ruins the fun
and i have to force end the game
how do i stop this
check if the spawn location has water
scan 25x25 of the world, make some logic to get the amount of water out of the amount of blocks
I already done, like in the foto, in the bungee directory I'm doing the bungee thing
if its above 50/100 then force end the game
that defeats the purpose
i dont want it to force end the game
i dont want water to generate entirely
bungee and spigot plugin
Can't you just follow this principle but instead of ending you regenerate it again till the outcomes good?
takes time to generate worlds
and usually people join in about 1 min before game starts
so it has 1 minute to cycle through worlds
not efficient
they said to try this in that thread
Field biomesField = BiomeBase.class.getDeclaredField("biomes");
biomesField.setAccessible(true);
if (biomesField.get(null) instanceof BiomeBase[]) {
BiomeBase[] biomes = (BiomeBase[]) biomesField.get(null);
biomes[BiomeBase.DEEP_OCEAN.id] = BiomeBase.PLAINS;
biomes[BiomeBase.OCEAN.id] = BiomeBase.FOREST;
biomesField.set(null, biomes);
}```
So would it be better to generate with 1-2 worlds being a buffer?
but it appears to be 1.8
Hey quick question: I'm currently trying to work with the Attribute Modifier on items and the first thing I'm trying to do is change the AttackSpeed of a tool. Unfortunately, I still don't quite understand how it works from the stuff I've found on the internet.Can anyone help me with this by chance?
Isn't it better to just loop through random location and change the spawn?
this will just remove the generation of ocean biomes
damn didn't expect nms to be that kind
guys does anyone know how eclipse works?
i mean im working in it i just dont know the features yet
ig its thejava olditemstack.setItemMeta(meta); then?
but that cant set the meta can it?
you change the meta that u got from this
then do ItemStack.setItemMeta(modifiedMeta)
okay im sad now, has anyone here managed to create a 1.18 plugin since the settings changed all over the place
'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
erm yes sure
all my 16 plugins are running on 1.18, what's your question? ^^
use mojang mappings
ill dm you if i can
Oh lol I was gonna say I am but realized I am not
LMAO
😄
in mojang mappings, there are no methods called x() 🙂
@digital rain
the problem is that when i add spigot-1.18 as my referenced library it just doesnt seem to contain all stuff
That's correct. Did you run BuildTools.jar --rev 1.18 --remapped ?
also: are you using maven, or adding the .jar manually?
anyone help
i just ran buildtoolds without the remapped thing
can anyone help me remove oceans from worlds
do you need NMS?
Maven
And lemme check if I used --remapped
show your pom.xml please
Guys i have a problem when i build my plugin:
Cannot determine path to 'tools.jar' library for openjdk-17 (C:/Users/TAAFRLE2/.jdks/openjdk-17)
you have the wrong dependency @digital rain
i just have downloaded buildootls and used this
instead of this:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
use this:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
How to use net.md_5.bungee.api.chat.hover.content.Content?
you want the spigot-api without a classifier, and the spigot thing with remapped-mojang
I see
where do i do that? im really confused
I'll adjust your pom and send it back to you
whattt
?
basically replace your current pom.xml with this
there is no such thing as pom.xml in my buildtools folder
huh? no, inside your plugin's project
ooh I'm so sorry
you were not the person who sent their pom
sorry I confused you
sorry I replied to the wrong person
check out what I wrote to Papple
do this @halcyon topaz
Yeah already did! 👍
does it work? 🙂
Not quite.. I still see the 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
IntelliJ?
Yeah
did you click the "reload maven" button?
Yeah
Try File -> Invalidate Caches and let IntelliJ restart
click Invalidate and Restart there
Kk
the problem im facing that this is how all 1.18 spigots look like, nothing else (this would be my question) 😄
you are using the bootstrapped .jar
the "real" spigot is inside META-INF/libraries
do you actually need NMS methods @digital rain ? Or just the normal API stuff?
Same issue 😦
normal api stuff
are you using maven?
nop
hm are you sure you ran BuildTools with --remapped?
Yeah I re-ran it earlier
just when i try to create a new project it cant import any of the org.bukkit methods
You should NOT use the .jar you currently use
Should I delete all the files and restart the BuildTools?
but the one that you can find inside BuildTools/Spigot/Spigot-API/target
shouldn't change anything. Please go to <YourUserName>/.m2/repository/org/spigotmc/spigot/1.18/ and send a screenshot
@digital rain When you use the jar you can find there, it should work. Be sure to use the one ending with -shaded
that looks correct
What do i have to do?
where does that error come from?
when i build the project
please run mvn clean package and send the output
how are you building it? maven?
build -> artifacts
then you messed up your build configuration to include something like "tools.jar" I think
i have never seen anything ending with shaded, can you quide me thru the exact steps of the buildtools thing for 1.18also thiss is how my buildtools folder looks like
tools.jar was removed in JDK 9. Are you trying to build a very old project?
for buildtools 1.18, just do this:
java -jar BuildTools.jar --rev 1.18 --remapped
here is the artifact
it should actually automatically install everything to your local maven repo
delete everything else right?
no you don't have to delete anything
is this right?
Lot of incompatible types: net.minecraft.server.level.ServerLevel cannot be converted to net.minecraft.world.level.World
after buildtools ran, add the following jar as dependency:
BuildTools/Spigot/Spigot-API/spgot-ap-1.18-R0.1-SNAPSHOT-shaded.jar
did you by any chance include both the remapped and the normal spigot jar?
because World is spigot's name, while ServerLevel is the mojang name
I don't believe so
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>```
That's all the spigot jars in my pom
yeah don't add craftbukkit lol
remove that
craftbukkit is included in spigot anyway
but now you have obfuscated NMS names from craftbukkit and remapped names from spigot
remove the whole craftbukkit thing
np
also can you show the code that caused this error?
Yeah gimme a sec
urghh
show the whole command please
it should be:
java -jar BuildTools.jar --rev 1.18 --remapped
i ran in 1.8 java since i have java 17 installed
Bloodlust-Infused? more like Lust-Infused 😉 
no
It is December after all 😫
you are passing the CraftWorld but you need the NMS world instead
Yeah it fixed itself after I removed CraftBukkit
you will of course need java17 for mc 1.18
okay so no problems anymore? 🙂
yeah idk mate but this whole 1.18 thing is confusing
switch to maven and you won't have problems again 😛
you are making live hard for yourself by doing it manually
Not regarding the original issue. I should be able to fix everything else on my own. Thanks! 😄
but my buildtools is outadated then since it only supports java 16
alright, np 🙂
well then update buildtools
?buildtools
h
?bt
Can maybe someone help me with this?
no
the jar is not downloadable
just run buildtools. then you have the API inside BuildTools/Spigot/Spigot-API/target
or switch to using maven and all you have to do is done automatically
Oof
where does this tools.jar even come from?
tools.jar doesn't exist post-Java 9.
as said it was removed in jdk 9
im giving for now, and ill take sleep
giving up
okay, but bookmark this link pls 😄
There is no tools.jar file
yah alr
but why does it show up this error
because you somehow somewhere reference the tools.jar file
e.g. in your buildpath configuration etc
as I tend to say: use maven and you won't have those problems 😛
And also, a small tip
i actually use maven
Any classes made available by tools.jar in Java 8 and below are not available to JRE users.
make sure your IDE is up to date
it doesnt look like you used maven to build the .jar though
A good friend of mine once made this project for Gradle that allows Java 9-compatible usage of the classes from tools.jar
Shameless plug btw
Is this right for minecraft version 1.18?
yes just click next, you dont need an archetype
ok
what does tools.jar actually provide?
first google result says I predicted
your IntelliJ is too old for java 17
what version are you running
The classes used by JDK tools like javac
java 17 was only just released, so you need the very latest version
Mainly, this allows you to patch into javac's AST via annotation processing hacks.
Y'know
Like what Lombok does.
hey, need some help
my maven config throws this when I run specialsource:remap
The parameters 'srgIn' for goal net.md-5:specialsource-maven-plugin:1.2.3:remap are missing or invalid
ah, alrighty. never heard of tools.jar before
In Java 9+ it's replaced by the module jdk.compiler and such iirc.
it will run as part of your build
I have no idea what all those things do lmao
Should i build the project over build -> artifacts or otherwise?
com.sun.source = AST declarations API.
com.sun.tools.javac = Javac classes.
com.sun.tools.sjavac = (or Smart Javac) An alternative entrypoint for Javac that apparently improves it but, as far as I know, goes unused.
"package" is basically what build -> artifacts does. but it does so according to your pom.xml
oh wait. you're using eclipse right?
do you have a "maven" tab in the upper right corner?
stop confusing the issue
just update your intellij
thats all you need to do
then you can go back to what you were doing before
yes
ok
(or alternatively, use JetBrains Toolbox)
(literally first result on google for that error would've told you this)
there is an update
IntelliJ IDEA 2020.2.4 available
still outdated
recent one is 2021.3.something I thnk
2021.2.3
thats the latest version, at least for IDEA Ultimate
so i making a plugin so you cant place tnt but im trying to replace the tnt that you place but for some reason it duplicates it
@EventHandler
public static void blockplace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
if(material.equals(Material.TNT)) {
block.setType(Material.AIR);
player.getInventory();
ItemStack item = new ItemStack(Material.TNT);
player.sendMessage(ChatColor.RED + "NO TNT FOR YOU DUNCE");
player.getInventory().addItem(item);
}
IntelliJ IDEA 2021.3 available
This one right?
public static void blockplace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material material = block.getType();
if(material.equals(Material.TNT)) {
player.sendMessage(ChatColor.RED + "NO TNT FOR YOU DUNCE");
event.setCancelled(true);
}```
yes
o so that just makes whatever event is there not happen
that would work way better lol
also dunno if u wannna make a whole variable for one usage, and why is there a player variable
so i can see who placed the block
is it possible to make players displayName inbisible at range by setting their setCustomNameVisible to false? does it work the same as it does for mobs?
no need to make a variable for something so short and used only once
java 17 support
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if(event.getBlock().getType().equals(Material.TNT)) {
event.getPlayer().sendMessage(ChatColor.RED + "NO TNT FOR YOU DUNCE");
event.setCancelled(true);
}
}```
also why is ur event static? i fixed it for you
what did you change
whats wrong with static tho
best to avoid it when you can, static makes shit hard while testing
is there a way to find nbt tag data without nms
https://github.com/AtlasMediaGroup/TotalFreedomMod/blob/main/src/main/java/me/totalfreedom/totalfreedommod/blocking/SignBlocker.java was thinking of a way this could be done w/o nms
if reflection or nms api only way then okie
how bad is the lag between using bukkit hooks and nms?
PersistentDataHolder?
I need help remapping my plugin 🤦♂️
both maven config and manual commands from here don't work
https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-release.534760/
maven config says my srgIn parameters are wrong and the manual command can't Initialize the main class??
Also tried this solution :
https://www.spigotmc.org/threads/1-17-1-specialsource-remap.522548/
but I'm getting a class not found error so I'm doing something wrong
thanks
Edit: 1.18 release is now available.
Dear All
As we mark the 9-year anniversary of SpigotMC.org, it is my pleasure to announce that...
uh theres literally a permission for that?
and isnt it op only by default anyway
minecraft.nbt.place is the permission
its an all op plugin plugin where we actually setOp to players but is controlled by denying permissions to users
i didnt make the plugin dont wor rey
worry
xd
alright im finished
Hey guys, quick question. 1.16.5 has net.minecraft.server.v1_16_R3.EntityFallingBlock, which has a noclip field. I'm trying to update to 1.17.1, which has net.minecraft.world.entity.item.FallingBlockEntity, but there's no noclip field in that class. Does anyone happen to know what that field was renamed to/how to turn on noclip for a FallingBlockEntity?
I see verticalCollision and horizontalCollision, are those the same thing as 1.16.5's noclip?
anyone got a good tutorial explaining the newer custom generation system
im making something simple where the world is empty except a few randomly placed structures throughout the world
i cant rlly find anything on it
like theres no examples or anything
i mean like the one with all the methods instead of the single method one
not just 1.18 lol
declaration: package: org.bukkit.generator, class: ChunkGenerator
thx
i just dont rlly understand like what ur supposed to put in generateNoise and generateSurface and stuff
it doesnt really matter if youre just writing a single pass generator
hi
how can i load a yml file in memory when server starts, then save it when the server stops
I don't think so, as it's rarely used
create a public variable?
well wherever you want to store it
thats not really a spigot question, that's just java
cuz i rlly dont wanna set blocks for each individual block of a structure and stuff (ik theres a way to use the nbt files to generate but idk how)
declaration: package: org.bukkit.structure, interface: StructureManager
Is that new
relatively
Since when it's there
1.17
can everyone on server see player.send message contents
Ooo cool stuff
no, its Player.sendMessage