#help-development
1 messages · Page 2183 of 1
Also 50 items, that's allot to do with out a loop
so just change the slots depending on what armor they wear
it will most likely just update every second or smt. that'd explain why tf their server performance is so trash
Lol
It'll update when they player equips and unequips armor
U can create an armorequipevent
yea i never messed with custom events, at least not in spigot
for custom events i always use my shitty horrible optimized own api lol
Inventory.setItem(int slot, ItemStack)
just re-add the item ig
set its contents to (get its contents)
I guess
does this make sense
with get its contents you hopefully mean the player's contents, and not the gui's contents
in that case, it does indeed make sense
i mean, when you jut set the contents to what is already set, it'd change nothing lol
This is the way btw
did Class InventoryOpenEvent cares about chestd etc. or only player inv?
how would i kill all dropped items without using /kill @e
Please help
I have a list of Protection, but I cant get the list from config
c3c73faa-eeef-2f10-9bae-67abcdd00f5f:
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
owner: &id001
==: Player
name: Armando_Sales
location:
==: org.bukkit.Location
world: world
x: 13.0
y: -60.0
z: -4.0
pitch: 0.0
yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
owner: *id001
location:
==: org.bukkit.Location
world: world
x: 18.0
y: -60.0
z: -5.0
pitch: 0.0
yaw: 0.0
CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString()); //is null
afaik Inventories are all GUI's with slots
Actually inventoryopenevent isn't called when player opens their own inventory
Player inventory is always marked as open
lol
InventoryCloseEvent is claled when it's closed though which is dumb and inconsistent
But it's mojangs fault
i mean can i check with that event if player opnes a chest?
Yes u can
cool
It worksfor chests
if not, you can't
i may actually create a clientmod someday which extends the amount of things that send packets
it's so dumb to see how many things don't inform the server about what happened
any1?
Levitation effect is not triggered under water
yes that's a thing
Now I have to check if the player is in the water and teleport him to the first block that is not water
so annoying
i love that it is like this
imagine looting endcities without that
water is the best thing against that stupid effect
does anyone know why when i have a prepareitemcraftevent and i get the crafting inventory, i set the result item and it only shows when i remove the current result in the crafting grid?
guys i know this isn't a development question but i have a really large build that i want to move (including mobs, inventories, biomes, etc) to another world, the place would be too large to do with litematica, is there anything like the old mcedit which can do that these days?
best to ask in #help-server
okey
Simple way to check if player is in water is to check if the block at his eye position is type = water?
That would not detect if only his feet are in the water
I don't care about his feet as the Levitation effect triggers as soon as your head is outside of the water
okay nevermind
what is the event for a player setting on fire
find the answer
it was entitycombustevent
.playEffect() is deprecated, what should be used instead?
yeah
are you sure that you cannot write to it?
The different icon can be explained by it being empty
pls tell me u arent creating a datastore system with yml files
it can get quite messy and bad if the server grows
id say its good for storing temp data
Temp data?
if you want a stable database consider SQL or Mongo
i use it to store game rounds and other temp shit that i delete later
I prefer my DataInputstream & DataOutputStream
I'd store that in volatile memory
oh alright
Proper databases are overrated
wut
there are way better databases to use
such as?
mongo is way better
Please can anyone help me with this thing
c4c5af3a-ee3f-3f90-91ae-67a5cfd00f6c:
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
owner: &id001
==: Player
name: Armando_Sales
location:
==: org.bukkit.Location
world: world
x: 2.0
y: -60.0
z: 21.0
pitch: 0.0
yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
owner: *id001
location:
==: org.bukkit.Location
world: world
x: 1.0
y: -60.0
z: 19.0
pitch: 0.0
yaw: 0.0
- ==: me.armando_sales.primeiro_plugin.eventos.Protection
owner: *id001
location:
==: org.bukkit.Location
world: world
x: 0.0
y: -60.0
z: 18.0
pitch: 0.0
yaw: 0.0
I'm trying to deserialize a list of Protections but the objects are all null
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString()) != null) {
List<?> list = CustomConfig.getContainersConfig().getList(onlinePlayer.getUniqueId().toString());
for (Object object : list) {
EventoBlockPlace.getProtections().add(((Protection) object));
}
}
}
[null, null, null]
mongo isnt relational though
they serve different purposes
(ideally)
then if you use it for something else thats on you
See, DataInputStream & DataObjectStream is much better if done properly
being a javascript main, id rather not have to learn how to write sql
its easier to use mongos driver for maven
The only issues are spontaneous crashes or power losses - but most DBs have similar issues.
And you don't want to have this anyways
yes but for scalability you dont always want to run a mongodb
why not
because complex queries can be much more scalable w/ sth like postgre for instance
postgre is enterprise gold
Could you add a bit more info there?
What does it say?
Then you are not writing to it
well i dont wanna go through the process of learning how to use another database since mongo provides me with more than enough to do what i want
ok but that doesnt make sql and its implementations dogshit lol
lack of proper orthogonality — SQL is hard to compose;
lack of compactness — SQL is a large language;
lack of consistency — SQL is inconsistent in syntax and semantics;
poor system cohesion — SQL does not integrate well enough with application languages and protocols.
dont spread fud about technologies that are actually really useful and meaningful
lack of compactness?
mind elaborating on these points you're making
there are 469 keywords in sql
and, you dont need to know them all to be able to use sql?
Man hate SQL all you want but it's lighter than a lot of others (looking at you mongo)
if you know the 36 most used ones then you're already quite knowledgeable in sql
SQLite is also really nice
for instance mongo is unstructured, and internally it saves everything to json documents, so it is efficient if you are gonna store key-value blobs, but for structured data sql is almost always the way to go whenever you actually want to seriously scale something (horizontally ofc)
Lmfao I love the argument that less is always better.
I mean you usually put your statements in constants and format them in a more readable way, anyway this is entirely besides the point
it is more efficient to write
u can shoot yourself in the foot so easily with sql
its not like you're writing a million lines of sql queries tho lol
I mean then you get a syntax error which takes a minute at most to fix (presupposing you wrote it syntactically wrong)
sure
Plus you can always use intellij to prep your queries in advance.
Welp, this reinforces my assumption that all DBs are shit
And like sure, thats a nice java wrapper for mongo ceryth
but those exist for sql impls as well
i can still use mongo more easily with my other applications if i want to access that data
elaborate?
Also if you've used Linq SQL can look way better than anything mongo has.
say you would like to make a discord bot for your discord server that verifies the player based on ingame data, or get their stats by running /stars <player> on discord
and its not like one is harder to setup or anything fyi
both have docker containers on docker hub etc
final int points = 18;
final double size = 8;
int upper = 256;
int lower = p.getLocation().getBlockY();
Bukkit.getOnlinePlayers().forEach(all -> {
for (int k = lower; k < upper; k+=4) {
for (int i = 0; i < 360; i += 360 / points) {
final double angle = (i * Math.PI / 180);
final double x = size * Math.cos(angle);
final double z = size * Math.sin(angle);
final Location locnew = p.getLocation().add(x, lower, z);
all.playEffect(locnew, Effect.MOBSPAWNER_FLAMES, 1);
all.playSound(locnew, Sound.ENTITY_ENDERMAN_AMBIENT, 5L, 5L);
}
}
});```
Are those too many particles or why is it not showing any??
how is that easier with mongo?
Imo people who hate SQL are just mad cause bad.
well mongo isnt bad
Now OracleSQL that's something to hate
I use both
same
public PrimeiroPlugin() {
ConfigurationSerialization.registerClass(Protection.class);
}
public class Protection implements ConfigurationSerializable {
@Override
@Nonnull
public Map<String, Object> serialize() {
Map<String, Object> stringObjectMap = new HashMap<>();
stringObjectMap.put("location", location);
stringObjectMap.put("owner", owner);
return stringObjectMap;
}
private final Location location;
private final Player owner;
public Protection(Location location, Player owner) {
this.location = location;
this.owner = owner;
}
public Location getLocation() {
return location;
}
public Player getOwner() {
return owner;
}
@Override
public String toString() {
return "Protection{" +
"blockLocation=" + location +
", owner=" + owner.getName() +
'}';
}
}
@quiet ice
yeah or well if you wanna take advantage of its structuring implementation
why did this function returned null
public void removeLevel()
it's my custom function
and there's normal code
and like
what
fyi, im talking mongo for my whole custom coded network not a single plugin
Knowing everything in the universe?
even if i created a single plugin, i doubt i would get myself through the process of writing sql
anyway for instance Netflix, Twitch and Instagram are some services that use postgresql due to the fact that its a good sql impl
I love mongo but it's slower compared to SQL.
Plus you can write the constraints and what not in your create query and that makes me happy cause then it's just simple inserts from there.
public void removeLevel() {
if (world == null || startLocation == null || name == null) return;
try {
LevelsConfig.set("levels." + name, null);
LevelsConfig.save();
} catch (Exception e) {
Bukkit.getLogger().log(java.util.logging.Level.SEVERE, e.getMessage());
if (WaterRun.get().getConfig().getBoolean("debug"))
e.printStackTrace();
}
if (WaterRun.getDatabase() != null && WaterRun.getDatabase().isConnected()) {
try {
if (WaterRun.getDataHandler().isInLevels(this)) {
WaterRun.getDataHandler().removeLevels(this);
} else {
Bukkit.getLogger().log(java.util.logging.Level.WARNING, "Level "+name+" isn't in database");
}
} catch (Exception e) {
Bukkit.getLogger().log(java.util.logging.Level.SEVERE, e.getMessage());
if (WaterRun.get().getConfig().getBoolean("debug"))
e.printStackTrace();
}
}
}
``` can someone help why did this return null exception
Have you ever configured a cisco router?
lets say you have a table of users that have some columns such as name, number and geolocation, with sql you'd be able to efficiently only get a number, or a geolocation for all or one user in a horizontally scalable manner
sql > nosql
in mongo, internally even though you might only want the number of all users it'd have to query entire blobs still
this becomes especially powerful with relational tables (sql)
[22:23:20] [Server thread/ERROR]: null
Ah beautiful
idk man sql sounds a bit edgy for me
u need to take care of so many exceptions and errors
wat
Caused by: java.lang.NullPointerException: Cannot invoke "com.martinecko30.waterrun.level.Level.removeLevel()" because the return value of "com.martinecko30.waterrun.level.Level.removeLevel()" is null
Well yeah but mongo just throws them secretly and if you get hit with one good luck. SQL has the balls to warn you in advance
mate have u seen mongo logs
Yes
its not like thats impossible to do with sql since thats a mere wrapper (logging)
Throw secretly as in you don't know something can throw an exception (like a query) until it does
its actually the opposite
there's nothing else, I know ho to go through the statrace and it's just pointing from where in code it moved there, and for real, I have no idea why did this happend, i think something corrupted interrupted it and broke it
how lol
i just found it trash that i have to learn an entire new language for such simple shit
it takes like 20 mins to learn
Yes but it's worth it
^this
public void createLevels(Level level) {
db.update("INSERT INTO Levels (Name, World, LocationX, LocationY, LocationZ, DoorX, DoorY, DoorZ\n)" +
"VALUES ('" + level.getName() + "', '" + level.getWorld().getName() + "', '"
+ level.getStartLocation().getX() + "', '" + level.getStartLocation().getY()
+ "', '" + level.getStartLocation().getZ() + level.getDoorLocation().getX()
+ "', '" + level.getDoorLocation().getY() + "', '" + level.getDoorLocation().getZ()
+ "')");
}
mysql, the update method is just querry
mongo takes like 5
ok?
but it would throw this:
public int update(String query) {
try {
return conn.createStatement().executeUpdate(query);
} catch (Exception e) {
plugin.getLogger().info(" ");
Bukkit.getConsoleSender().sendMessage("§c - Query failed! §4" + query);
Bukkit.getConsoleSender().sendMessage("§c - Error: " + e.getMessage());
return -1;
}
// System.out.println("UPDATE - "+ query);
}
I advice using prepared statements btw
sql moment
mongo takes longer to learn the little things. Plus you need a tonne of libraries to make it functional
no?
Yes?
can any one tell me how should I use the static deserialize method? Please
lol
Bson?
yes but prepared statements make it safer to use, why wouldnt you want to exercise best practices?
forgot to mention: no
querrying for me is easier in mongo
that still has to correlation to why sql would be dogshit
Hello everyone, anyone fumbling for MySQL? I hope so. In general - what kind of error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'enduranceY (NAME, UUID) VALUES ('MrLadad13','bdc1f5f7-413b-3775-96a7-eed8857f...' at line 1
Code:
PreparedStatement ps2 = pl.SQL.getConnection().prepareStatement("INSERT IGNORE INFO enduranceY"
+ " (NAME, UUID) VALUES (?,?)");
db.Collection_Name.findOne(query:<document>,projection:<document>)
to the untrained, sql developer eye it might come to a surprise when u can query with just one line of code

