#help-development
1 messages · Page 1697 of 1
it cant find it
.-.
so
how can i fix
kk
seems more like a server issue
an SQL library..?
like, connector/pool management?
or like query builder level stuff
query builder
hibernate
how?
reconfigure sdk or clear cache & restart
u meant check spelling of code right?
there are no errors in code
just that when i build
it gives that error
i tried switching to jdk 16
and still same error
Invalidate caches and restart
no this is a different error
the java thing is solved
https://imgur.com/a/W5Qrql3 this error i get when i build
using jdk 17 and 16 ive gotten this error
I don’t believe a lot of stuff supports java 17 yet btw
Hey, I have seen that when I right click on an EnderDragon ,
the result of event.getRightClicked() of the event PlayerInteractEntityEvent
is ==> CraftEnderDragonPart But There is no CraftEnderDragonPart in the javadoc. How can I turn CraftEnderDragonPart into EnderDragon entity ?
mb I resolved my problem, (EnderDragonPart).getParent()
well i got the same error with 16
The little picture you sent isn’t a lot to go on
But looks like your jdk 17 is missing something
is there a alternative for a list with one object inside?
i tried Collections.singletonList() but i dunni if thats good
Collections::singletonList?
maybe
It’s good
oki
It doesn’t require an internal array
As opposed to new ArrayList<>().add() would require an array to be created and a O(n) add operation
Arrays::asList which is mutable and requires an array tho no array creation
List::of which requires an array/vararg
great
and a O(n) add operation
actually the operation would be O(1) since the array has an initial capacity of 10 by default
but Collections.singletonList much much better for this
See!!
Hmm true lol
and uh is it possible when i use PersistentDataContainer#set(namspacedkey, PersistentDataType.STRING, some string) that it is overwritten when i recall it?
or is that because i use the same namespacedkey?
prob
Wym?
i'm storing uuids in a pdc instance but they seem to dissapear for a magical reason
Using the same key will override the old value
nvm that i use a key depending on the block coordinates
can't be the same
but still
update on spigotmc?
?paste
something like this
https://paste.md-5.net/devodavoli.java
what's the point of @loud prismtract("null -> false") if you can do a null check inside the method?
bruh tagg
its like @notnull but its a contract
@Contract("null -> false")
public boolean something(Object a) {
if (a == null) return false;
return other();
}
i dont understand the point of it
ok
smh some event is stopping me from moving
probably my own listener :/
also is it possible to di something like this?
stacktrace from registering command...
@quaint mantle I'm using your ItemPDC thing and I think either the setting, or the checking isn't working because I have multiple items now and when I right click one of them all of their events go off, actually all the events go off if I right click while I'm holding anything
yeah ik, also I made a new plugin
good news is the arrow is working, bad news is ^
send event listener class
I'll send them all because they are in the items,
If you have multiple different items, marking them all with the same PDC tag won't get you far 😅
^
uhh, i'm not that dumb lol
Well if you are just using the class you sent to assign custom item tags
But whatever XD show the code
My dumb guesses won't get us anywhere
👍🏿
in the parenthesis?
Yes
k
if (!pdcManager.isCustomItem(event.getItem())
Thanks, that was probably my shortest question yet 👍
I'm new to plugin coding. Following this guide (https://www.spigotmc.org/wiki/creating-a-gui-inventory/) I found how to make a gui, but I can't open it in game. How do I do this?
get the inventory then use Player#openInventory(theInventory)
// The GUI class
public Inventory getInventory() {
return inventory;
}
// Wherever you want to open it
Player player = ...;
player.openInventory(guiClass.getInventory());
how can i use NBT to summon a firework? for example if a player does /firework <some random NBT of a firework> | it would summon a firework with that NBT?
tnx
Hello I am doing Bukkit.getEntity(UUID) to fetch an entity object from a stored uuid. I know that the entity's chunk needs to be loaded before I can get it, which is why I am using a chunk.addPluginChunkTicket(Plugin) before I run the getEntity method. However, I am still returned with null in the getEntity method. I know the entity's chunk is correct as I am using a stationary entity (Ender Crystal) in the center of the chunk for testing purposes. Any ideas?
Alright ive been trying at this for hours but i can't get it to work.
here's my error, i really tried everything in intelliJ and no success
You have compiled with a newer java than ur server is running
everything is set to java 8
pom?
the problem popped up suddently, and i dont know how to fix it
check ur project jdk
Well, it recognizes it as being compiled with java 10
Are there any other factors that can affect it?
do you use windows, linux or mac ?
Linux
What is the output of echo $JAVA_HOME ?
what is your start script?
Then i can't help, i had the same issue like you.
For me the issue was that the path was incorrect within intellj (what ever cause that 😄 ), so i have to run export JAVA_HOME="/usr/lib/jvm/java-16-openjdk-amd64/"
ah :/
wdym by that?
java -jar spigot1.8.8 something
Don't use 1.8 sir
lol
I'm making a PvP plugin
You are using java 16 on 1.8?
Then make a PvP plugin on a up to date version 😄
and I doubt things like viaversion be good for 1.8 battles?
Cool but don't use 1.8 anyway
Ocm exists
use the path to the install of java 8
Aka old combat mechanics
^
are you going to use the java 8 install hello
yes
Dude
1.8 players won't see difference
Cuz they don't have cooldowns in their clients
Dude
if he wants to use 1.8
he can use 1.8
there are a ton of reasons for why I would use 1.8
Lolz
...
it now gives Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project PitRemake: Fatal error compiling
yeah maybe i'm just better off using a plugin to allow people from 1.8.9 to join the server
this is a hassle
Great
ugh is there a way to call this in a super call?
you mean in the constructor? then no
reason being, first the parent is constructed, then the current class, thus you cant call anything from the class thats being constructed
how can i use NBT to summon a firework? for example if a player does /firework <some random NBT of a firework> | it would summon a firework with that NBT?
are you willing to use NMS
🥲
Anyone got an idea why I cannot remove teams in onEnable() ?
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
List<String> teamNames = scoreboard.getTeams().stream().map(Team::getName).collect(Collectors.toList());
for(String teamName: teamNames)
scoreboard.getTeam(teamName).unregister();
19.09 19:43:03 [Server] INFO java.lang.UnsupportedOperationException: null
19.09 19:43:03 [Server] INFO at com.google.common.collect.ImmutableCollection.removeIf(ImmutableCollection.java:270) ~[spigot_1.17.1.jar:3231-Spigot-3c1fc60-e167f28]
19.09 19:43:03 [Server] INFO at me.mrgeneralq.survivednights.SurvivedNights.onEnable(SurvivedNights.java:39) ~[?:?]
If removing them doesn't work, and unregister, then how else can I do it
are you talking to me?
yes
Unregister should work
yeah
because NBT is not exposed to the API at all.
However it’s fully plausible you might need to fix that post bootstrap
So defer a task instead
ill use whatever i need to for it to work
@ivory sleet , any examples? I'm sorry, I don't fully get that part.
well, let me rephrase it then. Do you know how to use NMS xD
Also yeah yet another time when spigot fools you by showing you the type List instead of ImmutableList 🥴
Yea
ive never used it
Liskov substitution principle goes brrr, but uh try something like
Bukkit.getScheduler().runTask(this,() -> {
//unregister here
});
But how will I know that it will be ready?
Well, I'm interacting with the spigot APi correct ?
Yup
Why would the definition change post-load
It's discouraged to access the spigot API async
Most of the api yeah
yes I got that
Well a lot of stuff are either not thread safe or just will be catched when dispatched async
I'll try the async method
the scheduler I mean
Well your best bet is probably https://hub.spigotmc.org/javadocs/spigot/org/bukkit/UnsafeValues.html#modifyItemStack(org.bukkit.inventory.ItemStack,java.lang.String)
declaration: package: org.bukkit, interface: UnsafeValues
create a firework rocket itemstack
yeah but then id need to summon it
pass that and the user input nbt into it
then spawn a normal firework rocket
after that you can use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Firework.html#setFireworkMeta(org.bukkit.inventory.meta.FireworkMeta)
declaration: package: org.bukkit.entity, interface: Firework
to set the firework meta of the rocket to the one of the itemstack
mkay ill try it thanks
good luck 👍
@ivory sleet same error :/
you cannot removeIf if you are still doing that
the collection is immutable
the unregister way is the way to go

@eternal night , it does the exact same thing
well, whathever is going on , unregister also doesn't work
it throws the same error
Doubtfully the case
Bukkit.getScheduler().runTask(this,() -> {
Bukkit.getLogger().info("Cleanup of existing teams started ...");
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
List<String> teamNames = scoreboard.getTeams().stream().map(Team::getName).collect(Collectors.toList());
for(String teamName: teamNames)
scoreboard.getTeam(teamName).unregister();
});
PotionEffect#apply(Player) doesn't seem to not work in 1.14 as opposed to later versions. Do we need to remove existing potion effect of the same type before adding one of a higher amplifier?
Why not just Bukkit.getScoreboardManager().getMainScoreboard().getTeams().forEach(Team::unregister) @lethal knoll speaking of which
I think it overrides if it’s Player::addPotionEffect ?
Not sure how it works the other way around
Assumably
Hmm i will try this thanks
Bukkit.getScoreboardManager().getMainScoreboard().getTeams().stream().filter(t -> t.getName().startsWith("sn:")).forEach(Team::unregister);
like that?
nothing wrong right?
Why the filter?
I need it because my plugin adds teams with that specific name
Ig, you’re really obsessed with streams aren’t you
lol xd
I haven’t messed with the scoreboard api a lot although last time I tested the unregister stuff worked at its finest
If the API supports it
it doesn't

I guess it's because of the onEnable()
Feels like you’re not putting in the new jar into your plugins folder
xD
Btw do u use plugman or plugwoman?
Or the one able is too early
Nvm
Hello I am doing Bukkit.getEntity(UUID) to fetch an entity object from a stored uuid. I know that the entity's chunk needs to be loaded before I can get it, which is why I am using a chunk.addPluginChunkTicket(Plugin) before I run the getEntity method. However, I am still returned with null in the getEntity method. I know the entity's chunk is correct as I am using a stationary entity (Ender Crystal) in the center of the chunk for testing purposes. Any ideas?
Just FYI, i'm not a beginner dev
Maybe a tad later when a player joins?
I’m tho (:
so something odd is ongoing here
notably, entities are not loaded in sync with the chunk anymore as of 1.17
Yeah looks like it, assuming the error still yields from the current code of yours
just because you are loading the chunk, entities might not be loaded in yet
wait wtf
You might be right ....
im a bit confused with what your saying here, i have ItemStack firework = new ItemStack(Material.FIREWORK_ROCKET); ItemMeta it1meta = firework.getItemMeta(); Bukkit.getUnsafe().modifyItemStack(firework, args[1]); idk if im doing this right? args[1] is my argument with the NBT
Lmao
I just opened the jar with jdgui
Been there too
Hello, I have a question that has been bugging me. So for example I have a new BukkitRunnable() { stuff... } in my main plugin class, and sometimes I want to get plugin's instance with this, but it returns BukkitRunnable instance. I sometimes just make public MyPlugin get() { return this; } method just to get plugin's instance in a runnable method. So, is there a way to somehow get plugin's instance and not bukkitrunnable?
Maybe export it to somewhere else
yea, worst case
And from there shove it into Ur plugin folder
final Plugin plugin = this;
Bukkit.getScheduler().taskMethod(() -> {
// You can reference plugin
}, param);

well
The keyword this is a reserved variable which points to any instance of the class enclosing it before its instantiation is declared. You could use
OuterClass.this if you have a nested or inner class.

Fking mint
I know, I just used it as example, but many thanks
basically, create the itemstack like you are doing. Feed it into the methd like that as well. After calling modifyItemStack you get the item meta (which should now have all the effects defined in the NBT)
you can then spawn a new firework in the world
and apply the firework meta from the items stack
i have ItemStack firework = new ItemStack(Material.FIREWORK_ROCKET); Bukkit.getUnsafe().modifyItemStack(firework, args[1]); ItemMeta it1meta = firework.getItemMeta(); loc.getWorld().spawn(loc,Firework.class); now, but how would i apply the firework meta to a firework thats not an itemstack?
the spawn method returns the firework instance
on that instance you can call the method I linked prior
setFireworkMeta
and pass it1meta (great name btw xD)
you'll have to cast it
would i need to store the loc.getWorld().spawn(loc,Firework.class); or something then?
yea
final Firework firework = loc.getWorld().spawn(...)
you can also use the even cooler way of ```java
loc.getWorld().spawn(loc, Firework.class, f -> {
// do something with f
});
sorry for asking so many questions havent really worked with anything like this before but would this ItemStack firework = new ItemStack(Material.FIREWORK_ROCKET); Bukkit.getUnsafe().modifyItemStack(firework, args[8]); ItemMeta it1meta = firework.getItemMeta(); final Firework firework2 = loc.getWorld().spawn(loc,Firework.class); firework2.setFireworkMeta((FireworkMeta) firework); get the meta assigned to firework then summon it with that nbt?
ah alright thanks
but besides that, give it a try
alright
it is
so from the code i sent above it doesnt really work, i added nbt {FireworksItem:{id:firework_rocket,Count:1,tag:{Fireworks:{Explosions:[{Type:0,Flicker:1b,Trail:1b,Colors:[I;16711680]}]}}}} to test it, and nothing happened the firework just acted like a normal firework as if u just did /summon firework nothing special just disapears after like 2 seconds
that wouldn't be the nbt I think
you must keep in mind that you are technically applying the NBT to the item now
i got the NBT from a website
thats what goes after a command for example /summon firework <nbt stuff>
huh?
Ok im gonna get straight to the point,
I need a way of detecting if a player has more than 12 hearts, and if they do, setting their hearts back to 12. I am using this plugin https://www.spigotmc.org/resources/lifesteal-smp-plugin.94387/reviews but since it doesn't have a built in limiter to the amount of hearts a player can have, there are people which can have like 50 hearts which will just wont do for my purposes.
Any solution would be great, and any help is appreciated.
Im a noob with plugin coding so please nothing along the lines of ---- Code )(*&#$()YDFH and then do that )(#&()YHDAF and boom, done.
basically only what is inside the tag:{} part
you are not actually applying the NBT to a firework entity
but to an item
but the entire thing is the nbt?...
yea but it is NBT that would be applied to a firework rocket entity
the method right now applies NBT to a firework rocket ITEM
which is different
i just tried it still nothing
so theres no way to make it work with the NBT i sent? because im making this to follow the same syntax of another plugin which uses that nbt and it works fine so if it changes like that it would sorta mess everything up
hmmm, I mean you could do it but I guess not really with the method you are using rn
and concerning you don't know NMS
its kind of rough
well if ItemStack firework = new ItemStack(Material.FIREWORK_ROCKET); Bukkit.getUnsafe().modifyItemStack(firework, args[8]); ItemMeta it1meta = firework.getItemMeta(); final Firework firework2 = loc.getWorld().spawn(loc,Firework.class); firework2.setFireworkMeta((FireworkMeta) it1meta); is what i have rn and it isnt working, and just the tag thing isnt working, if i got this to work maybe the original nbt i sent would work with this?
let me try to reproduce
final String nbt = args[0];
final ItemStack fireworkRocket = new ItemStack(Material.FIREWORK_ROCKET);
Bukkit.getUnsafe().modifyItemStack(fireworkRocket, nbt);
final ItemMeta itemMeta = fireworkRocket.getItemMeta();
player.getWorld().spawn(player.getEyeLocation(), Firework.class, firework -> {
firework.setFireworkMeta((FireworkMeta) itemMeta);
});
and
/tmp {Fireworks:{Explosions:[{Type:0,Colors:[I;16711680],FadeColors:[I;16731983]}]}} work well for me
tho, tbh to do this right you should/would want to look into NMS
the unsafe method does (for whatever reason) not offer a way to see if the tag was parsed correctly
uhhh i tried it and now theres a bunch of fireworks being spawned and they dont stop spawning
that seems like you are doing some loop xD
its just inside of a bukkit runnable
hey is it not possible to make custom entity?
so I cant use blockbench?
entities do not have the concept of a CustomModelData tag like item stacks do
so you'd have to fully replace an entity
or model an item, throw it on an armor stand and go from there
^
@Override
public void run() {
Location loc = as.getLocation();
as.remove();
final String nbt = args[8];
final ItemStack fireworkRocket = new ItemStack(Material.FIREWORK_ROCKET);
Bukkit.getUnsafe().modifyItemStack(fireworkRocket, nbt);
final ItemMeta itemMeta = fireworkRocket.getItemMeta();
loc.getWorld().spawn(loc, Firework.class, firework -> {
firework.setFireworkMeta((FireworkMeta) itemMeta);
});
}
}.runTaskTimer(plugin, (long) (translated2 * 20), 1);```
use Bukkit.getScheduler().runTaskTimer
instead of new BukkitRunnable
Bukkit.getScheduler().runTaskTimer { Cannot resolve symbol 'runTaskTimer' tried using new and all that as well
thats not java
wdym?
im thinking of a different method
huh?
so keep my runnable how it was?
ye
any other ideas why the fireworks just keep spawning in and dont just spawn one time? my code worked fine until i added the code lynx sent but now its just spamming fireworks
Probably because its a loop
its not a loop
it is
how is it a loop
i fixed the issue of the fireworks being spammed but now the firework nbt isnt working again https://pastebin.com/z31afHk7
I mean, a) isn't yours args[8] not args[0] ?
lol
anyone know how to fix the missing sounds with mixins?
how about just pr them
is there a way to send a silent console command (meaning theres no feedback in the chat)? ive found some on spigot but they arnt working for me
what message do you want to hide?
the message that gets sent when you run a command from console, for example if u did /summon creeper it would say Summoned Creeper
just go into your server properties file and disable the setting for it
broadcast-console-to-ops=true // set to false to disable
but i need to do it in my plugin, hide the feedback
not sure if you can change the server file from inside a plugin...
but theres no way to just not send feedback from a consolecommand sender?
**What ? **
I'm trying to build a library that can help people using hibernate inside Spigot (Minecraft) plugins.
Why am I doing this ?
Because, when making spigot plugins that connects to database, some things are almost always needed :
- [as a spigot plugin developer] The ability to add the default hibernate configuration inside the plugin.jar resources.
- [as a spigot plugin user (a minecraft server owner)] The ability to modify this configuration within a /plugins/MyPluginName/database/configuration.yml in order to:
- Define connection URI and credentials.
- Change database type (mainly h2 but possibly postgres/mysql/mongo/...)
My questions :
I'm trying to simplify DAO/Repository creation:
- Can I force users to follow some good practices about DAO/Repository using inheritance (by creating for example some abstract DAO/Repository class) ? If so, what should I put in this abstract classes ? Already implemented list/find methods ?
- Is there some already existing library (like Panache or Spring-JDBC) I could include in my library ? I would really like to provide already implemented list and find methods and I imagine there is already libs that does this. But they seems to be built uppon framework components I don't want/need. I would like to avoid reinventing the wheel but I fear that including such libraries would add too much dependencies to those frameworks.
Thank you per advance for your advice !
You can also read this question here: https://stackoverflow.com/questions/69247350/hibernate-related-spigot-library
Since I don't think any people will respond quickly, please ping me if you answer my question ^^
I dont think so. its just a minecraft feature which you can disable
its nothing to do with spigot really
dang thats anoying, ive seen spigot forums on it though but dont work for me
if you can change the gamerule you can disable it
yeah but then i would need to turn it back on?
disable it at the start of your code and enable it at the end?
eh not ideal but i guess it can work, thanks
Bukkit.getWorld(args[1]).setGameRule(GameRule.LOG_ADMIN_COMMANDS, false);
### My console command stuff ###
Bukkit.getWorld(args[1]).setGameRule(GameRule.LOG_ADMIN_COMMANDS, true);``` i have ^ to check if LOG_ADMIN_COMMANDS in the given world is true/false, if its true i want to set it to false so the command feedback from a console command doesnt get send then at the end set it back to true. this isn't working, nothing happens i still get sent the feedback and ive also tried the gamerule SENDCOMMANDFEEDBACK
hi , anyone good with sql ?
i got a duplicatation .. :
this is my code for the insertOrUpdate
anyone can see what iam doing wrong here?
its been 3 hours trying to google it and trying to fix it but with no luck ..
this is where i create the table
its the same code as my ffa sql base
the weird thing is , my ffa working fine no duplicate , but the skypvp code [for sql] is not and its the same as ffa [ i just added the rank in it and that's all .. its driving me crazy for real ..]
That shouldn't be possible
If the primary key is the UUID column then it shouldn't even be possible to have duplicate entries
Is that the same query you have always been using to create the table
And this is mysql?
sqlo2 its same as mysql
and i use it in my ffa project
and its working finne
idk what to do .. i need to fix it today ..
how do i enable --enable-preview in gradle with intellij?
It literally won't allow you to insert duplicate entries into the primary key column
No, pretty sure that's a different table
The one you showed me the create query for has uuid in all lowercase
That one has UUID in all uppercase
A primary key column can't have duplicates
And it can't be null
but why its duplicate for me ..
It's not the same table
Like I said
Your uuid column is uppercase in the screenshot and lowercase in the query you showed me
I can only conclude it's a different table and UUID is not the primary key
same table
how do i enable --enable-preview in gradle with intellij?
how i can edit it to be uper case?
in my main server its upper case
[the old skypvp code .]
anyone?
i changed it to upercase
and still 😦
this is from my localhost : test >
and this is from my main server .. :
i dont know why its beeing duplicateed..
i only call it once when player quit ..
so that it save
and when server restart
how can I allow putting a certain block in the worldguard private?
did you register the event
doing that rn, its probably that
are there any errors in the console
I just forgot to register it, thx
lol
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project htmljv: Fatal error compiling: invalid target release: 16 -> [Help 1]
since when can sql have duplicates
😦 its just happend its been 6 hours iam so tired .. i tried everything i can think of ..
how do i enable --enable-preview in gradle with intellij?
huge shout out to how rotating blocks is ruining my life, I've been stuck on it for 3 days, I hate everything
https://github.com/ProjectG-Plugins/HardCore/blob/master/src/main/java/dev/projectg/hardcore/database/PlayerData.java I made insert and update seperate. Never had any dupe issues.
thank you //
It's not the best code but works for me :p
anyone know the issue?
?paste
If I want to implement my own land protection is it worth creating a system from scratch or is it better to use something like the WorldGuard API?
hello i need help ```int period = getConfig().getInt("periodDelay");
public void runnable() {
new BukkitRunnable() {
@Override
public void run() {
}
}.runTaskTimerAsynchronously(this, 0, period);``` i need to get a instance of the world inside of the BukkitRunnable, but ive tried so many things that dont work, can someone help?
What world
the servers world
The server has several worlds
Bukkit.getWorlds
nevermind
got it
I am using SpigotUpdater to check for new updates for my plugin, but when I update to the latest version, it recommends previous versions to the one I installed.
What does the code look like
int ID = 96330;
SpigotUpdater updater = new SpigotUpdater(this, ID);
try {
if (updater.checkForUpdates()) {
if (!updater.getLatestVersion().equals(getInstance().getDescription().getVersion())) {
getLogger().info("An update was found! New version: " + updater.getLatestVersion() + " download: " + updater.getResourceURL());
} else {
System.out.println("Plugin is updated!");
}
}
} catch (Exception e) {
getLogger().warning("Could not check for updates! Stacktrace:");
e.printStackTrace();
}
}```
There is a delay after posting an update iirc
Yes, I know that, but I don't know how to make it recommend only higher versions to me
You would have to make a way to check if the version is newer
I have tried a method to check, but it still recommends previous versions
Something like a simple semver implementation would work
Then getLatestVersion is returning the wrong version
@quaint mantle what version is it
It is limited to mvp+ and they can make there own server
so it's like max 5-10 people a server
I saying that because for your friends
most people don't have friends 10+
Create your own SMP server on hypixel and play with friends.
Aren't you like asking how they keep the servers non laggy
what you mean by main
no as I believe.
it's basically a bungee server
When you create your own smp , Your own world gets it own hardware, or a part of it
I doubt that
But they likely keep them separate from the main server machines in case someone does something stupid
This is why you properly divide up your hardware resources so one server can't hog all of them
?paste
https://paste.md-5.net/cemucitusa.xml
Hi guys, this is about maven resources plugin configuration. Aim is to copy output jar from project's build directory to the plugins folder of my test server directly. The above configuration only copies a corrupted jar. If I take away the includes and set filtering to false everything works fine except it copies other unwanted files as well (such as classes and surefire reports). Are there any ways to solve this?
Edit: Solved, change filtering to false but continue to put jar under includes.
is thread creation disabled in this channel....
can consider setting uuid as primary key
Must be now, wasn't earlier
hey so, i am new to plugin development and i learned java recently.
I wanna know how do i check like, if player hasnt moved for x seconds, then summon anvil.
for an example can someone help me with this?
I think this is fairly hard to do. The first thing I can think of is using pdc (PersistentDataContainer) to store the last alive tick that the player is moving.
sorry i didnt get you, i mean the terms
m quite new m sorry
is this for a minigame type thing
Is there an event for player move?
Yes, but for every kind of movement, be it client move or entity pushing it
If im not wrong
You could check if playerMove == true (set to true on player move event) each tick via the scheduler.
if playerMove == false for 5 seconds (which is like, 500 or 5000 ticks I think?)
then you summon a TNT entity
5*20
thx
so 1000 ticks then?
sorry correction
my brain malfunctioned
but you'd basically increment an int every tick and if it == 100 and playerMove == false, then you summon a TNT, on player move you'd also set the int to 0
actually you probably don't need a playerMove boolean
just use an int lol
Why would Entity#addPotionEffect(PotionEffect) ever return false on players? Only on 1.14.4. Works with later versions.
Edit: Turns out 1.14.4 cannot apply potion effect on entities that already have that effect. Need to remove it from the entity first, F.
Confused and angri
hey what should i add in the event?
only the int??
or weh
like an int noMoveTicks or smthn
uh well you'd set noMoveTicks to 0 in the event
then outside of your event, in the same class but different method, you register a scheduler that increments the ticks by 1 every tick as well as checks if ticks == 100, if they do then you spawn TNT and set ticks to 0
Use a timestamp
okk
Add it to a map with the player uuid, and use a task to check it every few ticks
ill read abt em first
how would you suggest doing the movement check tho?
Every time they move, update the timestamp
this seems a bit complex
alright well Coll's is probably better
oki
i found this raw code
Player player = (Player) sender;
int now = (int) (System.currentTimeMillis()/1000/60); // system time in mins
if (args.length > 1) {
HashMap<UUID, HashMap<String, Integer>> ml = members.getData();
UUID pId = null;
String pName = args[1];
pId = getId(pName, ml);
if (pName != null) {
if (ml.containsKey(pId)) {
Integer expiry = ml.get(pId).get(pName);
if (expiry - now < 0) {
expiry = now;
}
Integer pHours = (expiry - now) / 60, pMins = expiry - (pHours * 60) - now;
player.sendMessage(greenPrefix + "Player " + pName + " has " + pHours + "hrs " + pMins + "Mins of Play Time remaining");
return true;```
i could use this for refrence
right
So
Im trying to change a armorstands looking direction
Player plr = event.getPlayer();
if(plr.getVehicle() == null) return;
ArmorStand entity = (ArmorStand) plr.getVehicle();
Location locCopy = entity.getLocation().clone();
locCopy.setPitch(plr.getLocation().getPitch());
locCopy.setYaw(plr.getLocation().getYaw());
entity.teleport(locCopy);
and this isnt working
setting the locations pitch and yaw directly doesnt work either
i added checks after the plr.getVehicle == null and its running
also, its getting the correct entity since i have used other methods on it that have worked
100% they thought about that
Maybe it's like on skyblock
if you make a laggy smp, they wont let you on it
I have tried everything
Setting the body pose doesnt work either
Ok
i figured it out
Spigot doesnt let you teleport or change the location of a entity being ridden
So
To fix this i will just make its head angle change
👍
entity.setVelocity(plr.getLocation().getDirection().multiply((sidewaysFloat == 0 ? 0 : (sidewaysFloat > 0 ? 0.10 : -0.10))).multiply((forwardFloat == 0 ? 0 : (forwardFloat > 0 ? 0.10 : -0.10))));
Sideways float is >0 when moving left, and <0 when moving right, and for forwardFloat its the same but >0 is forward, etc. How would i be able to set the velocity relative to the players direction without just moving forward, regardless of Y direction
What?
Does somebody know how to delete a path with the value from a Configuration file? Without deleting the whole file?
Set it to null
Value
And the path how can i delete that?
Setting the value to null will remove the entry
Okay also with the self coded Config?
Is it possible to send messages cross server without being to the same bungee proxy?
having a plugin connected somehow
like have the same plugin on both servers
would be pretty hard
Could i use sockets?
Yeah
this is a question that will lead to more questions, im sorry
I generally recommend redis / jedis
You'd need to parse the midi file into notes
ok
Keep in mind BPM, volume, pitch and such exist
Redis... sql... an api alot of ways,you could have the servers sharing same database then simply querying every seconds or so to see if any new entrys are up
I explained how sql would work
ehh not the best but sure
Well its the... easiest of em all i think
help me guys... https://www.spigotmc.org/threads/a-way-to-respawn-at-the-nearest-set-location.526556/
U mean u spawn them nearby their respawn location ?
No, what i mean is this:
I set random spawn location all around the map, when player die, they will respawn at the nearest spawn location
Oh
Loop through all the locations and find the nearest one from their dead location
Then set the respawn location to the nearest position
Exactly what I want, but how do I find the nearest one :ajit:
Location#distance(location)
huh?
Use that method
It will give u the distance between 2 location
Wait I saw this method but wait wait...
And use that distance to compare
I thought to use that, but I thought that I need something else and that not work. Ok thanks for your help to remind me of something I already know lol
Thanks man!
Gl
lol
Player p = ((Player) e.getEntity());
if (!isInCombat(p)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.RED + "You are now in combat! Do not log out.");
}
lastDamages.put(p, System.currentTimeMillis());
new BukkitRunnable() {
@Override
public void run() {
if (isInCombat(p)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.GREEN + "You are no longer in combat. You may safely log out!");
lastDamages.remove(p);
}
}
}.runTaskLater(WAPvP.getInstance(), WAPvP.inCombat * 20L);```
this is prob bad code
but
how come this is flooding chat
with
You are now in combat! Do not log out
You are no longer in combat. You may safely log out!
when im in a fight
public static boolean isInCombat(Player p) {
return PlayerDamage.lastDamages.containsKey(p) && //if they are in the list
System.currentTimeMillis() - PlayerDamage.lastDamages.get(p) < WAPvP.inCombat * 1000L; //if it hasnt been > 5s
}```
that is the combat method
im trying to make anti combat logging thing
System.currentTimeMillis() - PlayerDamage.lastDamages.get(p) < WAPvP.inCombat * 1000L;
thjat wont fix my issue tho
no, but its simpler and more readable logic
check your value for WAPvP.inCombat
5
Well.. you do have a sendmessage on the 1 second runnable..
and make Player p final
hey, i wonder
why something like player p or some string need to be final
i dont think that it makes any sense
Doesnt rly need to be its just practice
You should also have a single runnable testing all contents of lastDamages for expiring timers. You are creatign a new runnable for every damage
more words = more perfomance 😎
if (e.getEntity() instanceof Player) {
final Player p = ((Player) e.getEntity());
if (!lastDamages.containsKey(p)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.RED + "You are now in combat! Do not log out.");
}
lastDamages.put(p, new BukkitRunnable() {
@Override
public void run() {
if (lastDamages.containsKey(p) && lastDamages.get(p).equals(this)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.GREEN + "You are no longer in combat. You may safely log out!");
lastDamages.remove(p);
}
}
});
lastDamages.get(p).runTaskLater(WAPvP.getInstance(), WAPvP.inCombat * 20L);
}```
would that work @eternal oxide
prob not
im dumb
oh your if (isInCombat test in yoru runnable should be a !isInCombat
wut
i got rid of that method
you are testign that they are no longer in combat
so yoru isInCombat test will not work correctly in yoru runnable
i got rid of that
i have a new method
read
you need them to be in the Map and the timers to have expired
in your runnable you also need to test the expired time, as they may have been added back in with a newer timer after this runnable was scheduled.
so they have to be in the Map AND the timer has expired
im confused
final Player p = ((Player) e.getEntity());
if (!isInCombat(p)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.RED + "You are now in combat! Do not log out.");
}
lastDamages.put(p, System.currentTimeMillis());
new BukkitRunnable() {
@Override
public void run() {
if (isInCombat(p)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.GREEN + "You are no longer in combat. You may safely log out!");
lastDamages.remove(p);
}
}
}.runTaskLater(WAPvP.getInstance(), WAPvP.inCombat * 20L);```
i put it back to this
what do i change
your second one was better
you just had to also check the timer had expired in the runnable
how do i track timer 😫
you already are. you are storing the time it was set
actually i could make a variable in the bukkitrunnable
player adn time
You can;t do that
hmmm
as you'd auto remove the player, even if they had a new timer set
lastDamages.put(p, new BukkitRunnable() {
long ms = System.currentTimeMillis();
@Override
public void run() {
if (lastDamages.containsKey(p) && lastDamages.get(p).equals(this)) {
p.sendMessage(WAPvP.PREFIX + ChatColor.GREEN + "You are no longer in combat. You may safely log out!");
lastDamages.remove(p);
}
}
});```
long ms = System.currentTimeMillis();
yes, but thats always going to be expired when it runs
so what happens when a player is hit twice, a couple of seconds apart
the first runnable executes, removes the player from inCombat
second task runs and the player is no longer in the Map
it only removes it
if the runnable hasnt been overrided
so if they hit again
it overrides with new one
that lasts another 5s
yes, so he's no longer classed as in Combat even though he has nor tasks left to run
why are you putting BukkitRunnables in a map
wait... how do i loop through something that isn't a number...?
for each?
that does what u need
(al though u would need to sort through dmth different)
because that goes through ALL Players
😎
how do you loop through those? i need to get the name of that
and that is what i need, only need the name of the start (the random names)
just save what ever string there id into an temporary variable
and use it then further
:/
w3school
i just searched that
getkeys lol
the 3rd one is exactly the one u need and want
Map<Player, Long> lastDamaged = new HashMap<>();
String PREFIX = "PREFIX";
int LOG_PREVENT = 5;
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
final Player player = ((Player) event.getEntity());
if (!lastDamaged.containsKey(player)) {
player.sendMessage(PREFIX + ChatColor.RED + "You are now in combat! Do not log out.");
}
lastDamaged.put(player, System.currentTimeMillis());
new BukkitRunnable() {
@Override
public void run() {
if (lastDamaged.containsKey(player) && !inCombat(player)) {
player.sendMessage(PREFIX + ChatColor.GREEN + "You are no longer in combat. You may safely log out!");
lastDamaged.remove(player);
}
}
}.runTaskLater(getInstance(), LOG_PREVENT * 20L);
}
}
private boolean inCombat(Player player) {
if (!lastDamaged.containsKey(player)) return false;
return System.currentTimeMillis() - lastDamaged.get(player) < LOG_PREVENT * 1000L;
}```
Should work
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
public class ClickEvent implements Listener {
@EventHandler
public void onClickEvent(InventoryClickEvent event){
event.setCancelled(true);
Player player = (Player) event.getWhoClicked();
if(event.getView().getTitle().equalsIgnoreCase(ChatColor.AQUA + "Server Selector")){
if(event.getCurrentItem().getType().equals(Material.RED_BED)){
player.sendMessage( ChatColor.GREEN +"Sending you to Bedwars Server");
player.closeInventory();
}else if(event.getCurrentItem().getType().equals(Material.GRASS_BLOCK)){
player.sendMessage(ChatColor.GREEN +"Sending you to Survival Server");
player.closeInventory();
}else if(event.getCurrentItem().getType().equals(Material.BEE_NEST)){
player.sendMessage(ChatColor.GREEN + "Vote For Us : Link 1 2 3 4");
player.closeInventory();
}
}
}
}```
Players not getting messages when they click on items
registered it??
it never sends me the You are no longer in combat. You may safely log out! message
sec
its probably a very close timing issue, increase the delay on the runnable. (LOG_PREVENT * 20L) + 5L
If you want to be very precise using System::nanoTime might be a better idea
Nah, he just needs close enough
but his runnable has to run after the time expires and not on or before
U got the answer u were looking for ?
yeah i think
maybe some minor bugs
Ok
im trying to make it doing what im intend to do
Gl
wait I can't do this?
for(String path : getConfig().getKeys(false)) {
Bukkit.getLogger().info("hello" + path);
}```
it still doing wrong :LLLLL
how do i make it not work if the event is cancelled
Um wat do u get in the console ?
i tried this
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageByEntityEvent e) {
if (!e.isCancelled()) {```
but that doesnt work
a very big thing: blank
Do u have anything in ur yml file ?
set ignoreCancelled = true
in the annotation
you also want to run highest priority. That runs last
we can't use "? i do prefer ' but sometimes i mistake with those two lol
Use it where ?
config.yml
i thought it was other way around lmao
btw even if i change to ' but it still not doing anything ....
U can
Yml specs accepts either
'str' or "str" or just str
This^
changed to this
let me test (again) to see how it work
Do u have a config.yml file created when u run the plugin ?
snipe
this is just testing purposes so i dont do anything much to this
no
Or log it for that matter
if i put the bukkit getlogger out of the for loop
then it would work
What is in the config.yml?
but if in the for loop then nothing will work
ummm
Well you should also use your plugins logger over the global Bukkit logger
just some random vietnamese word
just System.out.print
tried system.out.print already
they are the same
Wat
Oh like outside the scope?
this, will work
not this
Um can u print the size of the getKeys()
very cool moment
my brain cant comprehend this bs
Oh yeah well shouldn’t you call the saveDefaultConfig() before the copyDefaults?
no matter to that :v
i mean i just print only hello
nothing i tried really use config
Me too
gonna do this
Ok
i do think something weird is happening with the for-each loop today
Well they’re both stateful methods so yes it matters
This
^
?
Presumably
i only see the opposite way, from kody i think
ye
I haven’t used those methods in ages so can’t tell whether that’s the correct order but by the looks it seems more right
i dont think my way is wrong, both are right lol
thats the right order
No I mean the program can't see anything in that configmynl maybe
No that’s not true
i think
nah i mean i only print "hello" and it dont even work
I never used those methods cuz it hurts my brain
of course i print that "hello" in the for-each loop
so, nothing matter with those 2
Use this them tell us what it prints
so how else do undo configs?
in the for-each loop too right?
packedged into the plugin itself?
print i.size
I don't lol
perfect
Yes
Thing is, object orientation works with state, for instance you can’t open a file before closing a file and so on, we work with changes to the system. Therefore it’s conspicuously silly trying to close a file before opening it. The same goes here, one order will work whilst another shouldn’t. But make sure your config.yml resource is actually contained within your jar. Then in principle if you just want to access the data from config something like:
saveDefaultConfig();
reloadConfig();
should work.
print i.sizey() reeeee
kody do that all the times so i dont think it really matter, but, who knows?
Who’s kody
try
public void onEnable() {
saveDefaultConfig();
boolean has = (getConfig().isSet("hello.hello"));
if(has) {
System.out.println("config has value: " + getConfig().getString("hello.hello"));
} else {
System.out.println("config doesn't have value");
}
}
kody simpson
to determine if the config.yml is being loaded.
does the config.yml actually copy to /plugins/(plugin)?
Idk who that is
Nice
Oh it’s a YouTuber?
getConfig().isSet(<Path>)
wait
I just use files to store data and the config Is done in a gui
i just realized
didnt put {}
so i this case
I'll take a look at it
oh yes thank you lol
That shouldn’t matter rpgaccount
^
what?
gonna test this out
1 line of code after a statement is inside
Without {}
Java isn’t indentation based
If (isDead)
Inside
Outside
If (isDead) {
Inside
Inside
}
Outside
okay everything works fine now, gonna back to the start, maybe something weird just happens to for-each :l
System.out.println("String: "+(getConfig().isSet(<Path>) ? getConfig().getString(<Path>) : "Not Set"));
Logger(3
now gonna test this
Not gonna work
becuz?
any reason to not just use the default btw ? xD
There is no .
instead of a random tenary
Store the view when invoking HumanEntity#openInventory
wait
path + ".hello"
is what he is talking about
Correct
very nice thanks everyone for helping :sadman:
so, everyone's confusion is becuz my me?
sorry lol
Wat
In?
whatever example yapper threw in above
It's OK, I have done it over a hundred times by now, cuz of silly mistakes
but actually everyone dont even noticed that
OK OK OK @ivory sleet right now im very confused, but your way just work
Wait what are you actually trying to do?
Sounds plausible (:
but... wait, i always do this and it always work... seems a bit weird
I have no idea
this is weird
but anyways
thanks for helping
Well yeah the methods are badly named arguably,
saveDefaultConfig just takes the config from your jar and puts it into your data folder
Unsure what the copy defaults is doing exactly
never use copyDefaults() it pointless
i have no idea
that line literally does nothign. It returns a boolean. calling that method does nothing
Not to be mean now but kody simpsons is probably not the best guy to worship when it comes to opinionated spigot plugin development
nah man
it just really fun hearing his voice, like wtf idk but his voice kinda cool
Lol alr
Yes, one person added that one time to a tutorial, now everyone just copies it with no idea what it does.