#help-development
1 messages · Page 1583 of 1
You can register event listeners outside onEnable also btw
Just that you should probably bake them also if you do which can cause lag thus should be avoided
Yeah I more meant within the onEnable, it can only register them, not BE an event. Poor wording on my part
Oh yeah very true indeed
@twilit vector after some thought, boats would be better imo
can i make a new class that calls getServer().getPluginManager().registerEvents(new trackevents(), this); and implements listner
conventions out the window
or can i do getServer().getPluginManager().registerEvents((Listener) new trackevents(), this);
would this work
the window is getting larger by the second
oh
why?
and boats on land?
wont it be too slow
why wouldn’t you implement listener in your class?
…
you don’t implement it in your main class
yea i was going to sayt
you do it in your trackevent class
what yall talking abt
should i do ```public void eventregister() {
getServer().getPluginManager().registerEvents(new trackevents(), this);
}
Yeah implementing Listener in main class would violate sr principle but probably not relevant if you’re just a beginner
yes
but make sure you implementing Listener in your trackevents class
and add capitals to that class please
if you want to organize your code you can do smth like
main{
registerEvents();
}
registerEvents(){
getServer...
}
so its the same thing but looks better
Presumably not
and the main method gets smaller
Lucas showing yall how to write clean code 😌
😆
ok the getServer().getPluginManager().registerEvents( new trackevents(), this);
aint working
what can i use to replace this
Stop casting Listener
ikr, heres another one
if(condition) return;
is better than
return;
}```
do people actually do shit like this?
i do for events commands and schedulers
Uh that depends I like the latter but both reads good
jeff yeah it’s cleaner
Probably an insignificant change to a plugin but still
?paste
another way you could do this is on death event, cancel it, teleport the player to a location and delete all items but the compass and any other you want
xdddddddd
well obv you have to modify the movement, even if you used armor stands lol
and boats are made to be ridden, closest thing to a vehicle in minecraft already
im trying ttootooo
yeaa right
so i am doing that now
XD
add this into your onEnable
?paste
Test it now
System.out.println("it broke");
System.out.println("going to the spigot discord");
System.out.println("asking a million questions");
System.out.println("ok all fixed");```
whats that
Hey, I have a problem with two of my functions:
// Glow or unglow function
public static void setGlow(boolean glow, ItemStack itemStack) {
ItemMeta meta = itemStack.getItemMeta();
if(glow) {
if(ItemStackUtils.isAnArmor(itemStack)) {
meta.addEnchant(Enchantment.LURE, 1, true);
} else {
meta.addEnchant(Enchantment.PROTECTION_EXPLOSIONS, 1, true);
}
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(meta);
} else {
for(Enchantment enchantment : meta.getEnchants().keySet()) {
meta.removeEnchant(enchantment);
}
}
}
public void setGlowUnglowOthers(InventoryContents contents, ItemStack itemGlow) {
for (int columns = 2; columns < 6; columns++) {
if (contents.get(1, columns).isPresent()) {
ItemStack item = contents.get(1, columns).get().getItem();
ItemStackUtils.setGlow(item.isSimilar(itemGlow), item);
contents.set(1, columns, ClickableItem.of(item,
e -> {
e.setCancelled(true);
reason = e.getCurrentItem().getItemMeta().getDisplayName().substring(2);
setGlowUnglowOthers(contents, e.getCurrentItem());
}));
}
}
}```
Both functions are called correctly but the one that unglows the item when needed does not remove the enchantments. I don't see what the problem is. Could someone explain me the problem ?
its just for concole
?paste
ik i could put something in chat but there is no point because people are not going to see it anyways
unless a restart
but idk that much abt that stuff
i just need to know that it is in concle and working
concle
console
Anyways did it work?
im testing right now
just use skript
trigger:
give 1 glowing dirt named "&aI am dirt" with lore "&cOooh" to player
# Change the above item to any item you want```
loooool
LMAO
i shut down my server so i can delete the other plugin that doesnt work
ik it takes longer but i like to be neat
did you try to debug it?
it works pogggg
i seriously need more ram if i am going to be programing more
lol
How much you got?
8gb
AYO
did him like tht
You should be fine
😳
wack lol
I also got 8 gb as of now lol
ik it just is long and more tediouse
imma ask a 2080ti for my bday, considering i have a 11 yo gpu
amd r9 200 series
lool
go for the 3080 founder edition
and i like to have my browser,intellij,discord,mc all op[en at the same time so
it's like $800
nah
i would live constantily worried
what if something happens
there goes your 3080 founder edition
you dont even need that much
but price on it won't inflate
a 2080 is more than enough
Is GeForce rtx 3090 good btw?
unless you play those massive games
Since it's only sold by nvdia
1070 is ample
is there a way to have multiple people work on one project in intellij? if anyone knows. and is it like google docs where its real time edits?
For the price you pay it's not even worth it
yea
its uh
wait
Code with me
yea
-.-
let me get you the link'
Hmm alright but it looks hella delicious
💩
i mean, for coding, do you even need a gpu lmao. but i have heard it is vehry nice
Like me?

yes
the function that doesnt work
oh my bad i debug it, the for(Enchantment enchantment : meta.getEnchants().ketSet() is executed but it doesn't remove the enchantment
there ya go
hmm?
Can you safely change variables in a class that executes sync methods from an async task?
how to edit item's lore before enchant?
Alright! I can I also start a sync runnable from an async runnable without messing things up?
If one thread writes and multiple reads use volatile, if many threads write and read use a Lock or the synchronized mechanism
Mods
yeah
One thread will write and main will read only
so, can't i?
Executors.newCachedThreadPool().submit(() -> {
Bukkit.getScheduler().runTask(plugin,() -> {
this.variable = blah;
});
});
Somethjng like this would be fine
thats one of the hardest things you can do in java spigot, i would recommend starting with something easier, like an anticheat that doesnt lag the server
thanks for your help!
Since the runnable that mutates the variable is queued to run on the server thread (;
Yeah not possible. What you can do however is fake the effect by hiding enchantments and add the names to lore
my problem is not solved
but wtf, it's my answer
let me ask my 🔮 what your problem is
k, other answer. Can i edit item after enchant?
that's easier than "before"
i think
Enchant is not remove from the item
code?
// Glow or unglow function
public static void setGlow(boolean glow, ItemStack itemStack) {
ItemMeta meta = itemStack.getItemMeta();
if(glow) {
//ignore here, it's working and it's not where is the problem
if(ItemStackUtils.isAnArmor(itemStack)) {
meta.addEnchant(Enchantment.LURE, 1, true);
} else {
meta.addEnchant(Enchantment.PROTECTION_EXPLOSIONS, 1, true);
}
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemStack.setItemMeta(meta);
} else {
for(Enchantment enchantment : meta.getEnchants().keySet()) {
meta.removeEnchant(enchantment);
}
}
}
public void setGlowUnglowOthers(InventoryContents contents, ItemStack itemGlow) {
for (int columns = 2; columns < 6; columns++) {
if (contents.get(1, columns).isPresent()) {
ItemStack item = contents.get(1, columns).get().getItem();
ItemStackUtils.setGlow(item.isSimilar(itemGlow), item);
contents.set(1, columns, ClickableItem.of(item,
e -> {
e.setCancelled(true);
reason = e.getCurrentItem().getItemMeta().getDisplayName().substring(2);
setGlowUnglowOthers(contents, e.getCurrentItem());
}));
}
}
}```
That's not the problem, I want the glow of the item to disapear, not only the name of the enchant
is that a command?
i have no idea what you are trying to do
is it in a inv?
why do you use InventoryContents
doesnt that remove all enchants of the item?
you are missing a bunch of information
can you use this with the free version of intellij?
im trying to install from disk but it says my intellj is outdated but im on the latest version
yes
because i need to get the item in the slot
yes it does normally
yes
No
Map<K,V>.<K>keySet() returns a Set<K>
else glow?
no it's a report command who open a inv, and that when you press a specific item it enchants it. If you press another specific item it will enchant it but it will disenchant the other one
then use invclickEvent
if inv == the report inv
get item
item set glow true
theres no need to do what you did
you can also use InventoryFramework
if you want
it will create an inv with actions attached to the items
so you can add the set glow true
i use compile 'fr.minuskube.inv:smart-invs:1.2.7'
to the item
wat
yes but it's not the set glow true the problem
it's the set glow false
who removes all the enchantements
the problem is
if an item is already enchanted
it will still glow
after you remove your enchant
but
if you "unglow" an item you didnt glow
then you are gonna remove the enchant the item already had
No, the glow doesn't stay if you remove all the enchantments unless I'm wrong
the glow will stay as long as theres an enchant
meaning that if you try to unglow an item with other enchants
As long as the enchant tag is present
it wont unglow
That's why I want to remove all the enchantments from the item
but what if the item has enchants added by the player?
The player can't add enchantments because he can't take items from the inventory.
Hey,
i try to remove Entchantments:
Player p = event.getPlayer();...
This is literally the same code
it doesnt look like the same code
Hey is there a reverse packet for PacketPlayOutEntityDestroy to show entity?
Spawn entity
thanks
Follower by the meta packet
is there a way to check if the server is reloading instead of just starting up?
Yep
getLoadedWorlds() will be length 0 on startup and it will be longer on reload
Something like that at least
It may be just
Bukkit#getWorlds()
it does when "glow" is false in my code :
for(Enchantment enchantment : meta.getEnchants().keySet()) {
meta.removeEnchant(enchantment);
}
Hey! Quick question: Does anyone know how I can use multifacing on a glass pane that I want to set as follows?:
event.getBlockPlaced().getLocation().add(-2, 1, 0).getBlock().setType(Material.WHITE_STAINED_GLASS_PANE);
If its Directional cast and set facing
wdym with chest state's inventory name?
what?
the gui name?
yea
gui's name
java.lang.NoSuchMethodError: 'java.lang.String org.bukkit.inventory.Inventory.getTitle()'
Just Fucking Google It helps you help others to use Google and search on their own!
first link
Is it possible to get the name tho?
but in newer versions you gotta use what i sent
yes.. it is
I can't get the view from the chest's state
cuz chest state is not what you need
you can get the GUI Name with event.getView().getTitle() the variable "event" has the data type InventoryClickEvent
Something happened and Inventory#getTitle was lost
no
getTitle() doesnt work anymore
On InventoryView it does
I've tried won't work
It’s on Inventory it doesn’t
I can't get the view tho
Too bad
when you also use #getView before the #getTitle
So its not possible to get the view from Chest?
What exactly do you want to code?
Crates
okey
Well, I've never created a crate before, but I can imagine setting up a crate with a special persistant data and then building a listener that queries whether the crate has that persistant data. Then you cancel the event that opens the crate and open a self-created inventory where you can collect your reward.
Ideally don’t need the title yeety?
I mean BlockInventoryHolder should be enough if you want to keep track of stuff or smtng, well identifying the inventory
I also have a question: Does anyone know how I can use multifacing on a glass pane which I have created as follows?:
event.getBlockPlaced().getLocation().add(-2, 1, 0).getBlock().setType(Material.WHITE_STAINED_GLASS_PANE);
Are armorstands that you spawn with packets actually worse in terms of performance than normal armorstands? I would always use normal ones anyway, because that would be unnecessary but I am interested.
Probably better in terms of performance
What’s multifacing?
Blockdata
So I should create a block variable with the material WHITE_STAINED_GLASS_PANE and then somehow put this in the BlockData there.?
how to set the center of sound?
That i'm using now: p.playSound(p.getLocation(), "felmon:music_disc.18", SoundCategory.RECORDS, 0.1f, 1);
Change the Location argument
Yeah, set the sound to play at the location of the "jukebox"
Instead of at the player
ok how would i go about making like a tag system for player
stop.
Use PDCs
I don't know. But do you have a website or something that explains how to properly create and set variables with the data type block, etc.?
ah
So prefixes
scoreboards for you
not tag tag
change team's prefix.
so i can have something like this player.setCompassTarget(tracked);
Why do you need prefixes for that
well imma give the tracked and tracker
bc the tracker needs to be able to locate the tracked
- get target location
- get compass
- set target location in compass
- set meta
oh yea
it isn't hard
but you see i dont know how to get the target location
?jd
Well the Target is a player, yes?
yep
So... get their Location
You'll have to update it regularly
but how would it know witch person is the one getting tracked
Yeah you'll have to keep updating it periodically with the tracked player's new location
and have iq more than 1
No reason for that Koto
to had
bruh
you can tracking player
periodically taking his location
every tick, every it move
how you want
and writing in compass
i know that
good
that i understand
let's try
Hello, does anyone best way to store chunks in a yml file?
in there standard format, not in a yml
what's their standard format?
Quick question, is there an direct method to cancel the fall damage on Player.setVelocity
make them invincible or cancel the damage event I think
hi guys i am using Damageable from inventory tho when setting the damage my item literally gets removed like 100+ durability even tho its 18 blocks mined, i am making a area pickaxe
what are you setting for damage?
I am currently storing chunks with the location of the block of the chunk at 0 0 0
Store the chunk x and z
you know thats damage you are applying not durability?
then what about durability?
Is that setting the actual stats of the pickaxe (attack damage)
is there a way to get the title of an inventory?
Someone help, I made code to sense when a player gets 5 kills, but it triggers after 2
Full class:
https://paste.md-5.net/pozehobexe.java
your code is literally the worst i've ever seen, but it does run!
inv.getType().getDefaultTitle() maybe this
with booleans if the condition is true just put your boolean like this:
if(yourboolean)
instead if it is false
if(!yourboolean)
i'll Try 😄 thanks
Hey, I would like to know if it was possible to get the fishing rod from the event with PlayerFishEvent. If yes, how?
How would you install a Maven Dependency in IntelliJ?
probably this event.getPlayer().getInventory().getItemInMainHand()
Hum yes
sounds dodgy but I think it works
Whats wrong with it
i want to fix it
event.getHook()
I think
i think by getting the player and getting the item using getItemInUse() on Player
if the player is fishing from the offhand it wouldn't work
No, that's getting the Hook not the fishing rod
Ah ok
whats wrong with my code
the basics
u doing
if(urboolean == true) instead of
if(urboolean)
i changed
and also
u doing
if(urboolean == false) instead of
if(!urboolean)
also your variables can be stacked like so
Player player1,player2,player3
oh
instead of
Player player1
Player player2
etc.
Is this your first Java project?
no
?
also what is the point on making a string object for the args[0] and 1?
update 🙂
easier
ah
no lmao
oh
Extraaaaact smaller methoooodds (:
im not telling ur bad, im just telling u to get better 🙂 here is some documentation that could help you! https://www.w3schools.com/java/java_switch.asp
well idk what the problem is that let player win the game with 2 instead of 5 kills
i know how to use switchs
hm idk then, i can't understand your code, please learn how to make methods to make your code smaller and run efficiently, also instead of making playerkills = playerkills +1 just use playerkills++;
it was working until i added this, but its essential
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
if (hasStarted) {
if (player1.getLocation().getY() == 64) {
Location tp = new Location(Bukkit.getWorld("world"), 12.5, 87, -527.5);
player1.teleport(tp);
}
if (player2.getLocation().getY() == 64) {
Location tp = new Location(Bukkit.getWorld("world"), 12.5, 87, -527.5);
player2.teleport(tp);
}
}
}
this might very well not work
y being exactly 64 in a move event is pretty impossible
😌
you could use >=
if that's a thing in java
ik
or round it
but i need to see if they are on a certain Y
and taht works
that
but that requires more code
please make checks because PlayerMoveEvent can destroy your server performance
Wdym
Was anything changed in the inventories in 1.17? All my inventories load quickly and normally, but the inventories where you first open the inventory from a brewing stand load very long (I didn't have the problem in 1.16.5)
it can run up to 16 times per tick with 2 players
im checking if the minigame had started
Yeah if it has to run an event like almost every 10 ticks it can use up a lot of cpu usage
ok idk what to do then
even if a player spinned their head that would count as player move
there is a cool method
getFrom and getTo
use the respective .getBlockX .getBlockY getBlockZ
im confused now
to check if the player has walked at least a full block.
i dont want them too
i hate spoonfeeding...
i want it to go off when they hit the ground
ok i want a copass to target a specific player but i dont know how to make it target another player help
?paste
this will make it so that they have to walk at least a fullblock in the z and x axis for event to fully tigger.
get the player and use the lodestone
I dont want them to have to move
I want them to get tped when they touch the ground
You can;t target a specific player, only their location at that point in time.
i already know that
yes i know i just want it to target there position
yeh but they gotta move to touch the ground, i gave you the basic now make the foundations
ok ill try
i already hvae most of the stuff i just want to do a command that adds someone to a team that i can then track
You need to provide the target players location, however you choose to select a target
this should help you
still he would need to update it using a task.
yea i know what im doing i just want to know how to get a pl,ayer onto a specific team that i can then track
yes, but he's not even got teh target player yet
ill figure it out this wont work
this is helpfull but i already have that and just need to get the target
Interfaces? Abstract Classes, Normal classes that require parameters in constructor?
that would be a specific team
the code i sent you will work with some adjustment to it
just need to add another check in the line
you have x and z, what's missing?
nah ill just debug myself i need it to trigger the instant they touch the ground
the other one workerd
worked
ok, have fun with your 3Tps then 😄
try with 10+ players, i don't think you'll get that far, also learn java pls i was also at your point asking stuff like this, it only took me like 1-2months
Well if there is no other way to it without the player moving 2 tps it is
you didnt have to do him like that
So I am capturing BlockDropItemEvent and changing the drops however whenever for example a player breaks scaffolding the attached blocks still drop as scaffolding instead of the modified. Same with breaking the block a torch is on, the torch drops instead.
Are there any events for that which I'm missing?
There is an ItemSpawnEvent
How would I know with that event if the item is indeed from a block drop instead of something else?
You wouldn’t
Oh, welp
hi!
error
Could not pass event CreatureSpawnEvent
java.lang.NoClassDefFoundError: org/apache/commons/codec/binary/Base64
at ...getSkull(main.java:1422) ~[?:?]
Just google it
Like
I don't quite understand what is wrong here, did I import something wrong?
it takes 5 seconds
Better answer
thx!
Hey, I would like to store coords in a yaml file but I can't figure out the best way to easily use and modify it (I don't want to name children as there is not specific amount) so far I tested
warzone_drop_spots:
-
x: 0
y: 1
z: 0
-
x: 1
y: 0
z: 0
But I'm struggling to parse it into coords as I get a java Object 😒
Is there a way to cancel a runnable scheduled with runTaskTimer from inside of it's self?
can a dev tell me who developed TAB plugin
and why it disappeared from sipgot and planet earth
I mean should I worry and remove it from my server does contain a trojan etc
I'll try this one thanks
hey hey
how might i calculate the time it's been since a player has jumped
using PaperMC PlayerJumpEvent )))))))))
Spigot not paper here
you can generate the a new date when the event is fired, then do a check for
- if the player has a date already set to them
- if the date is after the current (should be if they have one)
then from there you can just use a simple method to figure out the time between both dates
simple way of tracking time between events
thank you for providing an answer!
tbh im mainly just checking IF the player is jumping with the Move event, but that does help too as i will need that :D
ahhh, def go ask in the paper discord if you're using their api since they may have a way to check that specific thing
there might be a isJumping() method but can't say (sorta like isSneaking())
is there any way to get the glowing effect to only apply to the visible parts of the armor stand rather than the whole thing?
Hey, I've got the setupEconomy() function taken from the example for the Vault API: ```java
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
return false;
}
economy = rsp.getProvider();
return true;
}
That returns false for some reason
Vault is running on the server and is set as a depend in plugin.yml
yeah, i'll have to haha
isJumping is client-side, so you might wanna be careful abt that
yeah
everytime I spawn in a magma it spawns in as a small one
You need to set the Size of your Magma Cube after spawning it.
Here's a Example Code:
cube.setSize(3);
0 = Small
1 = Medium
3 = Large
(If I recall correctly)
cube
ty i'll try it
Wrote a quick program that shows Slime Sizes https://i.imgur.com/9jv2be9.jpeg
0 and 1 are actually the same
So the values are 0, 2, 3, ...
smh scammed
sender.sendMessage should work for console and a player, right?
Okay
Wanted to be sure
Is it just me or is Gradle more trouble than what it's worth.. Like what even is this
does anyone know how I could call a block break event to actually break a block
don’t run it with intellij then
liek say I right clicked on stone and wanted that to break the block with the sound and possible drops
I LOVE YOU
gradlew -v says it's running Java 8, and gradlew build fails with the same error.
Oh might not be, hang on
What gradle wrapper version?
Also here set it to 16
Edit then apply and you probably have to reload gradle project
It should appear
😔
It's so useful and such a pain at the same time
Lol yeah
Hey guys, I wanted to ask if you can set gamerules for a specific area / chunk?
no
alright, thank you
Can someone help me with nms, that is not as easy as just sending some packet to player? (I am asking first, because I don't want to uselessly spam here with the problem)
i'm trying to use guice on my plugin but Preconditions gives me an error
I guess spigot has that dependency built-in
an old version
how can I fix that?
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V```
?scheduler
ok, so I have problem, that I am trying to make custom entity, that extends EntityInsentient, but should be sent to client as armor stand (and i couldn't find any way how to do it, because the entityType must extend the class that is extended by the custom entity)
And I also have one more advanced problem and that is, that I don't understand what exactly is ControllerMove.a(double, double, double, double) doing and how to use it.
because I need to extend EntityInsentient because I am using .setGoalTarget(), .......
does anyone have any idea on how i could trigger a left click animation for a player?
tf is goleTarget?
nope, it extends EntityLiving, otherwise it will be ok, because i can still use it as an entity type even if it extends the class that I am extending
product of working at 2AM, *goalTarget
ah
who do you want to see tha animation?
I ahve a plugin where you can easily replant a crop by rightr click it with the seed but no animation is happening
well you can play the animation for anybody but not the player itself
not for the player who replants
thats fine by me
can someone do an example of a scheduler that run a task 1 seconds later?
you gotta use this packet: https://wiki.vg/Protocol#Entity_Animation_.28clientbound.29
Bukkit.getScheduler().runTaskLater(plugin, () -> {code}, 20L);
(but i didn't test it if it works)
20 ticks = 1 second dude fixed it and now i look like stupid
is it just good form to load worlds on load instead of on enable?
am I misremembering? I thought that's how world management plugins did it
yeah I think they do
it's hard to tell because there's not exactly a message with a cutoff but they consistently seem to load it either on load or at the very top of on enable
Thank you
I figured that if I put world loading on onload instead of on onenable it might curb the weird issues I'm getting with startup entity loading (I'd then load entities on onenable) but I'm not sure
it seems like these methods called consecutively
but idk... ¯_(ツ)_/¯
I mean, I am pretty sure that I have failed to load a world on onload method
what bug
I ran into a weird issue where either entities are double spawning or not despawning correctly when adding them to a world that just loaded on startup
do you use something to load the world or is it just spigot
just the spigot api
if I wait for a few ticks it works just fine, but I would rather not do that if I can avoid it
I should revive my double chunk loading detection code
public static ItemStack amethystLeg() {
ItemStack amethystLeggings = new ItemStack(Material.NETHERITE_HELMET);
LeatherArmorMeta amethystLegMeta = (LeatherArmorMeta) amethystLeggings.getItemMeta();
amethystLegMeta.setColor(Color.PURPLE);
amethystLegMeta.addEnchant(Enchantment.DURABILITY, 70, true);
amethystLegMeta.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 10, true);
List<String> amethystLegLore = new ArrayList<>();
amethystLegLore.add(format("&7Amethyst X"));
amethystLegMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
amethystLegMeta.addItemFlags(ItemFlag.HIDE_DYE);
amethystLeggings.setItemMeta(amethystLegMeta);
amethystLegMeta.setLore(amethystLegLore);
return amethystLeggings;
}
``` I get this error ```Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem cannot be cast to class org.bukkit.inventory.meta.LeatherArmorMeta (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem and org.bukkit.inventory.meta.LeatherArmorMeta are in unnamed module of loader 'app')
i see
i wonder why
missed that one lol
thanks
So I am making a book that when you right click it, three axolotls spawn, but I want to add a cooldown of 20 seconds. How would i do that?
If you need to I can show you my code
You could keep track of Players who used the Book in a List and remove them again after 20 Seconds using a Scheduler#runTaskLater()
hmm
Map with a time stamp
give me idea for plugin
no
a plugin with an AI that can make any other plugin
Oh, I got a idea. I think I should create some kind of /eval command in game so the developers don't have to write a new plugin to test just around a single line
alot of bots aren't made in java
true
and they don't have bukkit and other imports
Yep, I do have a JDA Minecraft bot with java eval command with Bukkit
i'll now make that plugin commands based
and possibily post it as resources??
Mine lets you run it as a command or a book
This is more of a theory question, but why can't block changes be asynchronous?
They can. Its just takes so much more that doing async would cause more harm then actually just changing the block.
You can set blocks via the api which would be hard on the thread or use nms which you can do alot more with but complete asynchronous block change would require modifying the world file itsself. And alot of packets.
ah okay, thanks!
Look into Block change via NMS before trying to go completely async.
Not that I know of. Just use InventoryClickEvent and check for an merchant inventory.
I think you'll have to use InventoryClickEvent
It's a real pain when they there is no Events for the required fundamental thing
_<
Could always make your own with the provided methods in the API or PR one to spigot. Doubt it will ever be accepted though. I see 6 year old threads of the same thing xD
why do lighting bugs happen? (specifically using fawe) how can i fix those from a plugin? idk how that works, but i know there are plugins to fix it, and none are updated to 1.17, so i have to make my own
not worse than the alternative, wait half an hour just for a medium size cube with world edit, or even worse, put blocks manually
I think there is some methods to set lighting level
but i want to use the vanilla lighting, using the light emiting blocks, not just add light
and in some places, the light emitting blocks put with fawe dont emit light. //fixlighting doesnt fix it
didnt know about that
what is the second arg, radius in chunks?
what is a heightmap? can it be fixed somehow?
Heightmaps are data stored in the world file that save the highest block for certain conditions in each column
use a Map<Player, Long> and currentMillis
I'm noticing that my BlockExplodeEvent doesn't trigger at all for TNT and such, any ideas as to why? Am I using the wrong event for that?
I mean the TNT is exploding, its the event that isn't firing.
Entity explode event as it’s a primed tnt
thanks mate, didnt think of that!
👍
Afaik block explode event only fires for world.createExplosion
Actually beds and respawn anchors, didn’t think of those
@EventHandler(ignoreCancelled = true)
public void on(final @NotNull EntityExplodeEvent event) {
event.blockList().forEach(block -> {
Collection<ItemStack> drops = block.getDrops();
if (Math.random() < event.getYield()) {
drops.clear();
drops.addAll(Arrays.asList(new ItemStack(Material.STICK)));
}
else
drops.clear();
});
}
So I have this code for EntityExplodeEvent however for whatever reason the drops from the blocks are not modified. I'm assuming this is similar to BlockDropItemEvent in that you need to spawn item entities yourself, but I don't even see a place to get the list of item entities, so I am quite lost.
Even if I can just cancel dropping items that would be fine because then at least I can summon the entities with the block locations, but that doesn't seem to be the case.
So maybe set the yield to 0 and summon the items myself with block locations, that's what I'm thinking.
Cool, I'll give that a shot, thanks for the tip!
I know, I just like to do it everywhere I can haha.
lol fair
I'm using PrepareSmithingEvent to set a dynamic result - it works, but I can't actually take the resulting item out. any ideas what I've missed
how can i add something to the default config of the plugin and then save it?
I am getting a LOT of errors for Block Break event
This is the log
And this is the code
There are no errors in the code
Cannot invoke "java.lang.Integer.intValue()" because the return value of "org.bukkit.persistence.PersistentDataContainer.get(org.bukkit.NamespacedKey, org.bukkit.persistence.PersistentDataType)" is null
This tells me that your first calls to p.getPersistentDataContainer().get(new NamespacedKey(main.getPlugin(), "xp"), PersistentDataType.INTEGER); is null because it has not been set yet.
I'm struggling to decide which is the better code structure
@AllArgsConstructor
public class InventoryEventListener implements Listener {
private final Economy economy;
private final GUIManager manager;
private final PersistentDataUtil util = GalaxyShopAPI.getApi().getUtil();
private final Messages messages = GalaxyShopAPI.getApi().getMessages();
private final GalaxyShop shop = GalaxyShopAPI.getApi().getShop();
or, just require all of them as an argument
in the main class, if all were arguments
getServer().getPluginManager().registerEvents(new InventoryEventListener(manager, util, getEconomy(), messages, this), this);
getServer().getPluginManager().registerEvents(new InventoryEventListener(getEconomy(), manager), this);
and if they werent
the persistent data container call returns null
27
ok 1 sec
and also potentially 28
getOrDefault
oh
but i dont want it to be 0 whenever the server starts
i only want it 0 when the player mines the very first time
//pseudo
player:hasMined > player.getPersistentDataContainer().getXp else 0
how to make a timer in the plugin, wich wont block the plugin, but does something after a certain time?
use -1 instead then
and the code format above
new BukkitRunnable() {
@Override
public void run() {
// Code
}
}.runTaskLater(Plugin plugin, Long ticks);
understood, thank you
?scheduling 👈 see also
Ohh ok so this will get the datacontainer if its not null and if it is null then it will give 0
right?
how would you code it?
code what?
wym
//pseudo
PDC pdc = player.getPDC()
int xp = pdc.getOrDefault(key, PDCType.int, 0)
// ...
updateXp()
namespaced key
and is pdc persistent data container?
thats pseudocode its just an example
question, if some one does /command firstarg
and i do args[1] will it return null or will it raise an error (im kinda new to java :( )
error
arrays start at 0
ArrayIndexOutOfBoundsException
// pseudo
array = [elementOne] [elementTwo]
array[0] // elementOne
i know, i just wanted to know if the second parm was not given, what would it return
thank you
guys i have been having issues registering commands, can anyone help?
Sure, what's the problem ?
Send Code!!!!
gimme a sec
this is the code for my grappling hook command
but i dunno how to register it
in main
like without args, i could do it
You do
getCommand("nameFromPlugin.yml").setExecutor(YourClass);
You also won't really need this anymore
if (command.getName().equalsIgnoreCase("custom_items")) {
im just starting out so,..
All good, glad I was able to help!
yes ill use label.equals
Not even that!
then?
It will only execute the Method if you actually enter the Command
You don't really need a Check if the Command equals this
They will get their own Executors
oh
The Command itself and it's Aliases will all link to that Executor
ok thx
👍
im still getting an error :(
okey
its not spamming to help someone, this channel is literally to help people
True, will do so for further occasions then
NVM, typo XD
in a config.yml like so :
jail:
default_time : 60 # in minutes
location :
x : 0
y : 0
z : 0
i can access the x by giving the jail.location.x as the path right?
yep
Emotes not working Sadge
🤔
Hello i created leaderboard of kills with MySQL but it doesnt sort correctly someone can help me?
PreparedStatement select = connection.prepareStatement("SELECT * FROM PVP_stats ORDER BY 'kills' DESC LIMIT " + showPerPage + " OFFSET " + ((Integer.parseInt(page) - 1) * 10));) {
ResultSet top = select.executeQuery();
for(int i = 0; i < showPerPage; i++) {
if(top.next()) {
String uuid = top.getString("uuid");
int kills = top.getInt("kills");
int deaths = top.getInt("deaths");
}
}
Instead of "SELECT * FROM PVP_stats ORDER BY 'kills' DESC try "SELECT * FROM PVP_stats ORDER BY 'kills' ASC ?
yep
Ok i will try thanks
The ASC stands for ascending and the DESC stands for descending. You use ASC to sort the result set in ascending order and DESC to sort the result set in descending order. https://www.mysqltutorial.org/mysql-order-by/
in here : PotionEffect(PotionEffectType.WEAKNESS,timer.intValue(),100, false, false), setting ambient to false and particles to false, player or others wont see the effect particles on the player right?
i dont understand what ambient does here
You just need to set particles to false
Getting from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffect.html#isAmbient()
ambient's effect: Makes potion effect produce more, translucent, particles.
declaration: package: org.bukkit.potion, class: PotionEffect
so it just makes it to generate more particles ?
Seems like it, yes.
will doing "some thing \n something else" go to the other line in minecraft chat?
it would take me a lot more time to try and see it, then to ask it😕
Best way to learn is by doing/trying it yourself and hopefully running into errors
Cuz u best learn from errors
thats where break points come in, does alot of tricks.
i totally agree, but the stuff that im asking are super simple stuff.. and i know the answer to most, i just want to be sure (and im a bit lazy ;) )
is there an function to turn minutes or seconds into ticks, or do i have to do the math?
I mean
1 second = 20 ticks
Ticks = seconds * 20
Seconds = minutes * 60
i know that, i was just looking for a more clear and good looking way :/
...
Just make your own util functions
Right also, I'm having this issue with BlockDropItemEvent where I am changing the drops for the broken block. That's all fine, except for the fact that when I for example break a block with a torch ontop of it, the torch drops instead of my drop. I saw somewhere that I will need to use BlockPhysicsEvent, but I'm not quite sure how to go about that as I didn't see anything in there specific to breaking, only movement.
I asked a while ago previously but the only answer I got was to use ItemSpawnEvent, which isn’t useful because there are other cases where an item may spawn.
declaration: package: org.bukkit.event.block, class: BlockBreakEvent
might be worth checking that out
That only triggers when the player is the one breaking the block
Plus that’s already what I’m using in conjunction with BlockDropItemEvent which is a result of BlockBreakEvent
why cant i do this?
@Override
public void onEnable() {
instance = this;
new BukkitRunnable() {
@Override
public void run() {
instance.getCommand() // getCommand doesnt exists
}
}.runTask(this);
}
its not that
i was wondering how i could send an action bar message.. and i found this :
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("an string"));
is there an easier way to do it? like player.sendActionbar or something?
you can always just make a function
check if a command is overwritten if it is registered later
Tried this code:
public void onBlockBreak(BlockDropItemEvent e){
e.getItems().forEach(item -> {
if (!item.getItemStack().getType().equals(Material.SAND))
return;
item.setItemStack(ItemBuilder.buildNewItem(Material.STICK).setDisplayName("§bTest").build());
});
}```
And everything is working perfectly fine for me?
The Sand Drop is getting replaced with my Custom Drop and the Torch Block above drops the same old Torch, I don't see the problem here?
My case is basically getting the torch to drop a custom drop as well
OH, I see, let me try something
Nope, still works for me
Same code, just changed Material.SAND to Material.TORCH
No, as in when you break the block under the torch both that block and the torch drop custom drops. I have no problem with doing it for the block broken, it’s when the block the torch is on is broken when it’s not quite working
Yes, player.sendActionBar is a thing it seems nevermind, paper specific
Quick question: Does anyone know how to create a variable that creates a block and where you can then also edit the block data?
huh
Disregard that, apparently it’s a paper specific thing
So, let's say a Stone Block drops a Stick called "A" and a Torch Block drops a Diamond called "B"
When you break the Stone Block with a Torch above it, the Stone drops the Stick, but the Torch drops itself ?
could you rephrase that? It just sounds like you want a function
Or am I misunderstanding something here ?
Correct that’s what’s happening
Let me check
Still works fine for me
public void onBlockBreak(BlockDropItemEvent e){
e.getItems().forEach(item -> {
switch (item.getItemStack().getType()){
case SAND:
item.setItemStack(ItemBuilder.buildNewItem(Material.STICK).setDisplayName("§bA").build());
break;
case TORCH:
item.setItemStack(ItemBuilder.buildNewItem(Material.DIAMOND).setDisplayName("§aB").build());
break;
}
});
}```
This is the code I used
Could I see your code actually? I have a feeling I know what the issue is
We should've prob. started with that one lmao
Lmao yeah sure thing, just one moment
So I would like to place blocks and for this I wanted to store the blocks in variables, like you can do with itemStacks, to then put persistent data in the blocks and also set the facing from the glass.
I mean you can make your own class for that. But only containers can have persistent data
when placed*
oh yeah i mean persistantdatacontainers
https://paste.md-5.net/kanibayita.cs
All drops are being set to this different one because right now I’m just testing changing in general before anything custom
Why not setItemStack on the existing item
so its not possible to create and configure Blocks like ItemStacks?
Just in case I ever want to have something drop multiple of something
Also you only drop one there, regardless of the collection size
?
Multiple separate items?
Yeah I might do that
man
Don’t gotta do us like that
Shame that list can’t be written to
Just make a class that holds the data. Its not too hard
fuck
Lol I spent forever trying to do that before realizing it wasn’t possible
I don't quite understand how you mean that sry
gecko10000#7137 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.
What kind of English language vomit
hey idk if this is the right place to ask but anybody know how wynncraft has client side mining for wood? Ik it has something to do with structure blocks
yeah
all packets
you can just send packets to spoof the block being there despite it not
or vice versa
so like
mine the block
cancel the event
packet stuff
so the block isnt there for the player that mined it
right?
yeah exactly
cool beans thank you
well, that would be the easiest way of doing it
id recommend just going with that method
but
keep in mind when changing blocks with packets, once the chunk is unloaded or player dies it will reset
so you have to keep track of that
meh shouldnt be a problem
But for temporary things, like trees shouldnt really matter too much
yeah thats what i thought
Anyone know how to change the level of the light block itemstack?
im new to java so sorry about that
what do you mean?
haha thanks! you gave a great answer
the new light block in 1.17
there is different levels of it
lichen?
ah right. Would most likely be in the ItemMeta
but there doesn't seem to actually be a way to set the level on an itemstack
no
huh
There’s also the approach Hypixel takes in Skyblock where players break the same blocks but they slowly regenerate, different from what you’re asking but something to also consider doing
yeah thats how its working rn
it changes to bedrock whenever its mined i just wanted to see if maybe i could have smth cool like that :)
Go for it, sounds like a really nice idea
will do! gotta do some reading up on packets so ill be back with more questions
check out protocolLib
Seem to get somewhere with the BlockStateMeta
But I'm getting an error when I cast it to an itemstack so
OH I FORGOT ABOUT THE PACKET STUFF IN PROTOCOLLIB
yeah, far easier then regular packets
If you want to mess with packets yourself though without relying on protocolLib or anything check out this website: https://wiki.vg/Protocol
Wait wrong link lmao
Edited
oh wow
oh wow i have no clue whats going on here edit: was reading the wrong section
for editing and saving a the default config, do i do :
@Override
public static FileConfiguration config;
public void onEnable(){
getConfig().options().copyDefaults();
saveDefaultConfig();
config = getConfig();
//In some other file
Main.config.set("world.spawn.x", X);
Main.config.set("world.spawn.y", Y+1);
Main.config.set("world.spawn.Z", Z);
try {
Main.config.save(.instance.getCurrentPath());
}catch (IOException e){
//Log the error
}
like this? cause it raises file not found.
what should i do?
His code is fine, so long as he actually has a config.yml in his jar
other than static abise
he can scrap the copyDefaults line
but save default is correct
ok i got lost, i have a config.yml, now should i do RolePlayCore.instance.saveConfig(); or RolePlayCore.instance.saveDefaultConfig();
saveDefault, it will create folders and copy your yml from your jar to your data folder
what if its already created and i want to change it?
So long as your config.yml is actually IN your jar
it will not copy it if there is already a file there
if you want to change values you just getConfig(). It will load the config.yml from the data folder
im doing that, but i dont know what to pass into .save method of FileConfiguration
you just getConfig().saveConfig()
it takes an string but string to what
im gonna test saveConfig()
Is there a way to check if a server command exists from a string? I can already check bukkit commands using Bukkkit.getPluginCommand but how do I do that for a command like /say? Other than events like PlayerCommandPreprocessEvent
alright so packets question
lets say i want to use viaversion
wouldn't that break everything and crash people on lower versions?
because you'd have to import net.minecraft.server.(version)
No because you’re importing server side
The client never sees what’s going on in the plug in
I'm not sure how this is related to ViaVersion, but yes, you have to import from different packages depending on the server's version.