#help-development
1 messages · Page 2126 of 1
oh
track drop events and locations
Thanks!
All u need is drop item event then do ur work there
hash map uwu
got any plugin ideas guys?
Whenever a player puts a sheep on their crosshair, it starts glowing and levitates while being named _jeb
ok
is there a way to delete the "world" and regenerate it, without server restart?
with the nether and end it works fine, but with world it does nothing
Can someone explain to me why Block#applyBoneMeal has BlockFace parameter?
This might not be directly related to spigot, but anyone knows a good tutorial to learn hash maps?
It seems like everyone uses them
And useful for a lot of stuff
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.
Teleport all of the players that are there out of the world, then you may need to unload the world and then delete the world directory
This so Work Till delete, but it doesnt generate the world...
To regenerate the world do:
Bukkit.createWorld(new worldCreator("worldname"))
...
{
World world1 = Bukkit.getWorld("world");
Bukkit.getServer().unloadWorld(world1, false);
File delWorld = new File(Bukkit.getWorldContainer(), "world");
try {
FileUtils.deleteDirectory(delWorld);
delWorld.mkdirs();
} catch (IOException e) {
e.printStackTrace();
}
sender.sendMessage(DeathTimer.prefix + ChatColor.GREEN + "Generating overworld");
Bukkit.createWorld(WorldCreator.name("world").environment(World.Environment.NORMAL));
this is what i´ve done, and that isn´t generating the world...
who was the guy who asked about how to properly check if an inventory is a custom one?
like awhile ago no one replied
if u by chance read that ive found a great tutorial. not very nooby friendly but totally functional
any short "minecraft but" ideas guys?
by using what?Item Drop Event works but it summons lighting instantly
I got have a idea , i just am not capable enough to make it 😦
What is your idea
I am working on a magic wand , with magical spells and we have to creaft the magical wand by throwing some magical items in a cauldron and to use spells we need to creaft a special book in order to use that specific spells
but i am stuck on making the wand part(i have made one spell tho)
yah
the idea was not mine compltely
i am mainly doing the coding part and my one fried is giving idea about spells and recipes
show code
@EventHandler
public void onDrop(PlayerDropItemEvent event){
Player player =event.getPlayer();
Item item = event.getItemDrop();
if(event.getItemDrop().getItemStack().getType()==Material.DIAMOND&&event.getItemDrop().getItemStack().getType()==Material.DIAMOND_BLOCK){
player.sendMessage("Why are you so noob");
player.sendMessage("Get nethrite");
player.getWorld().spawnEntity(player.getLocation(), EntityType.LIGHTNING);
}
}```
this is the code
An item will never be both a diamond and a diamond block
its not the wand reipe as i was just doing some tests
Change && to || it can’t be both a diamond and a diamond block
i want to summon lighning if both are dropped on ground
not really
suppose if a drop a diamond
then after few mins i will drop a diamond block
then also it should work
…why would the event work like that?
if i try to get a player from a player name that doesn't exist will i get NPE or IllegalArgumentException?
the event gets called when one item is dropped
Neither, you will get a null Object returned
You could check for any items within a 0-1 block radius of the dropped item after 2-3 ticks
oh
ohh
what is going on in here
Also you could do player.getWorld().strikeLightning() instead of spawnEntity :)
this guy is very smart
You need to create a class and put an instance of that class in the inventory holder, than check if the holder is an instance of that class to check if its a custom inventory
Did you check that it deleted the world?
You can not unload teh main world or Nether
but with nether it works fine
i found a tutorial where u create a class that implements the inventoryholder interface and then u check if the inventory clicked is instanceof custom class
lots of up and downcasting
but it works just fine
can even store additional data because the parent class doesnt get lost
due to the nature of inventories
unless the inv gets closed
Yes that's what I mean haha
Does anyone know how to disable the ">" char and turn the bungeecord prompt to the normal prompt? My output streams don't work! Can't read the console!
I saw that exact video 👀
not video
anyways i let it run trough a for i to 10k loop couple of times to check for memory leaks
but it works just fine
guess someone made a video from it
let the instancing run for around 1m times
no increase in ram usage
so i suppose its not leaking
xD
The only way it would leak is if the inventory is stored inside of a map and never removed or the reference is never cleared so garbage collection can't delete it from memory @granite owl
yea ik as soon as the reference count of the inventory viewers hits 0 it should get GC'ed
even if its in a wrapper class
given the wrapper class has no other reference anymore
but since i actually pass the vanilla inventory with events and then upcast it without further reference like this
public static void onInventoryClose(InventoryCloseEvent event)
{
if (event.getInventory().getHolder() instanceof InventoryViewer)
{
//InventoryViewer inv = (InventoryViewer) event.getInventory().getHolder();
//TODO
//implement
}
}
there shouldnt be an issue
static?
its a callback
called from the callback
i dont implement my methods in the bukkit callbacks
cause it gets too messy too quickly
@EventHandler
public void onInventoryClose(InventoryCloseEvent event)
{
ViewInventoryCommand.onInventoryClose(event);
}
you are special
sure whatever
xD
oh no
public void onEnable()
{
Bukkit.getServer().getPluginManager().registerEvents(this, this);
Callbacks.init(this);
Ranks.init(this);
Admin.init(this);
User.init(this);
}
public void onDisable()
{
Callbacks.disable(this);
Ranks.disable(this);
Admin.disable(this);
User.disable(this);
}
also that code style breaks my brain D:
why
void method()
{
}
^^
imagine 4 different independent implementations in this. would get messy very quickly
How to get the name of a advancement the player just completed
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
PlayerAdvancementEvent or such?
^this
I'm a walking talking java doc
like uve said the compiler cleans it up anway
and in the end
the main reason for failed maintainability was always that it got too messy thanks to optimization
yes I have that but I cant figure out getting its name
xD
omfg it's not
nope its not
what will that return? the name?
interface keyed
Ok I didn't see that 👀
and then?
Methods inherited from interface org.bukkit.Keyed
I have never used Keyed in the past
.getKey().getKey() or .getKey().getNamespace() not sure
java.lang.Object
org.bukkit.NamespacedKey
seems u retrieve the name of the advancement from the key
in the end its a string
but seriously
enough help
abit own effort now pls 😛
ive been told not to spoonfeed ppl
xD
just read trough the docs u can lit apply the path u walk 1:1 in ur IDE in the end u want a string
@quaint mantle any idea how to implement the prefix in a chat msg in a better way?
@EventHandler
public void onPlayerChatEvent(AsyncPlayerChatEvent event)
{
Team t = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(event.getPlayer().getName());
if (t == null) return;
String msg = "<rank><name>: <msg>";
msg = msg.replace("<rank>", t.getPrefix().replace("%", "%%"));
msg = msg.replace("<name>", ChatColor.RESET + "%1$s");
msg = msg.replace("<msg>", "%2$s");
event.setFormat(msg);
}
problem being that javas native string formatter thats being used here easily breaks
like with using %

ive replaced % with %% to make it work but it feels like a sloppy solution
to a bigger underlying problem

What is Keyed used for
well like the inerhited inferface tells u
to namespace things
minecraft:...
bukkit:...
pluginName:...
ohh that thing
PDC for example is using it to namespace nms values so that they're seperated by plugin instance name
so to write metadata and seperate it by plugins
Is there an method to send an message to an bungeecord player? like replying to an chat event or something.
didn't find anything
how can i get the amount of an item laying on the ground?
get the entity, check if it's an item using instanceof Item then cast it to an item then you get get an itemstack from the item entity
lifecycle -> install
or use playeritemdrop event?
okay and now?
"laying on the ground"
it's building
we can get the itemstack and itemmeta using playerdropitem listner
but why isnt it like normal? So I can just press the green button
You need to setup a build configuration if you want to do that
And I would need to do that everytime I pull again? Why doesnt it remember that or smth
Reason for that is if the project has a .gitignore and it ignores the .idea folder (which is normal practice for developers), all the settings for that project are stored in that folder
so its normal to do that everytime again? Or is there smth I can/should do different so I dont have to do it everytime?
yeah it's normal
String advancement = event.getAdvancement().getKey().toString();
This will return smth like minecraft:book. How I do get the advancement name from this?
https://paste.md-5.net/ofatupaquj.sql Hi! I keep getting this error even if i moved the class
show project structure & your plugin.yml
are you talking to me?
.getKey().getNamespace()
I'm pretty sure
aight
Any ideas on how to make a cooldown without using a hashmap?
Don't
You make a cooldown without a hashmap by alt f4jng and never touching a programming language again
yeah I'm pretty sure it's impossible unless you have a custom player object in a list
but that's a shit way
U can make one using Thread.sleep (jk)
Ahahs
Because I'm dumb and don't know how it works yet
Only the Chad's use thread.sleep
learn java
Learn it
🤣
Fellow Chad meetup
now would be a great time to figure that out
I've been trying for the entire day (somewhat)
If you don't want to learn no point in you continuing coding much of anything just pay someone else to do it for you
Btw does thread.sleep freeze the server
Yea
ye
it’s pretty simple
It sleeps main thread
if done on the main thread
use put (player uuid, current time) and use getOrDefault(player uuid, 0)
then compare if the current time minus the get value is less than a certain threshhold
My hashmap is usually UUID Long for players
Thanks
try it out and let me know
👍 👌 🙆♂️
Isn't spigot single threaded
You can run tasks in a different thread
Oh ok got it got it
AFAIK it's single threaded if you try to run stuff in other threads your server dies
Like ur own threads
O
Related to bukkit directly atleast
All I know is world creator is not don't try it
Most of the stuff in the bukkit api is not thread-safe
aka stuff to do with blocks
Isn't that mojangs fault tho
anything that is dependent on game ticks really
you would probably only want to use async for external things like reading a file or connecting to a db
yea
I saw a guy, he made a like COOOOOOL AF mod like thing using minestom and all of it was server side so no mods
java: non-static variable this cannot be referenced from a static context |
could anyone help me?
what's on like 31 in Pets.java
the first image
there is no "this" in static context
@midnight shore do you know what "this" means?
yeah but the fact is that i didn't ever use this
?paste your whole class pls
what was the problem?
java
i made the class static which broke everything and i fixed by making it normal and creating an instance of the class on the onEnable method
how to get the player we are looking at
first google search
just check if its a player and boom
how can i read the config file in /src/main/resources/config.yml? i use bungee
just use the getConfig() method?
Is there an event for player killing player?
entitydeathevent
Is it possible to detect when a fishing rod hook hits a fishing "fish" thing but before the player clicks it to get the fish?
I tried projectile hit event but that doesn't seem to be working
https://paste.md-5.net/ilusemuzob.bash ? please help
Does anyone know if commons-text is part of Spigot or if I have to compile it into the plugin?
those variables are so confusing bro ngl
yes
am i meant to register command somewhere? whenever I go ingame and try to run my command, it tells me unknown command. i'm just messing around with stuff
yes
how would one do that if thats not too much spoonfeeding
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ah i see, thank you
:)
why aren’t you just setting it to petType?
also yeah those variables are like unintentionally obfuscated
in EntityDeathEvent will event.getEntityType() return me the entity that died or that entity that killed?
also you have getters when your fields are public
is anyone here?
fishing hook hit fish before player pulls rod back
how to get targetted entity
believe the entity that died
ok so how do I get the killer?
targetted what
give a bit of context as well please
if i am looking a ta pig how can i get the entity i am looking at
declaration: package: org.bukkit.event.entity, class: EntityDeathEvent
I don't see anything helpful here
how do i fix
[15:23:54 ERROR]: java.io.FileNotFoundException: plugins/HubPlugin/config.yml (No such file or directory)
[15:23:54 ERROR]: at java.base/java.io.FileInputStream.open0(Native Method)
[15:23:54 ERROR]: at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
[15:23:54 ERROR]: at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
[15:23:54 ERROR]: at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:77)
[15:23:54 ERROR]: at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:71)
[15:23:54 ERROR]: at world.netherite.hubplugin.Main.onEnable(Main.java:38)
[15:23:54 ERROR]: at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:315)
[15:23:54 ERROR]: at net.md_5.bungee.BungeeCord.start(BungeeCord.java:290)
[15:23:54 ERROR]: at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
[15:23:54 ERROR]: at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
[15:23:54 ERROR] [HubPlugin]: FAILED TO LOAD CONFIG FILE!
you have problem in the config.yml
Make sure the directory and file exists
i dont think it exists
how do i create it by default
wdym by default
it tells about nearby
not looking at
when the plugin is (re)installed
@harsh totem getEntity()#getKiller()
this.createDefaultConfig() is the easiest way, but you could also just use File() I believe.
You should just compile a config.yml in your plugin
event.getEntity()#getKiller();
Cannot resolve method 'getKiller' in 'TutorialEvents'
Creating the file by code and then manually setting default values is pain
yeah where shd i put it
in my file structure
are you still self-referencing enums while the class still isn't initialized?
weren't we talking about this like 2 days ago? 😛
thats correct
yeah it doesnt seem to be working
it's not creating config.yml on my server
np
Open your jar as archive and make sure the file is there
It should be there as long as you’re compiling with maven
clean package
nope this isn't an enum
and make sure you saveDefaultConfig on startup as well
did you solve it alreaxy, or not? I got distracted by other things meanwhile
nope
well
you initialize your Pet before you initiliaze the map
move the Map declaration ABOVE your PIGEON thing
it is
and how do i put values in the hashmap?
if you wanna keep it, at least make it static
the constructor of Pet should do it
and PIGEON should be a static field
same as your "values" field
this could be easily converted to an enum
Any idea on how I can generate a dome from my plugin?
but this is giving me an error
Can someone explain to me what is the difference between AttributeInstance#getBaseValue and AttributeInstance#getValue? I've read the javadocs but still doesn't understand.
i'm trying to avoid enums..
..in this case
wtf is a "dome"
well hover with your mouse over the error
Like a glass sphere that cuts of in the middle
no idea, you didn't show us the error message
thank you! now i'm millionaire
an attribute consists of a base value and a "modificator"
'willocore.willocore.structures.pets.Pets.this' cannot be referenced from a static context
e.g. let's say the "base value" of health for a player is 20 (which in fact it is)
for what
you can now have a "modifier" of 2
which a ... I forgot the name... of "multiply". now 2*20 = 40
but you could have the "modifier" thing to be "add" instead of "multiply"
then the result would be 22 instead of 40
It says that this line has an error but it doesn't tell me what the error is.
getServer().getBanList(BanList.Type.NAME).addBan(dead.getName()); (dead is a Player type variable)
?paste the error
it definitely does tell you the error
So If I want to modify the max health and get the max health of a player I should use the base value?
first ever null error glitch
it just marks it in red underline but when i hover my mouse on it I doesn't show me any error
should be a tab somewhere for problems
if it still doesn’t show it complie it and it’ll say
@tender shard
what placeholders are built into papi
look at the papi placeholder list
in ide or smth?
i cant download them > papi ecloud download Player [10:41:36 INFO]: Failed to find an expansion named: Player
addBan(java.lang.String, java.langString, java.util.Date, java.lang.String) in org.bukkit.BanList cannot be applied to (java.lang.String)
wtf does this mean
that you have to provide it all the parameters
it means it wants a string a string a date and a string and you only have it a string
how can i replace <sender> in a string with something
thanks
the build failed ```Execution failed for task ':compileJava'.
Could not resolve all files for configuration ':compileClasspath'.
Could not resolve org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT.
Required by:
project :
Could not resolve org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT.
Unable to load Maven meta-data from https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/maven-metadata.xml.
Could not HEAD 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/maven-metadata.xml'.
The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/7.3/userguide/build_environment.html#gradle_system_properties
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
- Try:
Run with --stacktrace option to get the stack trace.
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
the previous build worked fine though
yeah its there
how would i do that
how do I add or remove health points from a player's max health using attribute?
:checkTheDocs:
?
?jd-s
Player#setAttribute blabla
when I have a for loop in a while loop and I break in the for loop does it only break out of the for or while aswell?
i go to the website and its not loading... is spigot down?
it breaks out of both
it tells me that there is no such thing
thats why you have.. uhh.. i forgot the name
how can I get out of the for but not the while
how do i use saveDefaultConfig in bungee
like
for (int i = 0; i < 10; i++) {
inner: for (int i // blbla blaba aa) {
if true break inner;
}
}```
I used this setMaxHealth(killer.getAttribute(Attribute.GENERIC_MAX_HEALTH) + 2) but it the IDE tells me to use attribute instead of setMaxHealth
dunoo how thats called
do not think it does
It’s different for bungee https://www.spigotmc.org/threads/bungeecords-configuration-api.11214/
what does that mean setMaxHealth(double)' is deprecated
Use player attributes instead
means you shouldn’t really use it but it’ll still work
how
okay thank you!"
why shouldn't i
if so then why does it exist
?
They can remove it at any time
find it out ¯_(ツ)_/¯
errrr it says i should code the vars in
Player#getAttribute instead
and setBaseValue
The attribute is called GENERIC_MAX_HEALTH or smth
because they don’t want to break peoples plugins by removing a method
what
what does this do then
File configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
configFile.createNewFile();
try (InputStream is = getResourceAsStream("config.yml");
OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
} catch (IOException e) {
throw new RuntimeException("Unable to create configuration file", e);
}
}
i tried to add health points to the max health but I get this error even when I parse the attribute to int Operator '+' cannot be applied to 'org.bukkit.attribute.AttributeInstance', 'int'
killer.setMaxHealth(killer.getAttribute(Attribute.GENERIC_MAX_HEALTH) + 2);
all that can be replaced with saveDefaultConfig() in your onEnable()
oh wait i think youre right
It’s bungee
ah
yea you can use labels if you want to break from an outer loop
how can i make chances for my for example drops
like this, how
thought that was for inner loops
shouldn't it only break inner section?
That doesn’t return a Random
first one does
public class ThreadLocalRandom extends Random
iirc int n = random#nextInt() * (max-min+1)+min
what should i do like for example
i want a method to return one of these strings
50% chance for common
40% for uncommon
30% for rare
20% for epic
15% for exotic
10% for special
and 5% for mythical
how to do this
?
im bad at maths lol
[16:08:15 ERROR]: java.io.FileNotFoundException: plugins/HubPlugin/config.yml (No such file or directory)
it made the plugin dir
did you do saveDefaultConfig()?
ThreadLocalRandom is more performant than Random, interestingly enough
that should create it
it's bungee
ugh
saveDefaultConfig doesnt exist
Isn’t thread local random just an instance of Random on the current thread 🤔
mr demeng
it has more methods than random as well though
the config.yml wasnt created
in random.nextInt(5)
what numbers can be returned ?
1, 2, 3, 4 ?
the plugins/hubplugin folder was though
0 to 4
0 through 4
0, 1, 2, 3, 4 ?
Yes
upper bound is exclusive ye
so if i + 1 the result
i will get 1, 2, 3, 4, 5 ?
Yes
cool
Guys When I Create GUI for each player Should I set owner's "player"?
if I made a spigot API, where should I put my JavaDoc, should I rent a server then put it on, but will that cause some security issues?
i always set it to null
// LOAD THE CONFIG
//MAKE DATA DIR
if (!getDataFolder().exists()) {
getDataFolder().mkdir();
}
try {
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
File configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
configFile.createNewFile();
try (InputStream is = getResourceAsStream("config.yml");
OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
} catch (IOException e) {
throw new RuntimeException("Unable to create configuration file", e);
}
}
} catch (IOException e) {
e.printStackTrace();
getLogger().severe(ChatColor.RED + "FAILED TO LOAD CONFIG FILE!");
}```
output is the creation of the plugin dir but not config file
can anyone help
Error?
I wanna make like this. on GUI players can turn on/off skills and I wanna make this with config. It still should be with null?
none making it but
[16:10:54 ERROR]: at java.base/java.io.FileInputStream.open0(Native Method)
[16:10:54 ERROR]: at java.base/java.io.FileInputStream.open(FileInputStream.java:216)
[16:10:54 ERROR]: at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
[16:10:54 ERROR]: at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:77)
[16:10:54 ERROR]: at net.md_5.bungee.config.YamlConfiguration.load(YamlConfiguration.java:71)
[16:10:54 ERROR]: at world.netherite.hubplugin.Main.onEnable(Main.java:41)
[16:10:54 ERROR]: at net.md_5.bungee.api.plugin.PluginManager.enablePlugins(PluginManager.java:315)
[16:10:54 ERROR]: at net.md_5.bungee.BungeeCord.start(BungeeCord.java:290)
[16:10:54 ERROR]: at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:67)
[16:10:54 ERROR]: at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
[16:10:54 ERROR] [HubPlugin]: FAILED TO LOAD CONFIG FILE!```
The inventory holder mainly has to do with identifying the inventory
If you don’t need that it doesn’t really matter what you set it as
Oh I see
Thank you 🙂
why are you using a resource?
?
your entire method is way more complicated than it should be
getResourceAsStream
??
yeah
ok same thing pretty much
i don’t think it’s nearly as complicated as you’re making it
a resource would be using a file from in your jar
how do i make it work
wdym lmfao
i don’t know how to just “make it work”
.
if (!file.exists()) {
file.getParentFile().mkDirs();
}```?
if (!configFile.exists()) {
try {
configFile.createNewFile();
try (InputStream is = getResourceAsStream("config.yml");
OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
} catch (IOException e) {
throw new RuntimeException("Unable to create configuration file", e);
}```
what is getresourceasstream
pretty much what the name says
i've deleted all the config code
yeah but what is his code for it
ok so how do i copy config.yml from the root of the jar to the data folder ( getDataFolder() )
from jar file?
why would you do that in the first place?
to make the config accessable??
yes
URL
to set it as a default
you can use that
?
make the config
wait
@crisp steeple great! thanks for the input! how?!?!??!!
i’m telling you what you could do
Spigot has api for this?
public static void main(String[] args) {
URL name_of_your_res = Tester.class.getClassLoader().getResource("name of your res");
InputStream inputStream = name_of_your_res.openConnection().getInputStream();
}
i don’t know off of my head directly how to do it
this is how I usually access resource file from the jar file
i am using bungee?
Ah
is "name of your res" config.yml
Haven't read the entire conversation
does it make a difference though?
or the plugin jar file
it should still be more or less the same as spigot
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
like you wanna access abc.txt then you fill it with "abc.txt"
so "config.yml"
when I try to ban someone what am I supposed to put in the source area of the ban code line?
change Tester to your own class name
it's a reflection provide by java
so Main?
Generally the name of the player that issued the ban. Or Console, Server, etc. anything you want for the console
if your class name says so
?
why are you using class resources though? If the goal is to get an input stream, JavaPlugin supplies you with getResourceAsStream()
Does all the hard work for you
how do I set it to server. I mean I can't just put "server" there right?
Sure you can. You can put "I like cookies" in there if you wanted to
That string can be whatever you want it to be, it's the source of that ban. Whether that's the player or server that issued the ban, or just some arbitrary string, or null if there is no source
I don't know, maybe he wants to access resource in his jar file?
oh
ok
can you show us your code?
public static void main(String[] args) {
URL name_of_your_res = Tester.class.getClassLoader().getResource("name of your res");
InputStream inputStream = name_of_your_res.openConnection().getInputStream();
}
legit the code u gave me \o/
I lied, it's just JavaPlugin#getResource()*, not getResourceAsStream(). That's a classloader method
bruh please don't blindly copy code
hello i want to make a cooldown for a command, how can i provide that
yeh i'll edit it
you know where to change right?
If you want to get really easy,
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/java/JavaPlugin.html#getTextResource(java.lang.String)
Even gives you a Reader you can read from
er yeah
Wrap that in a BufferedReader if you want it to be easier to read from
URL config.yml throws an err
public class Tester {
public static void main(String[] args) {
URL resource = Tester.class.getClassLoader().getResource("config.yml");
try {
InputStream inputStream = resource.openConnection().getInputStream();
}catch (Exception e){
e.printStackTrace();
}
}
}
Tester change to your own class name
yeah ofc
there is also a much better way to copy files from the jar
you copy the main method?
what the fuck is this DIOASDOISAJDOIASJDIO0ASJDIOSAJDAS
Deveroonie you are on bungee right?
yes
bnugeechord
lmao
err what the fuck
package jdk.internal.icu.lang is not visible
try (var reader = new InputStreamReader(plugin.getResourceAsStream("config.yml"),StandardCharsets.UTF_8)) {
var config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(reader);
}```
in a nutshell
in the build
I assume you do wanna use the bungeecord config api?
yeh
I have a condition that if a player gets killed when he has 2 hearts he gets banned but when it should happen I don't get banned and then if I leave the server and try to join again I am banned
if I dont leave I can respawn forever without getting banned
public static void PlayerKillEvent(EntityDeathEvent event){
if (event.getEntityType() == EntityType.PLAYER && event.getEntity().getKiller().getType() == EntityType.PLAYER){
Player killer = event.getEntity().getKiller();
Player dead = (Player) event.getEntity();
if (dead.getMaxHealth() <= 2){
getServer().getBanList(BanList.Type.NAME).addBan(dead.getName(), "You lost all your hearts", null,"Console");
} else{
dead.setMaxHealth(dead.getMaxHealth() - 2);
killer.setMaxHealth(killer.getMaxHealth() + 2);
}
}
}```
thats the code
kick the player as well ig
instanceof is cleaner
Hi... https://paste.md-5.net/usupibifur.sql what does this error mean?
org.bukkit.configuration.InvalidConfigurationException: unacceptable code point ' ' (0x0) special characters are not allowed
yes i've seen that but i don't understand what does it mean
i don't have any spaces in the name
you can also check it at the top of the error
that there are special characters somewhere
wardrobe_97fd4734-b7c8-4cb7-a0a0-ca682aa45f06.willodb
where's the special character?
idk
Are hyphens special characters maybe?
nope
you can create files with them
also i don't understand where position 500 is?
Are you encoding with UTF-8?
i guess so
They are
new InputStreamReader(plugin.getResourceAsStream("config.yml"),StandardCharsets.UTF_8)
can someone send me pom.xml, im new in maven and dunno what to do
i think this error is referring to something else
Oh input streams. One sec, I may have something for that.
also it worked a second ago
now it won't
what does position 500 mean?
maybe something in it?
Oh, my bad then
You sure it's not something in the file
i don't see any special characters
Any one could tell how would I get TNT B puhed by TNT A explosion
entityDamageByEntityEvent is not working
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>/my/path</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
``` i dont know how to add this, and it fucked my classes (Java file outside of source root)
could it be this weird line break at the end?
shouldn't I get kicked automatically?
or the fact the hyphens are on the first column
put spaces infront of them maybe
Here is mine, stripped from all dependencies and repositories
Its super wonky in a .txt file
how can i reduce the gravity of a armor stand
Sure
Reduce or disable?
im trying to add plugin directly to my plugin folder
Ohh, @midnight shore. It might be a tab
yaml hates tabs
I don’t think that matters. As long as it isn’t spaced with tabs it should work either way.
ah
reduce, my armor stand is falling too quickly
It does, tabs tho. no good
You can't. You will have to make gravity yourself
Tabs yes, but the spacing between items in a list, not so much.
i think everything has a gravity attribute or nbt tag
Yeah
slow falling does
reduce gravity
sort of
Oh yeah...
so idk i think its possible through attributes
I just made a gravity class my self
why this happens
IDK if you can other than that
You need to import reflections i think
I did something and my code looks like this in IntelliJIDEA, anybody knows how to fix it
Just remove the build part I sent, and add your own
damn bro he needs to import mirrors
:>
close and reopem the file
usually fixes it
with stuff like that
Probably a theme. Check your settings.
thanks
how
it was a shortcut on keyboard
randomly i did that
Just remove everything that has to do with reflections
what do you mean by reflections 🥳
Remove the entire <build> part
Hi, I try to use NMS to spawn a EntitySlime, but when I create a class for my CustomEntity extends EntitySlime I get the following error, even after having a constructor:
'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
Does anyone know what the issue could be?
Your project files are in the wrong path. That’s why you are getting that error.
Your project files need to be put into src/main/java. Right now you have them in src
That could probably be fixed with a repository refresh. There’s a button for it in the Maven tab.
i cant find the main.
is it Main
i cant it says there is
Any help?
That’s probably because one of your package names is Main.
Copy your files out of src then create the folder named main.
how do you get the "epoch time" of a minecraft world?
same
As in, is there any sort of timer that only ticks up when the server is on?
I need to use this to store in-game dates and stuff
There is one for worlds if I remember correctly
You didn’t create the structure I told you to in the first reply.
src/main/java
That’s where your files need to go.
Also, your pom needs to go in the root directory of the project.
Extra files like config.yml need to go into the resources folder.
And your resources should be in src/main/resources
^
:V
Another thing worth mentioning, there is a plugin for IntelliJ called Spigot Plugin Development. It can create the boilerplate necessary to get started creating plugins. That way you don’t have to do it from scratch every time.
It works with maven too
I want to modify the login packet
But i cant inject a packet listener in
PlayerLoginEvent
And i dont want to use plib
How to do it
netty?
Yes
u need nms
I know
I cant inject a packet listener in PlayerLoginEvent
Cause playerConnection is null
And i want to modify login packet
1.8
You can inject in PlayerLoginEvent in 1.18
what do you need to do first of all
I'm pissed rn
Hardcore hearts
I had like 10 apps opened and my laptop gave me bsod
why not just turn on hardcore mode?
You are very wise man
But its bedwars
So?
That shouldn’t change anything.
but why
its the same thing as telling a player theyre in hardcore mode
But it makes no difference internally for a gamemode like that
if you send a packet to tell a player they are in hardcore mode, that is no different than setting the overall world to hardcore
iirc
pretty sure hardcore mode is client side but i am not a protocol master
when a player joins it creates the player connection and automatically sends it as soon as it's created
so.. it'd be hard without a modified version of spigot
@small current
Or… you know, use protocollib to intercept the packet.
protocollib guy on diff drugs
ikr
Some people are just built different
packet68blockexplode go brr
It was probably pretty similar across some versions.
nah that obfuscation
Any one could tell how would I get TNT B puhed by TNT A explosion
entityDamageByEntityEvent is not working
I am trying to change velocity of second TNT entity which is pushed by first tnt exploding
making TNT double jump
but does the world timer only tick if the world is loaded?
entityexplodevent?
or is it always running when the server is up
Wdym be epoch?
If the world is loaded I think
Gotcha
yeah
yikes that won't work
Then why not use the creation date of the world directory to calculate the time?
It has to be uptime
how would i check if a armorstand is colliding with anything
Because i only want to count the time that the server has been up
^
wait are you sure though? i think i remember logging off of a vanilla survival server in the nether
then when i hopped back on and went to the overworld, it was night time
Noop, not at all
If the world is loaded by the server I mean. Not specifically that someone is in it
oh my bad, i thought world only loaded if a player was in it
If you want to count the time the servers been up on enable make a task that counts up 1 second every tik
yeah I was gonna ask that
ye but i was just wondering if there was a more efficient way
Who cares all youe doing is incrementing a single number lol
thats influenced by lag
i'm tryna optimize my plugin as much as possible
Do you need to know the time for a server even if you plugin wasn't there when it was created?
yeah but still running a task every second
Ok what's it running though
Run it every minute :>
1 counter
not important, yes or no
which isnt that heavy
ugh wrong reply
And save every min or so
but then how would i save that
whatever i guess i'll just use a scheduler then lol
Objects is something cool that are in Java
That timer is like, a few operations total. A regular processor can do a few billion per second
Just saying
get the epoch and store it on plugin load and then fetch and compare?
If your server lags because of 1 number I personally take responsibility
oh wait a minute
(It wont)
thats very much big brain
It is, if the server is shut down correctly
Otherwise no
i'll have a scheduler increase it by 60 every minute then
Another thing you could do is store the server start time as a var if uptime is a command just do the math as it's requested
is spigot up?
Yeah?
Looks pretty up to mw
You can't get precision by the second if you do that. But ig you are aware
Then it is fine lol
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\tekin\Desktop\ALL\1.16.5 KINGDOM\plugins </outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
```i want to add this to pom, how can i
Just add it under project
Can somebody help me,i found plugin what i need but i can't find any placeholder.Is there any way to see in plugin jar are there any ?
You can, but you will have to find them
What plugin is it?
sec
if Bukkit.getPluginManager().getPlugin("name") != null
They would probably advertise any placeholders
under </project>?
advertiste?
Or at least mention placeholder API
On the spigot page
They would probably show them off
Yeah
it gives error
there are npc's with placeholders
Show
Ahh
so is there,but i can't find it,so myb in plugin jar but how to find
I thought you asked if there are any
Oh, yeah that is what I meant lol
so what i should do to find placceholders
yea i know
Ask there?
I,m there but server is dead
I can't dm owner before he send me friend req
And no body when i dm they say either idk,or ask someone else
So only option is plugin 🙂
one sec
It'll take you some time
this is just one exstansion
for plugin SaberFactions
@tepid oreso i open plugin via winrar?
Now i cant see the run config
this?
Wat?
No, idk if you've worked with PAPI before. But they are registered in a class
You need to find the placeholder class
Wtf is that code
how do you spawn silverfish with only one target
placeholders i think
It is that one
Hi! Does anyone have a tutorial on how to use GitHub and JitPack to share my project?
It is so chaos i mean
@Override
public void onEnable() {
// Plugin startup logic
System.out.println("Free for all plugin enabled");
//config.yml
getConfig().options().copyDefaults();
saveDefaultConfig();
no work >>>>> getCommand(name:"setspawn").setExecutor(new spawn(plugin: this));
}```
can you come dm?
ou okay
How to I spawn an entity with no AI?
accept fr @tepid ore
I only find answers with NMS, and wondered if there was a spigot API way
i dont think so
LivingEntity::setAI
e
which can be invoked in the consumer
getCommand("setspawn").setExecutor(new spawn(this));
in java we don't have this parameterName: value syntax
just pass the value
okay ty
Hello, How can I get this value from my JSON to my plugin ?
{
"Levels": {
"0": {
"commandes": [
"/Commande 1",
"/Commande 2"
],
"permissions": [
"permission.ici"
],
"blocks": {
"STONE": 5
},
This Value >>>>>> "requis": 500
},
"Test2": "test2"
},
"maxLevels": 10
}
Ping me
Hey Guys I created Inventory on My Command Class How Can I Use This Inventory on my another class
how can i check if a player is banned (or just have an event when they are banned)?
?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.
Passing things between a class is basic java
?di might be to assistance ntl
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
True
Who
?
the mean potatoe man
Ahha I just saw
wdym run it? do u wanna build it?
i want to build the prokect to specified loc
the huh to the huh?
mvn package
?
the kick event reason would be the reason i specify when kicking right?
help
you got a maven windows on the right, just press it and and doubleclick package
this?
yes click one of the arrows
anyone?
?jd-s
do i need to download sources?
lol no there are two tabs which you can expand
y clicking on the arrow in front of it
there is only 1 tab (maven)
you dont seem to have it as a dependency in your pom too
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\tekin\Desktop\ALL\1.16.5 KINGDOM ROLEPLAY\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<groupId>org.example</groupId>
<artifactId>Roleplay</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
</project>
``` its this
this is the dependency
https://www.spigotmc.org/wiki/spigot-maven/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
make sure to change the version
i guess you just added the jar manually
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>C:\Users\tekin\Desktop\ALL\1.16.5 KINGDOM ROLEPLAY\plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<groupId>org.example</groupId>
<artifactId>Roleplay</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
</properties>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
```like this?
Why is RecipeChoice.ExactChoice deprecated? what are the alternatives I could use to make a ShapedRecipe using my own special items?
or rather, why is it deprecated in 1.16.1 and not 1.16.5
oh ok, didnt know the deprecated tag could be used like that. Thanks 🙂
there should not be any problems with using that as it was a part of later API versions aswell, right?
presumably no, no problems
how can i tell if a player is banned
presumably this
player.isBanned()
ok
For the BlockPlaceEvent, why does this not change the amount?
event.getItemInHand().setAmount(event.getItemInHand().getAmount() - 1);
Makes 0 sense
why not just like this?
https://paste.md-5.net/ligemunusu.xml
it should change the amount. are you sure this line is being called?
fix the formatting btw
do you only have one item in your hand