#development
1 messages Β· Page 31 of 1
It'd work
But you'd have to register every single placeholder
And if there's duplicates then there's trouble
you could say that about identifiers
Well not that exact map
if the identifier was the key that would maybe work
but it still doesnt handle duplicates yeah
Yeah
well plugins have to register with identifiers, and im those have an exception for duplicates
sounds like a whole lot of effort for very little gain
And reduces clarity
yeah its not worth it for the devs to change that right now
I'm just saying it would "work" but not any better than with identifiers - mainly because of duplicates and clarity
Unrelated but {} > %%
Papi3 should do {} π
() π
Sad
Last commit to Papi3 was a year ago
"xD"
yes
having both be % causes a whole load of issues
maybe that's a slight exaggeration but you can't really do nested placeholders
why is this not working: ``` public void Kill(EntityDamageByEntityEvent event) {
Entity Damger = event.getDamager();
Entity entity = event.getEntity();
double damge = event.getDamage();
if (entity instanceof Player);{
if (Damger instanceof Player){
Player player = (Player) event.getEntity();
Player player1 = (Player) event.getDamager();
if (player.getHealth() == 0){
player.setMaxHealth(player.getMaxHealth() + 1);
player1.setMaxHealth(player1.getMaxHealth() + 1);
} else if (player.getHealth() < 0){
player.setMaxHealth(player.getMaxHealth() + 1);
player1.setMaxHealth(player1.getMaxHealth() + 1);
}
}
}
}
you probably want to use a PlayerKillEvent
not an entitydamagebyentity if health == 0
what is the purpose, every time someone is killed, they both gain a maximum heart?
also, the damage hasnt been applied to the health yet, that happens after your listener, so using getHealth() will not be accurate. And the last condition will never be true, since health is always positive (probably)
its not exist
how i can use this?
Read the readme
why its kotlin?
if you want to fork paper, check the paperweight-examples repo
why its kotlin :omegalul:
I'm on mobile, it's there in the org
kotlin bad
thanks
It's a gradle plugin
oh, everything explains it self
how i make this work
where's @EventHandler annotation, and did you register the listener
yes i did
print out thing ig
hm?
how do i make a falling block never despawn? or at least last a long time?
ik its something to do with FallingBlock#setTicksLived(int), but im not sure what to use as the int
why hm
i dont understand what you mean
you mean the output jar version?
yes
should be something lik
<version>1.0</version>
somewhere
<version>1.19.2-R0.1-SNAPSHOT</version>
not this one
wich then?
send .pom
<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>Drache</groupId>
<artifactId>.de</artifactId>
<version>Beta</version>
<packaging>jar</packaging>
<name>KeyAll</name>
<description>Key all large small and meduim</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
<groupId>Drache</groupId> // groupID like io.github.sdxqw
<artifactId>.de</artifactId> // name of the file
<version>Beta</version> // my version of the jar
<packaging>jar</packaging>```
then how do i fix this?
change beta with whatever you want
it build on wrong minecraft version
i commented what that are
1.19.2
what
1.19.2
what
tf
1.19.2
^, just click build and it will replace the dependencies with paper 1.19.2
but it dont work
what doesnt work
ok
its to long
kotlin dev moments:
dkim is an infamous troller

