#help-development
1 messages · Page 1639 of 1
Yes, show fine
Then I see no reason for you to be having an issue. You could invalidate caches and restart
what error?
Example for Consumer<T> being used to delegate a functionality to a new thread:
@Override
public void onEnable() {
applyToConfigAsync(new File("test.yml"), config -> {
config.set("TestKey", "TestValue");
});
}
public void applyToConfigAsync(final File configFile, final Consumer<YamlConfiguration> configConsumer) {
CompletableFuture.runAsync(() -> {
final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile);
configConsumer.accept(configuration);
try {
configuration.save(configFile);
} catch (final IOException e) {
e.printStackTrace();
}
});
}
I'm using those exact same dependencies here with zero issues
@lost matrix, help please
Wrap it in a CraftFallingBlock and get the Bukkit material from it.
Look at the gist ive sent you above.
Its a helper class to manage a players experience
Okay, I'll take a look, thank you very much
So, I'm trying to make it so that when a player clicks on a block in a GUI, they get $10. I'm using Vault for the economy API stuff. I tried the following bit of code: https://paste.md-5.net/conewulufu.cs
It gets a red line under it. How can I fix that?
Hmm, I'm so tired
what has a red line under it
Hover over it and tell us what your IDE tells you
The method bankDeposit(String, double) in the type Economy is not applicable for the arguments (Player, int)
Wrong arguments then. Look up the method and check what argument types it takes.
I use Eclipse so its different for me. You seem to have stumbled upon some wierd documentation issue with Intelij
what abaut the Future API? and whats the difference about CompletableFutures? i only used CompletableFuture
Okay
I'll try
CompletableFutures are completable. This was added in java 8 and just means you can join the Future on the current thread in a blocking fashion to obtain the result directly.
No clue with Intelij, its alien
so CompletableFutures are from the Future API?
Bruh
The last thing I've found googling change <type>javadoc</type> to <classifier>javadoc</classifier>
No clue if it will work as type is teh default to use for specifying javadocs
Ok, I'll do it
intellij light theme 
Not mine. Just a pic I googled 🙂
ok good, wait… does that mean you use eclipse?
Yes. Stream API and Future API.
Here is an (ugly) example of how to chain functions to run async and sync after another.
final File configFile = new File("test.yml");
// Load config async
CompletableFuture.supplyAsync(() -> YamlConfiguration.loadConfiguration(configFile))
// Do some stuff afterwards (still async)
.thenApply((yml) -> {
yml.set("Test.Key.One", "ValueOne");
yml.set("Test.Key.Two", "ValueTwo");
return yml;
// Do more stuff afterwards (still async)
}).thenApply(yml -> {
// Do some stuff that can only be done on the main thread
final Future<YamlConfiguration> syncFuture = Bukkit.getScheduler().callSyncMethod(this, () -> {
this.getSomeData().load(yml);
return yml;
});
// Block this thread until the main thread is done with the method
try {
syncFuture.get();
} catch (final InterruptedException | ExecutionException e) {
e.printStackTrace();
}
return yml;
// Do the rest async again
}).thenAccept(yml -> {
try {
yml.save(configFile);
} catch (final IOException e) {
e.printStackTrace();
}
});
Of course, nothing but the best for me.
I saw that
hahahaha
hey, Im making a plugin and wanted to ask if it affects performance much to run a RepeatingTask for the duration of the instance which checks something every 5 or 6 seconds.
Yes no clue then, it still doesn't work, I'm sleeping now
depends what you are checking
wether or not the player is standing on a block to remove a NoFallDamage ScoreboardTag
Checking every player on the server every 6s is really cheap if you evenly distribute your workload.
I have 2 of those tasks running currently and Im planning on offsetting the delay at the start by about 40 ticks
You can check section 3 of this post
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
run it Async as data reads are mostly ok from loaded chunks.
as you are getting the block below a player you know the chunk will be loaded
alright, thanks for your help 🙂 was worried that there would be lots of problems on bigger servers
Ah yeah that works. The behavior is undefined but i didnt have a problem reading Blocks from a loaded chunk async so far.
not sure what you mean by async, would you kindly explain?
most tasks run sync with the main server thread.
You might get a problem if you bulk check every player with a fixed delay of N ticks
so anythign you do in yoru task makes the server wait for yoru task to finish
running tasks async they run in parallel with the main thread, so will not make it wait
oh so basically offset the tasks so they will never overlap?
no
ok I will look into it then. thanks for the idea 😄
if i extend from the Location class, how can i directly modify its x, y and z values? they are private. if i create my own xyz properties, they will be used instead when casting back to Location?
don't extend location
create your own class that can return a location when you need
yes
bc im just adding some stuff that i need related to locations
if they are not already in Location then odds are they don;t belong there
ofc, theyre just specific to this plugin
just wrap your location and your custom stuff into a new class
Probably better to create a Utility class
hi guys who can help me ? i got this error when i try to commit and push a project. (eclipse ide )
Does teh user you using to push have rights on that repo?
it's not a private repository, its public
Its not public for anyone to push to
It's also a completely empty repo, so there's not anything to push to
https://www.youtube.com/watch?v=LPT7v69guVY i watched this video and I followed all the steps but not work
Free Courses - https://automationstepbystep.com/
Today we will learn:
- How to create github repository
- How to clone repository in eclipse
- How to add eclipse project to github repository
- How to commit, push and pull the changes
Step 1 : Create GitHub account and SignIn
Step 2 : Start a Project = Create a repository
Step 3 : Start Ec...
i also cant launch the fallingblock
i used #setVelocity
Github now uses auth tokens
Do you still use the packet approach ive sent you?
Yes
Then just setting the velocity wont work for obvious reasons
i created another falling block
with the same blockdata
its a normal falling block
FallingBlock
@lost matrix
...
worst code made ever
public PrefixGui(Player p) {
super("Prefix", 6);
if (LP.getPlayerGroups(p) != null) {
for (int i = 0; i < LP.getPlayerGroups(p).size(); i++) {
List<String> prefix = LP.getPlayerGroups(p);
if (!(prefix == null || prefix.isEmpty())) {
int finalI = i;
setItem(0, createItem(Material.OAK_SIGN, Utils.colorize(LP.loadPrefixes(p).get(prefix.get(i))) , null), player
-> Main.api.getUserManager().getUser(p.getUniqueId()).setPrimaryGroup(LP.getPlayerGroups(p).get(finalI)));
}
}
}
}
!(prefix == null || prefix.isEmpty()) 😬
de Morgan's law. Learn it folks
prefix != null && !prefix.isEmpty()
how do i stop players from taking items from an armorstand
PlayerArmorStandManipulateEvent
hello?
Hi, after some tests about plugins in minecraft I had a doubt: how should be done in case of multiple gui to pass any parameters (without interfering with simultaneous use by other players)?
while (resultSet.next()) {
int karma = resultSet.getInt("karma") - 1;
int id = resultSet.getInt("id");
statement.executeUpdate("UPDATE xpunishments_playerdata SET karma = \"" + karma + "\" WHERE id = \"" + id + "\";");
}
How do I prevent this from giving Operation not allowed after ResultSet closed?
Quite the google translate there. You instance the GUI per player (if it changes).
if i want to give the player names as tabcomplete is returning a new arraylist good or do i need null?
Sorry for google..
Can you explain it better?
you create a new instance of your GUI when a player access it, so each player is accessing their own copy of the UI.
If your GUI is static then you can use one for all players.
i cant launch a falling block
i used #setVelocity
The problem is that when a player use the command, it opens the first gui. After, with the Event class I intercept the item clicked and from there I open a new gui (that if clicked do the operations)
as I said, if your GUI is static you only need one GUI for all players.
all click events have the Player thats clicking
Yes, but on the main command I calculate some informations that i save in variables. I should use them after the click on the second gui, so from the event class..
while (resultSet.next()) {
int karma = resultSet.getInt("karma") - 1;
int id = resultSet.getInt("id");
statement.executeUpdate("UPDATE xpunishments_playerdata SET karma = \"" + karma + "\" WHERE id = \"" + id + "\";");
}
How do I prevent this from giving Operation not allowed after ResultSet closed?
Like, why is it slosing the ResultSet?
As soon as you execute yoru second query yoru resultset is closed
when a player right clicks an armor stand, playerinteractionevent isn't called, is this suppose to happen
How do I do what that loop does instead?
use a separate statement
how to turn off the physics of blocks such as gravel and sand?
spoiler BlockPhysicsEvent don't work
How can I launch a falling Block at the direction the player is looking?
can you send the code you used in the blockphysicsevent
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void physicsDisable(BlockPhysicsEvent e) {
System.out.println("WORK");
e.setCancelled(true);
}
}```
if you are trying to prevent them faling you need to stop them becoming entities
this is perfect idea but how?
cant you give them some sort of nbttag for that? (not that i know how, I just read about it somewhere)
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
private void onSandFall(EntityChangeBlockEvent event){
if(event.getEntityType() == EntityType.FALLING_BLOCK && event.getTo() == Material.AIR) {
event.setCancelled(true);
event.getBlock().getState().update(false, false);
}
}
like this
yea I try use this but this send unless packet to player about create new falling block set ...
what
.
hello, anyone know how i can see performances of my plugin ? With spark ? (timings, lag impact...)
How can I launch a falling Block at the direction the player is looking?
/timings on
wait
/timings paste
i can't see timings of my plugin
realy give me link
Aikar's Timings Viewer - View Timings v2 reports from Paper and Sponge
name your plugin?
WSS
sorry but I don't know how good read paper timings
Player#getYaw()
Player#getPitch()
uh
FallingBlock#setVelocity()
anyone else ?
what should i do ? i watched almost 10 video and they are same like this video https://www.youtube.com/watch?v=LPT7v69guVY&t=1s
Free Courses - https://automationstepbystep.com/
Today we will learn:
- How to create github repository
- How to clone repository in eclipse
- How to add eclipse project to github repository
- How to commit, push and pull the changes
Step 1 : Create GitHub account and SignIn
Step 2 : Start a Project = Create a repository
Step 3 : Start Ec...
how do i get the name of an EntityType?
maybe you have any idea?
No idea if this is any good - https://www.youtube.com/watch?v=rx8KuOt2IEM
getName is deprecated
Pretty sure toString works
So I got a problem players can take items from my gui shop by spamming shift+left click for example
and then exiting from it with E
should add delay to solw that or is there some other way
?
detect the spam and close it
So i've got some question about protocollib, I've got this so far which should be triggered when an entity moves. Can anyone explain to me why event#getPlayer#getName always returns my own player? I Am alone in the server so I don't know if that plays a role. It's still strange to me why even if I do not move it still broadcasts my name multiple times a second.
ProtocolManager protocolManager = mainPlugin.getProtocol();
protocolManager.addPacketListener(new PacketAdapter(mainPlugin,
ListenerPriority.NORMAL,
PacketType.Play.Server.REL_ENTITY_MOVE) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Server.REL_ENTITY_MOVE) {
PacketContainer packet = event.getPacket();
Bukkit.broadcastMessage(event.getPlayer().getName());
}
}
});
I should be able to get the deltaX, Y and Z of the entity position, how would I do that?
I think it is only case that happen in creative
from some reason weird
just tested
Possible but that would still be weird, it'd be more logical to give the entity sending the packets instead of recieving them right?
At least that'd be my logic lol
Correct
Wait I can test this by just leaving and looking at the console
Ye fair
Yup can confirm
The broadcasts stop when leaving
You got this yet?
How can i reference element from one public void into another?
Still need help?
Please help
Nope, ty
This is just basic java
^^ You put the variable outside
?learnjava You really should learn Java basics before starting with Spigot
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Then pass it along
public final class Credit extends JavaPlugin {
private Map<Player, Player> fireballHits;
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
Projectile snowball = event.getEntity();
ProjectileSource shooter2 = snowball.getShooter();
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
if(event.getEntityType() != EntityType.FIREBALL) return;
if(!(event.getEntity().getShooter() instanceof Player)) return;
if(!(event.getHitEntity() instanceof Player)) return;
// remember this action
fireballHits.put((Player)event.getHitEntity(), (Player)event.getEntity().setShooter(shooter2));
}
@EventHandler
public void onPlayerDeath(EntityDamageEvent event) {
if(event.getEntityType() != EntityType.PLAYER) return;
if(event.getCause() != EntityDamageEvent.DamageCause.VOID) return;
if(!event.getEntity().isDead()) return;
final Player player = (Player)event.getEntity();
if(fireballHits.containsKey(player)) {
Player shooter = fireballHits.get(player);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
fireballHits.remove(event.getEntity());
}
}
i need shooter2 referenced from onProjectileLaunch to onProjectileHit
?paste Please ;/
I will explain why is this the code. I code datapacks, and i made auto launch fireballs using snowballs. When snowball is launched it summon fireball with motion of where player is looking, and it countinue moving, while snowball get killed. Thats why i need to set snowball shooter as fireball shooter
Hello !
Does anyone know why this is deprecated ?
I'm wondering why this method is deprecated but the same method with a Runnable instead of a BukkitRennable is not deprecated 🤷♂️
Thats why i cant get shooter of Fireball, because nobody is actually a shooter, only for snowball
At no point are you creating a fireball
you also do nothing with teh snowball and assume it is a snowball
I just want to reference it. Is there way to do it or no?
From what you have posted you have no working code
fireballHits.put((Player)event.getHitEntity(), (Player)event.getEntity().setShooter(shooter2));
i need shooter2 to work here
You can set the shooter on the snowball, but also no need to spawn a fireball, just set the item for the snowball
Set item for snowball?
setItem
seems only legacy fireballs still exist
ok, where are you spawning your fireball?
Code is for giving credit to player who killed another player with fireball
I spawn fireball next to snowball when its launched
I'd assume you would spawn it in the projectile launch event for the snowball
I coded that in datapack(fireball launcher)
then take the shooter from the snowball and put it on the fireball
I want that but they are in diffirent voids
you mean methods?
why can you not get the snowball when you spawn the fireball?
Can i somehow use shooter2 in onProjectileLaunch
That depends on HOW you are spawning the fireball
When i launch snowball shooter2 get player who launched it, but when fireball hit player i want to assign shooter2 to fireballhits
look at code
You have still not shown or told HOW you launch the fireball
yeah, datapacks
just tell me how can i reference it please
As far as I know there is no interface between spigot and datapacks
no i mean how to reference it
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event){
Projectile snowball = event.getEntity();
ProjectileSource shooter2 = snowball.getShooter();
}
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
if(event.getEntityType() != EntityType.FIREBALL) return;
if(!(event.getEntity().getShooter() instanceof Player)) return;
if(!(event.getHitEntity() instanceof Player)) return;
// remember this action
fireballHits.put((Player)event.getHitEntity(), (Player)event.getEntity().setShooter(shooter2));
}
from onProjectileLaunch to onProjectileHIt
IF your fireball triggers a projectile launch event then you can do it.
You are creating your fireball through a datapack, so the only way to interact with it is if it triggers a spigot event
It triggers it when it hit a player
I'd assume it would trigger a projectile launch event
SPAWN not hit
it has to be created as an entity
So test what event fires when teh fireball spawns
I'd assume a projectile launch, but it could just be an entity spawn
Just tell me how to reference it form one method into another
You haven't given enough information to give you an answer
I told you where to look
check those two events to see where your fireball is created
By the time your fireball hits the snowball will no longer exist.
You have to get your fireball when it spawns and transfer the data
I have shooter of snowball i just need to asign it to fireball when it hits a player
Can't be done like that
You can see my code
I just need to reference it no need for other questions, like someone said thats involved into java not spigot necessery
It can't be done like that, and if you will not listen I can't help you.
What do you want from me
You have to transfer the shooter data from the snowball to the fireball when it spawns. That is the only time they will be in the exact same place for you to know what snowball triggered which fireball.
You have no other way to connect them, and by the time the fireball hits there will be no snowball to read the data from
You need to see which event triggers when your fireball spawns
I just use summon fireball
You need to see which SPIGOT event triggers when the fireball spawns
either ProjectileLaunchEvent or EntitySpawnEvent
one of those will trigger when your fireball spawns
sysout the projectile to see what triggers
you should see a snowball first, then a fireball
let me know if you do
what would be a good exception if somebody uses something they are not supposed to use?
thinking of Unsupported
but idrk
i see first snowball then fireball so its probably entityspawn event
idk how i dont code plugins
ok, well the thing you want can be done, but not without java knowledge. Its not a really difficult thing but its a little complex.
oh god, not code blocks 🤮
ElgarL can you maybe finish code for me?
Does Someone know how to use the CorpseReborn api? https://www.spigotmc.org/resources/corpsereborn.29875/ ? There is literally nothing about it
There is for how to use the api itself but not how to actually get it
How do you essentially reload the config ?
just calling plugin#getConfig() again on my FileConfiguration?
probably FileConfiguration#load(InputStream) if I am right
yours doesnt exist but i found this instead
thats the default config.yml
yeah sorry I didnt specify, I meant the default config
you might want to know saveConfig vs reload
I dont change anything so I am fine with reload
the config file is left unchanged by the plugin
but if a human changed something in it and decides to reload the plugin i need it
Is there a way to get all mobs which has a target to a play without tracking it myself or go through mobs in a radius of the player ?
?jd
((Mob) entity).getTarget()
he means if theres a way without looping through all mobs
no that would be a horrible code flaw and cause memory issues
Yea i already found that, but for that method i have to get all mobs in a radius of the player and then check the target which could be inperformant i guess.
So i asked if there is maybe a other way for that.
like Player.getTargettedBy() which should return a list of mob uuid's but that doesnt exist
😂
Yea a method like that 😄
Oh okay if there is no other way, i have to use getNearbyEntities and have to read/learn how the Predicate works, thanks.
Oh okay, looks quite easy
mob -> (mob instanceof Mob) && ((Mob) mob).getTarget().equals(player)
that could explode if there is no target
player.getWorld().getNearbyEntities(player.getLocation(), 5, 5, 5, mob -> (mob instanceof Mob) && ((Mob) mob).getTarget().equals(player));```
mine could too. test for null 😛
lambda 😄
true
bad
lamba good


