#help-development
1 messages · Page 544 of 1
just for comparison that is what a normal pom looks like https://paste.md-5.net/exawawigeg.xml
ur is way to short
copy missing parts from this one
or at least necesarry parts
you dont need the luck perm repository
which
build for example
you need that i suppose
and it should say the plugin name right here
i feel like this is more work then just creating a new project honestly tho..
why does my entire project contain errors??
can't find any classes of spigot api..
this is my pom file so far:
<?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>groupId</groupId>
<artifactId>RPGPlugin</artifactId>
<packaging>jar</packaging>
<name>RPGPlugin</name>
<version>1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
</project>
okay when editing it as you said
now I can click the run maven build button
yh+
idk where it's being exported right now though
package not install, unless you want to bloat your local maven with multiple jars
seems like question for google
chatgpt can answer you that
do it
mc client or discord client
import org.apache.commons.codec.binary.Base64;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
These lines of code are highlighted as an error since I setup maven
At least the games store is gone
https://www.twilio.com/blog/5-ways-to-make-http-requests-in-java doesn't seem really outdated
discord
You’ll need to add the dependency for Apache commons and authlib
the last client i tried was able to see channels i didnt have access too 💀 (not contents tho)
HttpClient with Java 11 is great
oh you are missing dependecys. In maven add dependencys the same way you did with spigot
Yeah because discord sends that to a client for some reason
its nothing specific to bukkit or spigot
i have no idea how their protocol works so gl ig
like just add the spigot-1.12 lib in dependencies tab?
||could see every staff channel 💀||
You can see members too
no search for the dependecies you use online and add the maven thingy for it in the pom
In hidden voice channels
no clue
if you search it its normaly right at the top
What event do I need to use to stop an experience bottle from being thrown by a player?
Either a ProjectileLaunchEvent or a PlayerInteractEvent would work fine
projectile
well how often does someone join
HttpClient in J11 has async-specific methods
just curious, why you need it
found this on a stackoverflow thread but it's paperspigot xD
<repository>
<id>paper-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
But that’s 20!!!!
just tell me what dependencies are you using rn
yeah
I like recent Javadocs 🙂
oh, right
I'll move to J21 Javadocs once it's generally available
Mc on 21 when
And then
that Mojang updates in 1.21 or something
I mean come on. Please give us J21 on MC21
when will we get mc 2.0
They better not stay on 17 for a decade
idk you make it
I don't think they will
I'd imagine they'll want to take advantage of some 21 features
They stayed on 8 forever
im thinking about making a voxel game, minecraft seems a bit too ambicious
those dudes know how to render, i cant even make pong 💀
well i nearly got it
im doing snake now 💀
Trust me making a basic voxel engine in unity is definitely the same as making minecraft
@analog snow already did that
What’s wrong with unity
yeah
c#?
Is there some way to get a stack from it in that case?
What’s wrong with C#
so what do you want to send in that request?
ehh lets just say i dont like it, been 3 years ago now since i last used it
okey
C# is basically just Microsoft java
does c# have operator overloading?
And in some ways better java
and you want to send that from a minecraft plugin to your own api?
it kinda is in some aspects but its also the more shitty version
but thats for every lang
anyways gn
?paste
Yes
https://paste.md-5.net/ejeqatoyan.cpp try using this in your plugin
Is there an easy way to control how much damage a firework rocket deals? (I still want decreased damage from distance, etc, but I want to change the base damage from the explosion.)
what about expressions that compile at compile time?
👍
okay so
<repositories>
<!-- Maven Central Repository -->
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Mojang Maven Repository -->
<repository>
<id>mojang</id>
<url>https://libraries.minecraft.net/</url>
</repository>
</repositories>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.6.0</version>
</dependency>
I copied it out of my plugin lol, I got it from GPT, but it works
like string formatting yes im looking at you java
lmk if you need help just @ me or dm me @rare aurora
is ConfigurationSection#contains(String) case sensitive?
If I pass "type" and the config contains "TYPE" will it be true or false
alright, thank you
Guess I gotta make a PR to VeinMiner
I'm excited to drop Material from VM in 1.20
yaml is sensitive. Like extremly sensitive. With everything. An empty line and it will stop working. A tab to much everything will stop working. A space it will stop working
But what about the legacy users!!
Ur getting a 1 star review
k
😡

np
it should get 5 stars
It’s the only way I sleep at night
I'd figured as much
for doing away with the legacy
i will give it 5 stars mister admin will i get mod now uwu