Funny cube has not fixed @neat pier in so long
Das Handle ist ungΓΌltig
π¦
There's like 3 issues with Barry that it had for like months
The paste being one of them
:Warning:
Partially fixable with modals
Awesome
Late
java.io.FileNotFoundException: https://discordapp.com/api/webhooks/1058467352271933520/*
i dont think this is a file lol
whats the name of your plugin
BetterCrystal ig?
yes
pretty sure it BetterCrystal vBeta
well you pasing a link like a file ig
its for discord webhook
yes, but you did it wrong
why
paste code
because paperclip and paper-api cant load it
how do i fix?
2
you missed 1
can you show the code
ok
cuz im the 1 π€
use the paste to paste that, it's a bit large
xD
why its parsin a link as a file?
idk
somethin is wrong with JSON
im confused
i send the main .jar file
public final class de extends JavaPlugin {
private URL url;
public static de INSTANCE;
public de() {
INSTANCE = this;
}
it seems like the constructor stores an instances of itself?
yes
you won't need that, you can always just use 'this'
big brain moments
new design pattern just dropped
using the this π€
using static instance from the same class π
when does the new access modifier drop?
privatetoself
wait some minutes
Do you see an error in the file apart from something else that could be done better?
yes, use this library instead
https://github.com/MinnDevelopment/discord-webhooks
im wondering how line 44 this.register() is not a syntax error
is that some paper thing?
Private to self?
referencing this
using Class.INSTANCE in the same class instead of this
(it's a yoke)
//listener
PluginManager pluginManager = Bukkit.getPluginManager();
pluginManager.registerEvents(new JoinQuitListener(), this);
pluginManager.registerEvents(new ChatListener(), this);
pluginManager.registerEvents(new DeathListener(), this);
pluginManager.registerEvents(new CommandListener(), this);
pluginManager.registerEvents(new SchildListener(), this);
pluginManager.registerEvents(new CrystalSettings(), this);
pluginManager.registerEvents(new PlayerHitListener(), this);
pluginManager.registerEvents(new Hearth(), this);
//commands
Bukkit.getPluginCommand("firestrike").setExecutor(new FireSrikeCommand());
}
ah i didnt see that
do you have any idea why the plugin is on wrong version
private boolean value = true;
public boolean realValue = value;
this is real coding
the log says its on wrong version?
the log probably says "wrong version?" because of your error
it is the right version
wait
the version is correct, it's just an error in your sendToDiscord() method
i send it in more lines
here
check this error buddy everything from here its wrong
its now working
no its not
retrying restating the server lol
always "debug"
alrigth
alrigth
(2)
When im using the Flame particle it creates like a explosion instead of just staying in place (trying to make a flame circle around a player). is there a way to fix this?
d;paper World#spawnParticle
void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra)```
Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.
particle - the particle to spawn
location - the location to spawn at
count - the number of particles
offsetX - the maximum random offset on the X axis
offsetY - the maximum random offset on the Y axis
offsetZ - the maximum random offset on the Z axis
extra - the extra data for this particle, depends on the particle used (normally speed)
@ashen lodge I believe the "extra" argument is what you're looking for, normally it's the speed of the particle, making it 0 (i think) will make the particles stay still
srr for ping but idk how to make a peper fork for 1.19.3, with custom paperclip and paper-api
Welp
what
Did you read the readme of paperweight? And did you check the examples?
there no info
lel
only talking
It's an example, the repository itself is a fork
There is also different branches that show how to do different things
And lastly read paper's CONTRIBUTING.md, should be more than enough to understand it
link
As I said, check the paperweight-examples repo, it's another repository in the same organisation
https://github.com/PaperMC/paperweight-examples what i need to do here ?
Paper's own contributing guide will also be of help to understand how to work with it, it's the same workflow https://github.com/PaperMC/Paper/blob/master/CONTRIBUTING.md#understanding-patches
this is not sleeping: ```while (chair.getTicksLived() < 100) {
try {
sleep(20); // sleep for 20 milliseconds
} catch (InterruptedException e) {
// handle interrupted exception
}
chair.setVelocity(velocity);
double p = chair.getLocation().getPitch();
double yaw = chair.getLocation().getYaw();
double p1 = p + 1;
double yaw1 = yaw + 1;
chair.setRotation((float) p1, (float) yaw1);
chair.setPassenger(player);
chair.setGravity(false);
}
chair.remove();
return false;`
how i make sleep in a while?
is there any way to replace while with something that work
yes
use a repeating task
also a minecraft tick is 50ms
btw what entity is this chair?
im a little confused on what your doing exactly
chair is an arrow
double yaw = chair.getLocation().getYaw();
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
double p1 = p + 1;
double yaw1 = yaw + 1;
chair.setRotation((float) p1, (float) yaw1);
}
};
new Timer(50, taskPerformer).start();```
like this?
chair.setVelocity(velocity);
chair.setPassenger(player);
chair.setGravity(false);
BukkitTask task = Bukkit.getSchedular().runTaskTimer(plugin, ()-> {
double p = chair.getLocation().getPitch();
double yaw = chair.getLocation().getYaw();
double p1 = p + 1;
double yaw1 = yaw + 1;
chair.setRotation((float) p1, (float) yaw1);
}
,0L,0L);
Bukkit.getSchedular().runTaskLater(plugin ()-> {
task.cancel();
chair.remove();
},20*5);
is this some sort of controllable missile?
yes
i think this is right
btw where did you pull this out of?
openai
i dont think using AI to write code for you is a good idea cus then your never gunna learn yourself
and its gunna pull this out of its ass that doesnt have enough context to write something that would actually work
ActionListener from a quick google search looks like its used for when you click something in a gui for awt
I am currently using a Custom Event called PlayerAttackPlayerEvent, which uses the EntityDamageByEntityEvent. This is working out great for me and makes it easier. However, I want to use the event.setDamage() from EntitnyDamageByEntity event in my PlayerAttackPlayerEvent. If i can, how can i achieve this?
r u extending EntityDamageByEntityEvent?
super?
ill send my current code
1s
@EventHandler
public void onPvP(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) return;
if(!(event.getEntity() instanceof Player)) return;
Player victim = (Player) event.getEntity();
Player attacker = (Player) event.getDamager();
if(attacker.getInventory().getItemInMainHand().getType() == Material.AIR) return;
Model weaponModel = new Model(attacker.getInventory().getItemInMainHand());
Bukkit.broadcastMessage(event.getDamage() + " : BEFORE PVP");
event.setDamage(event.getDamage() + (event.getDamage() * (weaponModel.getFrenzyStack()/100)));
Bukkit.broadcastMessage(event.getDamage() + " : AFTER PVP");
Bukkit.getPluginManager().callEvent(new PlayerAttackPlayerEvent(victim, attacker, weaponModel, event.getFinalDamage(), event));
this.plugin.getCombatManager().setCombatTime(victim, 16); this.plugin.getCombatManager().setCombatSet(victim, true);
this.plugin.getCombatManager().setCombatTime(attacker, 16); this.plugin.getCombatManager().setCombatSet(attacker, true);
NBTEntity nbtEntity = new NBTEntity(victim);
nbtEntity.setUUID("lastAttacker", attacker.getUniqueId());
}```
```java
private static final HandlerList HANDLERS = new HandlerList();
private final Player attacker;
private final Model weaponModel;
private final double finalDamage;
private final EntityDamageByEntityEvent event;
public PlayerAttackPlayerEvent(Player victim, Player attacker, Model weaponModel, double finalDamage, EntityDamageByEntityEvent event) {
super(victim);
this.attacker = attacker;
this.weaponModel = weaponModel;
this.finalDamage = finalDamage;
this.event = event;
}
public static HandlerList getHandlerList() {
return HANDLERS;
}
public HandlerList getHandlers() {
return HANDLERS;
}```
i recently just added the EntityDamageByEntityEvent parameter, that didnt work
for ur PlayerAttackPlayerEvent
Using this would i still use the Bukkit.getPluginManager().callEvent(new PlayerAttackPlayerEvent(victim, attacker, weaponModel, event.getFinalDamage(), event.getCause())); in the EntityDamageByEntityEvent to call it?
i think so, yes
ur constructor can look like this btw (using Player instead of Entity):
public PlayerAttackPlayerEvent(@NotNull Player damager, @NotNull Player damagee, @NotNull DamageCause cause, @NotNull Map<DamageModifier, Double> modifiers, @NotNull Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
super(damager, damagee, cause, modifiers, modifierFunctions);
}```*u dont need the `@NotNull`s*
yes, i already did that just not in the same order
wdym not in same order?
the parameters should be in the same order as the parent constructor from EntityDamageByEntityEvent
the super is the same
how do i make an arrow fly in an cicle
o ig that works didnt know that
you'd have to change the parameters here btw
unless its different on the version im using
it asks for
public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
super(damagee, cause, damage);
this.damager = damager;
}```
for me
it says thats deprecated for me
what mc version?
1.17
ye doesnt look like its deprecated so ur good
unlucky for me tho cause its deprecated in 1.11 
and idk how to get these from the original event: Map<DamageModifier, Double> modifiers, Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions
maybe it might be best to just remake all the methods that EntityDamageByEntityEvent has instead of extending it, im not sure what consequences extending it might have, i havent made my own event before
Basically, what im trying to do is make it so the enchants im making work together. For example if you proc a Lifesteal and a Electrocution at the same time it will do more since Elec will remove damage and Lifesteal will check the damage delt and heal you that much. what i do for Elec to do damage is victim.damage(scorch * 0.75); what should i be doing to add that to the total damage which will be collected by the float heal = (float) Math.min(event.getFinalDamage() / 3,2); in lifesteal
Does anyone know why the int i is not increasing when it finds itself looking at null or with no item meta? (context: im trying to remove items with item meta, to do that, i have a for loop, ++i for each null or item without item meta, once it bumps into something with item meta, it gets deleted)
for (int i = 0; i < 36; i++) {
ItemStack items = p.getInventory().getItem(i);
if (items == null || !items.hasItemMeta()) {
i++;
return;
}
if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
items.setAmount(0);
}
Hey can someone help me out
What is the boolean parameter arg2 in the constructor of net.minecraft.server.packs.FilePackResource
and what is the String parameter arg0?
I assumed java.io.File arg1 was the actual resource pack file
I also assume String arg0 is the file location? Or is it the actual name of the pack?
you dont need the first if statement
why
what i mean is, you dont need to i++ in the first condition
your for loop already increments by one
oh
but how can the loop find out if its null
or has no itemmeta
beacuse those are the issues that prevent the code from working
you return early
if any item has no meta, it just breaks the whole loop
try inverting your condition and nesting it
ok i removed return;
and it removes everything except for the next itemstack AFTER items with no meta
for (int i = 0; i < 36; i++) {
ItemStack items = p.getInventory().getItem(i);
if (items != null && items.hasItemMeta()) {
if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
items.setAmount(0);
}
}
now it goes through each item, never returns. and if it has meta, and the meta has lore, name, ench, then set it to zero
ill see if that works
it didnt work at all
im all out of ideas idk what to do
with the code above removing just return
it would delete all the dirt apart from the one next to the stone slab
anyone have an idea why the tnt is spawning where the player is looking instead of 50 blocks above them?
Player player = (Player) sender;
World world = player.getWorld();
Location pos = new Location(world, player.getLocation().getX(), player.getLocation().getY() + 50, player.getLocation().getZ());
TNTPrimed tnt = (TNTPrimed) world.spawnEntity(pos, EntityType.PRIMED_TNT);
new BukkitRunnable() {
@Override
public void run() {
Location tntLocation = tnt.getLocation();
tnt.getWorld().spawnParticle(Particle.COMPOSTER, tntLocation, 50);
if (!tnt.isOnGround() && tnt.isValid()) {
return;
}
TNTUtils.explosion(tnt.getWorld(), tnt.getLocation(), CustomEnchants.getTNTLevel(player.getItemInUse()) / 5);
cancel();
}
}.runTaskTimer(plugin, 1L, 1L);
paste your current code
if (p.getGameMode() == GameMode.CREATIVE && !p.hasPermission("limitedcreative.preventcheck")) {
for (int i = 0; i < 36;) {
ItemStack items = p.getInventory().getItem(i);
if (items == null || !items.hasItemMeta()) {
i++;
}
if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
items.setAmount(0);
i++;
}
``` current code rn, it deletes everything but also halts?
move the i++ into the top of your for loop
and get rid of all other i++ inside
negate your condition and nest the statements, like i had
in your code, the null check doesnt have a purpose, since it continues to the next if statement anyways
well no not really
if a player's itemstack slot is null
it doesnt continue
its just stuck
yeah because its an error
same goes for itemstacks with no itemmeta
thats why you want to check if its not null, and if so, run your lore, name, enchants check inside
otherwise it will throw a null pointer exception
when you're done, if it doesnt work, paste the code that you have and ill look at it again
well i did something yesterday
and it said
my plugin generated an exception
etc etc
i think it works now
ill have to do more testing
anyone have any thoughts on this?
when you say "in front"
is it in the direction the players facing
or just in like x direction or z
(the tnt)
no literally like where you are looking itll spawn at the tree or if you look at the sky itll spawn at height limit
wtf, bro accidentally added raycasting
???
honestly don't see what's wrong with the tnt code at a first glance
what command is this btw
it seems like youre overriding cmd
(tell me it's not antioch)
you talking to me?
yes
the heck is antioch
a command that spawns tnt where youre looking
nononoo
Whats a good api for checking when armor is equip and dequip
there's no way you can accidentally add tnt spawn where you're looking, so im assuming some other command is in conflict with yours
yes
this method is overriding onCommand() right?
im not even kidding you i was so confused why it wasent working sat here for like half an hour just confused
thanks lmfao
was it /antioch by accident or something
ah
listener wont register for some reasons
is asyncplayerchatevent deprecated?
Yes, you need to use AsyncChatEvent now.
I've heard the chat system changed in 1.19.
protocolManager.addPacketListener(new PacketAdapter(
plugin,
ListenerPriority.HIGHEST,
PacketType.Play.Server.CHAT) {
@Override
public void onPacketSending(final PacketEvent e) {
PacketContainer packet = e.getPacket();
Messenger.debug("Packet " + packet.toString() + " sent to " + e.getPlayer().getName());
...
this used to work in 1.18, but it doesn't in 1.19. what changed?
(protocollib)
ah it's SYSTEM_CHAT, not CHAT
Trying to shade two dependencies into my plugin's jar file, but when running the build gradle command the libs arent getting shadowed in
I am not sure what I could be doing wrong
IDK much about gradle but last time I used it I needed to add shadowJar to my tasks. Have you done that?
Yeah It was that mb
I'm trying to implement HikariCP to my project, though I am really struggling to figure out what my dataSourceClassName is.
I tried the MariaDB one and the MySQL one, but neither work
Both of them throw a ClassNotFoundException
you also need to shade the driver
shadowJar {
dependencies {
include dependency("com.mysql:mysql-connector-j:8.0.31")
include dependency("com.zaxxer:HikariCP:5.0.1")
}
relocate("com.mysql", "shaded.com.mysql")
relocate("com.zaxxer", "shaded.com.zaxxer")
}
``` am I not?
what specific error do you get?
https://paste.helpch.at/tekamikili.php This error
well that doesnt look like the right driver class name lol
why are you using the ms sql one?
i honestly dont know, I originally tried using the MariaDB one since the database I am trying to connect to uses MariaDB
as a library
But writing that as the dataSourceClassName did not work either
The error looks the same with either string
well if you want mariadb you need to shade the mariadb driver, not the mysql one lol
although i think mysql should be compatible with maria, you just need to use the jdbc url instead
do you mean in my build.gradle?
in my repositories section
Ah
either:
use mysql connector and jdbcurl instead of data source class
shade mariadb driver and use the mariadb data source class
I suppose the latter is better since the database I am connecting to uses MariaDB?
Where do I find the jdbcUrl though for MySQl's driver
I'll try doing the latter though just cause it makes more sense to me
Let's see
Are the errors displayed for an incorrect password and access being denied altogether separate?
?
Is there any API I can use for when a player c hangs their gear
I am trying to connect to my university's database through a Minecraft plugin, not sure if my password is somehow wrong or if the database is not allowing me to connect
This is the error I get

what do you mean by that
i dont know
i do

I think I am though
yeah the value returned by getPassword() is correct
hm
well then maybe it is getting rejected
try connecting with a normal sql client
if u have IJ ultimate there's one built in
Yeah the reason why I was connecting to the uni one was cause it was easier than setting up a dummy server myself π
At that point i'll just make one on my machine
However it does let me connect to the university database through HeidiSQL
Β―_(γ)_/Β―
maybe a \n character or something in the password
or try with jdbc url
like i said that's always worked perfectly for me
apparently that's what I gotta do yeah
it's some issue with MariaDB
Though I still don't follow where I can find out the jdbc url of different drivers
google dot com
jdbc:mariadb://server.company.domain:3306/dbname this is what I found online
mysql will work for maria
and they all follow that format
the only thing that changes is the start
Using that
I'll try using the MySQL one
Yeah even with the mysql one it throws a ClassNotFoundException
Okay I had to change way that I initialize the data source mb
Now I get the same access denied error THOUGH it says using password: YES
well then the username or password is wrong
or the database isnt accepting connections from ur ip
Yeah okay the password was actually changed by the uni and I forgot lol
Is there any way in minecraft 1.19.3 to have itemstacks go over 64 at least visually?
Got a strange Failed to initialize pool: Too many connections error
I forgot to close my connections when the plugin is disabled, though now how can I close all the current connections to my database?
They are all sleeping
What
restart your mysql server
I don't have access to the actual server
It's my university database
i would assume you send some sort of packet
what packet im not sure, imma have a look at wikivg
Set Container Slot
if you cant do it with the regular bukkit itemstack then using nms might be an option, i dont think there is any strict checks when using nms if there are any using bukkit
actually ive tried quite a few different thinks other then a packet and cant get it to show it as more then 64
maybe in fake inventories its not possible idk
Ah alright :/
No matter what I do it keeps creating a bunch of processes, I closed each of the 137 processes manually but after restarting my server a couple times there's 20 already
I close my connection in my onDisable() withconnection.close() though, and the actual variable is only ever assigned in my onEnable()
So the connection isn't being initialized a bunch
And now I am getting this error: https://paste.helpch.at/mayirewide.rb
afaik your supposed to close the connection as soon as your done with it or reuse the same connection instead of making more
ive reused the same connection tho that was with sqlite
I am using Hikari though just so that I don't have to look after closing and opening connections over and over again
https://paste.helpch.at/curavaxuvu.java Shouldn't this handle opening and closing by itself?
that's what this guide here says: https://www.spigotmc.org/threads/guide-datasource-and-try-with-resources-how-to-connect-to-your-database-properly.480002/
Nah this whole thing is buggy as hell
https://paste.helpch.at/adajuhufol.css getting this error now (While my code keeps creating dozen of connections I need to manually kill)
It's pointing at this code still
HELLO!!!!! i have api, i use implementation for my api when i use it in my other plugins
i want to make it so that a dependency from the api is compilyOnly for the plugins that use the api
how can i do this? does it involve the java-library plugin?
im doing this so i dont have to compileOnly jetbrains annotations for all my plugins, so if there is another, easier, way to accomplish this, please lmk (i remember i used to not have to declare jetbrains annotations as a dependency, but i have no idea what i changed)
oke
That looks fine, what does core.getConnection do?
share code
compileOnlyApi
and the implementation version of that would be api
and i think it does involve java-library plugin
ye if it involves api/Api it does
In JDBC parameters start at index 1, not 0, so you would do setString(1, ...) not 0
yeah figured my bad
Hold on
public Connection getConnection() throws SQLException {
return dataSource.getConnection();
}```
Yeah that's good π
But then why do a million connections keep popping up
@Override
public void onDisable() {
// Plugin shutdown logic
try {
getConnection().close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}``` I close the connection onDisable
infinite loop or not closing them or not reusing
Doesn't HikariCP open and close them automatically?
no dont think so
no
the guide says the try with resources closes it
but with the code you have it should close automatically, yes
Anyone can help me with regards of having server boost together with nitro? My nitro seems not activate bcoz its said it was credited?
you arent executing the statement, are you?
you're closing a newly created connection, you should close/shutdown the HikariDataSource itself
stmt.executeQuery()?
I am for my method with the SELECT query
Ah, let's see
btw how come you should close resources when the plugin is disabling? doesn't it get closed when the JVM stops?
And you should use try-with-resources each and every time you use a Connection, PreparedStatement, ResultSet etc, so hikari knows how to properly lifecycle the connections, it isn't automagic
you gotta run the insert statement too
Nono I mean
Those are two separate queries
yeah where are you executing it?
On your side yes (pretty sure?), on the server side not necessarily
PlayerQuitEvent
oh, wdym server side?
no PreparsedStatement#executeQuery
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
Core.getProfileManager().saveProfile(event.getPlayer());
}```
Static abuse 
actually idk when you'd be constantly opening files
but for the weird chance that you were
For some reason though, this does not insert any data to my table whatsoever though?
It doesnt throw any errors however
you shouldnt have a file stream open all the time afaik
yeah
THATS what im saying amigo
but im just saying for the weird case that someone has it open π₯΄
would there by any diff in closing in onDisable vs not closing at all?
I did not use DI since I only ever want one instance of ProfileManager
So I made it static
wasn't sure if that was for me or not
nobody else asked about it though
but youre creating a new instance of it, right?
To start with, flushing, and secondly even if you do call .flush it might not actually flush to the device (disk), there are lots of intermediate buffers, one the JDK keeps, another the kernel keeps and so on
Yep
Oke
see
I didn't test it yet
i was talking about the static abuse
i actually replied this time to the message
but eh
does ProfileManager have a constructor?
what is acceptable syntax for instance fields to be referenced outside its class
dependency injection usually
wdym?
getSomething()?
with a getter / setter
without a getter / setter in this case
huh?
yeah
properties π π π π π
then why do they have access modifiers
is it just for child class access management
private use
I'm on a call with some people and typing at the same time sorry lol
no problem
it's to make sure that other classes can only access what it needs to
and set what it needs to
and allows you to modify info sent in or out
with contructor parameters?
cannot issue statements that do not produce result sets
Nop
usually it's just the simple return value but if you want to change something (and to keep it consistent overall), getters/setters are recommended
where is that happening exactly
I mean this makes sense for making sure a subclass doesn't access a parents instance field, but aside from that having access modifiers on an instant field is pretty much redundant right?
The execute query line
no
no modifier does not mean private
without those it wouldnt work
Or is it just execute
no modifier = package private meaning that every class in its package can access the variables
yeah but my point is whats it matter if its private or not if you cant use it outside the local class w/o inheritance
even if its public, without a getter/setter I cant use it
wdym
if it's public you can use it, no?
unless you mean by following the "private variables" rule, then you should make getters/setters anyways
you could but you shouldnt
for ex in an interface: ```java
public interface Something {
SomethingElse getSomethingElse();
}
yea
i wasn't entirely sure what they meant
say I have a class, Options thats in the same package as Main, and Main has an instance field thats public. Even if its public, that doesn't mean it can be referenced in Options right?
Assuming Options does not extend Main
excuse me what
it can
you're thinking of protected
protected is what you're explaining right now
do you mean public static vs public etc
no not static
wait did you change it
ok maybe i read it wrong
you're referring to no modifier at all now
wait what
whats an instance field in your opinion
let me rephrase the question again
please just make a code example in a few seconds
public class Something {
/* any modifier */Object someField;
}
is what i think of
depending on the access modifier though
while he's typing, I'll mention this: ```ansi
[34mnothing [0m= [33monly within that [31msame [33mpackage
[34mprivate [0m= [33monly within that [31msame [33mclass
[34mpublic [0m= [33m[31mANY [33mclass
[34mprotected [0m= [33mmust [31mextend [33mor [31mimplement [33mthat class
^
I could π€ about how some of those are partially wrong but I won't :D
oh
please elaborate
π₯²
lol
Im saying is it possible to reference an instance field in another class without the use of getters/setters.
Code example;
public class Something {
String cheese;
Something(cheese) {} //constructor
}
Is there any acceptable syntax that would allow me to use that instance field below (whether it be with this or whatever
public class SomethingElse {
public void myMethod() {
this.cheese = "expired";
}
yes
no
(in order)
extends Somethig

what xd
hold up what
or implement that class/interface
Protected is not allowed in interfaces
oh
wait why
I know the difference between the access modifiers, its just about the legality of an instance field im asking about
yeah no i think my answer was somewhat correct
legality as in what's recommended?
what will be allowed to be compiled
if you want to access cheese in something else from something then you could extend it
no, not extend
our dependency injection
that's package private
Is there a way to do it without extending tho
make it public
di or just creating it yourself
you can't have protected on an interface so that last bit is incorrect
private means on the same class and inner/nested classes (more specifically, "nest members")
protected is also package-private accessible, so you don't have to extend the class to access a protected member if you're in the same package
you still wouldnt be able to edit cheese?
WHAAAaaat
protected is also package private?!
okay that I really did not know and didn't expect π₯²
because an interface defines a public contract
^ thats what Im thinking
and by the naming im guessing they are package private
if it's public, you can
dependecy injection (3x time now)
rn it's package private
I'm assuming that they know how to make an instance of a class and are using that
here's an example:
oh
public class Something {
public String cheese = "CHEESE"; // public!
}
public class SomethingElse {
public void coolStart() {
Something something = new Something();
something.cheese = "No cheese";
}
}
```this works
not recommended
but it works
if it's public you can access it from anywhere lol you just need an instance of the class
for example
yes
but you need an instance
yes
yes
you always do
you can't modify an instance field without an instance
there always has to be an instance for you to modify an instance field
how to create an instance of something?
BumP
for bitcash
is it correct to have the player UUID as my primary key in my database?
My father who's worked on databases many years says that I should have a separate table to pair auto-incrementing IDs with player UUIDs instead
And use the auto-incrementing ID as the primary/foreign key for all tables instead of the player UUID
i cant see much benefit to that
as long as the rows are all related to an actual player
Yeah that's what I mean, I think it just complicates things with avoiding duplicate values
yeah of course
its better for bigger structures as you can change the uuid in case
especiall if you have no control over the system that hands out the uuids
but for that stuff, nope, no need
but in Minecraft it's unnecessary
correct
yes
I hope this helps!
public class instancE {
public static instancE.somethinG SomethingInstance;
public static instancE.somethinG creatEinstancE() {
SomethingInstance = new instancE.somethinG();
return new instancE.somethinG();
}
public instancE() {
throw new IllegalStateException("This isn't something!");
}
public static class somethinG {
public somethinG() {}
public static somethinG creatEinstancE() {
return instancE.creatEinstancE();
}
}
}
it doesn't
No, I'm sorry
Yeah you better be
i aM
I've been thinking and.. how would this be valid syntax?
wdym?
like which part of it makes you think it's invalid syntax?
how can SomethingElse reference an instance field it was never assigned?
I think you're misunderstanding what encapsulation / inheritance means
My point is that it was not assigned within the constructor
doesn't have to since I already set it during initialization
public String cheese = "CHEESE"
```If it's already set, I don't need to set it again
HOWEVER
public String cheese;
```this would still work, but `cheese` would be null
(it won't give any errors I believe)
yes
if it's public yes
Ah I see..
and then you said you already know this but just in case I'll bump it back down: ```ansi
[34mnothing [0m= [33monly within that [31msame [33mpackage
[34mprivate [0m= [33monly within that [31msame [33mclass
[34mpublic [0m= [33m[31mANY [33mclass
[34mprotected [0m= [33mmust [31mextend [33mor [31mimplement [33mthat class [31mOR [33mpackage private
I'm trying to use a gradle task to run my server after the jar finishes building, and this is what I have so far:
https://paste.helpch.at/afubexakog.typescript
Am I doing something wrong?
Right yeah
But then still, if cheese is accessible, why can't I reference it with this
because it is not this
this refers to SomethingElse
When you are referencing cheese in the first method, it is inside of the Something object
yeah but this would be any object coolStart2() is called from
this refers to the class that all of the methods are in
so in that case, this would be referring to the SomethingElse object
umm
same thing
π₯²
so look here
coolStart2() is not static, and it is in the class SomethingElse
so, that means that this would refer to an instance of SomethingElse (if it was static, then this wouldn't work at all because static does not refer to any instances - static works fine with 0 instances of the class)
for example, you can do this: ```java
public void coolStart2() {
SomethingElse instance = this; // perfectly fine syntax
instance.test();
this.test(); // does the same thing
}
public void test() {
System.out.println("Hi!");
}
so, that means that you can call whatever methods you want on `this` that you can on an instance of `SomethingElse` (because it is)
does that make more sense?
yes
._.
Lol
well right yeah I get that part. this will take the form of any SomethingElse you call the method against
ignore the caller
the caller only matters when there's an error and it's shown in the stacktrace
Oh hold on. So you mean its not valid syntax in the case I sent above because this is a reference to SomethingElse and that only. It doesn't matter if you call the method using a Something, this will only behave as a SomethingElse
correct
the caller can be anything you want, as long as it has an instance of SomethingElse
I see..
this is because when writing java code, if this was the caller, then it wouldn't be able to run any methods or get/set any fields because how would it know what the caller is?
is there any programming language you are comming from?
right yeah that makes a lot of sense
I get what you mean now
Skript
π awesome
appreciate it :P
I agree, Skript is awesome
lol
me?
yup
^
cause ive had a few people come from languages not having inerhitance and everything just being one single instance of itself
Nah not really, my knowledge of coding was zero up until 2 ish weeks ago. started learning only recently
i see
idek how to code in skript lol
good
Blasphemy
lets keep it like that
Unless you call Bitcoin Script a language, albeit very low-level
do you need any diagrams to understand it better or
people go for like hourly pay in there (and they get hired)
but even in that Im adequate at best
Do you mean high level?
its a low level language
lol
low level in programmer terms basically means that it is very close to the actual hardware
such as C
or assembly
or even better, assembly
Or Skript
It is very close to C
I literally saw someone say f you
Or Java, the language they're using lol
Iβm so confused lol
what dont you understand
No it's not
Java is probably high level
Too many restrictions to access hardware
lol
python is low level π
The order is Skript -> low level -> high level -> python
what makes you say that

because its cool
he just had a medium rare steak
did you just quit your commitment to kotlin?
You know what, you convinced me, I think Java is a medium level programming language
i never said kotlin was uncool
Yeah you said it was awful
I heard you hate Kotlin
It's a bird
why dont we just take all the packets and redirect them to a python server. spigot.py
Sky you have to swear at someone again
die /s
Lmaooooo
people really adding flags to regular speech
/s = /seriously /s
what you know
Which country?
π²
πΆπ¦
a gas reserve?
what makes you say that
java is cool

scratch
declarative languages are definitely higher level than imperative ones i'd say
so yeah haskell, sql, prolog, etc are all pretty high level
higher than java and co that is
scratch is definitely imperative though
no assembly is highest'
i will direct minecraft packets to my cpp middleman, which will then optimize packet syntax by adding random hash-99999 number (a long one) to have checksum 100-200 times
then finally direct the minecraft packets back to the assembly server
when does it suit java naming conventions to make a variable all caps with underscores
example is the static Integer.MAX_VALUE
as opposed to the unconventional everyLetterCapitalized
this is usually for constant
this is usually variable name and stuffs
EveryStartingLetterCapitalized is usually for declaring classes and interfaces
right yeah
I see
public static final variables aka constants as WanderingPalace mentioned
it's when the value is always the same (for example, Integer.MAX_VALUE will never ever change)
expected
SCREAM_CASE or something like that is usually used on constants
static final
so not instance based
are constants always public
no
no they're not
they can be private too
never heard someone call it scream case lol

just code more lol thats how i got around all these conventions
it had a name something like that but i only remembered SCREAM CASE
idk why
theres no need to memorize them
im happy to review your code anytime :D
can you review this for me, once im done?
appreciate it :)
that too xD
appreciate it :D
although i really only know to review java, kotlin and maybe some other stuff 
I'm trying to use a gradle task to run my server after the jar finishes building, and this is what I have so far:
https://paste.helpch.at/afubexakog.typescript
Right now the problem that I have is that the runServer task isn't even being called. Am I doing something wrong?
Startup Log Location
Your latest startup log can be found in the logs folder of your
server directory, labeled as latest.log.
Please copy the contents and paste them to a paste service.
Type ?paste for more information.
Failed to read artifact descriptor for com.gmail.nossr50.mcMMO:mcMMO:jar:2.1.202
the code works in one plugin just not in another
how to get the translatable component key for each material?
so I need a player in the constructor in order to do some of the things in the gui but when I try and register the event than it needs the player parameter passed in and I'm confused what I'm supposed to put there since its the system and not player specific
public EnchanterGUI(GalaxyMC plugin, Player player) {
getServer().getPluginManager().registerEvents(new EnchanterGUI(this, ), this);
does anyone know how you would fix this
Show the code for the event.
I don't see anywhere in that where you're actually using an event.
You implemented listener, but you're not actually listening for any events.
Because later imma add a inventory click event I donβt have that in yet
But I need the player in the initializeItems how do I get that in that method
You can't from the onEnable. You would need to use the listener for it. as that will give you a way to get the player.
So like a listener for when the inventory gets opened maybe and get the player through that
InventoryOpenEvent
Ok thanks
so I added this
@EventHandler
public void invOpen(InventoryOpenEvent event) {
if (event.getInventory().equals(Page1)) {
player = (Player) event.getPlayer();
}
}
but im still having the issue from before it is disabling the plugin because player is null
here is the class again:
https://pastes.dev/sZAHRNjRRq
Call your initialize items method in the event, and pass player to it that way
@EventHandler
public void invOpen(InventoryOpenEvent event) {
if (event.getInventory().equals(Page1)) {
Player player = event.getPlayer();
initializeItems(player)
}
}
Then change public void initializeItems() { to public void initializeItems(Player player) {
Does anyone know what the events are when:
- someone destroys a block, that has something attachable like a torch, button etc
- someone destroys a block that has another block on top of them like rails, carpets
im trying to prevent these attachable blocks from dropping, whenever someone breaks the root block in creative mode, and idk how to start
pls dont direct me to the wiki i have looked there and dont know where and how to start
You have to check for the attached blocks and if there is an attached block cancel the blockbreakevent and set the block to air without updating its surrounding blocks.
hey guys trying to tell the player the translated name of some material
heres the code
library method
public String getItemTypeTranslationKey(Material material) {
if (material == null) return null;
net.minecraft.world.item.Item nmsItem = CraftMagicNumbers.getItem(material);
if (nmsItem == null) return null;
return nmsItem.a();
}
usage
TextComponent text = new TextComponent("");
TranslatableComponent materialTranslation = new TranslatableComponent(Main.getInstance().handler.getItemTypeTranslationKey(block));
DebugHandler.log(5, Main.getInstance().handler.getItemTypeTranslationKey(block));
materialTranslation.setColor(ChatColor.BLACK);
text.addExtra(materialTranslation);
getting the minecraft key works
but it doesnt work when i print it in book
please help
Why should the blockbreakevent be cancelled? whats the purpose of that
because if you dont, the server will be actually breaking the block that carries torches
and that will make torches fall
setting a block to air is a hard way to make block vanish, not to break block normally
Then it will cause the block to update as well as the surrounding blocks.
so, to get an attached block I need to get #getFace() ?
or getRelative
im confused
@unborn ivy you could try this... (Might need to adjust the code)
private BlockFace[] faces = new BlockFace[] {BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
private List<Material> attachables = Arrays.asList(Material.TORCH, Material.ITEM_FRAME, Material.RAIL);
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
Material blockType = block.getType();
if(attachables.contains(blockType)) {
event.setCancelled(true);
player.sendMessage("Can not break attachable blocks.");
return;
}
for(BlockFace face : faces) {
Block relative = block.getRelative(face);
Material relativeType = relative.getType();
if(attachables.contains(relativeType)) {
event.setCancelled(true);
block.setType(Material.AIR, false);
return;
}
}
}
```This might be wrong if I misread your question lol
1 sec ill try my own code
Where did your error go?
Need the full trace please.
no error
it just doesnt show anything when i print it
block.minecraft.oak_log
i tried printing the translation key, and found it in the texture pack language txt
the translation key is correct
i dont get it
when i tellraw translate it works
Can you screen shot those scenarios please.
tellraw, outputting etc...
@edgy lintel you're writing block but the method takes Material is this invalid?
im actually dealing with legacy code right here
the type of block variable is Material lol
Ok just making sure
its really hard to screenshot the actual senario
the translatablecomponent is supposed to go there
apologies for japanese
lmao
I think you reversed the logic here because I just want the torches to disappear whenever someone breaks the root block
Try debugging text I could be reading it wrong but it looks right to me.
Ah then you could just check dropped items. ItemSpawnEvent
Is it possible to just set the relative block to air?
just relative.setType(Material.AIR, false); instead of block,settype?
Yea thats what I was gonna do
text is basically the md5 textcomponent
the original author has bad naming methods lol
damn you are right
somethings wrong with adding translatablecomponent as extra in textcomponent
it just vanished
for some reasons
If you break a block and it has attached blocks those blocks will receive an update.
To use your example, a torch. If the block the torch is attached to it will drop the torch. If you want the torch not to be broken use my above method. If you want the torch to still be broken just remove its item on spawn event or you can still use the above method and just modify it to set the torch to air as well.
I figured as much. I really have never used that so you might have to look into the source of it or just keep debugging as you go along to figure it out. Or wait for another user to answer.
wow thx so much!
i just couldnt figure out exactly whats the problem until this
probably addextra isnt meant for translatablecomponent or sth
i guess i just have to find another way round by checking other method alternatives
Np.
@unborn ivy does this make sense?
yes I figured I just wasnt sure enough
TranslatableComponent giveMessage = new TranslatableComponent("commands.give.success");
TranslatableComponent item = new TranslatableComponent("item.swordDiamond.name");
item.setColor(net.md_5.bungee.api.ChatColor.GOLD);
giveMessage.addWith(item);
giveMessage.addWith("32");
TextComponent username = new TextComponent("Thinkofdeath");
username.setColor(net.md_5.bungee.api.ChatColor.AQUA);
giveMessage.addWith(username);
player.sendMessage(giveMessage);
guess i completely messed it up lol
it isnt how it seems to work at all lmao
π
Also that method won't work for more then 1 attached. For example; Cactus, Sugarcane etc...
Ah lol Guess I could have searched myself.
I forgot about having more than 1 attached
im stupid lol
and i dont know what parameters to pass in addwith
really dont wanna look into the source code π '
but why is that an issue tho, you already have all 4 blockfaces in faces
Because it will only check the 6 surrounding blocks not the blocks attached to the attached block.
Your best bet is recursion for multi attached blocks. (Be careful though as this could cause memory leaks if not done right)
Sugarcane and cactus are easy. But things like chorus flower etc... can get annoying.
well actually if it did check all 6 faces, then none of the torches would have dropped
Can I see your code? Also make sure the listener is registered
with this code rn, it only checks for 1 face
and im assuming that the first face it checks for is whatever is in faces first
@EventHandler
public void AttachedBlocks(BlockBreakEvent e) {
Player p = e.getPlayer();
GameMode gm = p.getGameMode();
Block b = e.getBlock();
for (BlockFace f : faces) {
Block relative = b.getRelative(f);
Material relativeType = relative.getType();
if (attachables.contains(relativeType)) {
if (gm == GameMode.CREATIVE) {
e.setCancelled(true);
relative.setType(Material.AIR);
b.setType(Material.AIR);
return;
}
}
}
}
}
So my code would break the block but keep the attached. Because it removes the block without updating physics.
Your code will return on the first attached and set the block to air and will update the physics, so all other attached blocks will break naturally.
right... so that means ill need to get the other relative types
and set them to air, before setting the block to air
yes