how would i turn
UUID,WINS,LOSSES,WINSTREAK
into
?,?,?,?
most efficiently
SQL?
I mean
StringBuilder questionMarks = new StringBuilder();
List<String> columns = Arrays.stream(SqlSetup.columns.split(",")).toList();
for (String s : columns) {
questionMarks.append('?');
if (!columns.get(columns.size() - 1).equals(s)) {
questionMarks.append(",");
}
}```
that's how im doing it rn
but i think its really inefficient and/or there is a better way
Config:
date-format: "yyyy MM dd HH:mm:ss z"
Code:
public static SimpleDateFormat dateformatter;
dateformatter = new SimpleDateFormat(config.getString("date-format"));
dateformatter.setTimeZone(timeZone);
String date = dateformatter.format(unix * 1000L);
With this code, the format of the displayed date should change, but it doesn't, displaying yyyy-MM-dd HH:mm:ss z
What do I need to change?
idek if it works
if you wanna use regex ([A-Z]+), "?"
aight ty
for(int i = 1; i < questionMarks.split(",").length; ++i) {
insert.setInt(i + 1, 0);
}```
now
if i had 4 question marks
would it set the 2nd, 3rd and 4th to 0
or is that not how that will work
.
oh
wait will it set the 3rd, 4th and 5th?
yeah but why
i want the 2nd 3rd 4th
because sometimes there is more than 4
if there is 5
i want the 2nd, 3rd, 4th and 5th to be 0
etc.
., but anyways
how do i fix the loop
How do you properly make a command that has multiple arguments(ex. /game start, /game end)? I tried using a case switch and it's telling me the command is incomplete when I use an argument.
Using Minecraft 1.16.5
case 1:
if (args[0].equalsIgnoreCase("start")) {
plugin.tag.tagged(plugin.tag.pickFirstIt());
return true;
}
if (args[0].equalsIgnoreCase("end")) {
plugin.tag.end();
return true;
}
default:
player.sendMessage(ChatColor.ITALIC + "" + ChatColor.RED + "Incorrect!" + ChatColor.WHITE + " Try /tag <start/end>");
}
return true;```
take a break
come back
then remember how java works
you shouldnt have a switch for one statement
I changed it to
plugin.tag.tagged(plugin.tag.pickFirstIt());
}
else if (args[0].equalsIgnoreCase("end")) {
plugin.tag.end();
} else {
player.sendMessage(ChatColor.ITALIC + "" + ChatColor.RED + "Incorrect!" + ChatColor.WHITE + " Try /tag <start/end>");
}
}
sender.sendMessage(ChatColor.WHITE + "You can" + ChatColor.ITALIC + "" + ChatColor.RED + " NOT" + ChatColor.WHITE + " use that command!");```
And it's still telling me Unknown or Incomplete command
list:
example:
description: "This is an example"
'0': "example sub 0"
'1': "example sub 1"
'2': "example sub 2"
example2:
description: "This is an example 2"
'0': "example2 sub 0"
'1': "example2 sub 1"
'2': "example2 sub 2"
How would I get a list of all options under "list"?
I think so, here's what I have:
this.getCommand("tag").setExecutor(new TagCommand(this));
thanks
But also, when I type /plugins in game it says 0, so that's a bit concerning. I have the plugin file in the plugin folder and when I type /tag it has an option to autocorrect to the command
Anyways, is there anything I might be able to try to fix this?
Config:
date-format: "yyyy MM dd HH:mm:ss z"
Code:
public static SimpleDateFormat dateformatter;
dateformatter = new SimpleDateFormat(config.getString("date-format"));
dateformatter.setTimeZone(timeZone);
String date = dateformatter.format(unix * 1000L);
With this code, the format of the displayed date should change, but it doesn't, displaying yyyy-MM-dd HH:mm:ss z
What do I need to change?
Hi. Can I ask for help here?
On july my account was hijacked and a malicious plugin was uploaded and my account banned.
Recently an admin unbanned me and restored my resource deleting the malicious plugin but then the resource was deleted again (probably a different admin did it).
The reason for deletion was "can't be decompiled at all" but the link to download the resource points to my GitHub page where the releases are and the code for the resource is hosted.
To be clear: The resource isn't obfuscated and I'm not currently banned.
It is okay to ask for help here or should I go to IRC or forums?
?support is probably best
Thank you, I'll send an e-mail too then.
how would I generate player data
for player which didn't play before from uuid
and get his name
?
how would i run
setState(MinigameState.PRE_GAME);
when Bukkit.getWorld("world_active");
becomes not null
uhm
this is weird
Could not call method 'public static org.bukkit.Location org.bukkit.Location.deserialize(java.util.Map)' of class org.bukkit.Location for deserialization
java.lang.IllegalArgumentException: unknown world
i know that means the world is null or something
but
the method is called 1 tick after the world is loaded
worldinitevent btw
1 tick after worldinitevent
the configurationserializable might not be registered
guys any clue what to code
code an economy plugin
already did that
like thats the prob i allready did all of that stuff so i dont have any clue what to do i coded for a city build server so also with bungee
add different database types support
same issue
make it platform compatible with maybe sponge and what not
and velocity and fabric and so on
lach try scheduling a task after the WorldLoadEvent then
well just to proof my cooding skills im gona programm a new one
yea i have
1 tick
give me a name
ConcluresBankCommission
1.7-1.17.1
i did 10 ticks still nothing
well
something
but
not what i want
it gave an error
Alright let's see,
- Bank system
- Platform extendable
- Platform independent API
- Network support (across BungeeCord or Velocity etc), by this I mean live synchronization between servers
- Database support for MongoDB, MySQL (Would be nice with Postgre and Maria), SQLite, H2, FlatFile (JSON, YAML and TOML)
- Split storage for the different banks maybe?
- Language configurable
- Clean code architecture
Well, that and possibly anything else.
@ivory sleet ok wtf is this
it says unkown world
the world isnt even null
have i been scammed
yeah
and it says unknown world
how do u get it
no
- ==: org.bukkit.Location
world: world_active
x: 14.5
y: 73.0
z: -28.5
pitch: 0
yaw: 90```
this
that is s
more code
if (plugin.getSpawnsConfig().getList("spawns") != null)
plugin.getSpawnsConfig().getList("spawns").forEach(s -> spawns.put((Location) s, null));```
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
that's what im doing
"unknown world"
the world aint null either
Are you getting locations before the world is loaded?
the world in question isnt null
but idk
maybe?
im unsure
predicate
Debug it...
config.getObject("some.location", Location.class); You're missing Location.class
no
im getting a list
of them
spawns:
- ==: org.bukkit.Location
world: world_active
x: 0.5
y: 73.0
z: 44.5
pitch: 0
yaw: -180
- ==: org.bukkit.Location
world: world_active
x: 15.5
y: 73.0
z: 29.5
pitch: 0
yaw: -270
- ==: org.bukkit.Location
world: world_active
x: -14.5
y: 73.0
z: 29.5
pitch: 0
yaw: -90```
like that
it saved like that
it works like that
thats not a list
That is a list
it worked fine this way beforehand tho
yeah I mean is the world present with such a name?

the world does exist yes
is it a spigot world or a world from some other plugin?
well
i create the world
WorldCreator wc = new WorldCreator("world_active");
wc.generator(new VoidChunkGenerator());
active = wc.createWorld();```
thats the code i use
have you manually loaded the world at startup?
so if you sysout Bukkit.getWorld("world_active") in yoru loading code it outputs fine?
lets try
player#getExp
no
declaration: package: org.bukkit.entity, interface: Player
declaration: package: org.bukkit.entity, interface: Player
help please
how do I get experience from players?
settext () does not work, because this is a school and the maximum number is 0-1
?
no
yes.
help please
how do I get experience from players?
settext () does not work, because this is a school and the maximum number is 0-1
set Total Experience ()
does not affect the experience, it is just a score that is shown after death
Whut
?google and please speak English
Google your question before asking it:
https://www.google.com/
setTotalExperience() sets the xp earned by everything ever.
I won’t say more
Because you need to google
or just check what i sent.
you want to get the experience?
there you got it.
but "no".
setTotalExp doesn't work
he dont want to listen
I bet you can find the answer with 1 google search
or check what cipher sent
why can’t people just read docs and use google
int value = p.getTotalExperience();
Bukkit.broadcastMessage(String.valueOf(value));
okay I won’t help you because you are not listening
I told you 2 times, cipher sent 2 links, and I have yuh advice.
this shows how much experience, but if you change this number, everything breaks down and when you get a new level, it is not added
how are you changing it?
p.setTotalExperience(Math.max(0, p.getTotalExperience() - 13));
I told you 2 times
that sets the max the player can each.
I know how, but I won’t say how because you need to google and read the docs.
I couldn't find anything
Lemme try
please tell me how to do this
the doc clearly states how to change the xp and the first google result was the answer.
declaration: package: org.bukkit.entity, interface: Player
I have everything in Russian, maybe that's why I can't find it?
read the doc that both cipher and now I sent you
This is a percentage value. 0 is "no progress" and 1 is "next level".
0.1, 0.2, 0.3, 0.3132?
0-1
it’s a float
p.giveExpLevels();
what about it?
thank you, I'll try it nowъ
this guy is either high or 5
probably going to play csgo now
this took the entire 41 levels
p.giveExpLevels(- 1395);
god help humanity
p.giveExpLevels(1395);
this gave me 14000 levels
If you round it yes
and how can you give out and take away not the level, but the experience?
Yes, experience
use the docs still
A chunk's coordinates are both Integers. Why store the whole chunk object?
what should i use? is there a tuple object or something like that in java?
There are a couple of ways to approach this.
firework doesn't detonate? ```java
Firework f = (Firework) event.getEntity().getWorld().spawn(arrowLocation, Firework.class);
FireworkMeta fmeta = f.getFireworkMeta();
fmeta.addEffect(FireworkEffect.builder()
.flicker(true)
.trail(true)
.with(FireworkEffect.Type.BURST)
.withColor(Color.RED)
.withFade(Color.ORANGE).build());
fmeta.setPower(0);
f.setFireworkMeta(fmeta);
new BukkitRunnable() {
@Override
public void run() {
f.detonate();
}
}.runTaskLater(new SlimeFun(), 5L);
I found a thread on spigot about your question 😛
I would personally go for the 3rd option.
the path name for my project on my local computer:13:21
java: cannot find symbol
symbol: method of(java.lang.String)
location: interface java.nio.file.Path
I get that error message when I try building my project on IntelliJ
Path path = Path.of("my path");
And when I remove this line of code, the error goes away. I havejava.nio.file.Path and java.nio.file.Files imported so what is causing this?
cannot find symbol
probably just doing something wrong
really?
normally a File represents your path
ohhh
File path = new File("my path");
oh yeah i had to go into proejct settings and change my java version
to use path.of
🥴
It’s better in every way
public void WriteFile() {
try {
FileWriter writer = new FileWriter("not gonna share path sry");
writer.write("Test");
writer.flush();
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
I have this script that writes "test" into a txt file and it works fine but since a new object writer is being made each time the files don't "save". Because instead of what I want to happen, which is the file filling with multiple "test", what happens is, the file only has one "test" in it. So basically I just need writer to be initilized outside of the method. The problem is I have to initilize it in a try catch statement which I can't do outside of the java main method
and someone told me to try Nio
“not gonna share path” yikes, why so paranoid.
how do i do loot tables in 1.8.9?
Sounds more like a design problem
thanks for saying sorry
i want to make a custom loot table
also greaterlplays file writer flushes automatically
And use try with resources statement instead of manually closing it
i got an error when there wasnt flush
wel actually no error it just didn't write
How do I do custom loot tables in 1.8.9? (sorry for using it lol i have no choice)
I'd like one for:
- Spawn islands
- Middle islands
there lol
fancy question
Also you can choose to append vs override in the FileWriter when constructing
stop using 1.8.9
Anyways I barely use it
no choice
you can
if youre a developer for someone they also can do it
and if its for your own use then you can also do it
alr ill do that tysm
why?
few reasons
anyway
how
is there a way
or do i have to make my own loot tables system
p.giveExp((int) - 1395);
you can only give out a level, but you can not take it away
Thats probably the best way if you insist on using 1.8
I believe they are hardcoded
oh
Idk what ur use case is but it shoulnt be too difficult to setup a lil system
Well bassicaly its a list of items and you just pick random items from the list right
A weighted random system is a good start
ayyye it worked tysm for the help
Could you give more context?
I got a few location in a configuration file and I want to place a block at each of those locations
not many
yet the line right underneath it : player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); works fine
Have you tried player.setItemInHand(new ItemStack(Material.AIR))?
ill try it
Are you using ConfigurationSerializable for the locations?
still doesn't work
Actually I remember you can't physically set items in the hand like that anymore.
if (player.isSneaking()) { player.setItemInHand(new ItemStack(Material.AIR)); player.playSound(player.getLocation(),Sound.ENTITY_ITEM_BREAK, 1, 1); return; }
sorry for poor formatting....
how do you set items in hand then?
setItemInHand is deprecated
so is getItemInHand, but it still works...
So you need to do player.getInventory().setItemInMainHand()
Nande kore wa
Lamp:
lampAmount: 2
'1':
X: 16.0
Y: 20.0
Z: -24.0
World: Studio
Pitch: 0.0
Yaw: 0.0
'2':
X: 16.0
Y: 20.0
Z: -28.0
World: Studio
Pitch: 0.0
Yaw: 0.0``` Looks like this. Not sure how to do it
in the configuration
Have you worked with ConfigurationSections before?
nope
cause the line below it works, so idk why this one wouldnt
https://www.spigotmc.org/threads/configuration-section.373459/ This thread should put you on the right track, if you continue to have trouble I can take you through it
Did you set it to null?
Does the sound play
yes!
thats what doesnt make sense lol
you'd think if something was wrong with my code the sound wouldn't play either
Try setting it to new ItemStack(Material.AIR) instead of null
nope...
doesn't work
basically i want to cancel drop event and destroy the item.
and eveything works except the destroy item part
for (String key : arenaConfiguration.getArenaConfig().getConfigurationSection(getSelected() + ".traitorTester.testerGlass").getKeys(false)) {
ConfigurationSection glass = arenaConfiguration.getArenaConfig().getConfigurationSection(getSelected() + ".traitorTester.testerGlass." + key);
Location loc = new Location(Bukkit.getWorld(glass.getString("World")), glass.getDouble("X"), glass.getDouble("Y"), glass.getDouble("Z"));
loc.getBlock().setType(Material.GLASS);
}```
Ended up trying this but did not work. Probably cuz I'm doing it wrong but not sure what I'm doing wrong
Just getting a snack from the convenience store and then I’ll help yah
Are you just trying to only allow them to drop it if they're crouching?
yes
but i dont want drop
sorry
i want remove
the idea is nobody else can have the item but them, however they can delete the item
so Q tells them they cant drop, but if they shift they can delete, thus removing it from their inventory
watch video
Hm that is interesting
If you drop a stack of items too it just sets the amount to 1 
are you testing?
Yes
well at least its not just me having this issue then
If you delay the remove by 1 tick it works
I would just do that, kinda weird how that works.
I mean it's just
Bukkit.getScheduler().runTaskLater(plugin, () -> {
//remove here
}, 1);
yeah, but is that not hard on the memory of the server
Not really, how often are people going to be destroying items?
idk, everyone on server will have items that can be destroyed
its a gamemode server with class based items that can only be destroyed not dropped
yeah, i was thinking of that. ill try it.
thank god that worked. thank you.

MySQL Question: What statement should I use to end up with a table like this (where you can have multiple of the same on the left hand side)
| userID | group |
|---|
1 | admin
1 | moderator
1 | test
why would you get multiple user ids
How accurate is the kotlin to Java converter?
the table is holding a player's groups
a player can have multiple groups, so I need to be able to store them
Adrift the you use the userID as a foreign key
no player has the same id
the issue is when I don't know what statement to use to set it without the next group overriding the last one
could you explain a bit more sorry
you could create a table with that id and set multiple groups to that id
@native nexus you back already?
Yes I sent you a message in pms
oh
You can't do that- MySQL tables dont directly support lists
How accurate is the kotlin to Java converter?
unless you're meaning create a table for each user, in which case I feel like thats not very efficient
yeah thats what i meant, but sql databases arent super efficient themselves imo
some i tried to use in the past were pretty bad, but would probably depend how complex what you're trying to convert
non relational databases are easier
Well what I would be trying to convert is massive so I dont think it would go too well
rip
but with relational databases usually each user does have tables with just themselves. https://www.ibm.com/cloud/learn/relational-databases#:~:text=A relational database organizes data,tables with a single query.&text=Report generators take these queries,demand to create formal reports.
user table and then independent user tables with transaction/cart or in your case groups
I think thats what i have
I have a playerdata table which hold's a userID, UUID
and then a 'friends' table
@ionic reef look into mongodb if you dont like relational.
might be more of what you are wanting
certainly more powerful when it comes to that kind of stuff.
CREATE TABLE groups (userID INT, group VARCHAR(255), PRIMARY KEY (userID, group))
You would definitely want them to both be foreign keys as well
But this should work
oh i have the table setup
its just putting the data in there
currently using what Im using it will just override the existing one
INSERT INTO groups VALUES (?, ?)
Okay that's a problem for many reasons
😭 ty tutorials
It means your primary key is probably only the ID column
A primary key must be unique
Insert ignore means "insert, but if it already exists, don't do anything"
You need to make both columns the primary key
It means that you can have multiple entries with the same id
But you can't have multiple entries with the same id and group
Which is what you want
so would I just do PRIMARY KEY (USER,GROUP)
And you can keep using insert ignore, you just need to fix your primary key
Yes
would it be neccesary tho? or would i be better off not having it
Make sure they're also foreign keys
how exactly do I do that
tried looking into it but didnt get a lot of info from google
Well it would avoid issues if you try to add a group to a user that already has that group
ah right
FOREIGN KEY (userID) REFERENCES users.id ON DELETE CASCADE ON UPDATE CASCADE
This basically says
"I'm referring to this column from this other table here, if the row I'm referencing is updated, change it here too, and if it's deleted, delete this row too"
And do the same for group
Yes
That's SQLite syntax though, it might be slightly different for MySQL
Look it up if it doesn't work
yeah
Good
If you're interested I also have a SQL helper that makes it easier
It just avoids you having to catch SQLExceptions everywhere and makes the code for performing SQL queries a lot less repetitive
I think I'm decently ok at the rest of SQL, just this had be stumped haha
ty for the offer tho
No it's on the java end
& as im still semi-new the repetitiveness helps me remember what to do at tleast
Mmk, fair enough
is it possible to get the player to do a eating animatoin when its in certain conditions
I think with packets it should be possible
oh no
SQL queries are too complex sometimes
PacketPlayOutAnimation can do that afaik
?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.
how do i can replace %player% to player.getName(); using placeholderAPI on my custom plugin?
bcz i want to add stats on holograms but i need to use placeholders
PlaceholderAPI is quite well documented. Take a look here:
https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Hook-into-PlaceholderAPI#first-steps
Example on how to use placeholders:
@EventHandler
public void onJoin(PlayerJoinEvent event) {
String joinText = "%player_name% &ajoined the server! They are rank &f%vault_rank%";
joinText = PlaceholderAPI.setPlaceholders(event.getPlayer(), joinText);
event.setJoinMessage(joinText);
}
Registering them is a bit harder but still straight formard.
okay sir thanks
jesus, what have i done...
Wait. What?
Did you modify the client so that pitch is no longer limited by 180°?
basically
and idk why and how
all i know is that yaw and pitch are switched
and yaw is limited to 90/-90 degrees WTF
i guess i definitely switched them ahaha
Thats what happens when you pass vertical. Its called gimbal lock
well, i had a weird thing, so i thought "hmm, maybe i accidently switched yaw and pitch", renamed both fields, and yeah, here we are
If you want to be able to flip you have to start working with matrices and quaternions.
no thats defnitely not what i wanted
i just wanted a perspective mod, and changed the wrong values
that should only happen in f5-mode
those were the ones i was supposed to change... my brain just got dead
now it works again, huh
uhmmm.... i'm not good at math, but... x is not pitch right? lol
nope
then there we got the issue lol
YRot should be yaw % 360.0F
XRot should be pitch % 360.0F
Yeah and this looks like it is for a mod?
basically
way beyond xd
.
do other people also see your head like that?
dm me a server to join and see
i'm in dev mode, so i'm currently not in onlinemode
😦
oh shit 180 degree vertical head rotation
lemme change my servers offline mode rq, and hope you dont fuck my server
You need to make sure you clamp the rotation btw
who tf dis
Oh
what the
huh
WHY
i just changed java pYaw = ModPerspective.INSTANCE.cameraPitch; pPitch = ModPerspective.INSTANCE.cameraYaw;
to
pYaw = ModPerspective.INSTANCE.cameraYaw;
pPitch = ModPerspective.INSTANCE.cameraPitch;```
why even try rigged things
wdym
CLAMP
What are you even making?
There is no such event
there is
Nope
Thats a Paper event
oh ok
so there is an event
look at the docs when you are not sure
this is a spigot server
Not in spigot
:think_smart:
read that wrong sorry
this discord here is for spigot i meant
please rename to rightClick
Yes but we also give support for paper
you can use something like https://github.com/Arnuh/ArmorEquipEvent
that name breaks so much violation
What Name
oh yes thank you
@vast ledge
copied from the other class
i cant get this to work anybody know how to send a message when somebody joins the server
rb im using
public void onPlayerJoin(PlayerJoinEvent event) {
if(event.getPlayer().hasPermission("tabnamecolor.yellow")){
Player player = event.getPlayer();
event.getPlayer().setPlayerListName(ChatColor.DARK_RED + event.getPlayer().getName());
Bukkit.broadcastMessage(event.getPlayer().getName() + "Has Connected");
}
}
This event has a method to set the join message
?paste or code blocks
declaration: package: org.bukkit.event.player, class: PlayerJoinEvent
event.setJoinMessage
okay i have kind of an issue here, I want to detect if a player MANUALLY puts on a carved pumpkin on their head and then basically cancel that event
However, I have a plugin which can put a pumpkin on their head (I use a texture pack for a scope pumpkin overlay), and that should not be cancelled
How do I detect that?=
ty
event priorities?
Why do you declare “player” but you never use it?
Listen for 2 events: InventoryClickEvent and PlayerInteractEvent to check if a pumpkin is being put on.
The Color of changing tab name doesnt work either
Or if you want to use the ArmorEquip event then you can also just use a blacklist for your event.
i thought if i decalre player it might work
ok I'll try
umm there is no ArmorEquip event?
public void onPlayerJoin(PlayerJoinEvent event) {
if(event.getPlayer().hasPermission("tabnamecolor.yellow")){
Player player = event.getPlayer();
event.getPlayer().setPlayerListName(ChatColor.DARK_RED + event.getPlayer().getName());
event.setJoinMessage(ChatColor.YELLOW + event.getPlayer().getName() + "Has Joined the Server!");
}
}
@silver shuttle also please follow naming conventions
there is for paper
If you want to use the PlayerArmorChangeEvent
private final Set<UUID> bypassedPlayers = new HashSet<>();
public void addArmorWithBypass(final Player player, final ItemStack itemStack, final EquipmentSlot equipmentSlot) {
this.bypassedPlayers.add(player.getUniqueId());
player.getEquipment().setItem(equipmentSlot, itemStack);
}
@EventHandler
public void onEquip(final PlayerArmorChangeEvent event) {
if (bypassedPlayers.remove(event.getPlayer().getUniqueId())) {
return;
}
// Cancel your stuff here
}
well I can't find it
where are you looking?
in my IDE
still trying to understand that lol
are you using paper or spigot?
paper
I don’t know how you do it in IntelliJ but you can open the page for all methods and stuff (can’t remember what that page is called) but someone here prob knows.
theres only these 2
You use the addArmorWithBypass method to put the players UUID in a Set. Then you listen to the PlayerArmorChangeEvent. If the player is in the Set then you do nothing.
If the player is not in the Set (That means he equipped something without the addArmorWithBypass method) then you can cancel the event.
This means no one can change armor unless its being done with the addArmorWithBypass method.
ok thank you
ArmorChange
Please take a look at this after too: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
https://www.spigotmc.org/threads/java-naming-conventions-why-and-how.179146/ Yes, i just read that one
sorry, I am too new to Java to know such stuff
Is there a way to send a packet to the player with a totem effect with custom model data?
If you know, tell me how to do it.
So I imported a jar plugin to my project and the IDE recognised it, but when i try to compile it says the package that I am trying to import does not exist (The com.shampaggon.crackshot.events)
I think I need to add something to pom.xml but I do not know what that would be, as I do not have that info
you can not import jars then build with maven
well it worked often times before
Argue if you like
erm
wth
Not seen by maven
It has no maven repo nor Github so you'd have to install it locally
well that's what i did
the plugin is a dependency
Which is why I added the plugin as a library
but apparently thats wrong?
If it has a github you can add it using... I forget the name
theres no source code on its github
That's the only info on how to hook into it
then you will have to install it to yoru local repo
which I do by importing the jarfile into my libraries right?
I don't even have maven installed outside of my ide
if you open a cmd prompt, can you type mvn and get a response?
no, that's what i said
Yes you said it, but many don't have a clue
Like - How do I just import the plugin into my project, the IDE is recognising the plugins methods but not compiling because then suddenly it can't find the package anymore
You MIGHT be able to add it to maven as a local reference, but its not recommended
i also used setRemoved(Entity.RemovalReason.b);
remove it as a lib first