He’s bribing staff!
IT'S NOT BRIBING
It's just... giving me what I want
well I am not staff
@quaint mantle
<?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>groupId</groupId>
<artifactId>RPGPlugin</artifactId>
<name>RPGPlugin</name>
<packaging>jar</packaging>
<version>1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.15</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.6.0</version>
</dependency>
</dependencies>
<!--<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>!-->
<repositories>
<!-- Maven Central Repository -->
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Mojang Maven Repository -->
<repository>
<id>mojang</id>
<url>https://libraries.minecraft.net/</url>
</repository>
</repositories>
</project>
this is my current pom.xml
keep it as well or nah
format it like that
<--<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<!-- Maven Central Repository -->
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<!-- Mojang Maven Repository -->
<repository>
<id>mojang</id>
<url>https://libraries.minecraft.net/</url>
</repository>
</repositories>
hi guys which event can check village trade slots ?
Spigot's repo hasn't changed at all. At least not since 1.8
Aren’t you supposed to use like 3 repos for spigot
No? Just 1
show your current pom. and please use ?paste
I mean unless you're counting transitive dependencies
?paste
put it in here
Oh it’s a gradle thing that it doesn’t automatically recognize them
whats '?paste'
this. you can put your code in there so it doesnt fill half the channel
ah hastebin / pastebin
yh
i have a question if i prevent craft if paper has modeldata after if i create custom repice with model data paper
my custom repice will work ?
What
@EventHandler
public void get(PrepareItemCraftEvent e) {
CraftingInventory test = e.getInventory();
for (ItemStack stack : test.getMatrix()) {
if (stack == null || stack.getType().isAir()) continue;
ItemMeta meta = stack.getItemMeta();
if (meta != null && meta.hasCustomModelData() && stack.getType() == Material.PAPER) {
test.setResult(null);
}
}
}``` i do this
read and if i create custom repice with paper with model data
this repice will work ?
alright i try
i have 1 question more
which event control village trade slots ?
inventory click ?
@quaint mantle https://pastebin.com/M108qamB
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
still same error for the lines of code @quaint mantle
idk anymore honestly @young knoll you do this idk
im getting brain damage from this
Uhh
😄
I don’t use maven 🙃
lol
How can I change the damage that a firework does?
on dmg event get the firework and set the dmg
Listen for the damage event and modify it there
or well thest if the dmg cause is firework
i have a problem i create custom items with paper modeldata
but if player trade to villager with my custommodeldata paper item
this trade will work i wanna prevent this but which event do this ?
I thought about that, but I did not know how to implement damage decrease due to blocks in the way, like vanila.
for gradle ^
which, if you are coming from fabric, would be your build system of choice anywa-

for paper 😍
😏
wait so what exactly are you trying to do? just decrease the dmg in general?
progress 🆙
@quaint mantle
no i still love maven
you are presumably missing the mojang repo

No, I want to have different fireworks that deal different amounts of damage, but I want to preserve the vanila mechanic of blocks in the way reducing damage.
Let’s update it to just rm -rf when you start the server
well then just decrease the amount of dmg by percentage
get the current dmg and decrease or increase it by ur wanted amount
Do I have to raytrace to figure out if there is a block in the way?
Just multiple the damage
what. Look bro just get the current dmg and multiply it with a number of your choice
Yes the damage event should already reflect that reduction
yep
well here we go
Idk you’d have to test it
increase explosion yield
Afaik it’s after the reduction
Fireworks aren’t an explosion
So you can’t increase the yield
ah fireworks
well
Afaik the only way to change the size is to change the shape of the firework
you could spawn an exploding tnt on explosion
Or make your own firework system
and change its yield
Is there a way to control the base damage with that?
you could pass the dmg from the firework into your new explosion
and basically do what ever you want with it
No
Explosions don’t have a way to control damage
Minus manual intervention via the event
well yh you could make a second event for when the explosion accours couldnt you
and change the dmg there
I guess, is the max damage of an explosion known so I can scale from that? or is it random?
I believe it’s based on difficulty
@quaint mantle isn't there a way to recreate the pom.xml without editing it manually
cuz that doesn't seem to work at all to fix the issue i am experiencing
bruhg
I was refering to the spigot wiki
I got it fixed
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
This was all u had to add @quaint mantle
Im knew I have question about the plugin i made, when loading up the server i keep getting the error with the plugin.
<Cannot find main class `org.invchest.spotify'>
the main class in the plugin.yml file is correct and spelled correctly
@quaint mantle why the heck is the package though not available although I got the pom.xml correct and all libs added?
Authlib and Apache commons are not part of the spigot api
Not verified? Upload screenshots here: https://prnt.sc/
so how to add?
you should not need authlib unless you are using nms
Most uses of authlib in plugins are due to using GameProfile for setting textures on skulls
?update
You shoudl use PlayerProfile now
is the world's uid.dat just the World UUID?
Use whatever case the conventions say
If you are making your own language then you get to choose what you like best :p
But only then
we call it lowerCamelCase for methods, variables and functions (with some exceptions) and UpperCamelCase for class namees.
w8 but why do I get errors then when trying to export the plugin? 😮
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
I don't get why I got errors while hitting "package" on maven although all packages are imported it tells me they aren't found.
this is not your plugin then?
it is? xD
what do u mean? i built the spigot-1.12.1 jar using BuildTools.jar and Git CMD
It's clearly not but, depend on spigot not spigot-api as you need authlib and apache commons
@eternal oxide wanna see my pom.xml file?
sure
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
change the artifactId to spigot instead of spigot-api
Hello, I am trying to save variables for when the server reloads to a json file, and I keep getting this error and idk how to fix it:
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 4 path $
I'll provide the snippet of code I'm using
What does the JSON look like?
how can i delete item in inventory i use removeItem method but this deleting even itemstacks i only want delete 1 item
setAmount(item.getAmount() - 1)
it's literally just
{}{}[][]
ok yeah thats not
it wont generate what I need in the file? ik it's empty but it wont save any values to it?
Well, you should be writing a JsonElement, not the HashMap and Sets directly. You probably want to use JsonObject, set the properties with values as the Map and Sets, and then write that JsonObject
done.
I hate to ask to be spoonfed code, but could you point me to an example of that?
ayo actually export worked now
Sure. Something like this;
JsonObject object = new JsonObject();
//Do this for all your properties
object.add("primaryRoleplayColors", primaryRoleplayColors);
gson.toJson(object, writer);
Thank you very much
I get a console error though @eternal oxide "invalid plugin.yml"
you are building using artifacts in your IDE not maven
Player#openBook() ?
wait would i use the same object for all of them or would I make 4 separate objects?
Yes. You just pass in the book ItemStack
Same one
oh okay cool
w8 wut
You could make them separate I suppose, probably would look weird though (and may actually be invalid, depends how Gson handles that)
I use package with maven
show me
I'm sorry I keep asking questions, is this in the load or the save? cause it says writer
Save
You'll have to modify it slightly so that it grabs the Map and Sets from the key you set in save.
Sure, depends on what version you're using.
If you're using latest, which you should be, openBook is the way to go.
If you're using outdated server software, then yes, you'll have to use packets.
what IDE is that?
Use openBook then 
IntelliJ Idea? 😄
show me your plugin.yml and an SS of your project structure for the resources folder
how can I do this?
name: Rpg
version: '1.0'
author: Proudyy
main: net.rpg.main.Rpg
description: Rpg in Minecraft.
commands:
tank:
description: abc
warrior:
description: abc
mage:
description: abc
witch:
description: abc
priest:
description: abc
hunter:
description: abc
getequip:
description: abc
aliases: [equip, kit]
removeclass:
description: abc
removeclasses:
description: abc
resetclasses:
description: abc
classesinventory:
description: abc
aliases: [classesinv, cinv]
rpgsettings:
description: abc
spawnclassvillager:
aliases: [scv]
spawnweaponvillager:
aliases: [swv]
build:
description: abc
@eternal oxide
Retrieve the JsonObject back from the file, and then start calling get on it.
ss of your project structure. Is your plugin.yml in a resources folder in /src/main
No its in /src/main/java
it should not be
so move both plugin.yml and config.yml from /src/main/java to /src/main
and its fixed?
to src/main/resources
I'm really sorry to keep asking for code, but I'm pretty braindead can you show me an example? I took an APSCA course this year and this is my first time developing a java plugin
works fine now exporting, thank you so much @eternal oxide
I'm not going to give you the code again, but I can point you in the right direction. Check the JsonParser class. It has what you need to get the JsonObject back.
Thank you
alright, well I figured out how to json parser I think, but how would i get the information from the json object back to the hashmaps and hashsets
@EventHandler
public void onSpawnArmy(PlayerInteractEvent e) {
Player p = e.getPlayer();
System.out.println("a0");
if (WitchCommand.witches.contains(p.getUniqueId().toString())) {
System.out.println("a1");
if (e.getAction() == Action.RIGHT_CLICK_AIR) {
System.out.println("a2");
if (e.getItem().getType().equals(Material.FLOWER_POT_ITEM)
&& e.getItem().getItemMeta().getDisplayName().equals("§1Armee, los!")) {
System.out.println("a3");
for (int s = 0; s < 5; s++) {
Entity slime = p.getWorld().spawnEntity(p.getLocation(), EntityType.SLIME);
passiveSlimes.add(slime);
}
}
}
}
}
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
Player p = (Player) e.getTarget();
System.out.println("0");
if (passiveSlimes.contains(e.getEntity())) {
System.out.println("1");
if(ClassManager.getClass(p).equals(Classes.WITCH)) {
System.out.println("2");
e.setCancelled(true);
e.setTarget(null);
}
}
}
why do the slimes still attack me? xD
lol so there's no way to avoid slimes attack a specific target/player? XD
I could use magma slimes but I guess it'll be the same result
You can make a bug report about it
I am trying to make my plugin detect when a player makes or doesn't make a water bucket clutch, but it doesn't seem to be working as intended.
I've realized that my save method works comepletely fine but for some reason the file gets wiped any time I try to use the load method and I have no clue why
I also could not for the life of me figure out how to use json parser and the json object stuff so I gave up on that
@young knoll well magma cube also not working
ArrayList<Entity> passiveMinions = new ArrayList<Entity>();
@EventHandler
public void onSpawnArmy(PlayerInteractEvent e) {
Player p = e.getPlayer();
System.out.println("a0");
if (WitchCommand.witches.contains(p.getUniqueId().toString())) {
System.out.println("a1");
if (e.getAction() == Action.RIGHT_CLICK_AIR) {
System.out.println("a2");
if (e.getItem().getType().equals(Material.FLOWER_POT_ITEM)
&& e.getItem().getItemMeta().getDisplayName().equals("§1Armee, los!")) {
System.out.println("a3");
for (int s = 0; s < 5; s++) {
Zombie zombie = p.getWorld().spawn(p.getLocation(), Zombie.class);
zombie.setBaby(true);
passiveMinions.add(((Entity) zombie));
}
}
}
}
}
@EventHandler
public void onTarget(EntityTargetLivingEntityEvent e) {
Player p = (Player) e.getTarget();
System.out.println("0");
if (e.getEntity().getType().equals(EntityType.ZOMBIE)
&& passiveMinions.contains(e.getEntity())) {
System.out.println("1");
if(ClassManager.getClass(p).equals(Classes.WITCH)) {
System.out.println("2");
e.setCancelled(true);
e.setTarget(null);
}
}
}
Using baby zombies works.
Yeah like I said the cube mobs are weird
also this doesn't work now that I realize it, I'm getting this error is shutdown
java.lang.ClassCastException: class java.util.HashMap cannot be cast to class com.google.gson.JsonElement (java.util.HashMap is in module java.base of loader 'bootstrap'; com.google.gson.JsonElement is in unnamed module of loader java.net.URLClassLoader @3b764bce)
Sorry, use Gson#toJson for that
squiggly characters
I am trying to make my plugin detect when a player makes or doesn't make a water bucket clutch, but it doesn't seem to be working as intended.
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Ok so I expect it to send the player the message "Nice Clutch", remove some blocks, teleport them to a certain area, play a sound, and set their inventory to the first slot being a water bucket, but instead, it just sends the message "Nice Clutch"
wtf is a water bucket clutch
Im testing out protocollib and I know you have to instantiate the protocol manager in an onEnable function, but it looks kinda messy. Is there a better way to do it?
What’s a mc
Ok that's got to be sarcasm lmao
Is there anything noticeably wrong with this code?
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION) {
@Override
public void onPacketReceiving(PacketEvent event) {
PacketContainer packet = event.getPacket();
Player player = event.getPlayer();
player.sendMessage("YOU moved");
}
});```
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Well I think it is more fair to say, devs don't play mc like everyone else do
Well some probably do, its just you are not very likely to see many devs play on popular mc servers or whatever
and if they do, they typically use different names or are very lowkey about it
I meant in general that there is devs that do play mc
I play MC, but I don't play on public servers
I find MC base so boring
and most servers are so annoying and repetative
or your just bad :P
I like to play just almost pure vanilla mc
how do you find joy in vanilla it feels so menotinous to me
a couple of QoL plugins and I am good
its a new strat trust
I like to make redstone stuff
mmm makes sense
I like to make farms nd stuff but it takes so long and you never use the resources
Create is awesome, you should atleast check it out
sounds like something from BK
Burger King
close
BK is a mod developer
and a really good one
he had a couple of mods for trains specifically
but as far as I know, no one else has come up with a decent trains mod like BK did
while I got to see some trains, that video didn't seem particularly about trains
considering they were just riding a converor belt the entire time lol
that is fine, but that tells me it isn't specifically for trains which is still fine but it just means to me there is a lot that is going to be missing in terms of functionality
yeah but now I need an additional mod just for that lol
anyways I might check it out, idk. I am still thinking BK had the best mod for trains
BK = bergerkiller in case anyone doesn't know
is there a way to add multiple splash potion effects while they are being thrown?
In this code snippet, I set a main effect twice, but I'm unsure if the weakness effect type just gets overwritten by the slow effect type...
@EventHandler
public void onThrown(PotionSplashEvent e) {
ThrownPotion pot = e.getPotion();
pot.setGlowing(true);
pot.setCustomNameVisible(true);
pot.setCustomName("§2Potionrausch");
ItemStack potion = ItemBuilder.createItem(Material.SPLASH_POTION, "§2Potionrausch", null, null, 1);
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
potionMeta.setDisplayName("§2Potionrausch");
potionMeta.setMainEffect(PotionEffectType.WEAKNESS);
potionMeta.setMainEffect(PotionEffectType.SLOW);
potion.setItemMeta(potionMeta);
pot.setItem(potion);
}
Can’t you set other effects?
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
I have a custom textured skull.
and I want to make it to work on other plugins.
like I want to add the textured skull on DeluxMenu's GUI
how can I make that on my plugins?
I am not good at english. idk if I can explain correctly
Hello, after adding <classifier>remapped-mojang</classifier> to my pom.xml as detailed here https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/#post-4184317, and running build tools with --remapped (I verified the new jars were created inside the local maven repo) The nms classes are no longer recognized, if I remove the <classifier>remapped-mojang</classifier> tag, it compiles fine, but everything is obfuscated.
came up with this idea now with a single event, but this error appears, although parameters of the method are met.
Thats happening because potions are not entities you can spawn via the world. Try Player.launchProjectile instead
Why does this event never occur although a splash potion hits an area as described in spigot wiki?
@EventHandler
public void onBlockThrows(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (WitchCommand.witches.contains(p.getUniqueId().toString())) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR) {
if (e.getItem().getType() == Material.SPLASH_POTION
&& e.getItem().getItemMeta().getDisplayName().equals("§2Potionrausch")) {
e.setCancelled(true);
Projectile proj = p.launchProjectile(SplashPotion.class, p.getLocation().getDirection());
((Entity) proj).setCustomNameVisible(true);
((Entity) proj).setCustomName("§2Potionrausch");
((Entity) proj).setGlowing(true);
((Entity) proj).setVelocity(p.getLocation().getDirection());
potions.add(proj.getUniqueId().toString());
}
}
}
}
@EventHandler
public void onThrown(PotionSplashEvent e) {
ThrownPotion pot = e.getEntity();
System.out.println("pot0");
if(potions.contains(pot.getUniqueId().toString())) {
System.out.println("pot1");
for(Entity ent : e.getAffectedEntities()) {
System.out.println("pot2");
PotionEffect slow = new PotionEffect(PotionEffectType.SLOW, 20 * 10, 1);
PotionEffect slowDig = new PotionEffect(PotionEffectType.SLOW_DIGGING, 20 * 10, 1);
PotionEffect weakness = new PotionEffect(PotionEffectType.WEAKNESS, 20 * 10, 1);
Bukkit.getPlayer(ent.getUniqueId()).addPotionEffect(slow);
Bukkit.getPlayer(ent.getUniqueId()).addPotionEffect(slowDig);
Bukkit.getPlayer(ent.getUniqueId()).addPotionEffect(slowDig);
System.out.println("pot3");
}
System.out.println("pot4");
}
System.out.println("pot5");
}
your way of debugging might be flawed
I don't know anything about your list for potions or how it is created or obtained
I don't see how the uuid of the thrown potion would be in the list if the entity isn't created until then
ArrayList<String> potions = new ArrayList<String>();
that tells me nothing
that's literally inside the huge code snippet lol
that tells you how it is created respectively initialized.
that's what you asked for...
and you are absolutely certain it is in fact in the list?
even if it wouldn't be in the list, the event doesn't trigger
the splash potion gets thrown and the event is registered correctly in the plugins main class.
although all the conditions are met, the event does not occur. no console output...
"pot0" never appears as a message in console
Potion has the correct name and the player is in your list?
I wonder if its because you cancel the interact event 🤔
I would put some debug code after your if statements. For example player is contained within witchcommands, action is right click, display name matches then you can see which if statement is stopping the event from triggering.
If it doesn't even get that far its got to be something with your registered event listener
Hmm maybe throwing a potion is not a right click action?
Bumping this, still no clue what I am doing wrong. Does the remapped-mojang rename classes like EntityPlayer?
this doesn't make all that much sense. I think it is because of the interact event being cancelled. If the action is cancelled, then some proceeding events can't happen
since its as if it didn't
did you read both posts?
there is another post in that post you need to read as well
odds are you didn't generate the remapped jar for your pom to use
well after reading seems you did, are you using the correct one ?
I added the second longer specialsource-maven-plugin one.
what does your build log say?
Unrecognized symbol is what the short log thing said.
I will look for a longer log.
using intelliJ?
Yes. Looked more, just a bunch of unresolved symbols. I am using the 1.2.2 version of the spectral source plugon.
Copyed the code from the ?nms link.
have you tried clearing caches?
typically something you need to do every once in a while with intellij
Will try that.
yo guys just wanted to try out making plugins I downloaded mcdev on intelliJ but it show this any idea?
is it even neccesary?
or I can just go with Maven
Maven works or gradle even server jar
ok
the interact event has nothing to do with the potionsplashevent though 😄
well it can, I don't have the source up to see if it has any effect or not. But if you cancel an action that some other event relies on then that other event won't get activated
Players:
Hunter:
- 791cace2-edf9-4fdd-b498-6978bda9401f
Priests: []
Tanks: []
Warriors: []
Witches: []
Mages: []
public static boolean hasClass(Player player) {
/*return TankCommand.tanks.contains(player.getUniqueId().toString())
|| WarriorCommand.warriors.contains(player.getUniqueId().toString())
|| MageCommand.mages.contains(player.getUniqueId().toString())
|| WitchCommand.witches.contains(player.getUniqueId().toString())
|| PriestCommand.priests.contains(player.getUniqueId().toString())
|| HunterCommand.hunter.contains(player.getUniqueId().toString());*/
return playersCfg.getStringList("Players.Tanks").contains(player.getUniqueId().toString())
|| playersCfg.getStringList("Players.Warriors").contains(player.getUniqueId().toString())
|| playersCfg.getStringList("Players.Mages").contains(player.getUniqueId().toString())
|| playersCfg.getStringList("Players.Witches").contains(player.getUniqueId().toString())
|| playersCfg.getStringList("Players.Priests").contains(player.getUniqueId().toString())
|| playersCfg.getStringList("Players.Hunter").contains(player.getUniqueId().toString());
}
hasClass strangely always returns false, even when trying "Hunter".
The code snippet which is in comment segment didn't work either to check.
why that appen? https://pastes.dev/9SskTvOSdY
I hate this so much
why though
Because you're repating yourself due to a poor data structure
Instead of having a bunch of collections
Let's rewrite it as such
Start by creating a Role / Class enum
public enum Role {
TANK,
WARRIOR,
MAGE,
WITCH,
PRIEST,
HUNTER;
}
And then instead of having a collection for each role, we use a map
private final Map<UUID, Role> roleMap = new HashMap<>();
public Role getRole(UUID playerId) {
return roleMap.get(playerId);
}
public void setRole(UUID playerId, Role role) {
roleMap.put(playerId, role);
}
public boolean hasRole(UUID playerId) {
return roleMap.containsKey(playerId);
}
public Collection<? extends Player> getAllPlayers(Role role) {
Set<Player> players = new HashSet<>();
for(Map.Entry<UUID, Role> entry : roleMap.entrySet()) {
UUID playerId = entry.getKey();
Role playerRole = entry.getValue();
if(role != playerRole) {
continue;
}
Player player = Bukkit.getPlayer(playerId);
if(player == null) { // Make sure you remove players onQuit
continue;
}
players.add(player);
}
return players;
}
feel free to make methods for the player too that just call getUniqueId
On your methods you could do something like
if(getRole(playerId) != MAGE) { // We only want to run this for mages
return;
}
For saving, the most obvious approach would be <playerid>: <role>
but you can do like a uhh
reverse map where you have a Map<Role, List<UUID>> for saving but seems like a waste of performance
and that's pretty much it
Hey this is gonna be quite the odd question
I have added Lua support for my plugin for custom mob mask effects and I need a way to spawn an entity with custom pathfinder goals (I have used the build tools to get access to nms in my plugin but I can't seem to access it in lua)
guys stupid question what archetype should I choose for plugin development?
in intellJ
I know I can do it in Java and call the method from Lua but I need the pathfinder goals to be able to be edited in the lua script
because if the Lua had access to it then Id be able to do CraftWorld.cast(world)
maven Java application or something to that effect if you want to build with maven
not sure if it has one for graddle
but if it does and prefer gradle choose that instead
Already got such an enum:
public enum Classes {
TANK("Tank", "§8Tank", "Stecke so gut wie alles weg, was dir zugefügt wird!", 1, new ItemStack(Material.SHIELD)),
WARRIOR("Warrior", "§7Warrior", "Stürze dich mit deiner Geschicklichkeit in gewagte Schlachten!", 2, new ItemStack(Material.STONE_SWORD)),
MAGE("Mage", "§1Mage", "Verursache gewaltigen Schaden und bekomme die Oberhand!", 2, new ItemStack(Material.GOLDEN_CARROT)),
WITCH("Witch", "§dWitch", "Mittels alten Zaubern gehen dir deine Tränke nie leer!", 2, new ItemStack(Material.POTION)),
PRIEST("Priest", "§4Priest", "Lehre deine Verbündeten SAFE zu spielen!", 3, new ItemStack(Material.INK_SACK, 1, (short) 1)),
HUNTER("Hunter", "§2Hunter", "Schleiche als Meister der Schützen herum!", 2, new ItemStack(Material.BOW));
// Rest of class (private vars, constructors, etc.)...
}
This still doesn't explain why I am experiencing an issue with the filecfg not recognizing an uuid in there...
no clue but it's a bad idea regardless
and adding more classes just means you'll have more lists to check
so I'll stop you right there
lol
Hi what would be the best way to store the my data with SQL. I have users and each user can do ‘quests’ and I want to store the xp of all of the quests, should I just store it like uuid quest1_xp quest2_xp …
Considering there may be 50+ quests eventually, or is there a better method i could use (I’d like to use SQL for storing my data)
have a table for each quest
and assign each quest an id
then a table where it's like
<playerid> | <questid> | progress
already tried googling this, but no success. how to make a snowball invisible (perhaps with some packets)?
public void shootParticlev2(Player player, EntityEffect entityEffect) {
Location location = player.getEyeLocation();
Vector direction = location.getDirection();
Snowball snowball = player.launchProjectile(Snowball.class, direction);
snowball.playEffect(entityEffect);
snowball.setShooter(player);
snowball.setSilent(true);
snowball.setBounce(false);
}
player.hideEntity is a thing
in older versions you can just send a single packet, yeah
There's only a hidePlayer() function.
maybe hideEntity is a paper thing and I'm stupid
Snowball != Player 😉
do you not have eyes
prolly, since i'm using spigot i need to work around this
declaration: package: org.bukkit.entity, interface: Player
hi guys, i'm getting a "Cannot resolve symbol" error on FieldUtils here? Pretty sure this has something to do with the protocollib stuff, no idea what the cause is or anything.. this all happens near but not at the top of the file :P
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.events.PacketListener;
import com.comphenix.protocol.injector.BukkitUnwrapper;
import com.comphenix.protocol.injector.PacketConstructor;
import com.comphenix.protocol.reflect.FieldAccessException;
import com.comphenix.protocol.reflect.FieldUtils; //here is the line with the error
import com.comphenix.protocol.reflect.FuzzyReflection;
protcol lib is in the dependencies and whatnot
probably a util that's no longer there?
probably
just access fields using standard reflection ig
how?
How can I check if a snowball reached ground respectively gone?
I tried this but it doesn't work at all:
public void shootParticlev2(Player player, Particle particle) {
Location location = player.getEyeLocation();
Vector direction = location.getDirection();
Snowball snowball = player.launchProjectile(Snowball.class, direction);
int taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Rpg.getInstance(), new BukkitRunnable() {
@Override
public void run() {
//player.getWorld().spawnParticle(particle, snowball.getLocation(), 1);
player.playEffect(snowball.getLocation(), Effect.MOBSPAWNER_FLAMES, 1);
Location snowballLocation = snowball.getLocation().subtract(0, 1, 0);
if(snowball.isDead() || !snowball.isValid() || snowball.isOnGround()
|| snowballLocation.getBlock().getType() != Material.AIR) {
snowball.remove();
this.cancel();
}
}
}, 1, 1);
snowball.setShooter(player);
snowball.setSilent(true);
snowball.setBounce(false);
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(snowball.getEntityId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
ProjectileHitEvent
!snowball.isValid() && snowball.getLivingTicks() > 600 would be enough
How can I get a custom player head knowing the skull id?
!snowball.isValid()
chatGPT gave me that method, but it doesn`t work. I changed "+" to "-", and i want it to rotate the other way. regardless of +, - it spins in one direction
how much degrees did you set?
4.5
it spins in one dir regardless of '+' & '-'?
yeah
then try getting the location, setting the yaw and teleporting
like this
Location loc = armorStand.getLocation();
loc.setYaw(loc.getYaw() + degrees);
armorStand.teleport(loc);
if this doesn't work, something else it interrupting
thanks, it works fine, even better than this code
How can I get a custom head (an ItemStack variable) knowing the skull id?
How can I get the original block that was changed by a Falling Block in EntityChangeBlockEvent?
Hey can someone help me making a plugin for a server
isn't it just EntityChangeBlockEvent#getBlock?
ye, wassup?
It is a very big plugin but it is out of my mind because i want to make like Custom Powers
shall i send it here on DMS?
dm I guess
Well assuming a falling block turns into a normal block when it lands it can be a block too.
Last time i was working with that event it was very inconsistant
though the event shoud fire before the block turns into the other one
what do you exactly mean by changed by a Falling Block?
Like grass getting replaced or smthg?
for example when a cobweb falling block falls on the ground
and changes the air block to cobweb
Then I dunno
getBlock() should be the from block, and getTo() should be the changing to material
i'll see what happens
would this be faster than doing pos / 8?
how can i find the cardinal direction a player is facing? im currently trying to use player.getEyeLocation().getDirection and splitting that vector into its x and z components. issue is that it only gives me -1, 0, or 1 in the x and z components and its impossible to determine which direction they are facing
im pretty sure there is something like Entity#getFacing
which would apply to player too
yeah
thanks
getFacing is only for Entities which are Directional, not Players
getDirection returns a Vector. it points precisely where they are looking
it is not an x,y,z location, it's a unit vector
ive got a thing that parses x and z and finds cardinal from there
parses x and z?
gets x and z from that vector then if abs(x) > abs(z) and x positive its north
do you mean you want to know if the player is facing more North than East?
or whatever
like
i need the block on the ground next to them in the direction they are facing
tf dont players have a direction
its in the Entity class
you don;t need any fancy math for that
so i assume it works for any entity
well its working for me now
all of it
lmao aight nice
im getting what i need
loc = player.getLocation();
direction = loc.getDirection();
block = loc.add(direction).getRelative(BlockFace.DOWN);```
that is going to work on Player location, if you want to use EyeLocation you need to setY(0), then .normalize() to make it a unit vector again
You may be correct also
I've never even seen that method 🙂
other than for things like Hanging
its in Directional block data too
Yep, thats where I've used it before
why making it so complicated 💀
speed
unless you are doing millions of calculations per tick
hardware is fast and i dont think bitwise operations will do much of a dif
nah this is for a chess engine
how are you measuring?
ideally should run a benchmark cuz just running smth and measuring the elapsed time is inaccurate
like gc starting takes away some ms
isnt a benchmark running shit a lot and measuring the elapsed time
and i think / 8 is basically as fast as the bitwise shit but just to be sure ill use bitwise
because maybe on other platforms division is slow
🤷♂️
or smth
lmao
well ye they are true about the branch prediction misses
now its crashed my gralde daemon
Is this the new stockfish
gradle 💀
yessir
imagine not knowing how to chess but making a chess game 💀
ye just imagine it
any decent compiler will optimize divisions or multiplications with powers of 2 to bitshifting anyways, there is no need to outsmart the compiler
yoooo 10,000,000 passes/sec
also depends on what the cpu is doing
i used to do the same crazy optimisations to my math parser and its nuts
yes, testing these kinds of things will 9/10 times be useless or lead to incorrect results
doesn't jit automatically convert diversion into shifting ?
probably, thats what I was saying
smh, was scrolled up again
i would be surprised if it didnt
sucks java doesnt have forced inline
you storing objects in an array?
why not a couple longs?
probably slower
look at you brute-forcing stuff
first get the applicable long, then do 500 bitshifts
if you want to be super optimized, java is probably not the language you would choose anyways
well
nah true id rather use C++ but i made an attempt and got a couple segfaults so im never doing that again
there's still the concept of weighting
yeah thats for the evaluation
rust :D
you search till a certain depth
and then you evaluate the position
with weights
dont think much people will appreciate that
yea sadly
but if you dont brute force a couple positions you cant find tactics
the moment i say the word rust people already start attacking me
why, rust is fine
sure but there are still a huge amount of moves that are just plain bad
yeah true but for that theres shit like move ordering and alpha beta pruning
discord their fancy reactions ig
lmao you used a super reaction
which try to exclude those moves as efficiently as possible
rip
just write raw x86 :)
discord adds weird shit, when was this added?
oh im just becoming a boomer then :<, thought it was a recent patch
longer than a month
but you only get like a few super reactions per week or some shit
why not?
nitro?
I thought you just get some every week
ah I ran out of them now
oh I see
just wasted all of them 💀
atleast those bastards made stickers public
fr
It's not as simple in JIT land. Proper benchmarking in java means using JMH or comparable as they do warmups before running the benchmark for real. Also provide Blackholes to prevent JIT from basically replacing your huge block of code with a single NOP
yeah true
but i didnt understand how to set up jmh
and this seems to work kind of fine
dont think a NOP would take 89 ns to execute
I am building spigot using build tools. how can I embed external library into the spigot jar itself?
The JIT only starts kicking in after some time
Are you trying to fork spigot?
Furthermore some JIT optimisations don't take effect if the application stays in the method
I think yes?
What exactly do you hope to accomplish by adding the library?
Chances are there are better ways to do what you want
However if you are absolutely sure that adding a lib is the correct way it probably is as simple as changing the pom.xml of the cb maven project
what's the process of doing that? I just finished running the build tool with default settings
I also have some patch files I would like to apply
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
^^ follow this without the CLA part
so I edit this?
Yep
Thanks
How do I add a library at a specific path like: org.bukkit.craftbukkit.libs.com.google.common.base.Optional?
By configuring relocations in the Shading plugin
Done. is there anything else that I need to do? like, adding the library itself? Also, do I just run mvn clean install in BuildTools/Spigot to build it?
You'd need to look at the documentation, but I'd guess mvn clean install should do the trick
tbh I am completely new to mvn and I am just trying to get a pre-compiled plugin to work. I checked the output which is Installing D:\BuildTools\Spigot\Spigot-Server\target\spigot-1.8.8-R0.1-SNAPSHOT.jar to C:\Users\Administrator\.m2\repository\org\spigotmc\spigot\1.8.8-R0.1-SNAPSHOT\spigot-1.8.8-R0.1-SNAPSHOT.jar but it doesn't contain the thing.
I am just trying to get a pre-compiled plugin to work
I sense that you accidentally picked the hard way
Yeah
what would be the easier way?
You can still modify it
how
Is the plugin even designed to run on 1.8.8
yes
Did you even include google-commons as a dependency?
If it's just missing a dependency you can make your own plugin providing it
Better question would be whether the the plugin is even designed to run on 1.8.8 SPIGOT
No need to modify anything
yes, it is designed to run on spigot
Then that plugin has a serious bug
I guess alternatively one could write a small .tiny file to remap everything from using org.bukkit.craftbukkit.libs.com.google to using com.google instead
.
I want to make a skeleton walk in a straight line
I've done setAI(false) but I don't know how to make it manually walk in a set direction for a set amount of time
any help would be great
you may want a custom path finder to make it walk to a specific point?
Or just apply https://gist.github.com/Geolykt/018163239ca6e544b1254f6f0cfc8239 on the plugin jar
Source code of the generator:
import java.io.*;
import java.nio.file.*;
import java.util.jar.*;
public class TinyGenerator {
public static void main(String[] args) throws IOException {
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get("gson.tiny"))) {
bw.write("v1 official named");
try (JarInputStream jis = new JarInputStream(Files.newInputStream(Paths.get("bukkit-1.8.8-R0.1-20160221.082532-43-shaded.jar")))) {
for (JarEntry e = jis.getNextJarEntry(); e != null; e = jis.getNextJarEntry()) {
System.out.println(e.getName());
if (e.getName().startsWith("com/google") && !e.isDirectory()) {
String name = e.getName().substring(0, e.getName().length() - ".class".length());
bw.write("\nCLASS " + "org/bukkit/craftbukkit/libs/" + name + " " + name);
}
}
}
bw.write("\n");
}
}
}
I'm making a plugin with a series of GUI's. there are a number of listener classes with e.setcancelled(true) in them to stop items being moved around. but now only the first couple of classes I'm registering are actually working the rest I am able to move items around in. is there a way around this, thanks
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
?paste
First mistake, do not compare inventories by name
https://paste.md-5.net/hozesuhili.java here's the code. I'm rather new to this so any feedback you have is appreciated
compare inventories by instance
if (clickedInventory == yourInventory)
also do not close an inventory you are currently in the event for. use the scheduler to close it one tick later
?scheduling
Tyy
thank you for all the tips, ill incorporate all this stuff your mentioning. any ideas on why im able to move things around in the inventory ?
probably because you are not correctly matching the inventory
It won;t cancel if you try to match by name and fail
Yeah quest levels and whether they hvae the quest activated
What is the event for frost walker
BlockFormEvent?
It would be a form event, yeah
And i cant get the player in blockformevent
Thanks
Hi can anyone help with how I should structure my database.
I have users that can do quests, and each of the quests have several requirements and I've represented the requirements as an integer which is just their 'completion' towards the requirement. So how would I store the quest for each user, whether they have the quest activated and their completion towards the requirements of the quests.
Im using SQL btw
Just a simple table there should work fine, no?
CREATE TABLE IF NOT EXISTS player_quests (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
uuid CHAR(36) NOT NULL,
quest_id VARCHAR(64) NOT NULL,
progress SMALLINT NOT NULL,
UNIQUE INDEX player_quest(uuid, quest_id),
PRIMARY KEY (id)
);
im thinking that most people that use sql dont need it because of the relational part they dont need
Boo storing uuid as a char
Depending on how complex your questing system, you can absolutely make it relational
Nah because each quest has multiple 'progesses', if you see the message i sent
Yeah, separate table with a foreign key to the player_quests table
probably also a requirements table or smth but idk what you would put in there
what does UNIQUE INDEX even do, that some kind of weird sql dialect?
It ensures that the combination of those two columns are unique
e.g. you can have (uuid1, "first") and (uuid1, "second"), but not two (uuid1, "first")s
what the index for, arent indices created automatically on unique columns? 👀
Yeah but you don't want uuid and quest_id to be unique independently
Else a player wouldn't be able to have more than one quest active
I thought you could just do UNIQUE
Possible design could look something like this:
CREATE TABLE IF NOT EXISTS player_quests (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
uuid CHAR(36) NOT NULL,
quest_id VARCHAR(64) NOT NULL,
UNIQUE INDEX player_quest(uuid, quest_id),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS quest_progress (
quest_id INT UNSIGNED NOT NULL,
progress SMALLINT UNSIGNED NOT NULL,
-- Optionally include a category for the type of progress to be made?
FOREIGN KEY (quest_id) REFERENCES player_quests(id)
);```
Maybe an "active" BIT column as well (or BOOLEAN, which is an alias)
Let's just ignore that primary keys cannot be null anyways
No. It is 90% the wrong way
If needed use different event listener instances for different events
But don't use a constructor to store all your logic
public final class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new MyListener(), this);
}
}
public final class MyListener implements Listener {
@EventHandler
private void onChat(AsyncPlayerChatEvent event) { }
}```
I mean it probably works, but you don't want to do that
Hm so the progresses could be a little confusing?
whats confusing about it?
different progresses per quest for one player?
So they might have to kill 10 players and break 20 blocks for example
For a single quest
then you'd need to have another table for that
im thinking that you could just create another quest progress record but im not really thinking straight now
Or just add a progress_type column or something
Like a table for if the quest for 1 requirement, a table for if it has 2 requirements etc.
?
The most recent schema I sent has two tables
You would be able to create two entries in the progress table that refer to one quest table entry
how can i cancel cactus growth ?
@EventHandler
public void cropGrowth(BlockGrowEvent e) {
if (e.getNewState().getType() == Material.CACTUS) {
e.getNewState().setType(Material.AIR);
e.setCancelled(true);
}
}``` this not working
Ohhh i see what you mean, I misunderstood before, thanks
Nah a table which stores questid, playerid and progressTypeid
I see what choco sent, that should work
But uh, you can just add that to the quest_progress table
maybe you can just change the cactus modifier to 0
growth:
cactus-modifier: 100
cane-modifier: 100
melon-modifier: 100
mushroom-modifier: 100
pumpkin-modifier: 100
sapling-modifier: 100
wheat-modifier: 100
netherwart-modifier: 100
Basically your constructor invocation
ah no i need cactus growth but i just wanna try something
Probably the wrong event
Ah no it is that event
I thought it was different for cactus and sugarcane my bad
i did this too
why set the newState to AIR and then cancel? you are undoing what you just did
i did only with e.cancelevent
a BlockState is a snapshot of what the block was or is to be.
if you make changes to teh BlockState then cancel the BlockState will never be used
im leaving at this discord
i forgot the register events
OMG
CYA
wtf
im stupid 😢
me too its ok
So if the quests have a type, should i do:
CREATE TABLE IF NOT EXISTS player_quest_types (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
uuid CHAR(36) NOT NULL,
quest_type_id VARCHAR(64) NOT NULL,
UNIQUE INDEX player_quest(uuid, quest_type_id),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS quests (
quest_type_id VARCHAR(64) NOT NULL,
quest_id VARCHAR(64) NOT NULL,
active BIT NOT NULL
PRIMARY KEY (quest_id)
FOREIGN KEY (quest_type_id) REFERENCES player_quest_types(id)
);
CREATE TABLE IF NOT EXISTS quest_progress (
quest_id INT UNSIGNED NOT NULL,
progress SMALLINT UNSIGNED NOT NULL,
FOREIGN KEY (quest_id) REFERENCES quests(id)
);
or
CREATE TABLE IF NOT EXISTS player_quests (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
uuid CHAR(36) NOT NULL,
quest_id VARCHAR(64) NOT NULL,
quest_type VARCHAR(64) NOT NULL,
UNIQUE INDEX player_quest(uuid, quest_id),
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS quest_progress (
quest_id INT UNSIGNED NOT NULL,
progress SMALLINT UNSIGNED NOT NULL,
FOREIGN KEY (quest_id) REFERENCES player_quests(id)
);
Or something else?
Well what does a quest type do?
Also, probably do want a progress_type column in the quest_progress table to distinguish which progress is for which
Well some quests will be 'levellable' but some youll just be able to do once, for example
Okay
Do you need that stored persistently though?
That should just be something available in the Quest object in code, no?
Yeah, but how would I store what level the quest is on
Hello, I am trying to write some data from hashmaps and hashsets to a json file, and the methods I have write fine, but the load method somehow wipes the file and gives me a whole malformed json error and disables my plugin, so can anyone point me towards a good resource to figure it out, or help me code the method? I'll provide a ss of my code
Given that not all quests are levelable, perhaps an additional table
Okay
CREATE TABLE IF NOT EXISTS quest_level (
quest_id INT UNSIGNED NOT NULL,
level SMALLINT UNSIGNED NOT NULL,
FOREIGN KEY (quest_id) REFERENCES player_quests(id)
);
Should be easy enough to do this
Ty
Small int
Sus
I can't possibly imagine a level being higher than that
Not with that attitude!
If, however, it can go higher than 65k, you can use a regular unsigned int to give a little over 4 billion
My in game level is the int limot
Okay thats all for now tysm choco
If you want to pull all of this data in a single query (which you can do!), you'll want to look into JOINs
Okay ill keep that in mind ty
In SQL is especially important because you're storing potentially millions of entries and for each entry, you're including 2x the amount of bytes for each entry
At least for a SMALLINT vs an INT
It's the difference between 2 million bytes and 4 million bytes for the exact same data
(granted that's 2MB vs 4MB, but still important lol)
In a garbage collecting language like Java it's less important, yeah. Still nice to restrict the scope of your integer values where obviously necessary, but yeah...
Im now only ever gonna use bigint
I just changed the first method I showed to the one that worked I forgot that I had messed with it earlier
8 bytes for even the smallest of values 😎
That's why people create static instances of them that they re-reference 
I'm currently tracking an index with an int even though a byte is probably plenty
Now my plugin is gonna OOM servers
also that code is full of deprecated stuff
I'm really new to the minecraft side of java I've never used gson or anything
The problem with smaller types in java is that you have to be explicit with them
how do you type the code on here like that? like what word do you put with the ` ``
watch me delete 12k duplicates of the same image because some ps3 game developer back in '08 decided it was good idea to put a default image with every save
```sql
SELECT WHATEVER
```
?code
!code
idfk
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
that
thank you
public void saveData(Map<UUID, ChatColor> primaryRoleplayColors, Map<UUID, ChatColor> secondaryRoleplayColors, Set<UUID> localChatPlayers, Set<UUID> staffChat) throws IOException {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
File file = new File(RPChat.getPlugin(this).getDataFolder().getAbsolutePath() + "/data.json");
FileWriter writer = new FileWriter(file, false);
gson.toJson(primaryRoleplayColors, writer);
gson.toJson(secondaryRoleplayColors, writer);
gson.toJson(localChatPlayers, writer);
gson.toJson(staffChat, writer);
writer.flush();
writer.close();
}
This is what I have that I feel like is better than making json objects and does work to save to a json file, but my problem is whenever I try to use a load method of any sort, it clears the json file and then gives me a malformed json error
I'd recommend to just use a data class and let gson do its thing
instead of passing all these params
What's stopping you from doing a
public class PlayerData {
private final UUID playerId;
private ChatColor primaryColor;
private ChatColor secondaryColor;
private boolean staffChat;
private boolean localChat;
}
couple setters
constructor n all
I've got them set and declared up top, but they're all private
Lowkey was just like following youtube tutorials and going off of what worked, this is my first like functioning plugin cause it works fine before the saving of the data
It saves just fine, I don't know how to get it to the read the file
I'm setting up a scoreboard display under each player's name. Only issue is the score integer value is displayed as white, and always displayed first. As I understand it, it will always be displayed before the objective name, but can I at least change the color of the score?
all I am asking is for someone to help me with that part
An ImIllusion smearch smindex
Get alex to make a blog on it
Image for reference https://pasteboard.co/ENI6rIDWo5ZV.png
Okay, so the issue wasn't that nms wasn't available, it was, the issue was the classes were renamed and in different locations. Thanks for the help.
Error occurred while enabling DeathClock v1.0.1 (Is it up to date?)
how do I fix this?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
?paste Error occurred while enabling DeathClock v1.0.1 (Is it up to date?)
java.lang.ExceptionInInitializerError: null
at me.creepinson.plugin.Main.onEnable(Main.java:73) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.enablePlugin(CraftServer.java:534) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at org.bukkit.craftbukkit.v1_19_R3.CraftServer.enablePlugins(CraftServer.java:448) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:589) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:414) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:250) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:975) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.19.4-R0.1-SNAPSHOT.jar:3744-Spigot-d1bd3bd-a7cfc77]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.1-jre.jar:?]
at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:106) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
at me.creepinson.plugin.listener.PlayerJoined.<clinit>(PlayerJoined.java:25) ~[?:?]
Hi ppl can u guys help me?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[guava-31.1-jre.jar:?]
at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:106) ~[spigot-api-1.19.4-R0.1-SNAPSHOT.jar:?]
You are trying to make a namespaced key with a null plugin
im making a plugin for my server, its basically so; a player does /call and the ppl who have "operator" permission gets "player" is calling, its like a telephone switchboard, u cant use /msg directly but through /call u can, but the operator will need to connect u
can u guys check the code? thx
oh
?paste
bro just AI generated his whole class
bruh
can u atleast check?
start coding by yourself
how would I fix that
Maake sure the plugin instance is not null
ok thanks
For what?