As if with just a few seconds of boilerplate you can produce a faster, more effective method of doing things
still dont see your point here
why is a mysql vs mongo debate turning into personal attacks 💀
its not lol
to the untrained, sql developer eye
oh
it makes the code more compact than writing a billion lines of sql boilerplate
billion lines?
@vocal cloud Do you know ho can I use this method?
public static Protection deserialize(Map<String, Object> args)
its not like the sql query is gonna be harder, more verbose or more complicated if you wanted to write something sql equivalent
Compact? Sure. Compared to the amount of memory mongo uses? I'll take it
everything has its use-case
Never seen it before so no
General rule of thumb for me when choosing between SQL or Mongo is just if the data is relational or not
^
thanks, this^
Help plz
none are inherently worse than the other unless you define a particular use case
to quote a reddit comment
SQL is like a shop, everything is laid out on the shelf. It's easy to pick what you need, but to do the job you have to walk up and down the isles to get each bit.
NoSQL is great of you're always making the same thing. SQL is great if you make a variety of things. Use the right tool for the job.```
INFO?
Should be INTO no
Also if it's multithreaded or not. If it's never multithreaded then I just use SQLite
Info?
as i said, coming from creating web apps i dont wanna learn sql when i can already adapt easier with mongo
sure if thats your opinion
but dont go around spreading shit about sql when you havent even taken the time to learn it
i didnt say that objectively its my opinion
You are the best
SQLite is thread safe
bit unorthodox to form an opinion about something you scarcely know about, then going on to make points that aren't even correct, anyway guess we're done debating now
thanks to @upper vale
I had a thread spamming my sqlite database and my plugin still functioned
It was to stress test it
Mmmm I think you have to enable it
I guess I'm just old
I mean most of them have to be thread safe
else the world would have met its demise long time ago
SQLite is really nice 
yeah as a mock implementation its rather nice
it has less syntax tho
wrong quote
i meant this
Yeah but for my application (lightweight program meant to run on a low-spec server) it's a lot better and you don't need the bloat of a db running alongside it. If I needed more complex types I'd be toast
perfect for a lightweight use-case
new File("asd.yml").create();
^
or new YamlConfiguration().save(new File("asd.yml"));

