#help-development
1 messages · Page 1398 of 1
Elaborate, compatibility as in possibly supporting legacy etc?
you can mess with the loader all you want and people won't need to change how they interface with the api
as long as the api maps to the new loader correctly and vice versa
does this server provide help for older versions such as 1.12.2?
I mean if the api is just interfaces why not shade it in? It’s plausible I don’t understand something here but yeah seems more logical to if they would have their api shaded
Yes space some people here do
okay
my friend has asked me to strike a player with lightning when they kill a pig, but nothing happens so i'm not sure what's wrong, im not sure where to check for errors but nothing appears in the console log
@EventHandler
public void EntityDeath(EntityDeathEvent event) {
if(event.getEntityType() == EntityType.PIG) {
if(event.getEntity().getLastDamageCause() instanceof Player) {
Player Player = event.getEntity().getKiller();
Location Location = Player.getLocation();
Block Block = Location.getBlock();
Player.getWorld().strikeLightning(Block.getLocation());
}
}
```
Though we advise against its use because we don't support it officially
ok
That being said, you could use that code in most Bukkit versions and it shoudl work lol. The only issue is this condition:
event.getEntity().getLastDamageCause() instanceof Player
last damage cause returns an EntityDamageEvent iirc
It will never be a player
Correct
oh
So you can get it, assign it to an EntityDamageEvent, check which event it was with an instanceof
so
If it was an instanceof EntityDamageByEntityEvent, cast it and work from there
Suppose that would work as well. Yeah
Yes
I guess they could do that but that would introduce a disjoint between interacting with vanilla vs. interacting with other mods. Keeping the API as a mod introduces uniformity.
Just beware to not use it when #equals can be used (in this case it cannot be used because you cannot detect null that way)
How would it introduce a disjoint? Or like could you elaborate just curious heh
I guess the uniformity is a good argument
oh ahtsdhgyifd
Well fundamentally there would be a difference, partly in implementation but also partly in perspective. If you interface with vanilla through a mod, it "feels" the same as interfacing with, say, Tech Reborn. It allows you to detach from the idea that vanilla is the "base game", which imo is a good thing because you ideally want to keep your mod logic pretty independent (to ease with updating etc)
Basically do NOT use == and =! for everything that extends java.lang.Object
Enums and other singletons (such as threads) are an exception there though
I see your point
It's a very specific question but I hope somebody can help me. So I want that there are particles on a location as long as the location is marked like pos1 or something. Bukkit.getScheduler().runTaskTimer(plugin, () -> { if(particlesActive){ PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(Particles.HAPPY_VILLAGER, true, location.getX() + 0.5, location.getY() + 0.5, location.getZ() + 0.5, 0.01f, 0.01f, 0.01f, 0.01f, 5); PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection; connection.sendPacket(packet); } }, 20, 20); This is what I have till now
that's not a question
the code still doesnt work after
- if(event.getEntity().getLastDamageCause() instanceof Player) {
+ if(event.getEntity().getKiller() instanceof Player) {
still no errors, or im not looking in the right place for them
what is it then?
it's a statement
So...?
ask a question
How can I make that particles spawn on a location as long as the location is marked like pos1?
you can store the bukkitrunnable and put it in a Location -> runnable map
and then cancel the runnable once you remove pos1 from the map
if(particlesActive){
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(Particles.HAPPY_VILLAGER, true, location.getX() + 0.5,
location.getY() + 0.5,
location.getZ() + 0.5, 0.01f, 0.01f, 0.01f, 0.01f, 5);
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
connection.sendPacket(packet);
}
}, 20, 20);``` That's what I have till now
alternatively, you can check if a set of Locations contains pos1 in it every time you spawn a particle, and cancel the runnable if it doesn't
why are you using the protocol and nms for particles though
what should i use instead?
World.spawnPaticle doesn't worked for me and I can't fixed it. So i used this
why doesn't it work for you and what did you try to fix it
Maybe he’s on a legacy version
well that's not my fault
I use 1.16.5
Ah okay then the methods nny specified should be working fine
how would i loop a command to run every few seconds, for example if i want the server to run "/?" every 1 second?
player.getWorld().spawnParticle(org.bukkit.Particle.VILLAGER_HAPPY, location, 5);
}```This is what I did
And it doesn't work
So what should I do?
Hi. Anyone has ready pack of server survival ? Just some simple plugins. Authme, log block, anty x-ray etc.
When I join the server at this location aren't particles
are there any particles anywhere
what do you mean?
there are not there at all
hm
and i checked that particlesActive definetly is true
strange. When I do player.spawnParticle it works
How do I get all the information from my MySQL table, in this case, all the players registered?
Wouldn't that just be something like SELECT * FROM <table_name>?
I've got a quick question too: Do I understand correctly that Chat API stuff to make clickable chat messages are not part of the Spigot API? So I have to depend on BungeeCord which is like 14 MB just for that feature? :c
I did, but how do I store it in a variable?
It becomes like an object, there is no way to reverse it
It’s shaded in both bungeecord and spigot
I'm not familiar with how you access the DB from code and I probably can't help you with that because I use MongoDB for my Minecraft stuff and SQLite at my workplace, but I'd imagine you can cast the object? You'll definitely find info on that online.
It just seems super overkill to use something that is supposed to multi-server framework just to be able to click on messages
Thank you for the response though, I'll use it
Wym multi-server framework
I told you it’s really not super overkill as the bungee chat api is shaded into both spigot and bungeecord so just add it to ur compile classpath?
ah, I wasn't familiar with what shading is! Makes sense
Ah sorry shouldn’t have made such bold assumptions lol
I'm just not a java dev
C++! Haven't written any Java lately before I started this project like two days ago :P
ew c++
C++ is nice (:
Vararg templates like geeez java look at this
It’s not April 1st tho
ignore him
Yeah whenever it isn’t python he starts circlejerking lol
Okay dumb question but what is the thingy after the equals sign called so I can look up a tutorial on what it is/what it's used for
PotionMeta potionMeta = (PotionMeta) meta;
because I've never seen it before (I found it in an example plugin)
You mean the manual cast?
Hey, I was wondering if there was a way I could implement my customized unicode into like skript or something
Yes thank you!
You're welcome!
Is there a way i could integrate my customized unicode characters into the player tab and the chat?
Does spigot make a POM BOM available? https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms
Is the singleton design pattern a bad idea in java? I've got a class that I need to pass into many other classes because it's the general handler for a filter in my plugin. There should never be two instances of this class because if there were, there would be two different filters with differing contents.
Idk I avoid singletons because it makes your program hard to unit test and it may also tightly couple your code which can be indefinitely hard to work with
Or maybe I should say static singletons
I'm guessing that my issue is that the scope of the class is too wide.
Wym?
is it ok/possible to save data in the world folder?
ig it doesn't matter much because I would store it per-chunk and overwrite it if a chunk is newly generated
Oh yeah
but still it would take up space uselessly
so yeah using the world folder seems like the most sensible option
Yeah it would remove the awkwardness for you a bit
it's a class that at first only contained a bit of information about something but grew to contain so much information that it has to be passed to many other classes in my plugin. I think my issue is that I made the scope of the class too large and I'm struggling with handling the places it needs to be passed because of it.
I use a singleton to handle database stuff. It's worth considering doing things differently though if you find a good approach, but with that f.e., I like doing it using a Singleton
Single Responsibility Principle
indeed
That sounds like you should not use a singleton in this case! :P
I adhere to SOLID a lot tbf although in spigot plugins it isn’t needed though might still be worth paying attention to.
But Skyy assume that class is a context class then maybe it’s fine
How is use of proper design principles such as SOLID not needed in Spigot plugins?
Benz arguably you don’t need to create an interface (dependency inversion) for everything such that you depend on high level abstraction instead of low level for instance.
I made an interface to define my "big bag of crap" API and have my plugin implementation implement that interface, then I pass that around - because most everything needs the plugin anyway
and within my various classes i use a decoupling strategy to make testing easier
SRP is probably something which is more essential to follow. But then for instance we have liskov substitution principle which if you declare a field to have the type HashMap instead of Map won’t make your entire application break but yes it’s generally good to follow (If S is a subtype of T then it should be substitutable with any subtype of T)
Why is my .conf doesnt work with multicraft jar file...?
for the decoupling strategy i define an interface (within a command class for example) called IDecoupler then i also create a class Decoupler implements IDecoupler - then i have 2 constructors - one that takes my plugin and another that takes an IDecoupler. I can then either make a stub implementation of IDecoupler in my tests or use mocks
Dependency inversion is far from simply introducing interfaces. I just disagree with not conforming to conventions simply because the piece of software you are developing is a Spigot plugin.
it doesnt make the server bungeecord
I’m not saying because of spigot we shouldn’t follow solid but I would argue that it might not be the most vital thing you should crucially pay attention to.
Also you don't have to summarize the principles. I know what they are and they are easy to look up. I just wanted to point out that just because you are developing a plugin doesn't mean you shouldn't follow proper conventions.
Oh, and my 'decoupler' wraps about every call to my plugin big bag of crap
Down the road no matter what you throw together you will thank yourself for maintaining proper conventions and consistency. But I do agree that it is a cost/benefit issue.
I avoid singletons and global/static state - makes for brittle code over time
static helpers are fine - so long as they have no side effects (only take action on the given inputs and output)
Of course it’s significantly better if you follow those. However as I stated before it may not be needed to strictly follow it. In my opinion getting something to work should be the primary priority. Then after that it may be beneficial to engineer what you’ve done such that it follows solid more strictly I guess if you wanna extend it later (:
That I can agree with. Refactoring is a crucial part if you want to be agile instead of rigorously planning and designing your software.
+1 - don't worry about doing it right until you are doing the right it
Yeah absolutely.
Loooots of prototyping xd
That's coming from someone with 16 years industry experience as a software developer here... just saying
Hehe
Was quite the revelation when I reconciled "test first is the only right way to create software" with my answer to "why don't i test first" being "because i can't - because IDK what i'm building yet"
Just NEVER allow your prototype / exploration code to become the delivered solution
stop yourself once you reach the point of knowing what you need to do and how to do it
That's the moment to go back and do it right
Behavior Driven Development really gave me the right reasoning for TDD. Write tests for the behavior you seek next.
Indeed BDD is my preferred flavor of test first
works better with the human mind than "what do i test next (that doesn't yet exist)
anyway, back to refactoring my projects to share maven modules lol
It's funny because with all the experience I have - I've never touched maven before working on spigot plugins cuz the big tech companies i've worked for always do things their own way and don't generally use standard tools :/
Feel free
Anyone know how to listen for any event ?
It’s avoided but I guess just register an event handler method for every event class which isn’t abstract
as in wild card? like listen for them all? it's a reflection tick
isn't there a saying about refactoring that somewhat says that you should be refactoring for at least the same amount of time you're writing new code?
Because
(Could use EventExecutor) to do it more convenient
Bukkit.getPluginManager()
.registerEvent(
Event.class, bukkitEventListener, hookPriorityToEvent(priority), bukkitEventListener, plugin);```
If I do that
It errors of HandlerList not found
Yes of course
there's no way to quickly listen for every event without registering every event
ya, you can't register for the base type
afaik, at least
i'll post a snip of how i do it
You could use smtng like dgraph or whatever it’s called
To loop through every class and then check if isn’t abstract and is a subclass of Event
Then register an event executor for it (:
Things is while using EventExecutor then I cannot do with EventHandler priority
yup
Yea you can
PluginManager#registerEvent takes one with priority
I copied that from somewhere at some point
Yes? Obviously
So you cannot do that using EventExecutor & Listener only
Wat
Do smtng like Ross but have an interface/class that implements both Listener and EventExecutor I guess and use that then in registerEvent?
I do have that
So what’s the issue
Yea well one now that is getting the classes
if I wanted to spawn an armorstand with a custom head texture from say Minecraft-Heads, how would I do this? Im only stuck on how to put a custom skull on the armorstand
Cause I gotta hook into each event for each priority
That's damn a lot of listeners lol
Oh well
There's only 2 ways to do it... 1 - the long way where you make a handler for every event type - or 2 - you use reflection like i posted
just listening to an event isn't going to hurt you. All that really matters is what you're doing in your listeners.
ya - there is no "every event" handler - that's not how the event system was built
I'm forwarding them into my system
Does the 2nd last reply here not work for what you are doing?
https://www.spigotmc.org/threads/listen-to-all-events-easily.235870/
I realize it is very old
some events can be fired many, many times in a single second. Make sure that your initial checks are quick, otherwise you're going to lag the server pretty badly.
I got a question, prob best for staff to answer but if I release a plugin, but someone else already stole my name like 5 years ago, do I have to rename it?
Benz I believe every event must fire at least once if HandlerList#getHandlerLists should give a collection of all handler lists as classes can come and go dynamically right?
I just check if there's the listener in a map by the event class name
That shouldn't slow down much
are you trying to make a custom listener system?
I assume you mean using the Spigot API... it's complicated - there isn't a ready solution, it's reflection heavy and you have to build a player profile and such
Not really
what are the advantages of having a universal event system? I feel it would make code harder to read, given that the source of an event may not be obvious
Being able to switch between platforms easily
Oh yeah it only takes an OffinePlayer iirc
And being able to write code that can work for different platforms easily
ya, easy if you are dealing with a real player head - harder if you want decoration ones
Yeah I figured
you can use previously uploaded skins for skulls
Plus I can do stuff like ...
Events.Simple
.hook(PlayerJoinEvent.class, event -> {
simpleBenchmark(event.getPlayer().getName() + "-tool-init", () -> {
getInventory(event.getPlayer()).initTools();
});
});```
I mean else use concrete abstraction
You can, but you need to inject the texture URL into a player profile you create via reflection
the easy way - is to just use dispatchCommand 😛
and do it with vanilla spawn entity commands
🤡
switch between platforms... am I misunderstanding? I was pretty sure that Java is cross-platform by nature
Programming is fun - i do it all day every day :x
He meant Bukkit/Velocity/Nukkit/Bungee etc
oh, I see
So.... want me to share my custom skull solution... it's going to be like 3 classes and a few hundred lines of code 😛
LOOOl
Well did that person steal the name? Or are you actually the one stealing it by copying it. Different angles - different answers.
The plugin i wrote for the survival server i run is over 40k lines :x
😅
I mean my library itself is 20k 😄
@paper viper
thats the SLOC from running a coverage report
How many lines are media lib?
Hello everyone, I have been creating a plugin and using custom heads and I wanted to make a tutorial since I don't think there is one already on how to...
it's all code i authored lol
My plugin is one line beat that
I don't think it takes hundreds of lines. I haven't tested this myself, but someone linked it here a bit ago.
GL with that
You could just write a big fat utility and the make it into a one liner (:
PlayerInventory should have 41 slots, right?
I mean, a big part of the lines i quoted for the custom skull stuff is a general class for NSM/OCB reflection and an easy HTTP fetching class i wrote
i mean, you don't have to validate the skin texture 😛
I mean I Just use nbtapi
it looks like that solution uses this: https://github.com/TigerHix/Hex-Utils/blob/master/hex/util/Skull.java
public InteliSkullItem texture(String texture) {
this.texture = texture == null ? defaultTexture : texture;
applyNBT(
nbt -> {
NBTCompound skull = nbt.addCompound("SkullOwner");
UUID id = UUID.randomUUID();
if (InteliVersion.isOrAfter(16)) skull.setIntArray("Id", _16_fromUUID(id));
else skull.setString("Id", id.toString());
NBTCompoundList compoundList =
skull.addCompound("Properties").getCompoundList("textures");
compoundList.clear();
NBTListCompound textures = compoundList.addCompound();
textures.setString("Value", texture);
});
return this;
}```
Weird use of a lambda but I guess nice
This is inside my item builder
¯_(ツ)_/¯
So Consumer is my bitch
Still no really need for that but I guess it’s cool
I just do that part of the lifting with string concatenation 😛
classic C style
https://github.com/Conclure/DeluxeAsyncJoinLeaveMessage feel free to pr
https://www.spigotmc.org/resources/deluxeasyncjoinleavemessage-fully-optimized-async-everything-open-source.88129/ - Conclure/DeluxeAsyncJoinLeaveMessage
😇
I only use static. Sometimes I forget to add it to my inner classes, but it always works out in the end.
:DDD
Lots of static, lots of fun right
yes. I tried to use non-static when I first started making plugins, but it was too annoying
GUICE 🤮
I do hate injection frameworks - the only person who understands an application built on them is the person who made it... and only for about 3-6mo before they forget the details and are also left wondering where the hell that wrong instance came from 😛
Anyone know of a plugin to obfuscate bedrock patterns? A quick google just tries to tell me how to obfuscate my plugins lol
bedrock patterns
obfuscating bedrock patterns is on my 1.17 punchcard
What's that
bedrock is always generated the same - there are tools that can be used to find a location from screenshots or streams / etc
easy enough TBH, just figured i'd try to be lazy
If you're lazy, use flat
hard part is getting the layers dynamically rather than just hard coding them
then ppl will bitch at me that it's too non-vanilla
Lol
IKR
Well just have a chance of bedrock at 0-3
then if it's chance met, put bedrock if not stone
until world gen changes, and there's top bedrock in the nether
it's easy enough to shuffle the layers on chunk create
just have to find a good enough way to future proof it
i was thinking of "learning" the layer heights by doing a chunk scan - but ya
I guess just get the sections array lenght
like the first time a chunk is generated if the plugin doesn't know where that world puts bedrock it searches for it then remembers
But thing is
but then once world heights increase - any old chunks will be different than new ones and crap
I have high doubts that they will have same chunk structure
They'll probs rewamp the whole chunks system
well, chunks / blocks will still be exposed in the spigot API 😛
Well spigot will have to adapt tho
I'm thinking of just hooking the new chunk event and mutating the chunk just after it has been generated instead of trying to directly modify world generation
anyway, i'll get'er done one way or another
that sounds horrible
imagine loading a new chunk and then all the sudden every block in it changes
still would affect mining but I see
mining in the bedrock sponge is already ... what it is lol
fileController.prerequisites(
fcp -> fcp.loadFromResources(resources -> {
resources.option(Paths.CopyOption.COPY_IF_NOT_EXIST);
resources.filter(path -> !path.contains("modules"));
})
);
Lol I just copied my whole plugin zip into the plugin folder, genius...
Hey, does anybody have any experience with entityportalenterevent?
I have a problem with that
Basically a normal portaltravelevent does not listen leaving end
So i have to use the portalenter
The problem is
leaving end via the exit portal - that's a player respawn event
ya, it sucks lol
basically
I have a plguin
and I need to check
if player leaves the end
and then he gets tped to a certain location
now im trying to do that under the entityportalenterevent
or whatever it is called
im using this code
@EventHandler
public void onEnter(EntityPortalEnterEvent e) {
System.out.println(e.getEntity().getWorld());
if (main.eventStatus) {
if (e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
if (e.getEntity().getWorld().getName() != ("world")
|| e.getEntity().getWorld().getName() != ("world_nether")) {
p.teleport(main.spawnLoc);
}
}
}
}
The thing is
this doesnt let me to go into the nether aswell
it just tpes me to the main.spawnLoc
Though i dont get why it does that
basically
what is main.spawnLoc?
Don't compare strings with !=
^
Yea
must use .equals
Oh okay
This is not javascript
main.spawnLoc is a location only set if a event starts
its a location of a trail start point
and here's how I detect a respawn due to exiting the end via exit protal
Location playerLoc = player.getLocation();
// Exiting the end by the central portal triggers a respawn - detect that case here (yes the player is marked dead too)
if (playerLoc.getWorld().getEnvironment() == World.Environment.THE_END
&& MoreMath.isBetween(playerLoc.getX(), -100, 100)
&& MoreMath.isBetween(playerLoc.getZ(), -100, 100)
) {
if (playerLoc.getBlock().getType() == Material.END_PORTAL || playerLoc.getBlock().getRelative(BlockFace.DOWN).getType() == Material.END_PORTAL) {
extraInfo = (extraInfo != null ? "; " : "") + "exit-end-via-portal";
}
}```
What about it? 😄
i've never seen kde user in spigotmc ever
Lol
you're the rare breed of powerusers
I'm guessing you're also a Lithuanian lol
what's about it?
As me
oh
i dont understand that code fully
Material sellitem_material = sellitem_seller.getInventory().getItemInMainHand().getType();
ItemStack[] contents = sellitem_seller.getInventory().getContents();
int counter = 0;
for (int i = contents.length; --i > -1;) {
if (contents[i] != null && contents[i].getType() == sellitem_material) {
counter += contents[i].getAmount();
}
}
So this code ^^ gives me the total amount (counter) of items matching the item material of the item in hand.
How do I do the exact same thing except matching all metadata of an ItemStack, except amount?
The players location will be at the "pre respawn" location when the event is fired.
So i check if they were in the end, on the central island, and look at if their feet are in an end portal block
That's a client thingy
if i had to guess, the way he's detecting the is the how end blocks are rendered. They're not full blocks so whenever he's inside the block and dies, it counts as death
No, exiting the end via the exit portal results in a respawn event being fired
there is but its clientside and it would involve manipulating the velocity of the player
I was like dfq
so basically
so this is how i determine if they are respawning due to exiting the end, or if they really died
basically whenever he eats, increase his velocity maybe
and consistent
That actually is 199iq
i had a player saying that he has a noslow bug 🤣
It always slows down for the same amount
extraInfo = (extraInfo != null ? "; " : "") + "exit-end-via-portal";
so you can hardcode the amount of velocity
I dont understand that part
the thing is it would allow to autosprint
and the MoreMath
AntiCheat what's that
I mean
You should get his velocity first of all
To see if he's moving or not
That's just code outside the snip i took - MoreMath is my own utility library the function used is just as described 😛
return min <= value && value <= max;
}```
yes, but still, lets say he started eating before he stopped
but i still think that he was hacking
or is using a bugged client
You cannot just run and bow
that's impossible
oh dear god
told him to reproduce the bug
that's possible only from clientside by sending invalid packets to the server
he said that he can't
Lol
we are on 1.8
and he was using 1.8
since i don't see any for couple weeks
taco
Just god dammit use an anticheat
we do
And you'll see invalid packets
ncp damn
better, use protocollib, and code your own packetlistener which checks what packets his client sends to the server
That's a high quality anticheat
and build your own patch
anyway, thanks for the help 👍
extraInfo = (extraInfo != null ? "; " : "") + "exit-end-via-portal";
is this needed?
seems like no
😄
so great, catches every haxor
No, that's just the point in the code you would know that they respawned due to exiting the end 😉
Okay but
the locations you check
in between
Why is this necessary?
you are getting like the center?
of the end
where the portal
usually forms?
I'm checking that the player is #1 respawning from somewhere in the end #2 they were on the center island (really that +/- 100 check could be +/-10) and #3 that they were standing in an end portal block when they respawned
the players location inside the player respawn event handler is their location BEFORE they actually respawn - aka where they 'died'
can anybody help whenever im following this turoial and i double click on the build tools.jar folder it only makes 1 extra folder however it should be making loads of other folders here the tutorial btw : https://youtu.be/clGVQXsVdiI
YouTube
I mean
&& MoreMath.isBetween(playerLoc.getX(), -100, 100)
&& MoreMath.isBetween(playerLoc.getZ(), -100, 100)
this is more like
special ensuring
i dont think its like too necessary
but its good
can anybody help
Hmm guys how does one loop thru Path children?
It's cheaper to check some floats than query blocks (well, that was my thought anyway - IDK if it's right)
But you are correct that it is not strictly necessary to check that the player is near the exit portal location before seeing what they are standing in to decide if they took an end portal
Ill use it anyways
but ill split them apart
like remove the &&
since i need to check a real respawn event
aswell
so i can just add else
Material sellitem_material = sellitem_seller.getInventory().getItemInMainHand().getType();
ItemStack[] contents = sellitem_seller.getInventory().getContents();
int counter = 0;
for (int i = contents.length; --i > -1;) {
if (contents[i] != null && contents[i].getType() == sellitem_material) {
counter += contents[i].getAmount();
}
}
So this code ^^ gives me the total amount (counter) of items matching the item material of the item in hand.
How do I do the exact same thing except matching all metadata of an ItemStack, except amount?
any ItemStack data like displayname etc
by lore?
basically just count the amount of items matching ItemStack
isSimilar() shoudl compare all bar amount
or compare the itemstacks
so if the itemstack is a diamond with amount = 1 and you have a stack of diamonds in your inventory counter = 64
like he's saying it to you
I tried this
but it didnt work
returned 0
and sellitem_sell_item has Amount of 1
okay hold n
so like this?
looks right enough to give it a run - ya
GG 😄
== and != almost never work - except for checking for null
This type of equality checks that the objects are the exact same INSTANCE
not if they contain the same information
yeah I used it for same material before
ya, material is an enum - there is only ever one instance of each material type so == works there just fine
== works fine for integers too - but not so well for floating point numbers (float/double)
i hate this old ass name
no idea on that one
as long as they are primitive
Ross
I didnt use your method but
I found a better one
Not a method just a simple check
you check if players world is equal to end
aka the world he enters from
then you run a task later
and execute your code there, that worked fine for me
But thanks for the help tho!
why do I get
this error
java.sql.SQLException: Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.
from some people which use my plugins they report it
I can't recriate it ?
Umm I kind of have a problem
How would I add a TEXT value with "" in it to the MySQL?
escape them
or encode the string with Base64
yeah I can just replace " in string with \" if I want it to be an ItemStack
so thatll probs work
thanks
Wait how would I do this: String itemsdbstring = String.valueOf(item).replace("\"", \"");
Does this work?
String itemsdbstring = String.valueOf(item).replace("\"", "\\\"");
item = testitem"name"
itemsdbstring = testitem\"name\"
How do I do that
it doesnt work
Pulse to the rescue
StringEscapeUtils, and the escapeJava method can do this
Or
if you don't have that
/**
* escape()
*
* Escape a give String to make it safe to be printed or stored.
*
* @param s The input String.
* @return The output String.
**/
public static String escape(String s){
return s.replace("\\", "\\\\")
.replace("\t", "\\t")
.replace("\b", "\\b")
.replace("\n", "\\n")
.replace("\r", "\\r")
.replace("\f", "\\f")
.replace("\'", "\\'")
.replace("\"", "\\\"");
}
🤡
lol
ummmmm
What is this black magic
stackoverflow
just saying, base64 may be better
lol
How would I make a GUI that when you click on a stick it would go to another inventory in a separate class?
anyone know the maven repo for essentialsX
that didnt work
Show us
whats the class name of the fireball entity
Trying to get the world spawn accurately, but it seems World#getSpawnLocation is just giving me a location in integers
because eclipse says that fireball doesn't exist
So I end up with the location at the edge of the block when I teleport to it
Location has two methods getX and getBlockX
@eternal oxide Yeah, figured I could just pass the teleport method the double getters
But it's kind of annoying how the teleport method doesn't unpack the double methods to begin with
From a Location
how do I set the explosive power of the fireball?
Just pass the location itself. If it tp's you to the edge of a block then thats where the spawn is
But when I set the spawn using /setworldspawn it tells me I set it down to decimals
._. Your POM doesn't even contain EssentialsX
Wait, no it doesn't
Yikes, I need sleep
but it searches for it in the spigot repo
it says
Cannot resolve org.bstats:bstats-bukkit:1.8
Can I please have some help?
nvm just this
it says just this
._. And what POM is that
wdym
Show your POM
?paste
How do I remove the displayname from the itemdata of an ItemStack?
Just set it to " "
wat
like how do I set it to the default name
how can i detect if a command is ran by console?
Set it to null
Wait can you
command sender object
Yes. It's nullable
thats what im trying to use @mortal hare
if (sender instanceof ConsoleCommandSender)
that works?
doesnt work @west lance
wdym doesn't work
Show your code
in that case use instanceof Player
Bad idea
instanceof Player still fires it
why ?
if(sender instanceof Player) HumanInterface.SendResultsToPlayer(p);
how tf i can get 2 ItemStack's with 2 AIR in it ;D
if (if) { } else if (else) { }
Command Blocks
looks like magic
nvm i found my issue
xd
it throws TRAP exception whenever you set amount to AIR itemstack in NMS lol
Dovidas maybe you’re using unsafe 👀
How do I define Player in a listener?
most of the events have a "#getPlayer()" or "#getEntity()" method
How about in the nventoryClickEvent listener how would I do that?
I can't see a mistake
#getWhoClicked
did you create your config.yml in your ide?
I get this: Incompatible types. Found: 'org.bukkit.entity.HumanEntity', required: 'org.bukkit.entity.Player'
cast it to player
// psssst... learn java
Player p = (Player) e.getWhoClicked();
oh
Yes. Right now, your config.yml is being exported under net/turkgamerz/minigames/
If you were to open your .jar file with some archive program like 7zip or WinRar, you'd see it there
Though Bukkit expects it to be in the root
https://paste.turingarch.com/paste.php?id=77
Is there something wrong here? I got config-related errors
Paste can store text, source code or sensitive data for a set period of time.
etc..
no idea what language that is
gerekli-oyuncu = required-players
geri-sayim-suresi = cooldown-time
lobi-spawn = lobby-spawn
dunya = world
arenalar = arenas
xD
I still don't get it, it looks right to me
can u explain please ^^
same names ?
"dunya" and "dunya"?
no you must move them to the same indentation level
so that looks like 4 spaces for 'dunya' under '0', since x, y, z, pitch, yaw are the same section it must be at the same level which is 4 spaces
how do i get player killer on playerdeathevent
ah, i relaized it
im dumb, sorry -_-
is it a problem if I use space or tab? So I can use both?
don't mix spaces and tabs, generally causes problems
get the last damage cause on the player and get (if and) who hurt them there
nah i figured it out
e.getEntity().getKiller();
use bungee chat components
1.16 supports this but I can't find any api to use it
bungee chat components and ChatColor.of or something
ah
ChatColor.of doesnt exist?
import bungee's chatcolor
1.16.5
bukkit's chatcolor is an enum
there are like 3 chatcolor classes
Oh yeah bungees isn’t an enum right
myeah
they changed it to a regular class with public static final fields when rgb rolled around
thank you
Ah
looks like it
I believe so
yes it is
How do i load a plugin before other on bungee? softdepends doesn't seem to work.
delete the other plugin's jar and force the server to restart
mmm converting bungee's chatcolors to ansi sequences
deleting a plugin jar and forcing a restart does absolutely nothing lol, why would you even ask me todo that?
... your joking right.
you just can't comprehend my genius
uh i think thats just bukkit
w0t
Anyone know what i can pass in the signature for the Property constructor when setting a texture for a GameProfile
oh wait im dumb lol
?paste
is there a way i can make it so you can apply lvl 6 enchants to items
addUnsafeEnchant
could possibly give it custom nbt and listen to anvil prepare event
Well, you have to take over the anvil at that point and add sharp 6 to the sword
You can't rely on an anvil to manage unsafe enchants
smooth👀
In other news, I'm trying to get the general statistic for Mobs Killed from a player, as seen here. According to my stack trace I need to specify an entity type, which I am well aware how to do, but that is not what I want to accomplish, as that would only output the kills of that mob. Any thoughts?
yes
whats TheAddons
a plugin i work on when i have no ideas
String output = ChatColor.GREEN + "--RGB TEST--\n" + ChatColor.RESET;
for (int y = 0; y < 16; y++) {
for (int x = 0; x < 32; x++) {
byte r = (byte) (x*8),
g = (byte) ((y-(x/2))*16),
b = (byte) (y*16);
output += ChatColor.of("#"+String.format("%02X",r)+String.format("%02X",g)+String.format("%02X",b))+"M";
}
output += "\n";
}
sender.sendMessage(output);``` @daring sierra
should i update from java 1.8 to java 11
if its really needed, you could loop over the entitytypes and join them
yes
explain?
updoot
does it need to be jdk
2014 -> 2018
full RGB chat :pog:
you need the JDK and SE
right, no emotes
SE to run and JDK for development
can u link jdk and se
int killed = 0;
for(EntityType type : EntityType.values()) {
killed += FROM_STATISTIC
}
@tall siren
@quaint mantle you dont need the JRE if you have the JDK
does installing java require a restart
no
restart recommended
no?
because the JDK comes with the JRE
is it Java SE Development Kit
since always
can someone answer my question
is this the site i wanna go to for java 11
is it java SE or JDK
but what if i am not developing on that computer
wdym
mhm
jdk includes jre
is that page the correct page for jdk
it literally reads jdk in the link, i'd say probably yes
it says jdk on th elink
wait but would it be good to install a newer java if my servers are running
Did I not find folder creation in intelijidea, or am I blind 🤔
depends what version you compile in
you can't create a folder in a package
whats the folder for exactly
yeah thats what a package is for lol
a package is just a folder for class files
and might have some metadata associated with it
just like you probably wouldn't want to keep all of your computer's files on your desktop, you also don't want to keep all of your classes in the same package
yeah its fine
cuz paper still thinks im using java 8
you can set primary version
i did that
now java isnt even installed anymore what did i do
restart?
@drowsy helm
i forgot how do i get all enchant there exist?
Enchantment.values();
No prob
so i have a system that sets a boolean in the main class to true
but after i set it to true
when i check the boolean from a different class
it didn't update the value it seems
show code
i CAN check boolean's value using == right?
k
its primitive?
you should be able to
you are able to
wait why check boolean values with == when you can just put the boolean
if(variable || !variable)
why you no dependency inject !!!
umm the getInstance is the di?
how the hell do install jre 11
it only gets jdk 11
and i am confused because i cant run jar files anymore
go to oracle.com and download it lol
oh
jdk = jre
i have
maybe ur jar file is corrupt
ye
yes
hotspot or openj9
Hotspot ig I haven't downloaded from them in a whil
for(World w : Bukkit.getWorlds()){
//loops through all worlds
for(Entity e : w.getEntities()){
//loops trough all entities on each world
if(e instanceof EnderDragon){
}
}
}
there has to be a better way of doing this right?
tag me please
why does the boolean not update
am i not supposed to get the instance of the booleans from the main class liek that?
event.getHand
.
Because the event is called twice
oh
Once for each hand
why is that?
uhhhhhhhhhh
Hence why MD told you to check e.getHand
but then the left click didn't have double log
k
okay thx
also i have a problem where changes made to a boolean on a different class don't carry over when i reference the same boolean from another class
Gonna need more than that then
ew
just make a single instance
Yo command class
Commands commands = new Commands();
// ***
also idk if you want to but i usually do this when handling multiple commands under the same executor
private void registerCommands(CommandExecutor executor, String... commands) {
Arrays.stream(commands).forEach(i -> i.setExecutor(executor));
}
completely optional tho
thx
actually might wanna use a normal for loop
i just think the stream looks cleaner
Is there a way to give an invisible armorstand with a custom skull full invisibility? (without having to change the helmet slot to air)
and it looks more professional lol
You could send out entity destroy packets
Just wondering, why is my code for playing audio from a resourcepack having a bit weird behavior:
for (final Player p : players) {
p.playSound(p.getLocation(), "audio", 1.0F, 1.0F);
}
Suppose the resourcepack has already been sent to players and the resourcepack is valid.
Running this first time, the sound plays. After that sound plays. I run it again. The thing is that for some odd reason, it won't play the audio for clients on the second play. However, if I just execute the loop again the audio will play properly.
Does anyone know how to fix this?
I swear that is the only place I am playing sound
Any more code you can provide?