#help-archived
1 messages · Page 73 of 1
whichever block you're targeting, make it the center of a 3x3x3 bounding box?
or whatever arbitrary size box you want
@fair abyss create first bounding box, then extend that bounding box out one, and check if there is anymore blocks connecting to that vein. If there is, extend the box in that relative direction
no loop involved with that 😉
that's true, it does have the expand methods
can you write a simple code?
cus i dont understand with just saying "check if there is anymore blocks connecting to that vein"
@fair abyss this is one of those perfect times to use recursion
recursion?
recursion is where you call your method from inside your method
yes, but not quite the same though
actually same.
wait hold on
so you're saying that recursively looping 3x3x3 boxes is not as fast as making a giant box, searching outside it, then recursively looping through it anyway?
recursion is faster then a standard loop
depends on the method's part which will be "re" done (dont sure how to tell) when recursion
but recursion is a form of loop, but it isn't the same as a loop. A loop keeps repeating until it is done. recursion keeps calling your method until something stops it. However both of these things happen in two different areas of the JVM. Recursion to the JVM is like calling your method multiple times without having to code a loop for it to do that.
Are veins contained entirely inside of a chunk?
So how does it know the blocks in black outline exist?
"recursion keeps calling your method until something stops it."
you can stop your loop whenever you want.
Red being the one I mined, blue being the bounding box.
if you use recursion to extend your box outwards if it detects more blocks that were connected it will know about them
i just wanted a method that wont loop
You'd have to extend every direction then lol
and you tell a method that loops
well, you can add a constraint?
well yes, you need a way to stop it
otherwise it will just be a race condition if you don't have a way to stop it lol
well, that is why they call it re-cursing
but unlike say a while loop, it will eat up all your resources and you will get stack exceptions XD
it will be same creating box and checking vein's relatives and expanding
or without box checking vein's relatives
you blow your stack, and out come the expletives
too many english word, much than my "capacity"
and google translate wont help me further 😛
anyways, I have told you the most optimal method if you are making something to run on a large server or keeping in mind performance
recursion is faster then standard loops and if done right more efficient, and contains checks are always faster then loops
Floodfill is recursion though
arent all our suggestions recursive
Still wondering why floodfill isn't better, considering it doesn't loop and is strictly recursive 🤔
Only if you implement floodfill to be recursive
floodfill?
Is there another way to implement floodfill?
Recursion is a special thing in Java that isn't done automatically
here is a simple example of recursion
int fact(int n)
{
if (n < = 1) // base case
return 1;
else
return n*fact(n-1);
}
you can think like it repeats itself until a conduition is true
So that example is finding factorials of a number, however it will overflow if the base case isn't reached or not defined
Recursion just means the method calls itself, yes?
yep
Then obv if you don't escape it you'll be in trouble
but it can be "infinity" and it will cause error
if you code it wrong*
Well, as for Qther's problem, I would do a recursive flood-fill instead of messing with expanding BoundingBoxes ¯_(ツ)_/¯
theres a class called "BlockIterator" whats about checking it?
BlockIterator, iterates over blocks in a defined area or line
can be async?
not that I am aware of
just searched class but couldn't see
@upper hearth can you try running this class async?
personally if it was me, I would just map out veins in region files though
isnt that the same as listOfBlocks.forEach(block -> something())
What class, BlockIterator?
yep
world.getBlockAt is not thread safe last I recalled
im just gonna start implementing my method and if its broken ill use someone else's
anyways, me, I would just implement an outside application to map veins though
just wondered, is dynmap running async?
But that is if I was going to have something on my servers though and not something that was a public plugin
because I mean, why not just read the region files yourself since you already have access to your own files 😛
me lol
^
didnt expect it to evolve into this
sorry dessie, I tagged you 😛
Nice thing about coming here, is sometimes you come out with more information then you were expecting
dont think i need to check anything yet i got a will and a plan
and other times, certain things get pointed out that you didn't bother thinking about as well
or didn't realize was a thing as well
that's true
Idc that you tagged me lol
🙂
so while although we may not agree on the best method here, you have plenty of information to go off of
no guarantee 😛 we can explode your server
lmao
@fair abyss Hm, yeah you can run it async looks like
You want me to try to delete the blocks?
I'm curious now tho lol
Yeah okay can't actually do anything to the blocks async, but you can iterate them async
you can't delete boxes async. If you try you will get concurrentmodification exception
due to async, other player can be interact with already in queue vein
it can be some problem
or CME for short
boxes? blocks?
too many word here 😄
I got IllegalStateException
I guess that is the other exception to occur
so said "if possible"
then delete them sync
or
the best
taskchain
aikar has api for this
BlockIterator kinda cool tbh
combine blockIterator with chunksnapshot
yep
and some taskchains
and some thread safe things
you have just crafted power puff girls!
but I would only design a public plugin that way though
if I were to implement this on my server, I would go the route of doing all this ahead of time. That is read the region files, store the veins into a binary file. Then when I need it, use memory mapped file to load all that information 😉
But what if the world changes :(
memory mapped files don't have to be loaded into memory all at once either
how is the world going to change ahead of time?
magic
Idk that seems like more work than it needs to be
my method works with pre-generating a map
so I mean, you would get all your ore veins then
I mean that might be the way to go if you know you're always gonna have 1 world lol
region files is just raw NBT, nothing overly complex about it
the point is to have the veins mapped out ahead of time, so that when players interact with said veins
you already know its a vein
and then you can save the data or remove it afterwards as it isn't needed
It wouldn't work
talking about this
then it doesn't count as one obviously so it takes care of player made ones if you didn't want it to work on player made ones
it can be best for "trees"
cus you cant just place it
and a exploit: a tree can grow
Well for trees you wouldn't want to do that
not for all trees 😄
could just make custom trees that are predictable instead of unpredictable trees
but I think there is some api for trees though
Meh, but with our methods before you could easily transfer that code to trees
thats the painful part
Floodfill and the bounding box are decently dynamic
its 6.04 am
i should sleep hours ago
if you could find a "good solution" tag me, i will read it when i wake
there is api for trees
but it isn't really all that great for say when trees have logs everywhere
like them super large trees for example
Yeah
the api would work for simple trees though
im talking about "well custom trees"
well I know, was kind of hoping there was some api though that would help in getting all the logs of a tree
since the server should know what a tree is and there is, but its really limited on it
there is that, and if you use the second method for generating the tree you can get all the blocks that are part of said tree
so that is handy for custom trees or even regular trees if you wanted to generate them
Hey guys, how do I get a mapview from an itemstack?
ItemStack i = p.getItemInHand();
MapView map = ((MapView) i);
map.setScale(Scale.CLOSEST);
This is what I have tried but it's not working
Am I allowed to make an auto update-downloader? I understand how to do this. At some point Bukkit had some specifications when it came to automatically downloading content. I'm just wondering if this could breach any Spigot TOS in any way.
how to disable spawner spawning
@keen compass I've got this, but when I click it doesn't change the zoom
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack i = p.getItemInHand();
MapView map = Bukkit.getMap(i.getDurability());
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
map.setScale(Scale.CLOSEST);
}
else {
map.setScale(Scale.FARTHEST);
}
}
https://www.youtube.com/watch?v=WcKQgZVDbfI&feature=youtu.be
ItemStack item = new ItemStack(Material.FILLED_MAP);
MapMeta meta = (MapMeta) item.getItemMeta();
meta.setMapId(mapId);
item.setItemMeta(meta);
@frigid ember
once you have a proper map, you should be able to set the scale
@keen compass theres no .setMapId, I'm on 1.8
Hello, this probably isn't fully related, but is there a way to completely update a line(Frame) on FeatherBoard.
hey I was wondering if anybody knew how to fix this issue
I have a shop set up in ShopGUIplus
but all of the spawners in the shop turned to stone after I updated my server
so did the spawners in crazy crates
PLEASE HELP
@wanton vine like updated minecraft versions?
in that case its probably a id mismatch
or something wrong with nbt
nbt?
yes
whats that
named binary tags
so I mean what can i do
How can I use FAWE in my plugin?
nvm
worked it out lol
nvm
I can't use this for some reason
EditSession editSession = ClipboardFormats.findByFile(file).load(file).paste(worldName, new Vector(0, 64, 0), allowUndo=false, true, (Transform) null);
It says that it can't find load in ClipboardFormats
can someone look over my code and try to see why it doesnt work at all and in fact crashes the server?
https://github.com/Vonr/RubiksUHC/blob/master/src/main/java/me/qther/rubiksuhc/scenarios/VeinMiner.java
nvm did it
The static abuse...
But if I were to guess, you're most likely creating an infinite loop of destroying blocks.
I'm new at plugin dev but aren't you missing a break; statement for this case? case WOODEN_PICKAXE:
switches are interesting tho
it goes to next case
it's considered as one case
for example
switch (mat) {
case oak_sign:
case birch_sign:
case everyothersign:
return true;
default:
return false;
}
for every signs return true
otherwise false
@tiny dagger in Java 14 switch case is a lot better 😄
yes, just pointing out that the updated java versions are better 😛
maybe slowly we can instill everyone to progress forward XD
that wouldn't be a problem tho
GC is a lot better in Java 14 as well, in case that matters to anyone
right now i have both java 8 and jdk 14 installed
😂
i'm afraid to uninstall java 8
maybe it messes something
I have java 8 installed, but I don't use it. I usually only keep older versions for purposes of debugging in the event it might be a java dependent thing or something
not very common but it happens sometimes
the only version I don't have and just completely skipped was java 9
gave me way too many problems and it appears many other projects did the same thing as well lol
you think?
Well, it is pretty obvious if it is
sorry i'm dumb
but i don't understand why from java 7 to 8 we moved fast
but from 8 we just stoped to it
🤔
because Java 7 was being dropped from support
Java 8 is an LTS release and its support ends at the end of this year
yes
the next LTS is Java 11
It's throwing an NPE
Java 16 is the next LTS after that if I recall correctly
would you ;lioke to see my very crappy code?
everyone has crappy code at one point or another
i've just started
so don't feel bad, but if you want help with the NPE, some code does help 😉
i have a good knowledge of java
?paste
but not very good knowledge of stuff
9ok
thanks
That's my code for is gn
gen
i'm using a command
and its just throwing null pointers everywhere XD
can you also create a new paste for the stack trace you received ?
ok
anyone know what might cause smoeone to instantly eject after being added as a passenger
if they press left shift, you get removed from a vehicle @green hornet
im doing spawnEntity and addPassenger but hten onDismountEvent is firing
are you also spawning the vehicle at the same time?
wait a tick between spawning your entities and adding the entity to the vehicle to allow the server to register the entity
it is the only thing I can think of =/
is there a free plugin where i can right click an item in my inventory and it can give me money from my economy plugin?
ok
Did anyone find out why my command is throwing an NPE lol
@idle zodiac so the first NPE is your world is null
reason being is the world doesn't get created because you don't have a method to create it
getServer().createWorld(WorldCreator wc);
would recommend a new class file that sets all the appropriate stuff for WorldCreator
I don't know what skript is
you are welcome 😉
premium plugins have an expiration date you know?
TF
it gets removed
but if you have it on pc it shou;ld still work
my braincells are deceased by the amazing engrish
if you dont get updates, so what
tf
that 's a bit dodgy
@idle zodiac your english is so good that you still struggle understanding bad grammar but okay 😉
no
ym eniglsueh nrie ag rea good
fuck
ye
ik
i mean
my enslguih is top tier
XDDDDD
i can't wait for someone to be wooshed now but
ye
XD
So
I'm trying to create a world
I was using multiverse before but am experimenting with WorldGenerator
How do I use it effectively?
hej, question, so i made an update for my plugin but how do i change my project version?
(in intelji idea)
I use a queue plugin, and I was wondering if there is a way to have a string of multiple words count as one argument?
guys I need help
I am making a listener event on some class, but I know I need to put this.getServer().getPluginManager().registerEvents(this, this); on Main class on onEnable, but how I connect this to the other class that the listener is there?
please help me
pleaseeee
you use this.getServer().getPluginManager().registerEvents(new ListenerClass(), this); in the Main class
Ok, thanks!
'this' is not required tbh
But someone can explain me what this line of that command doing?
it's registering a class that must implement a listener
if you don't register it , the event handlers won't work
Hey anyone working on spigot can give input regarding https://hub.spigotmc.org/jira/browse/SPIGOT-5737
Why are we doing it like that? or am i free to put it back to a normal state
maybe its not for survival purposes
Might be some rpg thing where they just walk about as civilians
Is it possible to cancel the 'respawn point set' message when clicking a bed, only using the spigot API?
I'm pretty sure there's a way with nms
Entity#addPassenger(anotherEntity)
spawn the entity then add the passenger to it
how
Entity#addPassenger(anotherEntity)
spawn entities a and b
Then a.addPassenger(b)
oh ok I will try
but the entity is not a
is just in a command
look:
@EventHandler
public void onLand(ProjectileHitEvent event) {
if (event.getEntityType() == EntityType.TRIDENT) {
if (event.getEntity().getShooter() instanceof Player) {
Player player = (Player) event.getEntity().getShooter();
if (STlist.contains(player.getName())) {
//spawn zombies
Location loc = event.getEntity().getLocation();
loc.setY(loc.getY() + 1);
for (int i = 0; i < 3; i++) {
loc.getWorld().spawnEntity(loc, EntityType.DROWNED);
}
}
}
}
}
use backticks for code like
```java
code
```
Entity drowned = world.spawnEntity(loc, Entity Type.DROWNED);
what
can you replace put that in this?
@EventHandler public void onLand(ProjectileHitEvent event) { if (event.getEntityType() == EntityType.TRIDENT) { if (event.getEntity().getShooter() instanceof Player) { Player player = (Player) event.getEntity().getShooter(); if (STlist.contains(player.getName())) { //spawn zombies Location loc = event.getEntity().getLocation(); loc.setY(loc.getY() + 1); for (int i = 0; i < 3; i++) { loc.getWorld().spawnEntity(loc, EntityType.DROWNED); } } } } }
Spawn 3 zombies separately, each on separate variable with Entity type
World w = loc.getWorld();
Entity zombie1 = w.spawnEntity(...);
...
Entity zombie3 = ...
zombie1.addPassenger(zombie2);
...
Can my friends recommend an enhanced plug-in for spigot1.11.2 version?
World w = loc.getWorld(); Entity zombie1 = w.spawnEntity(...); ... Entity zombie3 = ... zombie1.addPassenger(zombie2); ...
@sweet hemlock Ok, thanks!
how would i make a flying minecraft
gamemode 1
Turn gravity off for minecart and increment it's y position?
/fly
Minecart can't float with effects
Turn gravity off and vector it up
I haven't tried it, but I'd test that out
You mean the effect that will be attacked by the latent image shellfish?
That's status effects, yeah, and minecarts don't have it iirc
They cannot. Only living entities
World w = loc.getWorld(); Entity zombie1 = w.spawnEntity(...); ... Entity zombie3 = ... zombie1.addPassenger(zombie2); ...
@sweet hemlock And how I can make the zombies not fire on day and give them a item?
Search it up, maybe do something in their inventory
@ripe ledge don't ask how to do everything, look it up on the docs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html everything is well documented there and has everything that you can do to a entity
Ok, thanks!
Hello, my friend bought plugin and now is removed and not work. Please help
@ripe ledge don't ask how to do everything, look it up on the docs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Entity.html everything is well documented there and has everything that you can do to a entity
@pastel basin I cant find answer to how equip items to entitys on web...
I want to give a drowen a trident
Someone knows how??
Use LivingEntity instead of Entity type
Or use Drowned type
Drowned zombie1 = (Drowned) w.spawnEntity(...);
Do you know what is npc.getBukkitEntity().getPlayer() for ? Why we can"t just cast EntityPlayer into Player ?
Because EntityPlayer does not implement Player
Player is an interface in Bukkit, CraftPlayer is its implementation. Patched into NMS is a field in the Entity class to hold an instance of CraftEntity
Hey, does anyone know how I could display an item in chat?
You know how you sometimes see on servers you can type a command and the item name will be sent in a chat message in square brackets
and if you hover over it you can see the details of the item
miaochat
By default, the generated configuration files are all in Chinese. You only need to modify the configuration files.
right... I'll have a look I guess. thx 🙂
😋
Hello, my friend bought plugin and now is removed and not work. Please help
Why was it removed? be more specific.
Use LivingEntity instead of Entity type
@sweet hemlock Where
How do I get the item name of a default item?
I tried ItemStack.getItemMeta().getDisplayName()
but I don't think it has a name since it's default?
You mean the localized name?
ItemMeta#getLocalizedName()
ah, thx
Someone please help meee
I am trying to summon drowen that cant burn in day and I can't find answer anywhere how to do that
Someone knows?
And how to give the drowen a trident
add helmets to them
search it up on google you already asked this question 10 times, don't expect anyone to be giving you code just like that
Epicnitcity is still doesn't seem to work?
Hi, I Have a question. How to add permission on tab completion, I mean block default spigot command tab completion for player.
@formal nimbus I think you can't get the localized name from a created item, from what i read you can only get from items in the player inventory
I am trying to load a schematic, but when I recreate the schematic it isn't changing when i recreate the world
how tf am I meant to get the name then
you can check if the item has a localized name #hasLocalizedName or #hasDisplayName and if not just format and return the material name
and loading an oold version oof the schem
I guess yeah
also
for some reason my bukkit scheduler is ending at random points
the scheduler should stop once the timer reaches 3
I originally set it to 0
but the timer keeps going down to -4
and now it keeps going to 1/2
you cant mix async with bukkit api
wut
use
new BukkitRunnable() {
//runnable
}.runTaskTimer(plugin, 20l, 1l);
if you want to stick with BukkitScheduler you can always use #runTaskTimerSynchronously or whatever is called, I don't use BukkitScheduler
BukkitRunnable#cancel();
show me
since you are inside BukkitRunnable class you can just use cancel()
o swick
is there a way I can slow down the delay from inside the runnable?
so if the delay is a timer
*delay is a variable
and I change the variable inside the runnable
will that update it?
🤔
or you can run your code say every other time. add a counter inside your runnable, and an if
or you can run your code say every other time. add a counter inside your runnable, and an if
why check stuff and do math when you can do what I just said
what are the 2 itemIndexs for?
@formal nimbus runTaskTimer(plugin, delay, period);
np
however
what
why does a mutechat plugin need this????
the plugin is called chatmaster
why check stuff and do math when you can do what I just said
because depending on your use case canceling and starting runnables can be more expensive than incrementing an integer
my timer varaible will be reset right?
no because you already instantiated the class with that integer, when you do runTaskTimer it doenst instantiate it again
it just runs the method run()
because depending on your use case canceling and starting runnables can be more expensive than incrementing an integer
@formal nimbus you should probably use this then
instead of cancelling and running again just check the integer with a fixed time
wdym
I sent you an email 2 days ago, can someone reply?
for delete my account
at deletion@spigotmc.org
but noone replied!!
@fleet crane
I know that you think about account deletions.. please help me
@formal nimbus will the runnable run less than 20 ticks?
no, the runnable delay is going to increase
how much?
delay between each repeat I mean
by 1?
I'm making a crate scrolling system
so imagine it's scrolling fast
then when the timer gets low
it slows down by 15 / timer
or something like that
so every repeat
it gets slower
is this safe?
I dont want a plugin having all teh details of my pc
but its for a mutechat plugin :/
how did you do it with the old code
@pastel basin I didn't lol
it seemed too dificult
but this seems easier
this is easier however it may be a little performance expensive
@wind dock it's the standard metrics system. you can also opt out of it, read the last line in the screenshot
do any other plugins need it
so as long as the timer is accurate (which it is now) then it's gucci
besides mutechat?
many plugins use the same metrics site
oh
the plugin doesn't need it to do it's thing
but is it safe to just not opt out?
I think you would need two integers, one for the time passed and one for the delay you want to set it
it should be perfectly safe to opt out
is it safe to also not opt out?
that's up to you. it's a bit of a privacy thing, but the stats are aggregated for the most part
this is complicated idk how to this now
lol
as I said, it doesn't really matter
it's just a small cosmetic thing which would have been nice
but I appreciate the help 🙂
let me scribble down quickly something that might help Jet
😮
int counter = 0;
int delay = 0;
new BukkitRunnable() {
counter++;
if (counter > delay) {
// your code
delay++;
counter = 0;
}
}.runTaskTimer(plugin, 20l, 1l);```
uff
how do you format this thing for java?
` ` `java
` ` `
I am trying to load a schematic, but when I recreate the schematic it isn't changing when i recreate the world
https://hastebin.com/uqaviqexid.java
It's just saying "Index out of bounds" and loading an oold version oof the schem
How can I loop through this list backwards?
List<String> lines = plugin.getConfig().getStringList("lines");
int counter = 1;
for (String line : lines) {
objective.getScore(line).setScore(counter);
counter++;
}
```Java
// CODE
@formal nimbus so that's sort of a linear increase. first time it runs at 1 tick, next iteration after 2 ticks, 3rd after 3 more ticks and so forth
you can play with the increments and formula for different increases
int counter = 0;
int delay = 0;
new BukkitRunnable() {
counter++;
if (counter > delay) {
// your code
delay++;
counter = 0;
}
}.runTaskTimer(plugin, 20l, 1l);```
@wise dock interesting, but I would then have to restart the bukkit runable with the new delay right
@remote socket Use the traditional for loop starting at 0 and increasing until the length, but reverse it by starting at the length and decreasing until 0
no, that's the beauty of it
your code only runs inside the if when the time has passed, nothing extra for you to do
but how does that increase the delay between each loop of the runnable?
@remote socket Use the traditional for loop starting at 0 and increasing until the length, but reverse it by starting at the length and decreasing until 0
@marsh nova Then how do I get the list item
I think I've worked mine out lol
it doesn't increase the delay of the loop, but your relevant code only runs every xxx loops
lines.get(index)
wait nvm i have another solution
I'll try that now
List<String> lines = plugin.getConfig().getStringList("lines");
int counter = lines.size();
for (String line : lines) {
objective.getScore(line).setScore(counter);
counter--;
}
don't forget to add your cancel() at some point to finish the runnable 🙂
List<String> list = new ArrayList<>();
for (int n = list.size() - 1; n >= 0; n--) {
String element = list.get(n);
}
My solution also works
don't forget to add your cancel() at some point to finish the runnable 🙂
@wise dock yep 😄
@formal nimbus one other thing i wanted to mention, when you do Bukkit.getScheduler().cancelTasks(...) it cancels all runnables for your plugin. If 10 people are doing crates it'll cancel for all of them. Probably not what you want, so it's almost never a good idea to do CancelTasks unless say you do cleanup for your plugin
that why if you dont want to cancel the task inside the runnable you can just store it in a field and cancel somewhere else
it will cancel only the delay that was running
I've got it working 😄
I used the example heatseeker gave me, but I set the delay to -50
that way it's 2.5s before the delay actually kicks in
at which point it slows down nicely
now I can add some randomness to the delay
anyway I can turn this into a string?
I tried adding .toString afterwards
but it didn't wokr
getType() returns all caps
so I was trying to convert to string to do .toLower()
Is this an enum you made or
enum?
....yea
How can I run a command on an entity?
Is this the Material enum?
;-;
@formal nimbus try java player.getInventory().getItem(13).getType().name()
o
I see
👌
Has someone used SQLite here?
dispatchCommand
thanks
you know the javadocs exists tho
@formal nimbus try
java player.getInventory().getItem(13).getType().name()
@wise dock works thx
you're welcome
I've spawned in an entity, but then I can't run the command on it as when I set the entity as a variable it doesn't like it
Run a command with entity? What?
so
I'm Loading a schematic
and I want there to be a chest with items
but I cant have a chest with items in a schem
So I'm trying to either set a block with nbt
or spawn an entity then execute a setblock command
The Problem is though
that it's in a different world
sooooo.....
what tf do i do XD
unless...
I use skript for that bit
and use a custom skript cmd
probably is the easiest way out lol
@EventHandler
public void MesadeEncantar(PlayerInteractEvent e) {
Player p = (Player)e.getPlayer();
Block b = e.getClickedBlock();
if(b.getType() == Material.ENCHANTMENT_TABLE) { /*line 16, error*/
return;
}
if(e.getAction() == Action.LEFT_CLICK_BLOCK) {
return;
}
if(!(p.getItemInHand().getType().toString().toLowerCase().contains("pickaxe")
|| p.getItemInHand().getType().toString().toLowerCase().contains("sword")
|| p.getItemInHand().getType().toString().toLowerCase().contains("axe")
|| p.getItemInHand().getType().toString().toLowerCase().contains("boots")
|| p.getItemInHand().getType().toString().toLowerCase().contains("helmet")
|| p.getItemInHand().getType().toString().toLowerCase().contains("leggings")
|| p.getItemInHand().getType().toString().toLowerCase().contains("chestplate")
|| p.getItemInHand().getType().toString().toLowerCase().contains("spade")
|| p.getItemInHand().getType().toString().toLowerCase().contains("bow")
|| p.getItemInHand().getType().toString().toLowerCase().contains("hoe"))){
e.setCancelled(true);
p.sendMessage("§cError");
return;
}else {
e.setCancelled(true);
p.chat("/enchantmenu");
return;
}
}
Why is it wrong? Say it's on line 16, where I scored, but I don't see an error.
just use enums
@idle zodiac java Chest chest = (Chest) block.getState(); Inventory inventory = chest.getInventory(); inventory.clear();
And then you add items to it as you do with any other inventory
You just need to be sure that chunk is loaded, obviously
Almost everything you do will cause a sync chunk load anyways
Which is awful but unavoidable on spigot
Question, how do i change my project.version in intelji idea for spigot?
its probably a stupid question but how?
Personally I'm using Eclipse, but have you tried Google?
i have tried, but it only shows results on updating the ide
Google this "how do i change my project.version in intelji idea for spigot" without quotes and look at first 1 -2 results 🙂
@old barn that looks really bad
Is anyone proficient with Asynchronous Database Structure with the usage of the API? If so can somebody help me out to get a better understanding? I ended up developing my database way back not thread-safe and I am experiencing server lag with high player counts. This wasn't an issue with low amounts of players such as 20, but after the server increased with players I have noticed lag with the LoginEvent etc.
If so please @ me, thanks.
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html
this is pretty easy to use and can make database usage async
I'm getting a null-pointer exception when trying to change the block at a Location. It's saying that the chunk is loaded, and I tried my best to load the world. What's going on?
https://hastebin.com/kigixawahe.java
I have a question with the vehicles plus lite plugin. How do I become an admin in aTernos?
@idle zodiac what the hell is that code? -_-
World world = Bukkit.createWorld(worldCreator); will work for you
You just call all of the world interface
@trim fjord You should have used async for every database structure. Especially for login event. Spigot has async events(thanks to md_5) and you should use it.
As FendiTony777 mention it above, you may use CompleteableFuture task.
@elfin wave
@chrome edge Not what I meant, but thanks.
It's hard to explain to be honest sorry my man 😂
@trim fjord how?
can i get help here about spigot software
Please explain with more details so we could help you easily.
I'll DM you
k
don't ask to ask, just ask
also @trim fjord you can use a thread pool and connection pool, both fixed and of equal size, to maximise db performance
combined with completablefuture and if you need it use Guava or Caffeine caches
ok what does this part of config.yml mean (bungee)
`listeners:
- query_port: 25577
motd: '&1Another Bungee server'
tab_list: GLOBAL_PING
query_enabled: false
proxy_protocol: false
forced_hosts:
pvp.md-5.net: pvp
ping_passthrough: false
priorities:- lobby
bind_local_address: true
host: 0.0.0.0:2560
max_players: 1
tab_size: 60
force_default_server: true`
- lobby
@marsh nova I use HikariCP
i guess this is the wrong server
@chrome edge what evrything
@trim fjord you can also make the server's scheduler into an Executor for use with CompletableFuture
k
Executor asyncExecutor = (cmd) -> Bukkit.getScheduler().runTaskAsynchronously(plugin, cmd);
although the default thread pool is not the best tbh
the scheduler thread pool, that is
._.
what's the difference between host and listeners
bungee
hey lol, got no clue how to fix this error
code: https://hastebin.com/rituqicufi.java
error: https://hastebin.com/poconaniju.bash
simple: java if (!(sender instanceof Player)) { sender.sendMessage(Utils.chat("&cYou can't give yourself an item! You're the console")); return true; }
yw 🙂
huh
anyways i have another issue 😦
i have a listener which gives the player an effect when they equip these bits of armour
doesnt wanna work
listener:
whoops
also i strongly suggest you make some sort of method for verifying item meta and applying the effect instead of copying basically the same code 4 times. better readability and easier maintenance down the road
now im getting this error when i equip the armour https://hastebin.com/xegacazino.pl
repost the listener, seems you changed something in it
yea, check for null if they have no armor equipped in that slot
Equipment methods are all nullable
It's worth noting that methods in the API are all annotated with whether or not they're nullable
u lot are 10x more helpful then the guys on {TheSourceCode} discord server
can u give me an example
cuz i gotta do this like 100x
if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET))```
nullpointerexception is the easiest to fix
the hardest NPE I've had is when a sun.misc.Unsafe object was null because reflection failed on jdk11
Well that's just your own fault lol
?cla
Imagine catching NPE
someone actually recommended that
on the discord for a plugin I contribute to
"why not just catch all errors when the shop is loaded, and then no more NPE!"
catch Throwable and swallow the exception. The best approach
While what you quoted is terrible advice, catching NPEs actually depends on context, in some it makes perfect sense.
such as?
Such as in production when you must 100% ensure something keeps working, and you have a way to recover the state after catching whatever exceptions it is you never thought should happen but did.
in that case, you might want to catch RuntimeException or Exception
but never specifically NullPointerException
That is correct
I could perhaps point there could be edge cases where the recovery depends on the exception types, but we're nitpicking already 🙂
CraftBukkit does that for event listeners, commands, plugin enabling, etc.
catch Throwable, print the exception, let users know there's a plugin error
?help
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
lol still doesnt wanna give the effect on armour equip
what code should i send u
cuz there r no errors
it just doesnt give the effect
@wise dock or @subtle blade ???
@oak stump does the player get the message just not the effect, or neither?
aha. then it's a different issue. you sure your meta text matches exactly?
well then make sure 🙂
you could print it in the server logs and take a peek after you equip the items
you got this
@boreal tiger closest I found to detecting villages is https://dev.bukkit.org/projects/villageinfo
well, that is great!
mhm thats not quite what I was looking for but thanks. I'll keep looking @torn robin
what i do when such state happens is i take a break, and try to get my mind off it for a few mins to cool down
I agree, taking breaks helps when you're stressed over a certain problem
mhm right
what defines a village though?
is it certain blocks?
k doesnt work hrere is code of whole plugin, dont ask, some is messed up https://www.mediafire.com/file/rs8ebr2xkk7l15z/SpecrtumCore.zip/file
i'd look into structure blocks and world generation
what exactly are you trying to achieve?
i think "village" as a concept is based on world seed, so by reverse engineering the formula used in world gen you can determine where one would be placed
k doesnt work hrere is code of whole plugin, dont ask, some is messed up https://www.mediafire.com/file/rs8ebr2xkk7l15z/SpecrtumCore.zip/file
@oak stump .
@torn robin .
yeah but I meant, in the new versions a player can technically create a new village by bringing some villagers
again though what are you trying to achieve?
@wise dock could u find the issue, there r no errors and it just doesnt work
that's a different type of village, based off certain criteria such as valid housing and so forth
@oak stump i could, but honestly i don't have the time right now to look at a whole plugin. Plus it's valuable lessons to learn to debug issues youself. I can offer pointers in how to debug it though
yesh plz
right, thanks for the help. 👍 @wise dock
okay so print messages in the server logs. the more the merrier. print whatever crosses your mind, before if and inside the if.
then equip the item and see which ones actually get logged, so you know what code ran
print the meta text too, so you know how it looks, etc.
not in this case, because you said player doesn't see the message either
so i'd look into why the code inside the if block (sending the message and applying the effect) doesn't run
print things in the log
aha, now think where you'd print the next message, like right at the beginning of the event handler
if that doesn't appear either you know what to do 🙂
yep
have i registered it right???
Main: https://hastebin.com/aluxukafov.java
Listener: https://hastebin.com/zuhewilomi.java
nvm...
well, no at first i looked at your main and saw nothing getting registered, then realized you did it in the listener. i usually prefer to do it in main, because this way you can see at a glance which ones are event handlers rather than having to go thru the entire source code
yes, that is good form
however i do have a question: in your inventory click, you go thru all online players and then do your thing
why?
like, think about it for a moment because the error is a bit subtle i think here
so you're triggering whatever action when player is clicking in an inventory, right?
and you're looking to see if they have armor equipped. are you sure that happens in the same tick?
lol not at all
correct
so what would i do about that
so whatever action resulting from the inventory click will be visible next tick
not at all, it's a bit subtle this time, not something really obvious
so what would i do about the tick thing
like when you're trying to close an inventory from a click in an item in that inventory in the same tick. doesn't work.
lol i have never encountered waiting any amount of ticks
how would i do it
?ticks
lol
how to wait?
cmon mr bot
anyone know how to make it so that placeholderapiu doesnt detect me as online even though im vanished? I use supervanish
Supervansh has a placeholder for it?
one way, not saying it's best but works in this case is something like this: ```java
@EventHandler
public void onInvClick(InventoryClickEvent e) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
// your code here
}
}, 0L);
}
No idea
Idk have you checked the placeholder list on github?
yes
one way, not saying it's best but works in this case is something like this: ```java
@EventHandler
public void onInvClick(InventoryClickEvent e) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
// your code here
}
}, 0L);
}
@wise dock thank youuuu
//EventHandler
Bukkit#getScheduler().runTaskLater(plugin, ()-> {
//code w/o override run method
}, 0L);
@oak stump I'd say use lambdas since Runnable accepts that
whut
@naive goblet how is your code better from a learning point of view than explicitly listing all the code?
I think learning is a dynamic process. Learning how to spare lines and what some stuff is in code might be helpful later?
what does 0L mean
Represent ticks
0L in this particular case means next server tick
oh so it would apply after they equip the armour
it would run that code after the event that triggered it finishes to completion
^
think about it this way; what happens if the event is cancelled?
like say another plugin cancels the inventory click event?
so the way it works internally is all plugins that listen to InventoryClickEvent have a chance to process the event, then next server tick the armor (in this case) is actually equipped and visible if none of the plugins canceled it
why is there 1 bracket 0l);
so the method runTaskLater expects a long number as the last parameter. in this case we wait 0 ticks, and have to put a L to convert it to long instead of int
public void onInvClick(InventoryClickEvent e) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
Player p = (Player) e.getWhoClicked();
final ItemStack helmet = p.getInventory().getHelmet();
final ItemStack chestplate = p.getInventory().getChestplate();
final ItemStack leggings = p.getInventory().getLeggings();
final ItemStack boots = p.getInventory().getBoots();
@Override
public void run() {
if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET)) {
if (helmet.getItemMeta().getDisplayName() != null) {
if (p.getInventory().getHelmet().getItemMeta().getDisplayName().equalsIgnoreCase("§0Assassin Hood")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, true, false));
}, 0L);
}```
this doesnt work?
no it doesn't
im so confused lol
you have to look at the inventory next tick
Because it's kind of how it's built. You could as well do this:
Bukkit.getPluginManager().registerEvents(new Listener() {
}, Plugin.getPlugin(Plugin.class));
put everything except the first line with Player p inside the runnable
yep
@oak stump Another thing to think of is explicit else or implicit else.
It avoids nesting if statements which can be very hard to read.
and the first line with Player p before Bukkit.getScheduler(). You will also have to write it like so java final Player p = (Player) e.getWhoClicked();
so the logic reads like so: you get the player that clicked, wait 1 tick, then start looking in the inventory for armor
//nested
void method() {
if (condition) {
if (condition2) {
//code
}
}
}
//implicit else
void methodd() {
if (!condition) {
return;
}
if (!condition2) {
return;
}
//code
}```
lol im so confused
public void onInvClick(InventoryClickEvent e) {
final Player p = (Player) e.getWhoClicked();
final ItemStack helmet = p.getInventory().getHelmet();
final ItemStack chestplate = p.getInventory().getChestplate();
final ItemStack leggings = p.getInventory().getLeggings();
final ItemStack boots = p.getInventory().getBoots();
if ((helmet != null) && (helmet.getType() == Material.LEATHER_HELMET)) {
if (helmet.getItemMeta().getDisplayName() != null) {
if (p.getInventory().getHelmet().getItemMeta().getDisplayName().equalsIgnoreCase("§0Assassin Hood")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1, true, false));```
Can u do this one for me so i understand
okay but before i do it, did you understand the logic part?
That would be to spoonfeed you, no
like how things work?
okay but before i do it, did you understand the logic part?
the logic yes
how to do it
no
okay, there's a bunch of new concepts for you so it's perfectly normal it's a learning curve here
ye lol, usually im pretty good at this stuff, even helping others but ive hit a road curve xD
Okay so think like this
Bukkit.getPluginManager().runTaskLater(plugin, ()-> {
//code that should be executed after the event
}, 0L);```
Idk in your case as heatseeker said it might be worth checking if the event was cancelled or not?
lol where did heatseeker go xD
Idk
Idk in your case as heatseeker said it might be worth checking if the event was cancelled or not?
yesh but why would it be cancelled if that is the only plugin
Okay @oak stump I'm going to give you a bit of code, but I want you to promise me something
I want you to read it carefully and either ask or Google anything you don't know
also it might be worth mentioning when working with java use the java keyword in the block
```java
Don't just take it verbatim and move on, because it contains a lot of new concepts that you need to learn
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInvClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
checkInventoryNextTick(p);
}
private void checkInventoryNextTick(final Player p) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
final ItemStack helmet = p.getInventory().getHelmet();
// more stuff here
}
}, 0L);
}```
Start from the first line, go thru them carefully until you learned and fully understood all concepts
Once you do, I'd like you to tell me what the first line does exactly
There is only line 3 on the board
Is there perhaps something should be in the loop
//Event will always try to run and ignore if cancelled
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInvClick(InventoryClickEvent e) {
//Create a p variable from the event we can reference later
Player p = (Player) e.getWhoClicked();
//Use method from our own class
//this defines it as it will be from this class
this.checkInventoryNextTick(p);
}
//Custom function
private void checkInventoryNextTick(final Player p) {
//Creates a new BukkitTask
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
//Code to be executed in the task
//When called it will be called after the event is handled
final ItemStack helmet = p.getInventory().getHelmet();
// more code with the if's
}
//0L to make it execute 0 ticks later
}, 0L);
}
@oak stump idk if this helps you but mhm
@remote socket whats wrong?
Or I mean explain more
does 0L actually work? I've always done 1
The last line in the config is the only line which shows on the board
@torn robin Well, how it's handled should still make it execute afterwards?
Because it's kind of how it's built. You could as well do this:
Bukkit.getPluginManager().registerEvents(new Listener() { }, Plugin.getPlugin(Plugin.class));
@naive goblet
Please don't do this
lol
ooh that's a GOOD IDEA
🤡 .
If you really want to, use .registerEvent() 😄
Do I need to make a new Team for each line on the board?
Check so you have money on your acc
Is there a way to sync permissionsex through all of my linked servers on bungee cord? So I would add a player to a rank on 1 server and it would apply to all servers?
why i cant just buy with paypal
Lmao pex