or you rename an existing file and make it empty
wdym you cant write to it? whats the error message?
and how exactly can you "not" write to it?
What are you usingnto write to the file?
When u set, yu need to save
Does using set() on the FileConfiguration actually save automatically to config.yml
Not save every time
Save every x mins and on disable
Or if it's a one time set
You can save right after
no of course not
How would I do that then
FileConfiguration.save(File)
What, you were the one that put two carets
i completely forgor what java/kotlin does with pass-by-reference and value if any, would this actually edit and save the config
iirc yes
Does #damage() ignore armor?
IIRC it deals exactly the amount of damage you specify
so it basically "ignores" armor
^
Is there a way to not ignore the armor?
none that I know of
is armor a value you can substract from damage?
you can throw an event and see what the resulting damage is
wait question
Ill try that
how are you supposed to even update your plugins when rhey have the version of the api u use in the package name of bukkit stuff?
manually change all of them?
you shouldn't use those classes in the first place
just do search & replace
@upper vale Thanks for the help with SQL, bro
I think I found a better way to tackle the problem tysm for the help
ahh i thought that was all classes okay
sorry then
only CraftBukkit and NMS classes (prior to 1.17) had the version in the package name
if you stick to the Bukkit API, then plugins will basically run in every version
can anyone help me learn databases? i've been trying to make a system where you can set a default kit then the player can re arrange the kit to how they like and save it
you mean like SQL?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
is there any api for damage calculations using the player's current armor and effects?
or a way to do it that i can write myself
Are you trying to predict what the damage will be, or modify the damage?
modify
well acute at ye the fbe a tan fb se terry aei o the p i ato bc t sang at of
wtf
Damage events have something like getDamage(DamageModifier.Armor) that gives you the reduction the armor does. If you did setDamage(DamageModifier.Armor,0), armor would be completely ignored
it's drunk
is there no easy way to make a dictionary/map in java?
I'm getting ClassNotFoundException and I tried multiple things including checking the directory that plugin.yml leads to, I can't seem to find the issue, any help?
lmao
wowza
ok so what i was trying to say, is that im dealing with particles and i need to deal damage and not modify its
so u can only have up to 10 values?
since particles dont damage players
whut
just create a new Map yourself
k10, v10
can you put values here?
HashMap<>(....);
only existing collections
oh right
also the "here" part is called the constructor 😄
oh okay, i just get a lil confused with the <>() stuff
is <> just accepting a type and () the consturcutr
HashMap<T>
something with generics idk
nope
pr is it K, V
two different names
it doeesnt matter
it could also be called HashMap<Peter,Alex>
so you could name it anything?
but dont types have to be existing classes or sum
"K,V" is short for "Key" and"Value"
to use them
Generics aren’t classes
or is that only in the constructor
no, they are "placeholders" for a class not known yet
It’s when you don’t know the type of the generic
ohk
if you find generics interesting: this is the best tutorial https://docs.oracle.com/javase/tutorial/java/generics/index.html
This beginner Java tutorial describes fundamentals of programming in the Java programming language
When you define a class using a generic, you use a letter or word like T or Type
thanks i'll have a look in the morning 👍
When you use a class using a generic, you use the class or ? if you don’t know the class yet
Optional<?> for example is an Optional of an unknown type
You don’t specifically have to use the keyword T
so if i wanted to create a method that only works with my Effects abstract class i could use
public void blah(? extends Effect)
I mean you also use wildcards with super/extends for generic sub-/supertyping
no
you just use Effect
no you can’t do that
why would you need generics if you know what parameter you expect
just take a list for example
Use interfaces
you can have lists of ANYTHING
so list is generic
your method takes an effect and not a string or an integer or a player
so yours isnt generic 😄
never really touched them
You can do something like that with
public <T extends Effect> blah(T effect){}
mkay so it's only used if the value being passed is unknown?
That does, properly, what you sent above
or like anything
an interface is like a radial piston pump
should i know what that is
It’s an abstraction for simplicity. Imagine if list.get(5) returned an Object, then you needed to cast that to a Player when you know every element in that list is a Player
Exception in thread "Thread 1" com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 19 path $
at com.google.gson.JsonParser.parseReader(JsonParser.java:66)
at com.google.gson.JsonParser.parseString(JsonParser.java:47)
at com.google.gson.JsonParser.parse(JsonParser.java:98)
at com.yk.handlers.JsonHandler.getKnowledge(JsonHandler.java:40)
at com.yk.handlers.JsonHandler.clearCache(JsonHandler.java:74)
``` ```java
JsonArray array = parser.parse(content).getAsJsonArray();
show your json
hello friends what does this error mean? ```[22:04:32 ERROR]: Error occurred while enabling TazpvpCore v1 (Is it up to date?)
java.lang.NoClassDefFoundError: net/tazpvp/tazpvpcore/Commands/admin/GmcCMD
at net.tazpvp.tazpvpcore.TazpvpCore.registerCommands(TazpvpCore.java:37) ~[tazpvpCore-1.jar:?]
at net.tazpvp.tazpvpcore.TazpvpCore.onEnable(TazpvpCore.java:25) ~[tazpvpCore-1.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[paper-1.18.2.jar:git-Paper-341]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[paper-1.18.2.jar:git-Paper-341]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[paper-1.18.2.jar:git-Paper-341]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.18.2.jar:git-Paper-341]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[paper-1.18.2.jar:git-Paper-341]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-341]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-341]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: net.tazpvp.tazpvpcore.Commands.admin.GmcCMD
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 13 more```
I love it when people just throw in an error and do not even add any message lol
is GmcCMD from your plugin?
it is
When people don’t use a link for pasting their code 🥲
[
{
"name": "Wy",
"description": "yes"
},
{
"name": "Rya",
"description": "Walks"
}
]```
okay, how does that relate to an interface?
not seeing it
?paste your full log pls
mk
both are interesting and useful
can someone help me?
where can I find some good spigot code examples of yamlconfiguration / configuration / memory
lmao bruh
lol
memory?
Interfaces are just classes with predefined functions that you want to inherit in multiple instances
But I also am not good at explaining things
So
Uh
that sounds like an abstract class but without the need to override anything it just works
I was always told "an interface is a contract"
declaration: package: org.bukkit.configuration, class: MemoryConfiguration
never seen that 👀
you have
the huge benefit of interfaces is that they do not allow instance fields and one class can inherit multiple interfaces
FileCOnfiguration etc extends Memoryconfiguration
@round finch
o
what example precisely
oops
like in terms of design? Or something else?
what about Serializable?
i forgor
It doesn't look like its an issue in my json because I believe I formatted it correctly
no you didnt
Serializable is crappy java serialization
line 75 of interest
hm is that class actually inside your .jar file? open it with winrar and check if it's included
just trying to find the right way to make functional config code
it sucks
for example the alias thing never works for me
bukkit still saves it using the full class name
All there
Depends how readable you want to make your files but I would just stick to gson
writing a strategy object to serialize and deserialize objects is probably the wisest choice
that startup ascii is cool
Thanks, got bored and made it 😛
hm then I have no idea
thanks..
What is wrong?
how did you log it all with line breaks in the console?
I mean doesnt javadocs suffice for that?
reason for i'm asking i used hours to get hashmap in hashmap
your json
oh
multimap
mhm
i thought to myself maybe i'm being dumb and lack of understanding
What's wrong in my json?
itsvollx a good way is to write a facade and data transfers that carries the config data
how the fuck should I know, you never sent it. all you did is send the error and claim that your json is valid
put it into a json checker
says its valid
idk looks correct but i dont even know json syntax
so load all data and handle it in some functional fashion?
that's not the valid that threw the error
No?
it says line 1 column 19
your first line only has one character
or did you parse it without newlines in one line?
Wait what
First line in the json?
Is it not suppose to have one character?
I thought it was suppose to be just [
Like @sacred mountain said put it in a json checker…
I did
thay was before i knew it was valid
also i thought it was a large file didnt see how simple it was
what they sent is valid
interface ConfigFacade {
void load();
ConnectionCredentials getConnectionCredentials();
}
class YamlConfigFacadeImpl implements ConfigFacade {
final Path path;
final FileConfiguration config;
YamlConfigFacadeImpl(Path path) {
this.path = path;
this.config = new YamlConfiguration();
}
@Overide void load() {
try (var reader = Files.newBufferedReader(this.path)) {
config.load(reader);
}
}
@Overide ConnectionCredentials getConnectionCredentials() {
return new ConnectionCredentials(
config.getInt("db.port"),
config.getString("db.address"),
config.getBoolean("db.ssl")
);
}
}
record ConnectionCredentials(int port, String host, boolean useSsl){}
@round finch
just an example (and yes you could load and store the connection credential in a field from load if you wanna use more memory for faster access) [entirely up to you]
question mark paste when
Are there any examples of allowing people to make recipes in a config anywhere?
what is var
Apparently it's not formatted but its not
I'm not sure how I what should do it
I have a library for that
is var just a generic type that accepts anything given
Welcome to Java 10
oh right ok
Never mind, I found something
var str = null kekw
so you can supply it with anything you want
well once defined you cant assign random values to it
var x = 1;
x = "kappa"; //this would yield a compile error
"var" is just short for "use the type of what's behind the = sign"
behind?
oh
you know what I mean lol
sadly as disallowed
im not sure how this is gonna help me in my finals
hehe i know
sounds useful 
he never teaches much
we're currently learning in VB.NET which is quite a bit older than me
holy sh..
that really something
I feel like armature compared to that
I never specified local storage i mean plugin folder
but awesome code!! ty ty
visual basic meh
yeah I mean that would actually specify the file
i have to be honest but the windows font looks better than the linux one on discord lol
i can atleast make my own windows program now
so you could do something like
new YamlConfigFacadeImpl(plugin.getDataFolder().toPath().toAbsolutePath().resolve("epicconfiggamer.yml")) or sth
gets a bit long
i barely knows any sql
same
data tables is confusing :(
tho you dont need to know a lot of sql to be able to use it adequately
i created one that bluescreens a windows 7 machine :) because im nice like that to my friends
they should make it not string based
Yea im confused why its saying its not formatted correctly even though it is
i litterally got no clue
i see sqlite and mysql code and all the tables are just strings of mysql commands
all those shity tut got my head in pain with sql
i guess thats the way to run them
yes
thats why i used yaml for ages
till someone said it sucked
isn't there sql manage api?
for people with java skills
not for player settings and constant updates like player cooldown and cosmetics tho
alot of sql libraries
yes?
which handle writing the queries for yo
its doable lightfury
well it didnt look good to me
I mean you could use yaml on a replicated remote storage that every other instance also uses
but at least now its more efficient :D
It’s not impossible, but not recommended…
i debated on whether to try mongodb
apparently its better for bigger data
i probably gotta learn mysql w-w
myeah sorta, I mean depends on use case
document based nosql stuff idk
PostgreSQL is best for large structured sets
for structured data, postgre as itzdlg mentioned is gold beyond everything
what do you think the best storage system is?
im probably gonna get a "it depends"
feel like there is no best
idk depends on the system's needs
called it
depends
lmaoo
🖕
yeh i see
I mean redis has become really powerful recently
yeah i was thinking about mongodb and redis for async across servers
but it has some inevitable cons also
wait wait faster data storage?
yea i use alot of redis as well
HikariCP and redis still superior
async is yay
mostly pub/sub is rlly nice from redis
myeah
u have channels
an event bus implementation
like bukkit's event system
ohk
but deployable through multiple nodes
yea i got a full on packet system for communication between my servers
works very nicely
minion has somehting like that
the only thing i ever used packets for was showing the minecraft demo mode screen
A lot of plugins don't need to take it that far tho
on a different note ive been thinking about creating some of my own custom events
PlayerCosmeticSwitchEvent and a couple others
how do i make it accessible by other plugins?
making it an api or something
that sounds cool!
does anything go to your bungeecord?
no
well its fairly simple. have a packet that you can serialize/deserialize, send, receive them using redis
in short
those all your servers communicate with each another?
yea
woaw 😮
all servers send statistics like logins, tps, bunch of other stuff
is it possible to create a bungee plugin that allows the player to stay "connected" to a server whilst its restarting (bungee proxy)
and thats displayed using grafana
yeah just create an API .jar. but other plugins must not shade that, or the listeners won't work
so i can see everything
ok cool
other plugins then have to check if your plugin is installed, and if yes, register their listeners for your events
okay
for example this is how one of my packets look https://paste.md-5.net/rajosiweko.java
really quite simple
gn
what are you using?
some packet api?
no
sus
Among SUS
what is @NoArgsConstructor and @AllArgsConstructor? sounds a bit counterproductive lmao
constructor without and with all args as parameters (all fields i guess)
i need a constructor with no args to create the class when deserializing, and one with all when you want to send the packet
Default spigot stuff?
public abstract class Packet
{
public abstract void send(BaosOutputStream out) throws IOException;
public abstract void receive(BaosInputStream in) throws IOException;
}
no i made it myself. but this is all it is
why? you can have more than one constructor
no. redis allows you to publish on channels with certain names
you just listen to those
and all that allows me to do cool stuff like this https://paste.md-5.net/ramihepivi.java
Dammm
is there actually ever ANY reason to use Class.cast(Object) unless you want to use getDeclaredField / getDeclaredMethod later on?
makes sense
I just wonder because I just found code like this
final Object craftAdv = CLASS_CRAFTADVANCEMENT.cast(adv);
final Object advHandle = getObject(CLASS_CRAFTADVANCEMENT, craftAdv, "getHandle");
and after that, craftAdv is never used again
uh
so the cast is totally useless here
oh @tender shard i meant to tell you. i actually managed to make the cow thing work
nice, how?
like that
it bassically reregisters the mob with my own method for checking if it can spawn
what does Baos stand for
Byte Array Object Serialization / ByteArrayOutputStream
oh ok nice
who volunteers to write javadocs for me lol
I'm trying to create a custom horse using NMS, here's what I got:
public class SuperiorHorse extends EntityHorse {
public SuperiorHorse(World world) {
super(EntityTypes.M, ((CraftWorld) world).getHandle());
}
}
public enum EntityTypes {
SUPERIOR_HORSE("Horse", 54, SuperiorHorse.class);
private EntityTypes(String name, int id, Class<? extends Entity> custom)
{
addToMaps(custom, name, id);
}
public static void spawnEntity(Entity entity, Location loc) {
WorldServer worldServer = ((CraftWorld) loc.getWorld()).getHandle();
entity.teleportTo((WorldServer) worldServer, new BlockPosition(loc.getX(), loc.getY(), loc.getZ()));
}
private static void addToMaps(Class<? extends Entity> clazz, String name, int id) {
((Map) Utils.getPrivateField("c", net.minecraft.world.entity.EntityTypes.class, null)).put(name, clazz);
((Map) Utils.getPrivateField("d", net.minecraft.world.entity.EntityTypes.class, null)).put(clazz, name);
((Map) Utils.getPrivateField("f", net.minecraft.world.entity.EntityTypes.class, null)).put(clazz, Integer.valueOf(id));
}
}
are you on 1.17+?
the EntityTypes enum is mostly just copy pasted from online
yes
I'm not sure what to put in addToMaps, right now it causes an obvious error
is there a more modern tutorial for custom entities?
im on 1.18.1
I'd use mojang mappings for 1.17+, then you don't have to worry about weird field names like "c", "d", "f"
since persistent data cant be applied to blocks, does someone have an idea how I would store if the block has already been mined by a player?
what is that
with mojang mappings, you can use the "real" names for methods and fields
the names that mojang themselves chose
what's the error?
Caused by: java.lang.ClassCastException: class net.minecraft.world.entity.EntityTypes cannot be cast to class java.util.Map (net.minecraft.world.entity.EntityTypes is in unnamed module of loader java.net.URLClassLoader @18769467; java.util.Map is in module java.base of loader 'bootstrap')
i understand what it means, i just have no idea what im doing
ooh
if mojang is giving out the obfuscation map out for everyone, why do they still obfuscate -.-
what is the addToMaps method supposed to do btw?
yeah makes no sense....
still better than not having any obfuscation map 😄
but yeah it's so stupid
uhh
no clue lemme find the tutorial and see
it was a really old tutorial so im pretty sure its outdated
ok yeah i honestly dont know lmao
or wait
I found this comment
ok nevermind
I think its meant to add the entity to bukkit
so that I can spawn it
oh uuugh
that's not a good idea
idk but hacking into existing enums is a pretty dirty solution
also it's not needed at all
what's the preferred way of doing it
just do the rest as you already did but ignore the "addToMaps" part
is this persistent?
sure
sure??
hmm
@EventHandler
public void onProjHit(ProjectileHitEvent event){
if(event.getHitEntity() != null){
event.setCancelled(true);
return;
}
Projectile projectile = event.getEntity();
if(!projectile.hasMetadata("gunType")) return;
Location location = projectile.getLocation();
Block block = event.getHitBlock();
assert block != null;
if(block.getType() == Material.BARRIER || block.getType() == Material.AIR) return;
block.setType(Material.AIR);
location.getWorld().playSound(location, block.getBlockSoundGroup().getBreakSound(), 0.75f, 1f);
location.getWorld().spawnParticle(Particle.BLOCK_CRACK, block.getLocation(), 10, block.getBlockData());
why don't the particles spawn
well
because AIR doesn't have any "breaking" animation
Hi sorry to kinda interrupt whats going on above - Anyone have any idea how to make Minecarts NOT collide with players & people? I've tried cancelling the event - but it loses all velocity - And tried cancelling the collision - but it launches backwards
Is there a way to make pairs of entity instances have no collisions specifically for each other without affecting anything else?
I want minecarts to just pass through each other and people with 0 velocity change
Searched & searched and there's lots of threads with no answers
I don't think you can do it that easily. maybe you can do that by extending the NMS minecart and using that instead
Yikes ok I'll take a look
Thank you
np. if you find a way to do it, I'd be interested in how it works 😄
probably you can override some method from your custom minecart class but I am not sure whether its actually part of the minecart class, or of the world itself or sth
wouldn't scoreboard teams also work
Isn't that player only
I thought it could be used with other entities too
I just checked. the collisions and physics are inside AbstractMinecart(or in spigot mappings: EntityMinecartAbstract) in the method "tick()". You could override it but it contains the whole logic so it's pretty long....... I fear what you wanna do is quite complicated lol
this is the method you'd have to override
meta.displayName(MINI_MESSAGE.deserialize("<reset><gradient:gold:yellow>Feather Powerup"));
why is it still italicized
(this is for an item name btw)
Thank you that really helps! I'll keep note of this and come back to it, will update if I get it working
ok so im trying to install mojang remapped using the tutorial you gave me, and now im getting red underlines telling me that net.minecraft... can't be resolved
wrong reply oops
most casses have different names in mojang mappings
for example EntityArmorStand is simply ArmorStand in remapped
you basically now have exactly the names for everything like mojang themselves are using
does someone know if I can tell javadoc to add certain text to the generated method description when there's a certain annotation on the method?
For example here, I annotated it with "@NeedsNMS". I want the javadocs to automatically add an additional sentence for every method with this annotation
alright thx Imma google that
@tender shard figured everything out after installing mojang mapped, thanks!
god this is so much easier i wish i knew this earlier
perfect!
yeah I always try to make people using mojang mappings lol
I knew they existed for a year before I switched to them
I was afraid of all this pom.xml stuff lol
this is my first time working with nms
i was expecting it to be a huge pain
but this makes things so much easier
just one more thing
is this a good way to spawn my custom entity?
public static void spawnEntity(Entity entity, Location spawnLocation) {
ServerLevel serverLevel = ((CraftWorld) spawnLocation.getWorld()).getHandle();
serverLevel.addFreshEntity(entity);
entity.setPos(spawnLocation.getX(), spawnLocation.getY(), spawnLocation.getZ());
}
looks fine to me
but I have to add that I never did any "custom entity" stuff myself
alright
?paste
@tender shard im super ass with maven and I've got the right things in my pom from your spigot resource but I still get this error? https://paste.md-5.net/fayoyuzixa.cs
Can I use .getDisplayName() on a default item?
there is
What does needsnms do?
U can use existing ones like lamp or acf which is annotation driven and really easy to use
Or u can create your own but a hashmap in the command to the subcommand is possible
Pebble so basically a full command is a tree of literals and arguments
and each branch executes basically
what you got as of now?
Hashmaps are for fast access so u don't iterate thru em
Are you looking to have even better abstractions or are you trying to build stuff yourself?
Well here's how I write commands:
kill player:target {
hook kill
permission kill.use
}```
@CommandHook("kill")
public void kill(CommandSender sender, Player target) {
target.damage(1000);
}```
That's a basic example
Funnily enough I'm deprecating this library soon in favor of one I'm currently working on, but the concept is more or less the same so it's pretty effortless to port projects over
If you want to compare how you'd implement commands in mine vs others, I'd be happy to give more examples
do you have the "maven-shade-plugin" in your pom.xml?
Actually come to think of it I should make a spigot forum thread for my new library when it's ready
currently nothing
it's just to notify people that this method uses NMS
so people who use the NMS methods know that it might break on new MC versions if they don'T update the lib
yes
while methods without @NeedsNMS will continue to work fine without needing updates for the lib
Yeah breaking it up into methods is always a good idea
breaking people's legs however is not a good idea
U can do both
Basically if subcommand is in map execute that
If not let the command be the executor
So if you have /mine craft create dirt
you need to add the maven-shade-plugin, AND use maven to compile (not your IDE)
If craft is in the map, oass create dirt to your subcommand
https://blog.jeff-media.com/common-maven-questions/ read the second headline pls ("how to shade dependencies")
If not, let your command handle it
i love you
😗
🏳️🌈
is that the Why are you gay dude?
"You are gae"
yes
😂
?paste
jesus nms is messy
for some reason I still can't get it to work. can you take a look at this for me and see if I'm messing something up? https://paste.md-5.net/aluyusageb.xml
yep lol
but what did you expect? that code was written by a tiny studio in sweden and suddenly the game became sooo big
guys im selling my iphone 2
ok but not here
tf
true
you know that situation when you start a new project and you do everything as clean and good practice as possible
and a year later it's all messed up lol
yep
happens to me all the time
and he also wrote it in java
"well im not going to be using this too much so its ok if its a little messy"
fuck java
exactly lol
i love java
i like the syntax and stuff
but
its not low level enough for me
and the jvm takes too much memory
Valhalla when 🥺
also you can always just download more ram if needed
well just like windows, java likes to use as much memory as it can
lol
for disk caching etc
public static List<Block> getNearbyBlocks(Location location, double radius) {
List<Block> blocks = new ArrayList<>();
for(double x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
for(double y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
for(double z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
blocks.add(location.getWorld().getBlockAt((int) Math.floor(x), (int) Math.floor(y), (int) Math.floor(z)));
}
}
}
return blocks;
}
why does this give me a cube
i saw something where windows would use like 4gb if you used 16gb or something
I got anno 1800, fl studio, photoshop, 11 intellij projects, about 100 tabs in chrome open and still it's not at 100% lol
Because you're iterating in a cube radius
😩
what else would it give you?
a sphere 💀
Why
what
I didn't look into the math
LMAO
you could simply only add the blocks if the distance to the center is less than X but the proper way would be to improve your math 😛
maybe thats your problem
If you want a sphere then filter it to only blocks with a distance from the center <= radius
this is what copy and paste does to you
that seems like the lazy way
It's a good way
📸 you caught me
Just use distanceSquared instead of distance
also theres no reason to Math.floor
Well
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/BlockUtils.java
I always use this if I need a sphere but it's quite inefficient
It does technically have different behavior
because it loops over blocks that you don't actually need
but too lazy to look up the proper math
🤔
what
I don't see anything wrong with it
hey guys, what is the proper event for if I want to check if a player hit another player?
why
EntityDamageByEntityEvent and ensure both entities are players
is this event available on 1.8.8?
.-.
i asked why would casting to int round towards zero
update
Plugins can't listen for events on 1.8 you just have to poll the player's health every tick
/s
I'm gonna go get ice cream
what I'm trying to make is a plugin that would increase the amount of knockback a player gets depending on how many times he has been hit, are you saying such plugin is not possible on 1.8.x ?
well I'm basically iterating over blocks that aren't needed
So?
so it'd be better to narrow down the loop somehow 😄
public static List<Block> getNearbyBlocks(Location initLoc, double radius) {
List<Block> blocks = new ArrayList<>();
for(double x = initLoc.getBlockX() - radius; x <= initLoc.getBlockX() + radius; x++) {
for(double y = initLoc.getBlockY() - radius; y <= initLoc.getBlockY() + radius; y++) {
for(double z = initLoc.getBlockZ() - radius; z <= initLoc.getBlockZ() + radius; z++) {
Block block = initLoc.getWorld().getBlockAt((int) x, (int) y, (int) z);
if(initLoc.distanceSquared(block.getLocation()) <= radius)
blocks.add(block);
}
}
}
return blocks;
}
does this look overly inefficient :troll:
but who cares
almost
To my knowledge there isn't really a better way
I see
Like yes there are algorithms that would get you to iterate over only blocks within the sphere to begin with
But the overhead of those algorithms negates the benefit
.
if(initLoc.distanceSquared(block.getLocation()) <= radius * radius)
oh that's good lol
use brackets {
Instead of asking me if an event exists in 1.8.8 you could just type it into your IDE
It will tell you very quickly
it's a 1 liner
I did and didn't find it, but that wasn't my question
I should make an n-dimensional for loop utility
google codestyle
I typically only use brackets if it's > 1 line
is there any other proper events I can call to make such knockback plugin?
I should hope so
it fucking sucks
You have to use brackets if it's more than one line
@tender shard why the bitshifts
public static List<Chunk> getChunks(final World world, final BoundingBox box, final boolean onlyLoadedChunks) {
final int minX = (int) box.getMinX() >> 4;
final int maxX = (int) box.getMaxX() >> 4;
final int minZ = (int) box.getMinZ() >> 4;
final int maxZ = (int) box.getMaxZ() >> 4;
no need for the brackets if it's only one line but okay
because minX etc are chunk coordinates
1 is the same as dividing by 2 (rounding down)
nerds man
It's faster than division
by 2
I wonder whether javac would automatically turn / 16 into >> 4
Probably not
because I mean... why wouldn't it do that?
The java compiler makes very few optimizations
but why
not even declarations used in returns
yeah anyway the bitshifts are there to turn world coords into the chunk's coords imajin
String a = getSomeString();
return new SomeObject(a);
the bytecode will store a then load a after
i think the jvm might optimize this
¯_(ツ)_/¯
You don't need to worry about that kind of thing unless you're really trying to squeeze every possible drop of performance out of your code
It's a micro-micro-optimization
well now i know a >> b is the same as a / (Math.pow(2, b))
Rounding down
Or towards zero rather
Actually no
Rounding down
Because of two's complement
Ok go write everything without negative numbers
i could
boolean negative;
yup.
we need to make an OS that stores booleans as one bit
That would be extremely dumb
ik
oh ye
Worst case scenario you've got an extra 7 bits which is the minimum wasted on each boolean otherwise
you should add that into the jvm
The tradeoff is that it's slower to mutate and access the booleans
I'm pretty sure some JVMs already have it
Booleans aren't one bit?
y'know I'm thinking this sphere isn't very good 😂
I mean it's fine like I'll still use it, just odd
No, how could they be?
0 or 1
The minimum indexable address on any system is 8 bits
Really
