#help-development
1 messages · Page 1569 of 1
so had to do it all out of packets
Yeah you need to handle that exeption
oh what
Lmao
i should try{ then?
Yeah
Ima give myself ★★★★★ for that explination
Mhm
agreed
★ for spelling
Lmao
How can I get the spawndata of an item?
Get SpawnEggMeta
can I get it from a spawner?
okay 😄
Last time I worked with spawners I had to use NMS
API can be a bit limited at times
dam alright
Alright so for spawners use CreatureSpawner for block and I'm not sure about the item
alright, ima try some stuff then. I basically just wanted to allow players that aren't in creative to place a spawner that wouldn't turn into a pig
Don’t spawners have nbt tags
They do
But you need NMS to work directly with them
time to learn about nms lmao
Wait, spawners aren't in the spigot API yet?
they are but I dont think you can get the mob that would spawn out of it in item form
What do you mean by Item form?
Gotcha
yeah so I couldn't find a way to do it with the spigot api and so Im trying with NMS
but idk how to use it
what happens if a player connects before my plugin is loaded? should i iterate over each connected player somehow inside onEnable and call the join event?
i have my join event stuff in a separate function
that takes just the player
keep in mind if the admins do /reload it will be called aswell
Got reobfuscated in 1.17
the playerjoinevent will fire for them all unless it is due to a reload
So you'll have to find it's new name
otherwise you can just iterate over the already connected players on the first tick
ah it moved to getWorldServer
Ah
then i shouldnt worry about that
thanks
playerjoinevent wont fire for players in the server before the plugin loaded
in my experience at least
it's almost like i said that
Can they even join if the server hasn't loaded all the plugins?
no you said it will fire
no i said it will fire unless it's due to a reload
the event will be fired or not?
no players can be connected first if the server is just starting up
^
Just don't /reload and you won't have problems
They can't join before your plugin loads
they can connect tho
so, if the server is just starting up, the event will be called for the already connected players?
Connect and Join aren't the same
they won't be logged in until the server is ready
i never do /reload
true
thats bad, i read that somewhere
there are no connected players if the server is just starting up
im using join
so? no ticks until all plugins are loaded?
a connectoin can be established but the player will just see "logging in" until the server is ready
yes
ok
the server doesn't tick until it's ready
hmm apparently something changed in 1.17 in terms of loading plugins
calling PluginManager#getPlugin results in an error
as in youre trying to get your own instance?
i am pretty sure that should only return a plugin if and only if it is loaded
it used to work in 1.16
i think ill just add a static variable that i set to this in the first line of onEnable
i'd assume loaded != enabled
?jd
ok i just needed the link
[01:30:55 INFO]: [EssentialTools] Enabling EssentialTools v1.0
[01:30:55 ERROR]: Error occurred while enabling EssentialTools v1.0 (Is it up to date?)
java.lang.ExceptionInInitializerError: null
at net.thearcanebrony.essentialtools.mechanics.BarrierView.Start(BarrierView.java:35) ~[?:?]
at net.thearcanebrony.essentialtools.Main.onEnable(Main.java:87) ~[?:?]```
s there a way to make is to custom mobs spawn in worldguard regions or is there another way of doing that?
do you use paper
fork of it, yeah
but i just found another issue
private static final String bukkitversion = Bukkit.getServer().getClass().getPackage().getName().substring(23); fun stuff
i heard that they are altering the plugin lifecycle slightly, but i don't know the details
ah possible
public static int pingPlayer(Player p) {
try {
Class<?> craftPlayer = Class.forName("org.bukkit.craftbukkit." + bukkitversion + ".entity.CraftPlayer");
Object handle = craftPlayer.getMethod("getHandle").invoke(p);
Integer ping = (Integer) handle.getClass().getDeclaredField("ping").get(handle);
return ping.intValue();
} catch (Exception e) {
return -1;
}
}```
why was i ever using reflection for this??
Is there a reason why you are making it static?
so it can be accessed without a context
man some of this code is so naive lol
why am i using reflection when i can just Player#getPing()
didn't exist in earlier api versions
Hello, is this sus???||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||https://gstudiosx.cant-even-afford.rocks/
strings are genuinely the devil
they are the enemy
I think we should get rid of strings
I fuck up comparing two strings about 1/10 times
and I never notice it
specifically because there is a typo in one of the strings and I don't notice it
any idea why OfflinePlayer is red?
I write JS primarily at work, and I constantly find myself doing shit like this when I switch to Java:
if(world.getUID().toString() === cache.world) {
...
}```
I did C# intensively for a week then I went back to doing java intensively for a week and managed to spend 5 hours slamming my face against the correct way of using java generics
I feel that pain. Java is rough around the edges, we need Sun Microsystems to come back and save us
so why is OfflinePlayer red
Hover over it, what does it say?
hover over it, pretty sure it says deprecated
Your IDE will usually tell you what's wrong
You need to add an import for it
Imports don't quite work like that in Java
You need offlineplayer import
org.bukkit.OfflinePlayer ?
Yep
yeah this is just not right
thats so weird lmao
You import specific classes in Java, so you add an import statement per class you need from elsewhere
also your IDE should automatically suggest the correct import just fyi
hey joshua
it didnt lol
I think I can count on one hand how many times I manually imported things
I never manually import
I feel spoiled with IDEA, it'll just import for me.
thats just so weird because normally it'll say "Package org.bukkit", and then some other stuff that's the actual import
Screw manual importing
manual importing is the best
There are many classes that exist in the org.bukkit package
gives you so much potential in life
wak
yeah, but normally it'll show the import at the bottom
well not the import but the name of the class
It slows me down cause I just use the keybind for importing
Actually that big bold part tells you as well
Package is org.bukkit, it's an enum called ChatColor
Here's some more info on packages in case you need more help with it, and/or want to learn more
https://docs.oracle.com/javase/tutorial/java/package/usepkgs.html
time to create new things that I'll then have to fix
That hurt to read because I am in exactly the same boat.
ok there is no way that I am using java the way it is meant to be used lol
but hey it works
How can I use NMS to get the spawn data of a spawner?
What are you trying to do?
I want to get the entity of a spawner item inside of the players main hand
if im using EntityDamageByEntityEvent, will that still trigger if damager == arrow?
second, if damage by entity is called for arrows, does damager get set to the shooter?
i was thinking something like this?
?paste
can snowballs kill?
its just good to have a catch all
I'm a little bit new to Java (expierenced in other languages so dw) and I'm getting this error:
Test v1.0 attempted to register an invalid EventHandler method signature "public void me.okay.Test.Main.onEntityExplode(org.bukkit.entity.Entity,org.bukkit.Location,java.util.List<org.bukkit.block.Block>,float)" in class me.okay.Test.Main
I feel like theres something wrong with this line:
@EventHandler
public void onEntityExplode(Entity entity, Location location, List<Block> blocks, float yield) {
any thoughts?
i just realized my redundancy in getting the player when setting the owning player, woops
hm wait
so
like this?
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
yes
so how would i grab the entity, location, whatever
wish me luck ig xd
interesting choice to make the class final
are you registering those commands in plugin.yml @robust crypt ?
what issues
wait
Error occurred while enabling DrDukyGud v1.17 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "drdukygud.me.cringe.Main.getCommand(String)" is null
@EventHandler
public void blazeSpawn(PlayerMoveEvent e) {
Player player = (Player) e.getPlayer();
Integer chance = getRandomNumberInRange(0, 100);
if(chance <2 && player.isFlying() || player.isGliding() || player.isRiptiding()) {
return;
}
if(chance < 2){
SummerBlaze firedude = new SummerBlaze(e.getPlayer().getLocation());
WorldServer newworld = ((CraftWorld) e.getPlayer().getWorld()).getHandle();
newworld.addEntity(firedude);
}
}
@EventHandler
public void onSpawn(EntitySpawnEvent ee) {
Entity blaze = (Entity) ee.getEntity();
Location loc = blaze.getLocation();
double locx = loc.getX();
double locz = loc.getZ();
Line>>>45 if(blaze.getCustomName().contains(ChatColor.GOLD + "fire dude") && !(locx < 101 && locx > -101 && locz < 101 && locz > -101)) {
ee.setCancelled(true);
}
}
private static int getRandomNumberInRange(int min, int max) {
if (min >= max) {
throw new IllegalArgumentException("max must be greater than min");
} else {
Random r = new Random();
return r.nextInt(max - min + 1) + min;
}
}
}```
I am getting a lot of null exception errors in line 45 not sure why
?paste
what does this mean
ye
neither?
./nick work but not nick2
@robust crypt perhaps its a format issue, try encompassing the aliases in [ and ]
that shouldnt b the issue i think but
my guess is getCustomName() == null?
What's the driver for mysql?
Example to connect to the mysql database with examples on Driver, DriverManager, Connection, Statement, ResultSet, PreparedStatement, CallableStatement, ResultSetMetaData, DatabaseMetaData, RowSet, Store Image, Fetch Image, Store file, Fetch file etc.
Thank you just needed com.mysql.jdbc.Driver
Send your onEnable @robust crypt
tyty
bump
🤔 does /browhat work?
no
how woudl i get a potion effect from its ID, like 1 is speed, 2 is slowness etc
Try taking the "2" out of the command? Maybe it doesn't like that for some reason?
when i open my server it says this and disables the plugin
why?
naming convention dictates your main class should be your project's name
ah makes sense then
I wouldn't do it like that, but I think PotionEffectType.getById() is the closest thing you're gonna get. It's deprecated because magic numbers were phased out in 1.13
PotionEffectType.getById(/* potionid */)```
i want to get a random effect and thats the best i got
because i also only want it to be positive
ig u cant put numbers in commands
it worked out thx
👍 good to know I guess
:)
PotionEffectType type = PotionEffectType.values()[new Random().nextInt(PotionEffectType.values().length)];? Then check if it's a positive effect.
Could even make a static List<PotionEffectType> of all the positive effects and randomize from that one
that seems really complex 😓 i think ill see if my deprecated method works first
i know its not good practice but im stupid
Hmm... alright then I guess. Won't work for potion effects past 1.13 probably.
Unless Spigot assigns them an ID
Which it does :l
java with curly brackets is actually nice
i feel like its more organized than python indents
and all the chads write the code in one line
if i have a hashmap and i define it as private final, like this
private final HashMap<UUID, HashMap<Integer, Long> kits = new HashMap<>();, the private means that no other class can acces it, the final means that it can only be assigned once and that it will always contain this value, does this mean that it will only create this hashmap once or that it will always be an empty hashmap? if so why does this code work?https://paste.md-5.net/asofitataw.cs
its creating a new instance of the hashmap without making it final.
if i make it final and add a value inside this class in a method, will this produce nullpoint because you cant edit the final value of the variable? im so confussed rn
It creates it once, but doesn't make it Immutable
@sharp bough setting kits to final means you cant run something like kits = value at any other point in the code
So you can still add things to it, you just can't set it as another HashMap object
you guys just said opposite things lol
no
We said the same thing
we both said you cant reassign kits to another value
yes, you can edit all of its elements
Yes, you can still add/remove to it.
k thanks
wait no , so how does the code i sent work
the link
its creating a new instance of the class
but still keeps the data
the code you sent initializes kit as an empty HashMap
you can then put/remove elements in and out of it later
but you cant reassign it to another HashMap
so having kit = new HashMap<>(); anywhere else would throw i believe a runtime error
Also static & final aren't the same. If it's not static, a final variable still gets created for each instance.
but stuff like kit.put(key, value) will work
?paste
https://paste.md-5.net/qaqileyimi.java rate how clean this implementation of creating new types of config files is
Why aren't all the variables at the top
there are enums in there
+1
I don't use enums for paths anymore because it takes up too much space at scale
they follow a logical order, it makes more sense if you see the class it's extending
essentially they are above the methods that actually use them
ehhh still think they should be at the top
Maybe in the right order still but it looks weird IMO
I'd rather retain the execution order, also less scrolling as more stuff gets added
Does anyone here help with protocollib or is this just strictly spigot?
one of my classes was getting so large I had three windows of the same class open at once to add new fields symmetrically
As long as you know what you're doing I guess. ¯_(ツ)_/¯
I'm going to have so much fun redoing all of my configs in this format...
https://paste.md-5.net/aqelifayad.java this is what they used to look like, and mind you this is already a massively cleaned up version of what was there before lol
even with all the fields on there I think I'll be able to cut those 850 lines down to 400-500 with the new format
when you register a command using ...setExecutor(new CommandExecutorClass()) does this create a new instance of the entire class or just the method defined with @Override onCommand?
that would be a new instance of the class as you are doing new ClassName()
?learn commands
lol
Java Programming: The Anatomy of Java Program
Topics discussed:
- Classes & Objects.
- Methods.
- Naming Conventions.
- Java Program Structure.
- Packages.
Follow Neso Academy on Instagram: @nesoacademy (https://bit.ly/2XP63OE)
Contribute: http://www.nesoacademy.org/donate
Memberships: https://bit.ly/2U7YSPI
Books: http://www.nesoacadem...
look at this guy
indian accent 13 min video
10/10
so i have this basic plugin:
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@Override
public void onDisable() {
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
// ... stuff
}
}
how can I seperate the onEntityExplode event into another file?
how would i go about creating a plugin mob which is literally just a mob with a different model? like is there any way i can make a zombie where the only diff is that it uses the model of an ender dragon?
why did you delete the message and resent it
lol
wdym a model
create a new class
implement listenner
and make the listener
getServer().getPluginManager().registerEvents(new ClassName(), this);
but like do I need to do anything in Main or no?
yes in the main add getServer().getPluginManager().registerEvents(new ClassName(), this);
then create a new class
literally all im tryna do is make falling blocks which don't collide with things 😭
ah okay
thanks
and then do
@fresh templetHandler
public void MethodName(EventType event){
sorry even didnt mean to tag you lol
alright
ah yes
now that you have bestowed your genius upon this gentleman please bequeath unto myself some of your awesome intellect
thanx
you want to remove the AI of the zombie?
you just want a zombie
but you dont want it to move
attack
or anything else?
oh
haha
the reality is
i want to make a falling block entity
that doesn't collide
with blocks
worked, thanks
i've thought about making them ride vexes
np
@fresh temple do you enjoy this
just one question, how is onCommand different?
i've searched up online and the process for splitting up commands is very weird
you register the command using Objects.requireNonNull(getCommand("COMMAND")).setExecutor(new CLASSNAME());
and in the class you do
@Override (if you just type @Over it should autocomplete the onCommand)
pulic boolean onCommand(...){
return true; always return true here, if you dont it will send the usage message in the plugin.yml
and then you register the command in the plugin.yml file
using
commands:
COMMAND:
description:
usage:
etc theres a bunch of things you can add there
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ok thanks so much
also one more thing
how can i customize this list of suggestions?
if you made the plugin you can
otherwise you cant
maybe this can help
but never really made a suggestion
yooo realLine, what happend yesterday? did you manage to fix your error?
i was so tired i couldnt even read
but what was it?
hahaaaa nice
about this, i have no idea
bump
lol i dont understand
doesnt really matter for now
anyways i want to split up my plugin into two:
one file for handling commands
and the other for tracking a specific player, where the player to be tracked is set by the commands
https://www.youtube.com/watch?v=SNDjK5HKCmc This helped me make mine
Learn how to add tab completer to your commands! Super fast and easy :)
~ Sorry I missed last week, been super sick. More videos coming soon once I'm fully healed :D
CodedRed.setHealth(20.0);
------ Links ------
Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers
Download Spigot: htt...
idk if its the best practice but it works
ill save this
how can i make the two files communicate with each other?
alright if you need to know how to add more tab arguments message me and I can help
👍
do you mean two classes or two text files (.txt, .yml, etc.)
two classes
idk if this is the best way to do it but I use this
I just add this right under the class declaration so
public class testClass {
private ClassName variableName = new ClassName (); // This will get the class
}
then you can call that class by whatever variableName you use
hmm
ok i don't see how it would work
i have Commands.java and Tracking.java
so if i do /track someGuy, tracking.java should somehow pick that up
and both of these are under Main.java
so you want to run a method from tracking.java in your main class?
well
yeah
public class Main extends JavaPlugin implements Listener {
Player trackedPlayer;
}
as in
I want Commands to be able to update trackedPlayer
and then have Tracking do whatever with that
pass it as an argument to Commands? kinda depends on your code
Main.java
public class Main extends JavaPlugin {
private Tracking tracking = new Tracking(); // Get the tracking class
Player trackedPlayer = tracking.getPlayer();
}
Tracking.java
public class Tracking {
private Player target = blah;
public Player getPlayer() {
return Player;
}
}
would look something like that
if you wanted to get the target from the tracking class
oh i see
so correct me if i'm wrong main.java would look something like this:
package me.okay.Manhunt;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
Player trackedPlayer;
TrackCompass trackCompass = new TrackCompass();
Commands commands = new Commands();
@Override
public void onEnable() {
getCommand("tracking").setExecutor(commands);
getServer().getPluginManager().registerEvents(trackCompass, this);
}
@Override
public void onDisable() {
}
}
so then, when I want to get the player
is there any event to check when someone opes a book
i just do commands.getTrackingPlayer() and pass that in to some method of trackCompass?
I think on right click and check if its a book
is there anyother way? I want to keep overhead minimal
uh after I finish with okay ill look more into it for you 😄
okay cool thank you very much!
issue with this is that I want commands to call a method of main instead
im confused by what your asking sorry
if you want to get something from your main class then you can do something like this:
private static Main plugin = Main.getPlugin(Main.class); // Get this from main
that will make it so plugin will be the one to get any of the methods in main
no
ok lmao here lemme make it as clear as a i can:
oh? it works for me perfectly
how would you do it?
dependency injection
I have this Commands class:
package me.okay.Manhunt;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class Commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (label.equals("manhunt")) {
// set the tracking player
}
return true;
}
}
Now, at the comment in the code shown above, I want it to update a variable inside my Main class
public class Main extends JavaPlugin {
Player trackedPlayer;
After that, Main should invoke a method of another class, TrackCompass, and pass the information originally given from Commands over to TrackCompass
would it just be this? private final SpigotPlugin plugin; according to a page on the spigot wiki
lmk if something didnt make sense
i made that thread lol
oh lmao cool so that would be the proper way?
im gonna read more later but that was what I got from a glance
pass main class instance through constructor of Commands class
Id listen to him he wrote on spigot wiki knows alot more than me for sure

Is anyone aware as to the possibility of sending boss bar text without a boss bar?
imagine can my name be changed back to my discord username by chance?
cool thank you 😄
?changename
Name changes on the forums are granted to those who have donated to the project. Donations are processed manually and generally take up to 24 hours. The donation widget can be found on the home page of SpigotMC at: https://www.spigotmc.org/.
i see
any ammount? or is there a threshold?
5 usd or more i think
Anyone understand this? https://imgur.com/a/tq8k24F
okay cool ill do that in a bit I gotta figure out if theres another way to track if a book is opened other than right click event
I don't think theres another way unless im mistaken but I don't see anything in the Spigot-API
thanks for the help
no problem sorry I couldnt do more
its fine
I did however find this idk how to use it but it says it added in the event
https://www.spigotmc.org/resources/bookapi.41998/update?update=167597
ight brb
THANKS
no prob
😎
well, i dont think its text at least
Yea I'm trying to figure out what it is
whats it from
what kind of value are u grabbing
What do you mean? @quaint mantle
is it possible to add strings to a string collection
is that a collection
idk if it is
String[] === multiple strings, as mpst poeple know
is it possible to like, loop lines of a file.. and add them to a String[]
bump
What is the entity class for Furnace minecart, I cant seem to find it
Spawners don’t save their spawned entity in item form
any idea why this wont work..?
the top String[] ri = Main.blahblah
oh im stupid nvm
Huh, forgot you could stick the data tag on items
Anyway you can’t read that without NMS I would guess
shshsshs it never happened
Yeah im using nms
Well you’ll have to work your way through the compound tags
net.minecraft.world.item.ItemStack spawnerNMS = CraftItemStack.asNMSCopy(spawner);
if (!spawnerNMS.hasTag()) { return; }
NBTTagCompound spawnerTags = spawnerNMS.getTag();
NBTBase spawnerNBT = spawnerTags;
thats the code im using
[01:34:39 INFO]: Thread RCON Client /127.0.0.1 started
[01:34:39 INFO]: Thread RCON Client /127.0.0.1 shutting down
[01:34:39 INFO]: Thread RCON Client /127.0.0.1 started
[01:34:39 INFO]: Thread RCON Client /127.0.0.1 shutting down
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 started
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 shutting down
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 started
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 shutting down
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 started
[01:40:24 INFO]: Thread RCON Client /127.0.0.1 shutting down
any idea why the server is not shutting down?
from a python script:
with mcrcon.MCRcon('localhost', 'SqrzrjiE6nH9jju5phNc', port=25585) as mcr:
mcr.command('/stop')
ive set rcon.port to 25585, enable-rcon to true, and the rcon password in server.properties, do i need to change anything else?
how can i loop something multiple times
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
What are you doing
i think i fixed it
im doing the
for(int i = 0; i < 100) i forgot the rest
im just gonna while(i != 100)
and add to i
That works I guess
thats what i thought
its only registering rank 0
twice? (3x actually)
pardon the reload, its an air world and test server
the yellow 0, and 1 are the integer rank
It's not registering 0 twice, 0 and 1 have the same name
wdym
They're both named "L"
What does it return if the id isn't found?
the this."fewofkofw are strings because for some reason it wouldnt work if i just used String color = "whatnot"
Can you still send the entire file?
You should create a Rank class/enum and use these values in that
Enum would be the best.
Part of your problem is because you're not using an Enum, that will help solve your issue
how do u remove all dropped items?
Look through the World's entities, check if it's an Item, Item#remove
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
yea but i want it to do it in all world
So loop through all the worlds and do it
YouTube might help
DM me
this this this
?
mf said who needs switch statements
/kill @e[type=minecraft:item]
its not wrong
tru
lmfao im noob
its w/e
Whats the best way to get players health on leave
and restore it on join
(reason: In my plugin I give players an extra bar of health)
Listen to PlayerJoinEvent and PlayerQuitEvent
yeah but how can I restore it when they leave and join? im already listening to it
Just apply it like you did the first time?
I assume you're already giving them the extra bar, just do that onJoin
that wouldn't be taking into account any of the health they had in the second bar
I want them to keep the same health like if they had 2 hearts missing out it would be 36/40 health but if I do the logic that I have now since their health bar would still be 20/20 on join it would add back the extra 2 hearts that they lost
like the get the extra bar on join but they don't keep the health they had
qHey I have a Weird Issue,
- Players rubberband
- when they rubberband it usaully says "Your teleport was a Success!"
- There is no rubberbanding or teleport was a success for OP
Remove plugins until it stops happening, then once you find the one that's doing it, check with the plugin author on why it's doing that.
How are you adding the extra health? You might have to save how much health they had.
How else do you recommend figuring out what plugin is causing issues?
Just disable them
That works too I guess, if you know how to do that.
Sure ¯_(ツ)_/¯
🤷
I get the health they have before adding the healthboost to them then I add that to the new healthboost which gives me their health plus another row of hearts pretty much, it just adds 20 to the health.
However if I do it like this on join if the player has 14/40 health on leave they would have 34/40 health on join so they could get unlimited health by leaving an joining
Yeah, I think you're just gonna have to save how much extra health they had when they left & then add that to them when they rejoin.
Health boost is really weird with how it works.
alright, an extra file but should be a couple kiobytes
yeah, wish I could give them extra hearts without it
I remember I made a Spigot patch to fix Health Boost resetting when re-applied lmao
It's a really buggy effect IMO but oh well
yeah, its the only way to give hearts tho so its the only thing I can use :/
You can use attribute modifiers
can someone help me with my problem on #help-server ?
How can I set block's skullmeta with value? (not like setOwner())
there is no google results (for setting block's skullmeta with value)
is it possible to cancel Bukkit.getScheduler().runTaskLater
this.cancel()
or just cancel()
can I cancel it outside of the scheduler?
is it possible to make compasses work correctly in the nether?
I believe so yes
No
I tried using setLodestone but the compass is still spinning all over the place
What is the limit of GENERIC_MAX_HEALTH?
What version of spigot
I don’t think there is one. But I could be completely wrong
1.17.1
pretty sure its 25600, not 2000% sure though
I did some quick reading online, do I need to have an actual lodestone block in order to use setLodestone?
so I put 10000 health to the dragon but it spawned with 200 health
ah, theres your answer
,
what
Why not just use Player#setCompassTarget
well if you put a huge number, and it only spawned with a number LESS than it
clearly that must be the max
I was using that, but it wasn’t working in the nether
Can I see some code?
i dont think compasses or clocks work in the nether
I wish I could but I’m not on my pc atm
In the nether you need to set the lodestone
I thought you didn’t Olivo
If you are on an old version the compass won't work
I was asking if there wasa way to make it work
setLodestone requires a location, I don't think it necessarily has to be the location of lodestone block.
^^
I always thought lodestone was useless
No need for a block there
Well I put a location and the compass was still drunk
Mind showing how you instanced Location object?
Location location = (Location) player.getLocation()
…
Why are you casting
^
Well I probably wasn’t then i don’t remember what I put
Are you trying to create waypoints?
is player set
no, tracking a player like a manhunt
kinda cringe
I see, Which event are you listening to?
dweam
Oh Dreamm!
dammit
OnPlayerMove
There are already like a 100 tracking plugins
or something like that
PlayerMoveEvent*
I’m doing something a bit more dw
I even made one (private)
I’m doing more than tracking
Hence why I know the need for lodestone location
yeah that
Olivo will give you his/her source code 🙂
?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.
if thats what your trying to use for the compass just make it point in the direction of the player?
Hm, How are you setting the Compass Meta?
it’s not really spoonfeeding I’m gonna legit try to make sure I understand ¯_(ツ)_/¯
well the way I was doing it was super inefficient, I was just desperate to get it working at the moment
He did ?spoon because of what I said
No jtx wanted me to give you the code which is spoonfeeding
Which is what setLodestone is for
they grow out of it at some point
copy and pasta
but basically I would loop through every players inventory and find a compass, if it was a compass, CompassMeta meta = (CompassMeta) item.getItemMeta();, then meta.setLodestone()
god that’s hard to type on mobile
Also, To update the compass, you'll have to do a loop through online players
ye I did that
hm, Alright, So what is being wrong?
hmm do I have to set lodestonetracked to false?
CompassMeta#setLodestoneTracked(false)
declaration: package: org.bukkit.inventory.meta, interface: CompassMeta
Go to javadocs
Yeah I am
Yeah I saw that and even read it like 5 times but it felt very confusing
thanks so much though, will try it out when I can
Block#setType(); not working!
Hi,
this is my code.
block.getLocation().getBlock().setType(Material.BEDROCK);```
player teleports well, but
block isn't changing. (location, block isn't null)
Anyway it should just be set lodestone tracked
is it also possible to get rid of the enchanted glow with the lodestone
I don't think thats how you replace a block
It can be
So what should we do? 🙂
Yeah I didn't bother with looking in to that. Minecraft wiki might have what you're looking for
is you code callable?
alright then
thanks guys
[16:39:14] [Server thread/INFO]: CraftBlock{pos=BlockPosition{x=388, y=105, z=342},type=BEDROCK,data=Block{minecraft:bedrock},fluid=net.minecraft.server.v1_15_R1.FluidTypeEmpty@347bdeef}```
here you go!
wait
type=BEDROCK what
block isn't updated in game
Umm, intresting
yeah also, we haven't event.setCancelled(true) or another replace
Make sure you're looking at the right block
ok! i made sure
It's correct
SkullMeta skullMeta = totoAPI.setSkullByValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzVlMmUwOTU5NzEyZGNkMzM1N2NjM2NlYTg1Zjk5YjNmZDgwOTc4NTVjNzU0YjliMTcxZjk2MzUxNDIyNWQifX19");
skullMeta.setDisplayName("apple");
skullMeta.setLore(Arrays.asList(" lore"));
itemStack.setItemMeta(skullMeta);
// event.setCancelled(true);
event.getPlayer().teleport(block.getLocation());
block.getLocation().getBlock().setType(Material.BEDROCK);
Bukkit.broadcastMessage(block.getLocation().toString());
Bukkit.broadcastMessage(event.getBlock().toString());
event.getBlock().getWorld().dropItem(event.getBlock().getLocation(), itemStack);``` here is my full code
yes or if it's from a sapling placed by a player
yoo
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
at com.ankledev.nectar.serverevent.Server.onJoin(Server.java:77) ~[?:?]
at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor71.execute(Unknown Source) ~[?:?]
at org.bukkit.plugin.EventExecutor.lambda$create$1(EventExecutor.java:69) ~[patched_1.17.jar:git-Paper-79]
at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[patched_1.17.jar:git-Paper-79]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[patched_1.17.jar:git-Paper-79]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:624) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.players.PlayerList.postChunkLoadJoin(PlayerList.java:357) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.players.PlayerList.lambda$placeNewPlayer$1(PlayerList.java:299) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.network.ServerGamePacketListenerImpl.tick(ServerGamePacketListenerImpl.java:308) ~[?:?]
at net.minecraft.network.Connection.tick(Connection.java:399) ~[?:?]
at net.minecraft.server.network.ServerConnectionListener.tick(ServerConnectionListener.java:196) ~[?:?]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1576) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:477) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1404) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1180) ~[patched_1.17.jar:git-Paper-79]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[patched_1.17.jar:git-Paper-79]
at java.lang.Thread.run(Thread.java:831) [?:?]```
any idea why thats happening
i dont have any length checkers.. so idk what Index 1 out of bounds for length 1 is
i also double-checked, and none of my indexes are out of bounds lol
Hello! Should we cancel BukkitScheduler.runTask()? I mean it will run forever or it will stop after what done in lambda? If it run forever, we should .cancel it.
Arrays start at 0
i know that
i dont have anything that checks for the length of an Array[1] for the length of 1 though
That won't work. If length is 1 you need to access 0
i know it wont work
but the error claims i have something that checks for the length of Array[1] i think??
i wonder what 😱
Show your code and maybe we can help
i think i'll debug first?
Aight
hi, sorry for the late response, i got the expected response but things that depend on the config don't change
._.
.___.
Try changing set config_value to set args[0]
Great 🙂
thank you so much god i spent way too long on trying to fix that
xd
wait
h it doesn't seem to have actually saved to the file
hi @chrome beacon sorry for the ping but I'm getting nowhere with this :c
or it could just magically fix itself apparently
ok then
um k?
Hey, I would like to program a method in my plugin that I could call in the joinlistener, which then saves the player's values in a MySQL database when a player joins the server for the first time. I have already dealt with JDBC and know how to create a table via JDBC, but I got stuck when reading and inserting data, because somehow nothing really works and every tutorial says something different. Can anyone help me with this?
Show us what you tried
How do i set server resource pack without using Bukkit.getPlayer().setResourcePack()?
So first I tried to create the following method in an extra class:
public class addPlayer {
public static void addPlayer(String username, UUID uuid, int coins) {
Database.update("insert into playerdata (username, uuid, coins) values ('"+username+"','"+uuid+"','"+coins+")");
}
My idea was to call it later in the right place.
However, this had not worked. Then I got the recommendation for another tutorial. There it says as an example that the same class should be made as follows:
public static boolean addPlayer(String username, UUID uuid, int coins) {
try (Connection conn = conn(); PreparedStatement stmt = conn.prepareStatement(
"INSERT INTO playerdata(username, uuid, coins) VALUES(?, ?, ?)")) {
stmt.setString(1, username);
stmt.setString(2, uuid.toString());
stmt.setInt(3, coins);
stmt.execute();
return true;
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
But with this method, my IDE gives me the error "Method call expected" in the try block when calling con().
Can someone help me? After formatting the file, it shortens the code. How do I use my full screen?
Probably some setting for hard wrap line length
I found the way when I'm studying thanks u for help!
Hello,
!
How do you place the player's head? (but I want to set the head skin with value instead of 'setOwner()' like )
eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMzVlMmUwOTU5NzEyZGNkMzM1N2NjM2NlYTg1Zjk5YjNmZDgwOTc4NTVjNzU0YjliMTcxZjk2MzUxNDIyNWQifX19 << value example
We can't use ItemStack because we'll place it
we can't place itemstack right?
You would need NMS
if you using paper you can setplayerprofile
is this something bukkit that when you place gravel in the air (for example with worldedit) it just falls down and it breaks?
could also be a plugin causing it
Thanks you.
Hey~!
how can I do it with nms?
there is 0 tutorial/thread on spigot database 😦
package io.github.Epicmania.randompotionplugin;
import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class RandomPotionEvent implements Listener{
@EventHandler
public void on(EntityDeathEvent event) {
boolean randomPotionGive = event.getEntity().getKiller().getPersistentDataContainer().has(new NamespacedKey(RandomPotionPlugin.getInstance(),"randompotionplugin"), PersistentDataType.INTEGER);
if (randomPotionGive == true) {
int potionIDNum = effectRandom();
PotionEffectType effect = PotionEffectType.getById(potionIDNum);
int newEffectLevel = effectLevel(effect,event.getEntity().getKiller()) + 1;
event.getEntity().getKiller().addPotionEffect(new PotionEffect(effect,Integer.MAX_VALUE,newEffectLevel));
}
}
public int effectRandom() {
while (true) {
int[] goodPotionEffects = {1,3,5,8,10,11,12,13,14,16,21,22,23,24,26,28,29,30,32};
int randomNum = ThreadLocalRandom.current().nextInt(1,33);
if (Arrays.asList(goodPotionEffects).contains(randomNum)) {
return randomNum;
}
}
}
public int effectLevel(PotionEffectType effect, Player player) {
int effectLevel = 0;
if (player.hasPotionEffect(effect)==true) {
effectLevel = player.getPotionEffect(effect).getAmplifier();
}
else if (player.hasPotionEffect(effect)==false) {
effectLevel = 0;
}
return effectLevel;
}
}
Are there any issues with this code that would crash the server, because paper crashes when the event is called.
public int effectRandom() {
while (true) {
int[] goodPotionEffects = {1,3,5,8,10,11,12,13,14,16,21,22,23,24,26,28,29,30,32};
int randomNum = ThreadLocalRandom.current().nextInt(1,33);
if (Arrays.asList(goodPotionEffects).contains(randomNum)) {
return randomNum;
}
}
}
that while loop
also randomPotionGive == true
is redundant
just check (randomPotionGive)
wait does that auto check if its ture
whats wrong with the while loop tho
you should probably use persistent data
cuz i dont think spigot interfaces well with mc commands
that while(true) is making my head die
its blocking server thread execution
Oh I think I found out what the problem was. I have now replaced what was in the parenthesis directly after try with
PreparedStatement stmt = Database.getConnection().prepareStatement(
"INSERT INTO playerdata(username, uuid, coins) VALUES(?, ?, ?)")
now this error doesn't come up anymore. But when joining the server I now get the following console output:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''false)' at line 1
does anyone know how i can fix this?
assuming that your predicate is fale (the contains thing) then it will try again until its true right
and its just once it can return that the server thread execution can continue
possibily because u left a value empty or used a wrong type for the value
is ther another way to do that
can i pikc a random number from an array?
yeah
thats how I would do it too :]
which value?
does this look better
public int effectRandom() {
int randomNum = 0;
int[] goodPotionEffects = {1,3,5,8,10,11,12,13,14,16,21,22,23,24,26,28,29,30,32};
randomNum = ThreadLocalRandom.current().nextInt(0,goodPotionEffects.length+1);
return randomNum;
}
oops
i forgot to sort through array
im stupid
Just return goodPotionEffects[ThreadLocalRandom.current().nextInt(goodPotionEffects.length)]; ?
wow that speeds things up, but also will that randomize from 0
or 1
Hi conclure please check your pms mate
cuz ik it excludes the last number
That would grab a random element in the array
no but would the randomize generator from 0 or 1, because if it starts from 1 then you would never get speed
Random#nextInt(int number) generates from 0 to number-1
So nextInt(5) can give u 0-4
but what if i wanted it inclusive 
just + 1
yeah but that is stupid
I mean it's not really an issue
lmao im just joking with u

I have a doubt, can you make an enderpearl invisible?
technically yeah i guess
How can i disable /[tab] and show the commands that i listed in config without protocollib
finally fixed :p
Bump!
hacked client be like
why are you not using protocollib?
Future has alt manager too
also usefull for tesing the anticheat
yeah ik ik i was joking
😂
can somebody help me there?
Not familiar with databases, so no
I believe someone already responded to that anyways
yes but he had not answered me again
Would be helpful if you could show some more code
ok. What do you need?
@ivory sleet the randomization works but now the potion effects dont stack, this is my code
@EventHandler
public void on(EntityDeathEvent event) {
if (event.getEntity() instanceof Player) {
boolean randomPotionGive = event.getEntity().getKiller().getPersistentDataContainer().has(new NamespacedKey(RandomPotionPlugin.getInstance(),"randompotionplugin"), PersistentDataType.INTEGER);
if (randomPotionGive) {
int potionIDNum = effectRandom();
PotionEffectType effect = PotionEffectType.getById(potionIDNum);
int newEffectLevel = effectLevel(effect,event.getEntity().getKiller()) + 1;
event.getEntity().getKiller().addPotionEffect(new PotionEffect(effect,Integer.MAX_VALUE,newEffectLevel-1,false,false));
}
}
}
public int effectRandom() {
int randomNum = 0;
int[] goodPotionEffects = {1,3,5,8,10,11,12,13,14,16,21,22,23,24,26,28,29,30,32};
return goodPotionEffects[ThreadLocalRandom.current().nextInt(goodPotionEffects.length)];
}
public int effectLevel(PotionEffectType effect, Player player) {
int effectLevel = 0;
if (player.hasPotionEffect(effect)==true) {
effectLevel = player.getPotionEffect(effect).getAmplifier();
}
else if (player.hasPotionEffect(effect)==false) {
effectLevel = 0;
}
return effectLevel;
}
Why are you using == true and == false :sadge:
q: im trying to listen and modify AsyncChatEvent but im a bit lost:
public class inline_dice_listener implements Listener {
@EventHandler
public void onChat(AsyncChatEvent event) {
String msg = event.message().toString();
if (msg.contains("[[") && msg.contains("]]")) {
TextComponent new_msg = new TextComponent("Hello ");
event.message(new_msg);
// requires component, not TextComponent but no clue how to create that
//.message is private and .setmessage() doesn't exist
}
}
Isn’t it called AsyncPlayerChatEvent
That's not spigot API
h
wath else do i do
i can jsut do else
is there a paper support discord somewhere
Yes
Can you provide a reload code for the plugin please?
?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.
== true does nothing. and == false can be replaced with ! before the statement
thanks
This should have been covered in java basics
ill keep that in mind
How can I do reload config.yml?
but for some reason people cant access player commands
Just answer the question
We're not going to give the code to you. You won't learn anything that way. Explain what you're trying to do and what part you need help with
like i put this in my onCommand and all the permissions are also defined in the plugin.yml
can you help with why the potion effect levels won't go up, like if a new effect is rolled then its added fine, but if the same effect is gotten again it doesnt take you do level two like i want it to
k (Also, i don't use protocllib btw)
Anyone know this?
Looks good
runTask just queues that runnable command to the server thread which is to be executed the next tick and that’s it
You’d use runTaskTimer if you want to run something with a fixed interval
How could i update a specific line in my scoreboard im trying to put money in the scoreboard and making it update but it just adds the line and doesnt delete the old one
Ok thank you!
Score s = o.getScore(C.Cl("&eMoney: " + d.money));
s.setScore(0);
p.setScoreboard(board);
o is the objective p is the player
d is the data of the player
ScheduleSyncRepeatingTask?
dont do score
do teams
oh
and then update the team
runTaskTimer tho
it removes flickering
how do i use teams?
But I don't use spigot scoreboards I use this https://github.com/ThatKawaiiSam/Assemble
my update code:
Bukkit.getOnlinePlayers().parallelStream().forEach(p -> {
PlayerData d = PlayerData.getPlayerData(p);
Scoreboard board = d.board;
Objective o = d.obj;
o.setDisplaySlot(DisplaySlot.SIDEBAR);
Score emptyScore = o.getScore("");
emptyScore.setScore(1);
Score s = o.getScore(C.Cl("&eMoney: " + d.money));
s.setScore(0);
p.setScoreboard(board);
});
Why are you paralleling that
declaration: package: org.bukkit.scoreboard, interface: Team
idk my friend told me its faster
It’s also unsafe, I don’t believe the scoreboard implementation is thread safe
idk how i would do that with money tho
bc i need a different scoreboard for everyone
use this
removes flickering
easy and stuff
if you wanna be clean and easy use this
ye idk how that works the docs dont help me they are confusing
What part is confusing
^
it just not clear for me
it doesnt explain it well for me
i just want examples
so i can understand it better
You're going to have to learn to use those sooner or later. I recommend taking the opportunity and letting us explain things for you
What code should I send you?
I still have, the class that connects to the database, the class that creates a config file with the data needed to connect, and just the joinlistener, where so far I have just called
addPlayer.addPlayer(player.getName(), player.getUniqueId(), 100);
in relation to it. Otherwise, in the joinlistener there is a method that creates a custom head, a PlayerJoinEvent method that contains my above call and opens an inventory for the player where he can choose his language. There is also an InventoryClickevent method.
the class
?paste
Even better upload the entire project to github so we don't have to ask you for everything
me or him?
him
ahh
okey
Do u guys have an example how i would use the teams thing
what don't you understand?
I just dont get how i would use it in my playerdata
or just at all how i would use it
That's called spoonfeeding
im just asking for an example
sry i am not familiar with github yet. Do you have a tutorial on how to import a project in the current version?
Intellij
ohh ok thanks
is there also a way to get the player name from an uuid?
while that player is possibly offline
or does this also work?
plugin.getServer().getPlayer(owner).getName();
getPlayer can be null, if they are not online.
Alright so what was the problem
hmm true but i was looking for something fast, a request to the mojang sessionserver doesnt seems really fast
Hi what is the best way to delete a world (world, world_nether and world_the_end) ? with onLoad, in the onEnable, onDisable, a separate program ?
I want the server to regenerate one after
How do I use chatcolors when using plugin logger? I tried and it didn't work
Bukkit.getConsoleSender().sendMessage(chatcolor.idk + "")
with the plugins logger it wont work
I tried a couple mins ago and for some reason bukkit.getConsolerSender wouldn't work
now it does
oh
How do u set head textures without using setOwner, so by using a minecraft link
if i try it it just makes it a steve head
SkullMeta headMeta = (SkullMeta) m;
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", url));
try {
Field profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
i have that
bro what is the command to activate this plugin
What plugin?
do /help BlockShuffle
thank u
whats a simple way to allow users to edit messages without using the config file?
