#help-development
1 messages · Page 1474 of 1
well saveDefaultConfig only takes things from that file and puts it onto disk
that is the only way to have comments with the bukkit config api yes
you need to write your config, defaults, and comments in the config.yml
ah..
Ok, last thing then ill stop bothering you
We did just tell you, saveDefaultConfig takes the config.yml from inside your jar and saves it
?paste
so doing this https://paste.md-5.net/bequmoniba.java is pointless?
yes, it is pointless
send the line 45 in snoballLouncher
((Player) p.getInventory()).updateInventory();
why do you cast updateinventory to a player
you are casting an Inventory to player
Because i need to remove a snowball from the player
p is a player not the inventory
lmao i dont even know why addDefault exists its useless you would add every default in the config.yml in the plugin anyway ;-;
ah
also theres already a bunch of crates plugins why are u making one???
((Player) p.getInventory())
method calls take precedence over casting
the p.getInventory is executed first, yielding a PlayerInventory
only then does the cast happen
which then tries to cast a PlayerInventory into a Player
which explodes
i see
((Player) p).getInventory().updateInventory();
this casts p to Player first
and then calls the method
same principle as with how 1 + 2 * 3 is different from (1 + 2) * 3
yeah
how do i get all entities in a 20 block radius
using player.getNearbyEntities
How do i fix this?
you are passing it a String
it doesn't take a String
either make it take a string, or give it what it wants
yet still it overrides the old config with the new one
you're using config.save or saveconfig or something somewhere
basically, you never want to use bukkit's saveconfig or config.save or whatever
no i just checked that
all of them nuke the comments
^
and what should i use to edit the config file
nothing
you simply don't edit the config file through code
you edit it through the config.yml file
anything other than that nukes comments and newlines and formatting
does the set(path value) call the saveconfig?
Or you take the time to find an API that keeps comments
Wether it be modern SnakeYML or something third party, you can probably find it on the forums
or make ur own
lmao it was a DestinyCrates.get().saveConfig(); in the onDisable
no
@wraith rapids for(ItemStack item : ((Player) p).getInventory().getContents()) {
causes https://paste.md-5.net/losafogida.cs
bruhhhhh google wants me to confirm my age on youtube and i dont have a id or credit card ;-;
Caused by: java.lang.NullPointerException
a NullPointerException is thrown when you try to call a method on a variable that is empty
check for null
make sure it isnt
before doing the code u do with the itemstack
just that you have a variable isn't a guarantee that there is something actually stored in that variable
for example, your p variable could be empty
ah
it might not point at any object
it might be a null-pointer
and calling any methods on it would throw a null-pointer exception
i wonder what null actually goes to XD
In C it does, so it wouldn't be a big surprise of java doing the same
no, item is defined
i just thought of it as like a space that anything u put in it just disappears
you define it in that exact line
right
like I just said just because you've defined something, you can't expect that something to have a value
ItemStack item; declares aka defines a variable named item
but does not assign anything to it
that means item is empty, it points at nothing, it's a null-pointer
you figure out what is null
and then either make it not null, or don't do stuff with it if it is null
on that line, there are 3 things that could theoretically be null
firstly, p itself could be null
secondly, the return value of p.getInventory() could be null
thirdly, the return value of inventory.getContents() might be null
ok
now, figure out which one of these 3 is the case
so its not p because i have Player p = e.getPlayer();
ok
please only for debugging xD
Or get those wonderful java 15 NPEs
yeah, it doesn't look good, only use for debugging
^^ the dude that added these is crying everytime people do this
i don't have the effort to try and explain how to do that
so it has to be getInventory or getContents
cause muh spigot tutorial says java 8
java 17 when
should i just run an if statement ``if (p.getInventory() == null){System.out.println("getInv is null");}
that is more effort than hitting enter 2 times
That and long chains like with builders
Iirc inventories can’t be null
Only empty
good point, pretty soon I'd imagine
since it's an LTS version
Yeah, then we just wait for all the linux distros to upgrade to 17 as their default
and we shall never have this issue again
neither inventories nor inventory contents should return null
rip all plugins
why xD
lmao why does electron even use so much cpu
if you are in trouble because of jigsaw
you were doing something very shady to begin with
for(ItemStack item : ((Player) p)
.getInventory()
.getContents()) {
you're jumping 6-7 java versions
depending on what got deprecated and removed
some things may break
lines 45-47
I mean ye, java 9 removed a bunch of incubators I believe
and obviously nerfed reflection into the groud
It’s running an engine (v8 iirc)... to render a page
^
well this says line 48
if(item.getItemMeta().hasDisplayName()) {
It’s like running a basic browser just for one or two pages
an item may not necessarily have item meta
the return value of getItemMeta may be null
Yeah it contains Chromium iirc
check hasItemMeta or check if meta == null
and don't call getItemMeta multiple times
every getItemMeta call clones the entire itemmeta
which can be catastrophically expensive for larger items
call it once and store it in a variable
if(item.getItemMeta().hasDisplayName() && item.getItemMeta() != null) {
the other way around
the first statement is run first
which would explode
check first, then do stuff
and then again, also incorporate NNYs suggestion
final ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasDisplayName()) { ... }
for(ItemStack item : ((Player) p)
.getInventory()
.getContents()) {
final ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasDisplayName()) {
like so?
since we're no longer debugging, you can put those .'s back on the same line
the exception should have at least changed
45 for(ItemStack item : ((Player) p).getInventory().getContents()) {
46 final ItemMeta meta = item.getItemMeta();
47 if (meta != null && meta.hasDisplayName()) {
getContents is the one that returns an array right? that's nullable iirc
that is, the individual elements of that array may be null
which means that item may be null
well yeah you gotta check for null and air items first lol wyd
oh ok
which brings us to what I always tell everyone
whenever working with bukkit inventories
always check for both null and for air
if (item == null || item.getType() == Material.AIR)
bukkit is incredibly inconsistent with whether empty slots return null, or whether they return an itemstack of air
best always check for both and save yourself from a bunch of headache
wouldnt we want !=?
depends
if we want to cancel, we want ==
if we want to do stuff, we want != and &&
if item is null or item is air, don't do thing X
if item is not null and item is not air, do thing X
show code
for(ItemStack item : ((Player) p).getInventory().getContents()) {
final ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasDisplayName()) {
if (item != null && item.getType() != Material.AIR) {
again, again, again
check first
final ItemMeta meta = item.getItemMeta();
this happens before you check
repeat after me
you can not do stuff with the contents of a variable
if the variable has no contents
right right
well
it seems like that was that
thank you so much for your patience
👌🏿
Ait I got a BlockBreak Event for when chests are broken but one of my things doesn't work unless I use static and I am trying to not use that.
ArenaManager class
public static List<String> testerConfiguration = new ArrayList<>();
public static List<String> chestConfiguration = new ArrayList<>();
private final ArenaConfig arenaConfig;
public ArenaManager(ArenaConfig arenaConfig, TIMV game) {
this.arenaConfig = arenaConfig;
}
BlockBreak Event class: https://paste.md-5.net/ijotoqexuw.cs
Main class for block break event:
pm.registerEvents(new BlockBreak(this, this.arenaManager), this);
is there anything i can do to stop getConfig().set("something", something); wiping comments and the other things
It doesn’t
getConfig.set doesn't
Saving the config does
can i do anything about that then?
something better
ah
something that doesn't depend on half a decade old snakeyaml
very specific
is there a way to disable ppl from getting illegal items from their saved hotbar while in creative mode?
glhf basically
Hey, does anyone know how I could possibly make a fake EntityPlayer able to have gravity and be vulnerable?
hah?
an npc?
oh also can someone link me to the plugin that combines wither bossbars
yea packet based player which is also npc
i though npc already have gravity?
never worked with npcs
XD
NPCs are just a packet sent to the client
In order for them to move, you need more packets
well yes, but in the newer versions of minecraft (1.16.5), there is a function for each, for example for taking damage, I have already found it, you can override tick function and apply your damaging
so no need to send additional packets manually
but just stuck in applying physics, which still trying to find...
the class does extend the EntityPlayer and implements the values it needs, and I do also add it to the world via addEntity, and then sending packets for showing npc, and etc...
for reference of what I mean https://www.spigotmc.org/threads/custom-entityplayer-class-with-skins-that-take-damage.437594/
:) ait anyone know?
how would you make an entity not attack another entity?
does it require teams with friendly fire off?
EntityTargetLivingEntityEvent
wdym
why is it not EntityTargetEntityEvent
XD
i mean i got the attacking down
That works as well I guess
lemme explain what happens better
wait EntityTargetEvent is legit EntityTargetLivingEntityEvent
mhm
I want a zombie that acts like a dog, I figured out how to make the zombie attack the mob that I hit, but when the zombie attacks that mob it then turns around and targets me
thats the issue, i want it to continue targeting the mob I hit
should i just make it so that when the zombie hits the mob an event is called to target the mob again?
or is there a better way?
i mean here is the code:
Creature zombie = (Creature) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
zombie.setTarget(entity);
yeah its api way
ok
ok, are nms pathfinders better?
You can set the target again and cancel any target event on the player
hopefully well get pathfinder api in 1.17
well nms pathfinders directly controls the AI basically
you can remove the player from the hostile list
oh, thats exactly what i need
ok, lemme find one
gonna just bump my thing
why is a manager used as a single instance thing?
shouldnt the manager hold multiple instances
e.q.. the manager should have a list of Arenas in wich each have theyr own lists or such
me?
yes
also you didnt rly give relevant code
for example how you are accessing the lists
The list isnt the problem
me not being able to use the constructor in the block event is
arenaManager.setChestLocation(event.getPlayer(), event.getBlock().getLocation());
cant access this
we dont know what setchestlocation is
There is nothign wrong with it
also what the error is
wut Caused by: java.lang.NoSuchFieldError: END_PORTAL_FRAME
thats not a constructor issue
at com.onarandombox.MultiverseCore.listeners.MVPortalListener.portalForm(MVPortalListener.java:74) ~[?:?]
just not when I use it as a constructor
yes probably the second one
nope no error
I just cant seem to use the constructor, but it works fine when I use static
and I have no idea why
what is the ide error
no error
There is no error so I have no idea why it cant use the constructor
ait got an error message out of it there
and line 27 is arenaManager.setChestLocation(event.getPlayer(), event.getBlock().getLocation());
This might be a dumb question but I want to create a function that I'm pretty sure does not fit into the listener or event type so I guess I'd just make a void function with no parameters? I'd like to leverage world.getEntities to then set their gravitiy all at once every x minutes
What do you guys think would be a good starting point?
um BukkitScheduler takes in ticks and it does it every x ticks
20 ticks is one second
1200 ticks is one minute
or be lazy and do 20*60
lol
yep i usually write that as time
yeah but how would I define the function? can I just do it in main as a void function without parameters/arguments?
yeah
public void blah () {code}?
i mean its a simple void function
yeah but then would I just call it in main?
hmm can someone link me to a turotial on how to use maven?
So I saw this for loop online
.forEach(world -> world.getLivingEntities().stream()
.filter(entity -> (!(entity instanceof Player)))
.forEach(LivingEntity::remove));```
can someone explain that last line? how can I go thru all living entities and set their gravity one at a time? doesn't seem like there's a variable for them
i forgot what these types of loops are called but Im pretty sure they're a shortcut to the full for loop. If you guys tell me the name ill research it in java
sweet I got it!
its a forEach loop
can I expand it like a regular loop instead of it being a one liner?
i dont think so its normally for one line
actually i think u can
i think its .forEach((entity) => {code});
what are we talking about
idk tbh
wait forEach can run a function???
i generally don't like streams but my unbiased recommendation on them is to forget about them until later
inside it
no
stick with imperative for loops for the time being under you've found some better footing
foreach should be one line statements
ik that
but its not limited to one line
if you have to use -> {
then use a for loop
@tawdry plume don't worry about it for the time being but that last line is a method reference
.forEach(world -> world.getLivingEntities().stream()
.forEach(LivingEntity -> LivingEntity.setGravity(false)));
}```
basically a substitute for (entity) -> entity.remove()
that's what I'm trying
thanks
which is basically a substitute for new Consumer<LivingEntity>() {@Override public void accept(LivingEntity entity) { entity.remove(); }}
which is basically a substitute for
public class LivingEntityConsumer implements Consumer<LivingEntity> {
@Override public void accept(LivingEntity entity) { entity.remove(); }
}
new LivingEntityConsumer()
XD
but yeah, until you get some better footing on what everything does
steer clear of streams
and maybe lambda expressions too
thanks, so those are called streams good to know
the .stream() part is called streams
i've done those in a diff. language but i'm still getting under Java
haven't used this language in a while
whats wrong with lambda
the -> part is called lambda expressions
the thing wrong with lambdas is that it isn't super easy to grasp what they are and what they do if you're a beginner
this didn't do anything for me
but didn't throw out any errors when loaded into the world
I'm calling the function in onEnable
rewrite it with imperative for loops
make sure the world is loaded before doing the function
hmm ok ill search up how to do this
and this
for (World world : Bukkit.getWorlds())
for (Entity entity : world.getLivingEntities())
entity.remove()
or more verbosely
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getLivingEntities()) {
entity.remove();
}
}
these are so-called "enhanced for loops"
yeah i like that way lmao the {} makes it more easy to read
they take a multiple of something, and then iterate over its elements one by one
for example Bukkit.getWorlds() returns a List<World> if i remember correctly
List<World> is a bunch of World's
so the : operator takes one World at a time from that list, and runs the { code } block once for each element
everything in bukkit that returns a array of something it returns a List<SomeClass>
idk i just think ArrayList is better even tho its not that different
to me
the return type is a List intentionally
unless necessary, you don't want to program against the implementation
you want to write your code against the most generic interface that provides what you need
lol
f.e it is very strange for something to return an ArrayList rather than a List
ArrayList is a List
doesnt it have a few extra methods?
that doesn't make it not a List
100%
10000%*
what is a good way to see if the worlds have loaded before executing code? do we check for a not null world?
if world != null then proceed?
where are you obtaining this world
local server
no, how are you obtaining this world value
trying to make a plugin to make everything in the world not have gravity
what are you calling to get this world
i'm asking because my answer depends on your answer
not going to lie i've been searching thru the docs looking for the right method to use for this
i want to use the world where the players are currently located in. I'm guessing this way we use less resources
or we just do it x amount of blocks around the player
in that case, you need to get yourself a Player first
do you want to do this for a specific player, or all players
then the starting point of your code should be Bukkit.getOnlinePlayers()
which returns a Collection<Player>
that is, a series of several players
in arbitrary order
i'd like to test the code for just all worlds right now then dive in that way. just want to see if it works but if i execute it i'm pretty sure it's executing before the server completely finishes loading because the script is being called under onEnable
does that make sense?
oh hmm
unless you've changed that in your plugin.yml
show code
import org.bukkit.*;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.*;
//import org.bukkit.entity.Player;
//import org.bukkit.entity.LivingEntity;
public class Main extends JavaPlugin {
private static Main instance;
public static Main getInstance() {
return instance;
}
@Override
public void onEnable() {
instance = this;
getServer().getPluginManager().registerEvents(new Listeners(), this);
System.out.println("We're LIVE");
callGravity();
}
public void onDisable() {}
public void callGravity() {
for (World world : Bukkit.getWorlds()) {
for (Entity entity : world.getLivingEntities()) {
entity.setGravity(false);
}
}
}
}```
when in doubt throw stouts at it
isn't there World#isLoaded?
probably
depending on how you obtain it, it could be null as well
there aren't very many cases where you'd get your hands on an unloaded world I don't think
well, probably only when loading on startup
or when using custom worlds. idk if postworld is called after or before custom worlds
RIP
well, i guess you wanna set gravity to false for every entity?
if so, you'd probably apply it to a spawning entity instead of on enable. because that doesn't apply on later-spawning entities
How different is Spigot from Fabric modding
well
fabric is modding
spigot is server-plugins
or to be more clear: spigot is a server software - fabric a client-modloader/api
u can do more with fabric than spigot
lmao
without texture packs i mean
cuz with modding using fabric u can add textures and custom items
and things
fabric is client-modding.
so obviously you can change like the whole game with fabric/forge
and with spigot just what the server gives you
wtf?
actually dont listen to what i say
lol
yeah
fabric is a modloader, and modding api
from concept, it's like the same as forge
i believe u can add custom items with textures in fabric
yeah
or change like everything in the whole client
you could technically make like skyrim with that i guess
u could do same with spigot but they would have to install a resource pack tho for custom textures
wait a sec
custommodeldata....?
yeah, still very limited
can't modify blocks
can't modify entities
can't modify gui
you can basically modify specific block textures and specific item models and that's it
compared to actually modding the client, that is jack shit
u can change models of items with customModelData tho and still kinda make blocks with like barriers and armor stands i think
yeah and lag the client to shit
XD
sometimes i feel like my pc is like a potato
not feasible
XD
i think spigot is only server side and mods can be client/server/both side
you guys dont see it like this, right?
nah
oh
i changed my settings. so like i thought, thats only clientside
well, guess you cant read german lol
so useless
ToTALEN KRIEG
isnt that the option where it always compresses files above 10mb?
oh
if i enable it, it shows like this. default
that feature can protect u from crash gifs
true
btw on emojis what is the ?v=1 thing actually mean in discord
never heard
btw:
i bought a iphone 12. that's my first iphone in my whole life. probably will change my life entirely
idk why i tell you that, but yea
iphones are gay
yeah... idk
i think they're cool. only thing i hate without having one, you have to buy like everything seperately
i mean, i luckily got an usb-c to usb adapter, but without i would have to buy a fucking adapter to charge it lol
well, i got no reason why android is better for me. i dont think i do anything where android is better
i mean, i almost never installed some apk's, i never tried to root/jailbreak/whatever it...
i mean android is kinda like iphone now
i usually was using huawei because of prising, but because of that google thing, i need to get another one. and wanna try apple for the first time
i mean, i cannot even create a .inf file onto my sdcard, because of permissions. wtf is that...
um u dont have permissions to make a file on a sdcard
?
but if i try to rename smt to .inf, or create/copy an inf file, it's like permission denied
i used it to save my music on, where i had a phone in past with like 8gb of memory. now, i just use it to like copy files to my pc fast, because my loading-slot was kinda broken when moving my phone like 1mm
i will wait for that iphone to arrive, and test it out.
i think maybe android blocked making .inf for a reason so it doesnt autorun things XD
i wanted to create that onto my otg-usb, but couldnt. my pc was broken, and i had like no way to recover my pc
yeah obv its bc of that, but why can't i do what i want with MY OWN BOUGHT phone
i mean, i pay money to not get permissions
¯_(ツ)_/¯
idk
well, let's install life is strange 2. wanna try out that game
even if it's probably not as good as lis1
@sullen dome do u know how to come up with plugin ideas
create the 1.000.000th high customizable lobby plugin
use winrar if its .zip .tar.gz or .rar
nah
wtf
what setup uses that much memory
mc doesnt even take that much and its a bigger game than that life is strange shit
yeah, thats the bad side of downloading games [fully legally ofcourse cough]
do u pirate games or no lmao
same i just have no money i cant afford games that i just want to play but i actually payed for minecraft
lmao i got among us for free without pirating
tf
gifted or what
oh lol
interesting
i actually got gta5 free like 1 year ago, where it was free on egs
see, i don't always just pirate games
if i like them, i'll buy them after i played them
or while playing them
the thing is, i mostly only play like storygames or offlinegames in general, so i have like no con's lol
i only pay for the games i llike alot
well, i dont mean i personally like
i mean games that i've played, and where i can see that they're well made
recreate a zombie shooter game or some fps game in minecraft
not like cp xd
sounds boring
i mean, cp is well made but.... buuuugs
unless you make it boring 😉
i've seen hundreds
bugs?
i see a bug everyday, that has not been fixed since like 1.5 or smt
or whenever it occured
with the graphic issues on held items
of some stuff
the Only bug i know about in mc is the infinite markers on map bug and it crashes your game and it can crash servers
thats from 2b2t lol
i k
but it works on any server
playing fnf on itch.io
yeah its got week 7 on it
thats why i play it there sometimes
cuz they havent released week 7 :(
on itch or whatever
lol
intellij users crying in the corner
oh maybe i know why my pc uses 10gb
should probably close intellij AHAHA
mine normally uses about 1gb
well, if youre used to code a minecraft 1.16 client, you usually use like much ram
with a 500mb+ big project lol
lol
oh yea intellij
getFullTime and getTime work as intended
declaration: package: org.bukkit, interface: World
getGameTime is documented
what version is your server
1.16.5-R0.1-SNAPSHOT
and it cant find getGameTime?
mhm
what the fuck
@Override
protected boolean exec(CommandSender sender, String label, String[] args) {
if (!(sender instanceof Player)) {
MSG.tell(sender, Lang.COMMAND_PLAYER_ONLY);
return true;
}
Player player = (Player) sender;
MSG.tell(player, "The current time is &e%d &7/ &a%d &7/ &b%d", player.getWorld().getTime(), player.getWorld().getFullTime(), player.getWorld().getGameTime());
return true;
}
Honestly not sure
I don't see why it would throw that error
can you provide the entire stacktrace?
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
line 22 of TimeCommand?
MSG.tell(player, "The current time is &e%d &7/ &a%d &7/ &b%d", player.getWorld().getTime(), player.getWorld().getFullTime(), player.getWorld().getGameTime());
I know how to code guys 😂
ima decompile spigot give me a sec lmao
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Im confused lmao
either way I dont have a 1.16.5 jar
u just need to open where getFullTIme is
also it looks like getTime and getRelativeTime are returning the same methods
which- I don't think is intended?
Does anyone know of a way to make a timer of how long a player has been online on the server?
Not sure about the problem here, the method exists in the spigot jar I just decompiled... https://cdn.rackdevelopment.tech/img/LWfxDPmFnI.png
Make sure you are on the exact latest then id say /ver should say up to date or whatever it is
might be that, says im 36 versions behind
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [cmd.exe, /D, /C, sh, applyPatches.sh]
oh that's lovely
hey i am new to coding. But I am trying make a plugin that when I player rights click with a sword to force the player to crouch. I am trying to go this to allow geysermc allow bedrock players block one 1.8 But I can seem to force sneak even with player.setSneaking(true); is there way to force block or for shield on spigot 1.16+?
It is impossible to control what the client does aside from limiting their mobility via packets/events.
If the client wants to sneak, the client will output packets as if it were sneaking. setSneaking only gives them the appearance server-side of what you set it to, but the client will do what it chooses to do. Granted, if the client were sending sneaking packets but walking normally, the server would catch on (or anticheats would, at least).
https://www.spigotmc.org/threads/player-setsneaking-false-has-no-effect.303165/
@vagrant stratus would you know anything about this?
nvm think I got it, sorry for the ping
I believe it's a purely client side thing functionality wise, you can only stop other players from seeing them sneaking
not that lol
lmao
^
i think it was because i was running it in CMD
it always used to work, but I guess running it in git bash is required now
updating fixed that issue, cheers
ooof thanks
is it possible to force block with a shield by sneaking?
how do i check if an entity is in a players line of sight?
i dont want an answer like "oh just use vectors"
cuz idk what to do
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
for (Entity entity : player.getNearbyEntities(20, 20, 20)) {
}
}
what i have so far
I'm so confused
what's the point of Objects#requireNonNull
it just throws a NPE, aka what would happen without it
@south onyx you can raycast
it just checks if the object is not null. You can also specify a String message as the second argument if you want to make a custom NPE exception
without it, nothing happens (if isnt null)
seems redundant
it isnt, its useful for null checking..
Yeah but it throws a NPE either way right?
wdym
Not necessarily, like if world is null
like if that was from Bukkit.getWorld
if the world doesnt exist
it returns null
then in that case, you can use that
@south onyx get the vector from the entity to the player, cast a ray using that vector, and check if the ray's length is longer than the original vector
if it is, it went past and there are no blocks between the player and the entity
It is usually more widely used in like argument checking for like constructors/methods
like if an argument is null, (and cannot be), throw the NPE with the custom message
that makes more sense
ok
IntelliJ's just annoying with it suggestion
and would it also check if the entity is in their line of sight?
thats cause intellij infers contracts
and sees that the method can return null
yes
so it just does that
i mean.. you shouldnt ignore them either
well lik
and doing a simple conditional like if (world == null)
event.getLocation().getWorld()
that can return null..?
probably
definitely shouldn't be able to call a CreatureSpawnEvent with a null world though
The server doesn't enable my plugin. (It doesn't even try).
Main class:
package me.FarrosGaming.SpawnPillager;
import org.bukkit.plugin.java.JavaPlugin;
import me.FarrosGaming.SpawnPillager.commands.PillagerCommand;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
new PillagerCommand(this);
}
@Override
public void onDisable() {
}
}
Command Class:
package me.FarrosGaming.SpawnPillager.commands;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import me.FarrosGaming.SpawnPillager.Main;
public class PillagerCommand implements CommandExecutor {
private Main plugin;
public PillagerCommand(Main plugin) {
this.plugin = plugin;
plugin.getCommand("chase").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players who can send this command.");
return true;
}
Player player = (Player) sender;
Location location = player.getLocation();
World world = player.getWorld();
for (int i = 0; i < 10; i++) {
world.spawnEntity(location, EntityType.PILLAGER);
}
return false;
}
}
plugin.yml:
name: SpawnPillager
version: 1.0
author: FarrosGaming
description: blabla
main: me.FarrosGaming.SpawnPillager.Main
commands:
chase:
description: Spawn pillager in your location
usage: /chase
No errors
No "INFO" for enabling the plugin
1.16.5
lemme try
no .5?
ok
I'm getting this error when I start a server with my plugin
Fatal error trying to convert TerrorGames v1.0:me/TerrorGames/SurvivalGames/Main.class
java.lang.IllegalArgumentException: Unsupported class file major version 8243
can anyone help?
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player player = e.getPlayer();
Vector playerLookDir = player.getEyeLocation().getDirection();
Vector playerEyeLoc = player.getEyeLocation().toVector();
for (Entity entity : player.getNearbyEntities(20, 20, 20)) {
Vector playerEntityVec = entity.getLocation().toVector().subtract(playerEyeLoc);
float angle = playerLookDir.angle(playerEntityVec);
if (angle < 0.2f) {
entity.setFireTicks(4);
}
}
}
code i have rn
it sets the cow on fire when i look at it
but it even sets it on fire when there are blocks in between me and the cow
any way to get all blocks in a 20 block radius?
java version
maybe you are using a older java ver on your system
and a newer one to compile the plugin
It's still doesn't work
what is your plugin yml?
name: SpawnPillager
version: 1.0
author: FarrosGaming
description: blabla
main: me.FarrosGaming.SpawnPillager.Main
api-version: 1.16
commands:
chase:
description: Spawn pillager in your location
usage: /chase
here, @candid galleon
can you send them just in case?
send what?
the logs
wait
after world generation:
Time elapsed: 2002MS
Done (12.729s)! For help, type "help"
ok
How can I copy all of the logs, tough?
there it is (More than 2000 characters)
@candid galleon
@candid galleon it might be an error here "Could not load 'plugins\PillagerChasing.jar' i
n folder 'plugins''"
Could not load 'plugins\PillagerChasing.jar' i
n folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError
: me/FarrosGaming/SpawnPillager/Main has been compiled by a more recent version
of the Java Runtime (class file version 59.0), this version of the Java Runtime
only recognizes class file versions up to 52.0
@candid galleon what is this even mean?
please help me
Your server is running an outdated Java version
And you’re combining with an updated version
so, I need to update java?
Either down compile or update the Java
ok, so I need to update java
k
What’s your %JAVA_HOME% pointing to?
where?
homie out there using bandicam
Hello everyone !
I'm trying to create an enumeration with all my inventories for a plugin... But I don't know if it's possible...
Does this work ? Or is there an other way to do ?
public enum PunishEnum {
TEST(Bukkit.createInventory(null,54));
private final Inventory inventory;
PunishEnum(Inventory inventory) {
this.inventory = inventory;
}
public Inventory getInventory() {
return inventory;
}
}
Maybe infer the creation of the inventory inside the construction
Yeah I know but I'm searching a "better" way to stock inventories
I mean
Also haven the suffix name Enum is somewhat redundant
If I have only 3 inventories it's okay, but what if I have 1000 inventories ?
Enums will be easier to setup i guess
Registries
This ^
Registries ?
I don't know what it is, gonna look up, thank you 🙂
Basically you back yourself on a Map or BiMap and then you have some methods like register getByName getByValue
👍
i have a question: Is it possible to temporarily save messages from the chat in Minecraft and translate them with the Google translator?
That’s many questions lumped together:
Yes
- is it possible to change a message in chat before people see it?
- how can I use google translator with Java?
and really I wouldn’t use google translate
you can cancel messages and then send them once they're translated
Anyone know how to add additional methods to a lombok superBuilder?
been searching everywhere cant find an answer
what would you use instead of google translator?
ok nice. And how can i use this?
.
Google usually has good docs for their APIs
So find that
Delombok (:
delombok
ok thank you
funny
Deeptranslate
People tend to use google’s not because it’s good but because it’s easy to access
It’s not bad there’s just better
OK
can you get the api from it somehow?
you have to use google's api
if i want to use deepl translate?
Hmm, I notice that most of the translation APIs are paid and I understand why but is there like some library so I can run the translation locally?
Is there any problem to build 1.8.8 on Windows 10?
difflib.PatchFailedException: Incorrect Chunk: the chunk content doesn't match the target
I’m assuming this is build tools? @echo ether
oh ok
That's right, it is.
I've tried to build on Ubuntu and Debian too but the result was same as Windows 10.
Hmm idk then
someone can link me how to use NSM to add 1.8 support to a 1.12.2 plugin
or everything you can suggest for me
After some searching and testing on my VPS, the problem caused due to internet provider or the country by itself. I know it sounds ridiculous but I am 100% sure about it.
can i make a plugin prevent accesing an event?
without modifying the plugin or the plugin that has that event
what do you mean by prevent access
So
let's say that a plugin listens for UserBalanceUpdateEvent from essentials
how can i prevent that plugin from listening for UserBalanceUpdateEvent
Huh, glad it works
how can i get this:
import org.apache.tiki.language.LanguageIdentifier
I am trying to google it but can't find it
You can't. Not unless the plugin itself allows you.
😢
Hey everyone
I'm trying to set the pickup status of an arrow. Currently, I'm doing:
Arrow arrow = p.launchProjectile(Arrow.class); arrow.setPickupStatus(PickupStatus.DISALLOWED);
but I can't get it to work. Applying effects to it doesn't work either. Has someone an idea why this is not working?
Can you make a npc with pathfinding? Basicly I want to make custom mob with player skin. Mob that I can attack and it can attack me
Here's a tutorial on how to do it using nms https://www.spigotmc.org/threads/how-to-create-and-modify-npcs.400753/ but I highly suggest you find an API for that like citizens
Hey everyone
I'm trying to set the pickup status of an arrow. Currently, I'm doing:
Arrow arrow = p.launchProjectile(Arrow.class); arrow.setPickupStatus(PickupStatus.DISALLOWED);
but I can't get it to work. Applying effects to it doesn't work either. Has someone an idea why this is not working?
(repost since I didn't verify my account before)
I didn't even know there was a pickup status method, I've just been setting the pickup delay to a value beyond what the arrow's duration is
Hmm... I can't set any properties of the arrow. I don't know what I'm doing wrong xD
At least it has no effect
If I have a timer task inside a method and I return inside the timer task, will the task stop or cancelled?
@Override
public void load() {
Common.runTaskTimerAsynchronously(0, (20 * ConfigValue.SALARY_MODE_ANNOUNCE_EVERY), () -> {
if(!ConfigValue.SALARY_MODE_ENABLED) return; // will this make the task stop?
});
}
the method will be called onEnable
no
it will just stop that time, but the other ones will still run
cancel() will cancel the loop
make sense ?
cool
Ok, so this is basic java probably but idk what to do.
I have a StringBuffer that contains this text:
{'translations': [{'detected_source_language': 'EN', 'text': 'Hallo Mein Name ist Ollie!'}]}
How can i access the text
anyone has a good free 1.16.5 vehicle plugin in mind?
vehicle plugin??
You cant like summon cars lmao
you need to get a mod
not plugin
bukkit cant make a custom item
forge mods can
plugins work and i know it], dont pretend ur the smartass here, explain this, i wanted this but its 10 euros https://www.spigotmc.org/resources/✈️vehicles-no-resourcepacks-needed.12446/
@coral sparrow
Um what?
read it
this is literally different than what you call a "forge mod"
dude
Yeah that's a bunch of armor stands
yes
yes
wdym yes it is different when forge can make its own texture
i asked for a plugin, then u said i need a mod
I recommended
I never forced you to download mods, I just said the best way is to download a mod lol. I dont know of a plugin which cant do that
wtf lmao
i simply asked for a free plugin, nothing else
just using blocks
I dont know
its good for being a plugin
i dont have money
idk
can someone help me creating .gitignore in intellij?
Sure what do you need in it
idk how to create it
i want some folders that will be ignored when pushing to the git
Also there's a .ignore plugin
https://github.com/aglerr/TheOnly-MobCoins
i want to remove .idea and target
Create a .gitignore
what, there is .gitignore in .idea
Hello i'm new in the development, so I registered my "api" in my onEnable, but how can I acces it from other functions?
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable()
{
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager().getRegistration(LuckPerms.class);
if (provider != null) {
LuckPerms api = provider.getProvider();
}
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e)
{
Player player = e.getPlayer();
User user = api.getPlayerAdapter(Player.class).getUser(player);
String prefix = user.getCachedData().getMetaData().getPrefix();
System.out.println(prefix);
}
}
I can't acces "api" in my onChat since it's registered in onEnable
anyone could help me?
I remember using luckperms api in the past But I completely forgot how to, I took examples from https://github.com/LuckPerms/api-cookbook
Store the api instance in a variable
Thanks
@eternal oxide it worked, thanks!
put below of onEnable Luckpersm = null and then in the onEnable only api = ...
Hey guys, in java, can we use .replace(x, x1) if the x doesn't exist? I mean like if the x doesn't exist it'll raise an error or just pass?
?paste
just pass, else if x1 is null it raise NPE
The problem is already solved thanks!
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
But my question is more, is the error because in my config I didn't put every things ("$prefix$, $suffix$" ...) ?
My config looks like that:
format: "$prefix$ i'm new"
x1 shouldn't be null ;-;
try this
Stop spoonfeeding
if you use replace and the search items is not in the string, the complete unchanged string is returned.