#help-development
1 messages · Page 1786 of 1
i made evil pigs
they send random message when they get hit
Got make them attack 😉
scary
yes i will try to
import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
public class Pig implements Listener {
@EventHandler
public static void onPigHit (EntityDamageByEntityEvent event){
ArrayList<String> message = new ArrayList<>();
message.add("fuck you!");
message.add("you are stupid!");
message.add("ok can you just leave me alone -.-");
message.add("i hope you die!");
message.add("i will destroy your life!");
message.add("i hate you so much");
Collections.shuffle(message);
if(event.getDamager() instanceof Player){
if(event.getEntityType() == EntityType.COW) {
message.add("I am Cow");
event.getDamager().sendMessage(message.get(1));
}
if(event.getEntityType() == EntityType.PIG) {
message.add("I am Pig");
event.getDamager().sendMessage(message.get(1));
}
else{
return;
}
}
}
}
this is the code i used
now make item attack players
I am cow
Arrays.asList
ok, this might work
ChatColor.valueOf(sign.getColor().toString())
But that's stupid; ChatColor#valueOf() is also depricated
lol would be funny
gn(ap)
Hello everyone i hope your all doing good, i have a little question : how can i change the color of the player name above the player head ? i read team will help but it doesn't ...
i am noob too but i think this could help you
https://www.youtube.com/watch?v=2anG7qWFAho
In this episode, I'll show you how to use TagAPI in your plugin.
Websites:
TagAPI ~ http://dev.bukkit.org/server-mods/tag/
Code:
TagMe.java ~ http://pastebin.com/d4KMbaRZ
plugin.yml ~ http://pastebin.com/RtWUSq4N
thanks
?paste
https://paste.md-5.net/yisaleviru.java does anyone know how to fix these issues in my code?
final Score score = plugin.o.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "Time:"); //Making a offline player called "Time:" with a green name and adding it to the scoreboard
score.setScore(countdown); ```
if(Bukkit.getOnlinePlayers().length == 4) {
A objetive can have a string entry why need search for a "fake" player?
the length?
its in red
ok ty
can anyone help?
is there any shorter way to do this: Math.signum(-x)*(360-Math.abs(x))
you create the class GamerulesCommand and set the plugin instance.. but when register the command you create another instance of GamerulesCommand with not plugin instance set
basically i want the negated difference to -360 / 360 (whichever is closer).
-340 should return 20
330 should return -30
and so on
try making a contructor in the command for pass the plugin instance
oh ye i fixed that earlier
wait is it supposed to work now then
oh ok it works now, thanks
hey am still struggling to get this :
test: testv12
test2: test2
test3: test3
i have this in a custom config file and i want to get the keys test test2 test3 and send them to player
o.o
idk how to do it
YamlConfiguration#getConfigurationSection("Tags")#getKeys(false)
ok i will try that thank you
:o IT WORKED
thank you
how can i store them in an array ?
what's better for my server? having one method that checks for 30-ish different things, or having 30-ish methods
like which one would lag less
Are they being run at the same time regardless
wdym
Is it 1 big method being run vs 30 methods being run at the same time
Or are the 30 methods spread out
i just want to be able to display them into gui
how can i do that ?
basically i have this gui, in this gui there are toggleable things, to make them toggleable, i have to run a method of some sort to check if it's on or off, and act accordingly
so should i have 30 methods (1 per toggleable thing), or should i have 1 method where you can input text that will then run like 30 if statements and will find the one i need
Sure, just loop over the list and add the name onto an item or whatever
okay
The difference between the two is very minimal, do whichever is cleaner and easier to read
@lean gull just use an array or map
wdym
in which you store the boolean for each button
no it's with gamerules, i'm making a gamerules gui
so like announceAdvancements, that's toggleable
ah
and then commandBlockOutput
so like each toggleable gamerule would have a true item, and a false item
two items per gamerule?
well not exactly
wait wym with item
all i need to do is have a gui that can toggle them
and you want to have two buttons, one for on and one for off?
the storing whether it's true or false is already done by minecraft, i just set the gamerules
instead off a toggle
no
if it's true, then you will have an off button
if it's false, you will have a true button
well each item is gonna have it's own lore, explaining what it does
so i think it's best if i just have like the lore, and then i create the item with 2 different items if it's true or false
So you basically then have a list of <your class that contains the gamerule name and the lore>
If you only care about true/false ones I can think of an easy way to do it
nvm i'll just do it my way, thanks tho
just loop over all gamerules and if true : red wool, if false: green wool
u dont need 30 ifs for that
ye but i want it to look pretty
also i'm not gonna use 30 ifs, i'm gonna use 30 methods
even better
^
wat dat
switch(){
}
huh
Make a list of gamerules and get the one you want to edit based on the index of the clicked slot
let me look up the proper way to code it into the switch
just do it your way and then we can compact it, alright iDerpy?
yeah
thanks btw
no problem, thats what i'm here for
same
give and take, isnt it
u two are way better than the normal people around here
lots of good people here tho
i can only wish i would one day have enough knowledge to give
if you keep asking questions you at one point will
😄
true :D
but dont ask them on stackoverflow, they dislike the hell out of you
if ur a beginner
how does getNearbyEntities work? what parameters does it need?
the param names are not very explicative
i just ask here, since u get answers quickly instead of having to refresh the page every 5 minutes
also i don't think many people even use forums and stuff
i think its the radius
i mean what do the parameters do
how far in each direction
you give it an X, Y and Z and it will give you all the entities within that radius
ah so it's a cube
a cube if all the parameters are the same
yea i meant a cubic shape
a 3D rectangle or whatever u call it
can you get them in a circle?
c u b e
not without problems
isnt a cube same length on all sied? xD
yeah theres a function i think
squares are rectangles
nvm, that function only exists in the client, not in server
:c
ye but squares are rectangles that are even on all sides
want me to write u the function?
so like a cube in this case can't be a 3d rectangle
i thought of looping every entity and checking the distance from location
a rectangle is a shape with 4 sides which only has 90° angles
is there a better way?
it is?
could do
i stand corrected then
yes there is
Loop all entities in the world and use distanceSquared
loop every entity thats in the box
Actually
less entities to loop over
might wanna limit it to LivingEntities if your application allows it
nah don't worry but if you have a better idea lmk
oh ye
Loop every entity in the box and then use distanceSquared
so first getNearbyEntities
that would be optimal
issue is i might need it around a location too
Location.getNearbyEntities exists
world does
you can do location.getWorld().getNearbyEntities()
in case you need to match worlds with a certain entity
yea and then i check the distance to make it a circle
mhm
yeah
aight tyy
Using circles in a square game is cursed
Use an abstract class
Make the class abstract
And make the method abstract
ah thats what abstract is for
make class and method abstract
3 years of java and never used it
oh someone told already
how does one make a field variable for a spesific method that deletes itself after it's used?
when i figured out my brain kinda exploded ngl
xD
make the variable inside the method
you are you probably did something wrong if you never used them
:(
the thing that actually creates it is in 2 if statements, so i need to make a field in the method, set it in one of the if statements, then return it
oh nvm i used it in my commandbuilder
show ur code so i can understand better xD
me?
I know im doing something wrong in my plugin. I havent used any interfaces or abstract classes even tho now I see where I could use them. Now im in too deep to change it. XD
yeah
Sameeeeee :D
And static all the way
xD
rewrite your plugin from zero
rewrite your plugin from zero
as I said. Im in TOO DEEEEEEP
public class Blaze implements AttackEnchant, ChanceEnchant {
@Override
public String getId() {
return "blaze";
}
@Override
public String getDisplayName() {
return "Blaze";
}
@Override
public String getDescription() {
return "Chance to burn all enemies in an area of the victim.";
}
@Override
public int getMaxLevel() {
return 3;
}
@Override
public EnchantRarity getRarity() {
return EnchantRarity.ELITE;
}
@Override
public EnchantType getType() {
return EnchantType.AXE;
}
@Override
public void onAttack(@NotNull AttackWrapper wrapper, int level) {
}
@Override
public List<Double> getChances() {
return Arrays.asList(2.0, 3.0, 4.0);
}
}
``` very abstract
static => global access => less lines of code => efficienancnecy? (/s)
yuss
If your 50 line classes don't turn into 1000 lines of bytecode it's not abstract enough
Ok so what variable do you want to be deleted after "being used"? and what does being used mean in that case?
im not sure what you want us to help you with. elaborate?
I oftenly use abstract classes to share common stuff between interface implementations
because the announceAdvancementsItem goes into the trash collector after being used.
i'm trying my best to not use a lot of storage, so what i want to do is make the item, return it, and then delete the variable of the item so it's not going to take up more storage
My enchantments are abstracted out of Java code :p
I rarely actually use abstract classes, mostly interfaces and then concrete classes with strategies
^
ah i see
or well atleast delete the variable for the method, not for where i need it to be returned
sometimes tho i need abstract classes
dont worry about it. it already deletes itself after being used. (basically)
so i should just use a normal field for every gamerule?
tho now that i discovered interfaces have default methods
iDerp, your variable is just a reference to a memory adress
i'd rather use them
well actually depends
me no big brain help me no understanddd
you cant have fields on interfaces though
a
u no need delete
ok!
xD
you are referencing a memory adress, the memory adress contains the value. when dereferenced (after the method is through) it will be used for something else
so normal field outside a method?
when you return your arraylist, it doesnt get duplicated
so therefore no need to delete it in that method
what you actually return (under the hood) is just the memory adress the arraylist is saved at, and not a copy of the arraylist.
yea
actually could you give more info on that? not sure what you mean by it
passing objects like events in parameters and cancelling them in the method
as an example
If you pass an integer into a method, and then add 7 to it
The original integer you passed in will not change
search up the difference between primitives and objects
primitives dont have classes is what Im coming up with myself
for Obejcts, you pass a reference to it. On primitives, you pass the actual value
and mutable and immutable
got it
int.class, double.class tho ☹️
xD
Integer.class
Integer.class != int.class
Does primitive.class just return the wrapper class? I actually have no idea
The main difference is that primitives are special types that cannot be null, primitive datatypes cannot create objects for instance an int is not an object.
Nope
that's now how it works
it returns a special class instance representing the primitive data type
Interesting
ye
o.O
it is if your API is good enough
is there a way to check if a command from PlayerCommandPreprocessEvent actually is the command i want for /namespace:command and aliases?
or do i just have to check them manually
lmao
yuh
how 2 get opened gui of a player
Integer is a wrapper around int that extends Object, so you can use ints in context where Object is required like hash maps
Player#getInventory()
but dat is their inventory, not the top part
getOpenInventory iirc
player.getOpenInventory().getTopInventory()
yea i went to check and was abt to say that
or bottom for their actual inv
me too slow :c
.
Iirc you have to do it manually
why the heck do you have to use e.getEntity() in the PLAYERDeathEvent
yAy
are the params in getNearbyEntities the length of the cube? in that case i'd need to double the radius to make them
wouldn't I
so no multiplying
its the sides. first x, then y(height), then Z
it says the params are half the cuboid size
simply the radius
so if i input the radius it multiplies by 2 itself
and makes a full side of the cuboid
yeah, the side length will be radius*2
it means the X side will be double the value you enter
because it goes into positive X AND negative X the same amount
and thats the same for the other 2 parameters too
so if you enter getNearbyEntities(5,3,10) you will get a box around the center with the size of 10, 6 and 20
mhm
yea i mean i need to input the radius of my circle
its a box
did you read what i'm tryna do
get the entities in a radius from a location
i get the entities in the box
and check if they are in a circle radius
oh I seem to have missed that
that's why i was saying radius
sadly getNearbyEntities is in a black box.... cant see the implementation or I could tell you wether its worth getting that first. might actually loop through all entities in the world and select the ones close enough to be inside
ok i have finished one toggleable thingy
if anyone can help me make it better, and less laggy since i need to make a lot of methods simillar to this one then that would be great, thank you!
https://paste.md-5.net/torozeboze.cs
I mean it isn't in a black box
Spigot is OS
Also this is java so you can decompile things
didnt wanna do work but youre making me do work
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z) {
if (location != null && location.getWorld().equals(this)) {
AxisAlignedBB bb = new AxisAlignedBB(location.getX() - x, location.getY() - y, location.getZ() - z, location.getX() + x, location.getY() + y, location.getZ() + z);
List<net.minecraft.server.v1_8_R3.Entity> entityList = this.getHandle().a((net.minecraft.server.v1_8_R3.Entity)null, bb, (Predicate)null);
List<Entity> bukkitEntityList = new ArrayList(entityList.size());
Iterator var11 = entityList.iterator();
while(var11.hasNext()) {
Object entity = var11.next();
bukkitEntityList.add(((net.minecraft.server.v1_8_R3.Entity)entity).getBukkitEntity());
}
return bukkitEntityList;
} else {
return Collections.emptyList();
}
}
here you go
it kinda looks like it goes through all the entities tho
so its literally getting every entity and checking wether its close enough to you
yeah so only implementing the circle and going through every entity in the world to check if its close enough to you seems better
Depends what this.getHandle().a does
i kinda need to study now :p
It may be smart and use chunks
no
it does iterate through all the entities
Yes, and entityList comes from this.getHandle().a
I'll go look what getHandle.a does
public WorldServer getHandle() {
return this.world;
}
imo something thats called entityList.iterator and is used on something that contains net.minecraft.server.v1_8_R3.Entity with no predicates will contain all entities
protected void a() throws ExceptionWorldConflict {
this.checkSession();
this.worldData.a(this.getWorldBorder().getSize());
this.worldData.d(this.getWorldBorder().getCenterX());
this.worldData.c(this.getWorldBorder().getCenterZ());
this.worldData.e(this.getWorldBorder().getDamageBuffer());
this.worldData.f(this.getWorldBorder().getDamageAmount());
this.worldData.j(this.getWorldBorder().getWarningDistance());
this.worldData.k(this.getWorldBorder().getWarningTime());
this.worldData.b(this.getWorldBorder().j());
this.worldData.e(this.getWorldBorder().i());
if (!(this instanceof SecondaryWorldServer)) {
this.worldMaps.a();
}
this.dataManager.saveWorldData(this.worldData, this.server.getPlayerList().t());
}
``` oh wtf
how can i make an abstract method always run another method?
@Override
public List<Entity> getEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, Predicate<? super Entity> predicate) {
this.getProfiler().incrementCounter("getEntities");
List<Entity> list = Lists.newArrayList();
this.getEntities().get(axisalignedbb, (entity1) -> {
if (entity1 != entity && predicate.test(entity1)) {
list.add(entity1);
}
if (entity1 instanceof EntityEnderDragon) {
EntityComplexPart[] aentitycomplexpart = ((EntityEnderDragon) entity1).getSubEntities();
int i = aentitycomplexpart.length;
for (int j = 0; j < i; ++j) {
EntityComplexPart entitycomplexpart = aentitycomplexpart[j];
if (entity1 != entity && predicate.test(entitycomplexpart)) {
list.add(entitycomplexpart);
}
}
}
});
return list;
}
pretty sure you can't
:/
yeah so you just have to for(Entity e: world.getEntities()) through it all and check for each wether its close enough...
any workaround?
Make sure to use distanceSquared over distance
can't think of any, never needed that
a kk
You just need to make sure to square your threshold
so range * range
yep
i guess this is because computing multiplications is faster than sqrt?
or divisions
what's math
Well the distance formula returns the squared location
so you just do distanceSquared and it gets you the actual distance in blocks?
And sqrt isn't the cheapest mathematical operation
thats cool
oh ok fair enough
I believe it's Manhattan distance? not sure
lol
oh youre serious... i thought you were going on about how people in the US (specifically manhattan) like to measure distance in blocks
thats what someone who doesnt have enough dedication would say
I was making mobs with Armor and when testing them they release their armor, how can I make that not happen?
you mean drop?
I have the class Menu (which is abstract) and the class ChunkMenu, which extends Menu.
In Menu have the method onRender(), which is abstract, or in other words, ChunkMenu has to override it.
Now I want every onRender() call of a child (f.e. ChunkMenu) to also run a specific function (or some default code) in the Super-Class (Menu).
Is abstract wrong for this?
I dont want to have to call super(), it should be automatic
How do I do it?
if so you can set the dropChance to 0
Yea it implicitly invokes super()
Oh thanks
oh
if it’s a nullary one (no args) then you don’t have to declare it
can it be abstract tho?
Constructors can’t be abstract
well i dont want it to be a constructor, onRender() should be a method
Yeah then it can be abstract given that the class isn’t a concrete one
says Abstract methods cannot have a body
xD
Is
abstract class Blah {
protracted abstract void onRender();
public void render() {
//DO OTHER STUFF
this.onRender();
}
}
wait, ill send my code ok?
its almost midnight forgive me tired
Then derive Blah and override onRender
so then its gonna do the OTHER STUFF before running the onRender function?
Idk
It’s in case you wanna take full advantage of a concrete-abstract inheritance relationship
So these are my two classes:
https://paste.md-5.net/jolokakudu.java
https://paste.md-5.net/pasihamubu.java
And now I wanna do
ClaimChunkMapMenu menu = new ClaimChunkMapMenu(menuName, player, mapItem);
menu.onRender(...);
and it should (by itself) run the defaultRenderStuff() method in MapMenu before (or after) running the onRender() function in ClaimChunkMapMenu
but idk how to connect it in the MapMenu class
i only know one can do super() in the children
If you want that
You’d have a public function which runs defaultRenderStuff then onRender
Going back to Blah
in render
You’d have
public void render() {
this.defaultRenderStuff();
this.onRender();
}
and then call render() on the child?
You’d make the abstract method protected
and make the renderDefaultStuff internal
Such that you enforce any users of MapMenu to use render()
internal = private?
Yes
it should be inaccessible to outside classes, which have no tight relation to MapMenu or one of its subclasses

makes sense now :D
🥲
is there a way to intercept when the console uses a command?
since it's PlayerCommandPreprocessEvent
ServerCommandEvent perhaps?
Hi, how can I modify static final with a reflection on java 12+? I can't just change modifiers like in java 8
You can
Can you?
At least up till 16
Ah right, with the runtime flag
I had a bookmark for it, but not at mc pc
Basically use the new reflection API as it doesn't check
I'm currently using 17
I have the ugly unsafe code somewhere, which should also work
depends, if the static final field is a primitive data type or String, then it will get inlined
thus impossible to change at runtime
I found this page, but not sure if that's what's I'm looking for https://www.buzzphp.com/posts/change-static-final-field-in-java-12
?paste
Thanks, I was looking exactly for that
I'd use that over unsafe
Does it work in j17?
"This approach may break at any time so best not to rely on it. In general, nobody should expect to be able to change a static final field. "
Yeah well, try being a mod dev
Actually this isn't an issue with forge/fabric so nvm
mixins 😄
I'm gonna try that one. looks a bit simpler
ATs as?
Plugins 👏 are 👏 not 👏 mods 👏
ah yeah
wait can you remove final with access wideners?
\tranformers
Yep
interesting
They're meant to become less :(
public-f
I still need to figure out how to actually modify spigot properly, because am slow XD
🌞
I know how to make the changes in Bukkit/CB, but not how to build a jar with said changes
In which project? Spigot I assume?
Bukkit/CB
Is the bungeecord plugin messaging api safe to use async (ie asyncplayerchatevent)?
Ah, will that still output a spigot jar
No but usually not necessary for simple testing
If you want one, you would commit and then run BT with --dev --dont-update
Should be
Ok
Oops replied to wrong one
md_5, spelling mistake in MapPalette description
"These fields are hee base color ranges"
was wondering for 5 minutes what a "hee base color" is
xD
hex
HEE-HEE
hex makes sense yea
well i assume hex since theres not a lotta other things that make sense
xD
i only use --dont-update not remember why not use --dev xd
--dont-update was yeeting my changes when I tried last
If you want a graphics file with one pixel per map palette color, you can download them from bobcat00.com
Maybe because I hadn't committed them
It probably is the
I don't think you can add hex colors to maps
my only issue is when change the branch to master and for error make changes in this branch xd
ty, good to have i guess
No, you're stuck with the 244 colors defined by the map palette.
isnt it all of them?
Believe it tries to get the closest color to the passed argument with one of the methods, but yeah you’re stuck with those colors
And I don't think any of them are black.
can someone help ,me with components, again pls
because my formatting is leaking into the other ones in my BaseComponent[] for seemingly no reason
Minecraft does a lousy job of matching colors. If you're trying to display an image on maps, you're better off using the files I linked above with an image editor to adjust the palette of your image. Use dithering, instead of the closest match.
usernameColored has a hover event, that leaks into the arrow, and chatmessage
mute also has both a click and hover event, but it stays in its own thing
I believe you have to set the hover event to null again?
tried that, nothing happened :(
well wait, how
i tried making a new HoverEvent() and making everytihng null for it, and then i tried (HoverEvent) null
neither worked
i can try again tho
An example:
Oo. That’s a good example
Let me peek at the javadocs
?jd-bcc
i'll do the same^
Seems like you could specify format retention
tried
i'll try another null HoverEvent, because for al i know it didnt save /shrug
Hmm seems like format retention works fine for me
FormatRetention.HOVER?
NONE
ah, tried NONE -- didnt work, trying the empty hover event now
so i should apply this to arrow?
will it clear all of the formatting FOR arrow?
Try applying it in every append maybe
alr
yeah that didnt work @ivory sleet
here's my updated code, i could just be doing a dumb thing and not fully understanding
What event gets triggered when a creative player opens his inventory?
In survival not, but in creative there should
cuz the inventory refreshes
all fake items dissapear
means it asks the server for the inventory
means event
Try InventoryOpenEvent
might be it, ill try
define "fake items"
items that i created by sending a packet
so its packet
therefore, its a client-side event
what
if it doesnt exist to the server, how is the server going to remove the fake items
the client removes the fake items
but think about this: how does he know theyre fake
so then how would triggering a server event activate that
when the player opens his inventory in creative, it sends a packet to the server. server sends back the real inventory. client sees the fake items arent there and removes them.
-> theres an event for creative inventory opening
in survival the fake items stay
im not entirely sure thats how that works
but you dont know basic inventory events? 🤔
yea im new to spigot
xD
ive made clients tho
where i worked a lot with packets
so yea
I'm having an issue using Gson, ```json
{
"from": 1,
"to": 1,
"currentPage": 1,
"total": 1,
"totalPages": 1,
"queryTime": "0.020",
"totalTime": "0.025",
"partial": false,
"canonicalUrl": "/v1/products(sku=6453207)?format=json&apiKey=SECRET",
"products": [
{
"sku": 6453207,
"score": null,
"productId": null,
"name": "Sony - 75" Class X85J Series LED 4K UHD Smart Google TV",
"source": null,
"type": "HardGood",
"startDate": "2021-04-26",
"new": false,
"active": true,
"lowPriceGuarantee": true,
"activeUpdateDate": "2021-04-26T00:01:52",
"regularPrice": 1599.99,
"salePrice": 1299.99,
"clearance": false,
"onSale": true,
"planPrice": null,
"priceWithPlan": [
]``` is what I'm getting from my url, i'm trying to get "regularPrice", this is my java code: ```java
String jsonS = "";
URL url = new URL("https://api.bestbuy.com/v1/products(sku=6453207)?apiKey=SECRET&format=json");
URLConnection conn = url.openConnection();
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
jsonS += inputLine;
}
Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(jsonS, JsonObject.class);
String id = jsonObject.get("products").getAsString();
in.close();
System.out.println(id);```
how do i get "regularPrice"?
so far I can only get everything from before products (i'm new to Gson)
I feel personally attacked
lol
use getAsJsonObject on products then you can access the child keys
You right, its not how it works. Doesnt get fired
But then how does the client suddenly know the items are fake
o.O
because its all client side lol
well ofc, but how does it know they dont exist
cause the server tells them
and theres no event catching it?
throws a classcastexception
(its about creative inventory opening btw)
see @quaint mantle
That's like the only way.
Or creative players have some kinda second inventory, but idk
Post your code
Gson gson = new Gson();
JsonObject jsonObject = gson.fromJson(jsonS, JsonObject.class);
JsonObject id = jsonObject.getAsJsonObject("products");
String rp = id.get("regularPrice").getAsString();
in.close();
System.out.println(rp);```
^
Where does it throw the exception
JsonObject id = jsonObject.getAsJsonObject("products");```
this is the entire error Exception in thread "main" java.lang.ClassCastException: class com.google.gson.JsonArray cannot be cast to class com.google.gson.JsonObject (com.google.gson.JsonArray and com.google.gson.JsonObject are in unnamed module of loader 'app') at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:182) at d.cop.main(cop.java:27)
oh my b
use getAsJsonArray
then get first element in the array and that's your jsonobject
I am very confused lmao hold on let me try that
we're actually getting somewhere but now it says Exception in thread "main" java.lang.IllegalStateException: Not a JSON Object: [{"sku":6453207,"score":null,"productId":null,"name":"Sony - 75\" Class X85J Series LED 4K UHD Smart Google TV","source":null,"type":"HardGood","startDate":"2021- ........... at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:90) at d.cop.main(cop.java:29)
jsonObject.getAsJsonArray("products").get(0).getAsJsonObject().get("regularPrice").getAsString()
I edited it make sure you have new version
Ye that's like the shittiest way to work with GSON
DTOs are way easier
but I don't feel like explaining that
heard
Ok, so opening the creative inventory does not trigger the OpenInventoryEvent, but it requests the inventory content from the server.
is there any event for that request?
or do i have to use nms
I doubt it requests the content from the server
Creative inventory is fully client side
then how would it know the real item?
it definetly does
See how the leaf disappears exactly when i open the inventory?
the client thought theres a map in that slot. how would it suddently know there's actually a leaf-block
What inventory, you are typing a command
on the right bottom?
The bottom right of the screen isn't even in the gif
but the hotbar is
look at the hotbar, thats the important part
the selected slot
didnt wanna do fullscreen gif as thats like 60 MB
u can see everything important in that gif already
Yesss, i got it
it triggers InventoryCreativeEvent and InventoryClickEvent (even tho i didnt click a thing)
good to know
told ya it communicates with the server xD
how can I run a command from console in my plugin
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "command";
Bukkit.dispatchCommand(console, command);
I saw that thread, does it matter if theres a slash or not?
alright, thank you 😄 hopefully it works cuz ive been trying to do it and it hasnt
hmm it worked, I guess there was a conflicting plugin
is there a way to send it as op?
nvm ill look it up
isnt console op by default?
yeah but some plugins dont let console run command so wouldn't running it as op make it so that the check for console not care since its still a player doing it
if you run it thru the console, you run it thru the console
xD
which is op by default, so cant check that
maybe you want Player#performCommand ?
ehh oh well if theres issues with that, thats a later issue to fix
yea
is there a way to hide that the console ran it? just so I don't spam console
idk, sry
im making a team per player
team = board.registerNewTeam(player.getUniqueId().toString().substring(0,15));
i get no errors but in game the team isn't there
would the floating writings be armor_stand?
how does each different player see their name or stats on the floating text?
Generally they are client side entities made using packets
ArmorStands or AreaEffectClouds are the common used entities
Coll why are you a nerd?
Idk why are you smelly?
Because you stole my soap
Rekt
aw
does anyone know how i can push the victim to attacker at speed 3?
like i'm trying to get the vicitm pulled to the attacker
You supply a vector to the method
.
event.getCaught().setVelocity(event.getCaught().getLocation().toVector().subtract(event.getPlayer().getLocation().toVector()));?
if(!(event.getCaught() == null)) {
if(event.getCaught() instanceof Player) {
Bukkit.broadcastMessage("debug");
if(event.getPlayer().getInventory().getItemInHand().getItemMeta().getLore().contains(Color.translate("&3Grappling"))) {
Bukkit.broadcastMessage("debugxd");
event.getCaught().setVelocity(event.getCaught().getLocation().toVector().subtract(event.getPlayer().getLocation().toVector()));
}
}
}
}
}```
doesn't work
and none broadcast
yes
LOOOL
ok i added @eventhandler
@young knoll
put pushes them really far away
from me
not pulling them torwards
[02:29:22 WARN]: Excessive velocity set detected: tried to set velocity of entity #2750 to (0.4499006208195624,0.9361249792364532,5.40070935867368).
[02:29:22 WARN]: java.lang.Exception: Stack trace
pushes at me too quickly
errors this as well
Like I said, normalize it
And then multiple it if you want to speed/slow it after that
how do i normalize it
.normalize
At the end of the new vector
You may want to use some variables to clean that long line up
event.getCaught().setVelocity(event.getPlayer().getLocation().toVector().subtract(event.getCaught().getLocation().toVector().normalize));
doesn't work
event.getCaught().setVelocity(event.getPlayer().getLocation().toVector().subtract(event.getCaught().getLocation().toVector().normalize()));
?
Vector velocity = event.getPlayer().getLocation().toVector().subtract(event.getCaught().getLocation().toVector());
event.getCaught().setVelocity(velocity.normalize());
public void onFish(final PlayerFishEvent event) {
if(event.getCaught() instanceof Player) {
if(event.getPlayer().getInventory().getItemInHand().getItemMeta().getLore().contains(Color.translate("&3Grappling"))) {
Vector velocity = event.getPlayer().getLocation().toVector().subtract(event.getCaught().getLocation().toVector());
event.getCaught().setVelocity(velocity.normalize());
event.getCaught().setVelocity(velocity);
}
}
}
}```
?
Get rid of event.getCaught().setVelocity(velocity);
why
Because you already set it the very line above
what would i use to check if an item display name is italic
using PlayerInteractEvent btw
Event doesn't really matter
Check if the name contains §o
Actually using ChatColor.ITALIC is probably better
can i have en example?
if(event.getItem().getItemMeta().getDisplayName().toLowerCase().contains(ChatColor.ITALIC.toString()))
Several things can be null there
Fair enough
Do you check if the item hasItemMeta
Otherwise you make a new meta instance for no reason, also getItemMeta returns null for air
Is it normal for entities to still take knockback from a punch bow if their knockback resistance attribute is 1? 
What version
The scale of horizontal knockback resisted from attacks and projectiles. Vertical knockback is not affected. Does not affect explosions.[3] 1.0 is 100% knockback resistance
I guess they still go up
It moves horizontally though 
The entity is in the air, wonder if that as anything to do with it
Yeah I do when wearing the armor as well
Let met test sp
Still move horizontally in sp too
Weird
So minecraft issue?
Guess so?
Interesting
I'll do more testing soon to see if I can find the exact cause/issue
Hey there! I was just wondering peoples' opinions on the best way to create a player shop. The way I was thinking approaching it was
// Page index, slot index, associated function
private static final Map<Integer, Map<Integer, Runnable>> pageFunctions = new HashMap<>();```
Thoughts on this approach?
I can just look up which page they're on, which slot they've clicked on, and execute the associated function
You could use a table to avoid the nested map
just check for events and certain properties with the clicked items i feel like
i.e; Page: 7 >, you could remove "Page" and "7" to see ">", which would go to page 8
etc.
java.lang.NullPointerException: Cannot invoke "net.neednot.LastLife.getConfig()" because "this.plugin" is null
at net.neednot.commands.Transfer.<init>(Transfer.java:18) ~[LastLife-1.0-SNAPSHOT.jar:?]
at net.neednot.LastLife.onEnable(LastLife.java:15) ~[LastLife-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:730) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1217) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-338]
at java.lang.Thread.run(Thread.java:831) ~[?:?]
i added commands and now it does this
this.getCommand("transfer").setExecutor(new Transfer(this));
public Transfer(LastLife instance) {
plugin = instance;
}
FileConfiguration config = plugin.getConfig();```
Is there a way to get all the classes that have a certain annotation instead of grabbing each class manually?
I do it per package
See https://github.com/Jishuna/MineTweaks/blob/c171aa154b7a015820a02b9301cc572953f00c44/src/main/java/me/jishuna/minetweaks/api/tweak/TweakManager.java#L38 and https://github.com/Jishuna/JishunaCommonLib/blob/5f76edda199d0fcc0b8c6142fd56dec69c71c55e/src/main/java/me/jishuna/commonlib/utils/ClassUtils.java#L24
i do it the exact same in my other plugin but it wont work in this one
You are instantiating config before the constructor is called
I kinda want to treat it more like a tree, if you know what I mean. This could mean setting it out in this way, but just skipping numbers according to the tree.
LastLife plugin;
public Transfer(LastLife instance) {
plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
FileConfiguration config = plugin.getConfig();```
same error
send main class
package net.neednot;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import net.neednot.listeners.Events;
import net.neednot.commands.Transfer;
public final class LastLife extends JavaPlugin {
FileConfiguration config = getConfig();
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new Events(this), this);
this.getCommand("transfer").setExecutor(new Transfer(this));
config.addDefault("Random", true);
config.addDefault("Min", 4);
config.addDefault("Max", 7);
config.addDefault("Set", 7);
config.options().copyDefaults(true);
saveConfig();
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
Events and Names it works fine
i'd make it into a config then, instead of hardcoding
I havea custom interface that as things such ass String name() I got different classes using the annotation I want to be able to grab every class and display the variables without doing something like ```
SomethingModule anno = Class.class.getAnnotation(SomethingModule .class);
See the code I sent
new error ```
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "net.neednot.LastLife.getCommand(String)" is null
at net.neednot.LastLife.onEnable(LastLife.java:15) ~[LastLife-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Paper-338]
at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:730) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:317) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1217) ~[patched_1.17.1.jar:git-Paper-338]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-338]
you need to put the command in your plugin.yml
i did
send plugin.yml
Hello. when i try to use Bukkit.getWorld(name) for a multiverse world, the world will be null
Make sure your plugin loads after multiverse
thanks
yeah but when I try it returns it empty
Weird
im not using spigot btw
Are you entering the package name correctly
yea
Don’t see why it would be any different outside of spigot
Unless you are giving it the wrong classloader
I don't think I am
for (Class<?> clazz : ClassUtils.getAllClassesInSubpackages("me.jtx.nitrous.module.impl",
this.getClass().getClassLoader())) {
if (!TYPE_CLASS.isAssignableFrom(clazz))
continue;
for (DraggableModule annotation : clazz.getAnnotationsByType(DraggableModule.class)) {
try {
DraggableModuleContainer moduleContainer = ((Class<? extends DraggableModuleContainer>) clazz)
.getDeclaredConstructor(Nitrous.class, String.class)
.newInstance(plugin, annotation.name());
name.add(moduleContainer.getName());
} catch (ReflectiveOperationException | IllegalArgumentException e) {
e.printStackTrace();
}
}
}
i'm trying to make plugin for catserver, but console says COULD NOT FIND MAIN CLASS.
plugin.yml is right under the src folder
can i get any way to solve this
Because the main field in your plugin.yml isnt pointing to your main class
..so?
Take a look into this: https://www.spigotmc.org/wiki/plugin-yml/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yo wait guys holldup
?!?!/
Yall how long has this been around for
like since 1.16 I think
nothing changed
i already did same
If it says it cant find your main class, the main field in your file is 100% not pointed at the main class extending JavaPlugin
<console>
[14:03:13] [Server thread/ERROR]: Could not load 'plugins\ping.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.miro243.Main.Ping'
<plugin.yml>
main: me.miro243.Main.Ping
name: Ping
author: miro243
version: 0.0
description: YES
sry for that
several spigot plugins seems working in catserver but
why mine doesnt?
hold on i cant use that to upload pngs
plugins.yml
https://paste.md-5.net/ozizatozeg.http
🤔
That does in fact look right
when you left click on someone in spectator mode you can view their perspective, is there a way to do that in this api?
Are you in spectator
Well I’m just trying to make it so when you die you instantly spectate a player
With their perspective
Let’s see the code
One second
My mc crashed for some reason
public Files data;
@EventHandler
public void onDeath(EntityDamageEvent event) {
this.data = new Files(Main.getInstance());
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (((Player) event.getEntity()).getHealth() <= event.getDamage()) {
event.setCancelled(true);
if (!this.data.getConfig().contains("Players." + player.getUniqueId() + ".Banned")) {
this.data.getConfig().set("Players." + player.getUniqueId() + ".Banned", true);
long timeUnbanned = System.currentTimeMillis() + 10000;
this.data.getConfig().set("Players." + player.getUniqueId() + ".Time Unbanned", timeUnbanned);
data.saveConfig();
spectate(player);
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&c" + player.getName() + " &7has died."));
}else {
this.data.getConfig().set("Players." + player.getUniqueId() + ".Banned", true);
long timeUnbanned = System.currentTimeMillis() + 10000;
this.data.getConfig().set("Players." + player.getUniqueId() + ".Time Unbanned", timeUnbanned);
data.saveConfig();
spectate(player);
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&c" + player.getName() + " &7has died."));
}
}
}
}
public void spectate(Player player) {
player.getInventory().clear();
for (Player chosenPlayer : Bukkit.getOnlinePlayers()) {
player.setSpectatorTarget(chosenPlayer);
break;
}
}```
Hmm
You aren’t using the death event, so I figured it would work
Use event.getFinalDamage btw
oh ty
did you make player spectre mode? @final fog
when I did that it just teleported me to the player
so I tried removing it
now I added it back and it doesn't do anything.
You’ll get an error if they aren’t in spectator
oh wait I know why it's not doing anything, wrong player variable
Perhaps it’s a distance thing, try teleporting then to the target and then setting the spectator target 1 tick later
sg
and my main still hiding
console cant find it until now
does my exporting occurs error?
i have no idea about this checkboxes doing
is there anyway we can get the heads like spectator gui has in vanilla?
Don’t think so
when i import one world it says an internal error occured
in multiverse
no
Uhm i see
Origin realms was able to do it
I tried decompiling client jar and it seems to have a SpectatorMenuItem which i dont think is available to server
[15:06:35 ERROR]: Could not load 'plugins\ping.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError:
me/Ping has been compiled by a more recent version of the Java Runtime (class file version 59.0),
this version of the Java Runtime only recognizes class file versions up to 52.0
a first catserver plugin i made(me.miro243.Ping) has error in spigot too
It's been compiled by a more recent version of jaba runtime. What server version are you using?
1.12.2 spigot
I did a sneaky nbt test on their items and they dont have CustomModelData
Use java 8.
Well you should be able to see what item they use
uninstall my current Java and
download Java SE dk 8?
By using F3 H
Its player_head
Might just have all player heads set to render as flat in the inventory
And it has normal texture and signature like a normal player_head