#help-development
1 messages · Page 1408 of 1
No your thread continues after scheduling the async task
so how I create the itemstack with number of items defined by mysql after that run? because I should not use bukkit api inside async task
would * 12.5 work
You call a sync method or run a sync task from inside your async task
@sage swift which multiplier would make the max 20
what
i wanna make animals max 20
aaaaaah, so i cannot put the itemstack creation inside async task, but when i call a method that it creates it from inside, it is totally safe...
any1 know how to make somthing like this?
deluxemenus, lol
if you use teh Bukkit scheduler to call it
basically you are jumping back sync using the scheduler
level = (int) (Math.min(2, Math.abs(rand.nextGaussian())) * 5);
scheduler.callSyncMehod
// some SQL
plugin.getServer().getScheduler().callSyncMethod(plugin, testMethod());
});```
yes
oh god, why shouldn't I know that earlier 😄
There are other ways, like Futures, but thats the no frills
just keep in mind that anything you schedule to happen on the main thread doesn't happen now
it happens at the start of the next tick
meaning that blocks of code that you want to run synchronously will run after the blocks of code below them, despite being higher up
so it will run the async code and when the async code is done, it will hop to the main thread with the callsyncmethod, and then run the testmethod with the results from sql, did I get it right?
yes
Aikar iirc wrote something that is intended for this purpose called task chain
which is a more abstracted way of hopping off and back on the main thread
well its like sql atm machine, so if it does not happen right now is perfectly fine, i need to get number from sql, rewrite the number in sql with zero and the original number give to player as itemstack
I just dont want to hang the main thread with sql query for every player, when someone ejecting money from atm 😄
thanks for the help @eternal oxide btw, really appreciate it 🙂
point is that the execution order of
public void runMeSync() {
//do sync stuff here (1)
Bukkit.getScheduler().runAsync(() -> {
//do async stuff here (2)
Bukkit.getScheduler().runSync(() -> {
//do sync stuff here (3)
})
//do more async stuff here (4)
})
//do more sync stuff here (5)
)
is 1,5,3,4,2
so keep that in mind
paper's async chunk api is an interesting entry point to doing stuff off the main thread
since their chunk futures are always completed on the main thread
any1 can help to make something like this?
🥲 without taskchain
this is #help-development
i think he is referring in code?
or did I not see the history
and im telling him he doesnt need to
..
he's looking for a way to sell ranks for in-game money
lol
"we do a little bit of trolling in this discord"
Bukkit.getPlayer("PulseBeat_02").openInventory(((Supplier<Inventory>)()->{
Inventory inv = Bukkit.createInventory(null,"Ranks",9);
for (int i = 0; i < 5; i++) {
inv.setItem(i+2,new ItemStack(Material.NAMETAG));
}
return inv;
}).get());
@wanton cipher yw for the worst code to exist 😄
why is 4 before 2?
why did the chicken cross the road
egg
Does anyone have a Util for getting someones name for bungee.
getName ?
will I get restricted from spigot if I edited my current resource to be premium, which is technically impossible and now it's waiting for approval?
it even has a external download link, which is also not possible with premium resources
I can show you how I did it if it's considered a bug
No, Like for ProxyPlayer to be not null. The player need's to be in the server. I have the UUID stored in my database, I just need to use the UUID to get the name of the person.
call mojang api
Yeah Ik I was wondering if some one had one made?
google has like 4
Ight
That one looks nice
how can i remove just one item from inventory?
find the item and reduce its stacksize by 1
paper has nice utility methods like subtract and add on itemstacks
bout how to code it 🤣 ?
I suggest Java
inv.set(i, inv.get(i).subtract())
like i have my plugin but this is last thing i need to do
Yeah, not a spigot method
get rekt
up ya bum 🙂
im still confused about L1, L2, L3 CPU cache. For example if i get the itemstack reference through the method in another thread, can it cache reference (pointer adress) in that cache or it would get it straight from L3 cache
so fucking confusing
yeah it's basically rocket science
there's so much little information about it in technical depth
all i can find is simplified version of that shit
without explaining it in depth :/
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.WORLD_PARTICLES) {
@Override
public void onPacketSending(PacketEvent e) {
Player p = e.getPlayer();
WrapperPlayServerWorldParticles packet = new WrapperPlayServerWorldParticles(e.getPacket());
if (packet.getParticle().getParticle() == (Particle.REDSTONE)) {
Location particleLoc = new Location(p.getWorld(), packet.getX(), packet.getY(), packet.getZ());
if (p.getLocation().distance(particleLoc) >= 10) {
System.out.println(particleLoc);
e.setCancelled(true);
}
}
}
});
Yo can anyone help me and tell me why particleLoc is returning all 0 cords?
use distanceSquared()
square root is expensive
that way its more optimised
idk why it returns like that
I don't need to add an else statment to an if statment if I want it to do noting when it doesn't match the if rule, right?
correct
thx, anther fast q how can I show text to player above hotbar?
that's called actionbar iirc
ye
ChatMessageType.ACTION_BAR
yeah I forgot that
Why is my plugin not showing up
your servers latest.log will tell you
Thanks @eternal oxide and @wraith rapids , the sync from async works flawlessly 🙂
Is there a way removing config sections from yamlconfiguration? also like ```
fun delmember(world: String, uuid: String): Void? {
val ccfg: File = File("world//" + world + "//world.yml")
val cfg: YamlConfiguration = YamlConfiguration.loadConfiguration(ccfg)
cfg.remove("- ", uuid)
try {
cfg.save(ccfg)
} catch (e: IOException) {
e.printStackTrace()
}
return null
}
What does website in plugin.yml do?
simple metadata printed in timings and version command
set to null?
hey, i am getting this error when I am trying to compile buildtools 1.8.8
at org.eclipse.jgit.lib.BaseRepositoryBuilder.build(BaseRepositoryBuilder.java:585)
at org.eclipse.jgit.api.Git.open(Git.java:93)
at org.eclipse.jgit.api.Git.open(Git.java:73)
at org.spigotmc.builder.Builder.main(Builder.java:303)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)```
I am using the command `java -jar BuildTools.jar --rev 1.8.8` in Git with the directory pointed to where `BuildTools.jar` is located.
take the folder off your desktop to somewhere like c:\buildtools
put buildtools in that folder adn run it in a command prompt
alright
for that what i want to do is null no solution
*** Please rerun BuildTools using an appropriate Java version. For obvious reasons outdated MC versions do not support Java versions that did not exist at their release.```
I got this error now
You need a compatible version of java for teh version of Spigot you are going to build
Should I just install java 8 then?
hmm, doesn't it would just remove the content of the configurationsection?
no, it removes the configurationsection
keys with null values are not written to the file by the bukkit config api when saving
so anything that is null gets omitted entirely
@eternal oxide now i have the spigot 1.8.8 jar, how would i import / add it into intellij?
are you building with maven?
yes
then you don;t import it. You add the entries in your pom
alright, but i don't have to add it into the project?
no
a list is not a key
alright thanks
Correct. I was just pointing out nulls can be added, just not keys
@EventHandler
public void onInvClose(InventoryCloseEvent event){
System.out.println("test");
if(event.getView().getTitle().equals(getTitleName())){
System.out.println("test1");
Player player = (Player) event.getPlayer();
new TeleportPlayerToDefaultLocation().TeleportPlayer(player);
}
}```
this returns null?
isint event.getPlayer the player?
NVM read wrong one sec
thats not a thing
hahaa np
and event.getPlayer.getName doesnt work
cuz its a string
debug it. It should return the player.
Your TeleportPlayer method might be the one being null
i get CraftPlayer<name=Paradis120202>
Player player = (Player) event.getPlayer();
System.out.println("test2 " + player);
doing that
Line 20 of teleport player
Location loc = new Location(Bukkit.getWorld(getWorldRespawn(spawnLocation)), getXRespawnLocation(spawnLocation), getYRespawnLocation(spawnLocation), getZRespawnLocation(spawnLocation));
getWorld is null
Caused by: java.lang.IllegalArgumentException: Name cannot be null
at me.paradis.main.TeleportPlayerToDefaultLocation.TeleportPlayer(TeleportPlayerToDefaultLocation.java:20) ~[?:?]
yea name of the world
but thats fine right
i get the string
and then the world of the string
using Bukkit.getWorld(String)
is the world loaded?
yea
respawnLocations:
'1':
world: world
X: -210
Y: 64
Z: 259
'2':
world: world
X: -210
Y: 64
Z: 254
Debug it. bukkit.getworld is saying the name is null.
is the world loaded?
Check for this to.
but its the normal world
its right next to me
i debuged the name of the world and i do get null for some reason
Well something isn't right lol
let me check
you are doing config.get() instead of config.getString()
get() returns an object
Check your code.
yea but i dont have a single loop
Can you show your code?
The only thing I can think of is maybe you registered the listener twice.
Like you used /reload
i didnt and even if i did that it would only run twice
I'm not seeing a reason it would run multiple times based off that code then sorry.
boolean equalsCommon(CraftMetaItem meta) {
if (!super.equalsCommon(meta)) {
return false;
}
if (meta instanceof CraftMetaSkull) {
CraftMetaSkull that = (CraftMetaSkull) meta;
// SPIGOT-5403: equals does not check properties
return (this.profile != null ? that.profile != null && this.serializedProfile.equals(that.serializedProfile) : that.profile == null);
}
return true;
}``` ???
running latest version
the only time that profile and serializedProfile are written to is here
this.profile = profile;
this.serializedProfile = (profile == null) ? null : GameProfileSerializer.serialize(new NBTTagCompound(), profile);
}```
so idk why im getting the NPE
nevermind
reflection
used somewhere else
so i added this
if(spawnLocation == 0) spawnLocation =1;
and it broke my server lmao
thers a constant loop for some reason
until it brakes
is there some kind of bruteforce stop?
not return
if i add return on inv close event it says unnecessary
How can I create an object that has unique ID everytime I create a new instance and also I want to save and load them on config.
UUID should have a static method
lucas, the reason it's looping (i think) is because the InventoryCloseEvent is called before the inventory is actually closed
so when you teleport the player with the inventory open, it closes the inventory and calls the InventoryCloseEvent again
to solve this, put it in a task
Bukkit.getScheduler().runTask(plugin, () -> player.teleport(location));
oh
you are right
i did add a player.closeInventory
but that calls the event
and the event closes the inventory
what does this do
delays the teleportation until the inventory is closed
this is what i have right now https://paste.md-5.net/hesukuyeyu.java
why dont you want to storage it in the yml file tho?
alright, i'll find my way, thanks.
is there a way to cancel jumps?
There is with Paper API
well im using spigot :/ is there a way to get that?
you'd have to do it the old fashioned way and I don't know how 
i disabled jumping in my mc server /s
xd
im trying to make a freeze plugin sorta thing and the simplest way I have found to do it under my circumstances is to give the player slowness infinite
i remember once i saw a guy doing something like player.setSpeed 0
you cant do anything
i think it was from some plugin
i have no idea i saw it years ago
but you could jump walk run anything
you could cancel the PlayerMoveEvent
i think that stops the jumps too
yea the problem with that is im running on a weird event
Any of y'all trying to help me do a school project for some cash?
It requires me to write Java code and I totally am blanking out rn, Need all the help I can get.... xD
and it just bugs a lot
sure
dm me
hey so ive read up on NMS and i kinda want to use it because of the detailed mob customization but heard there were downsides too, should i use it and why?
im working on a custom mob arena with levels/waves etc and want to make bosses etc.
the downsides is that it changes a bit from version to version
and if you use obfuscated code you may have ot update it
so its not ideal for public plugins, unless you make a pretty good reflection utility (or use someone elses)
i read stuff about methods being a.b(c,f) and stuff like that, is it readable?
sometimes depending on what you want you have no choice to
MiniMappingViewer
this (for the most part) is accurate
yeah i would love to experiment with spiders's ability to climb walls etc.
that looks pretty neat, i'll look into it and probably start using it and try it out!
id say avoid it as much as you can
but yes there are very cool use cases
especially when it comes to pathfinding and mob behavior
so i think the best way of using it is to use both spigot and nms where applicable then?
and so nms is basically the methods that spigot puts readable wrappers around and unlocks more options right?
code: https://paste.md-5.net/giwerulove.cs
issue: https://gyazo.com/12f05057357ea5c8783ea5a9c9f74a35
no console errors
catch (NullPointerException e) { return; } gotta love that
Give the player jump boost > 128
ty
just try catch the entire plugin eZ bug free
But > 128 will overflow to negative, which stops jumping
Gives me a good idea for a challenge to add to my plugin as well
I dont like errors ok
but ik its
dumb
idk why I did it
do you like knowing what's wrong with your code?
but when theres a error it means somethings wrong XD
so it should be fixed not hidden
XD
well we don't wanna hear it either then
😦
"why isn't this working" is synonymous with "what's wrong with this"
guys why is my code not working
if player can fly
report player
else
do something idk what
end;
who here types fast
you are missing indent
if player can fly
report player
else
do something idk what
end!
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commandss implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase(anotherString: "createPant")) {
Player player = (Player) sender;
player.getInventory().addItem(me.mrpiedot.PantsThatPoopTnt.items.items.TntPants);
}
}
}
for some reason I'm getting a error saying anotherString cannot be resolved in a variable```
yeah I have that
its not working
@novel hornet please use a paste site or ``` ``` to format the code
even the scream at the end?
anotherString you aren't declaring a variable named anotherString anywhere in your code
fixed
anotherstring: “createPant”?
What is the anotherstring part about
Java doesn’t let you do that sadly
so do i remove that
anotherString: is probably IntelliJ?
if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK) || !(event.getAction() == Action.RIGHT_CLICK_AIR)) return;
That needs to be && not ||, otherwise the statement will always be false
Also you want to use ... != ..., not !(... == ...).
if (player.getItemInHand().getType() == null) return;
This is complete nonsense. The type is an enum and can't be null.
if (!player.getItemInHand().getItemMeta().getDisplayName().equals(CC.GREEN + "Toggle players " + CC.GRAY + "(Right Click)")) return;
if (!player.getItemInHand().getItemMeta().getDisplayName().equals(CC.RED + "Toggle players " + CC.GRAY + "(Right Click)")) return;
Having these after each other is nonsense. The second part is basically unreachable.
thanks, this is really old super messy code I copy and pasted and just cleaned up
I know your ide will tell you the name of the parameter
or am trying to
i use Eclipse so how would i do it on there
But it shouldn’t be inserting that name
and replace it with ?
Can someone help me with this error? https://paste.md-5.net/cegohawiro.sql
This line, player.teleport(project.getLocation());.
oh
It's a world from multiverse core.
May need to depend on that
or softdepend at least
thanks
Softdepend doesn’t change load order iirc
Don’t remember who told me that ¯_(ツ)_/¯
How do I use this? It's in different class than the main class.
what
it say cannot resolve
You learn about object oriented programming
And pass an instance of your main class around
Or pass the config itself if that’s all you need
Don’t create a new instance of your main class
i dont even think youre allowed to
Correct
How do i get the dependency net.minecraft.server.v1_16_R3? I have a plugin that im trying to decompile, and im missing this dependency. I use Maven, so i have every other dependency added except for this one.
Demo main = new Demo();
like this?
main class name is Demo
ok it says
java.lang.IllegalArgumentException: Plugin already initialized!
hmm yes create another instance of your plugin
what you want to do is something called a dependency injection, where you pass the main already existing class to other classes for use
oh he already told me this
Make a constructor and instantiate your main class. Try learning basic java before trying to do spigot plugins
Also why would you send the player the getConfig() method lol
:? its a message in the config file
I wanted to send string in the config to player
Ah
Try learning basic java before trying to do spigot plugins
am i at the spigot-forums? lol
Ok that makes more sense lol
?
when having a problem at the forums, 90% of time, the answers are just learn java
so just a joke from me
Wow funny joke
thank you
Real kneeslapper
I mean, I assume it’s often a fair answer
i mean...
most of time, people just dont know what to say, but they want to say something
I feel like people say learn java but then never explain how
Like
I feel like it would be better if we told people HOW to learn java
Use the internet
Cause some ppl just don’t know
It has more tutorials than I have brain cells
Although to be fair, 2 isn’t that many
Lol
i mean yeah, there was this guy didn't knewing why his code was giving errors, while he didnt used semicolons
in this case he has to learn java, really... but...
that are 1% of the "problems"
Debatable
If he knew about constructors and oop he wouldn’t have asked that question
Literally 99% of problems are basic lack of java knowledge
it's always easier to just ask, instead of reading hundreds of sites
i mean, i can't say anything, i wasn't better lol
ok I am real confused. How do I make instance of class without creating instance of main class?
but I don't have
Hey can somebody help me by that: java -Xmx1G -jar spigot.jar
Der Befehl "java" ist entweder falsch geschrieben oder
konnte nicht gefunden werden. (German)
only java_work is set :(
so I made a object in main class sDemo main = new Demo();
now how do I pass it in another class?
you could do it like that
how would i change the distance that an entity's customName would show
all livingentities are called [Lvl. Level] MobName
and i dont want to look down
and see nothing but nametags
underneath the ground
class TestClass {
public Object object = new Object();
}
public class Test {
private static TestClass test;
public static void main(String[] args) throws InterruptedException {
test = new TestClass();
Thread readerThread = new Thread(() -> {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(test.object);
}
});
Thread writerThread = new Thread(() -> {
while (true) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
test.object = new Object();
}
});
readerThread.start();
writerThread.run();
}
}
so i have this class for testing read writes of two threads
don't mind how bad this looks this is just a test
why these threads values, which are changed are not cached inside LM CPU cache?
output from reader thread which reads data asigned by writer thread:
java.lang.Object@b04089e
java.lang.Object@35b13d4b
java.lang.Object@1b45ade7
java.lang.Object@47bf623f
java.lang.Object@6c54d2ae
java.lang.Object@50b3f10a
java.lang.Object@662f446e
java.lang.Object@5a3d6c0e
so I use this in main class?
yes
i think it cant be bcz your trying to get like new class everytime @mortal hare
but there will be no method in another class
there will be proxyghost
just use in other class Demo.getInstance()
im asigning new object in the writer thread and reading that object from another
by default it should not sync the values
in threads but it does
i guess cache is fast?
well yea ig the object is resetting everytime u do the TestClass test;
i dont wanna say stupid things idk
that's understandable, but the thing is threads act funky on memory. They do not share variables by default. If the code running on Core 1 and the other code on Core 2. They will have different values without volatile keyword
oh yea
you should ask in #general ig
bcz like this is "Serious Spigot and BungeeCord Programming/Development Help | Ask Questions Here" well idk
@quaint mantle java.lang.IllegalArgumentException: Plugin already initialized!
I used what you said but got this error
code?
public final class Demo extends JavaPlugin implements Listener {
private static Demo main;
@Override
public void onEnable() {
main = this;
Demo main = new Demo();
getLogger().info("Starting a demo!");
getConfig().options().copyDefaults();
saveDefaultConfig();
getServer().getPluginManager().registerEvents(new ItemDrop(), this);
getCommand("feed").setExecutor(new Feed());
getCommand("heal").setExecutor(new Heal());
}
public static Demo getInstance() {
return main;
}
}
this is main class
this is from another
player.sendMessage(Demo.getInstance().getConfig().getString("NoPermMessage"));
remove the Demo main
in your onENable
ah
how do I get color codes from config file?
ChatColor.translateAlternateColorCodes(#Char, #String);
thanks
player.sendMessage(ChatColor.translateAlternateColorCodes(&, NoPermMessage);
'&' is anything
Well, if it compiles it compiles, if it does not it does not
But I can say that javac will not accept stray ampersands
Ugh
'&'
'&' exists
:/
idk what happened there, probably makes sense after it is resolved ¯_(ツ)_/¯
show the code
its fine now
oh okay
it was problem with maven
so I have to run clean first and then package
okay
thanks
is there anyway I can generate a yml?
if so how
its just filled with examples and stuff
by generate u mean like create a blank yml or with smth?
How could i get an entity by its id?
getEntities() getLivingEntities() getTileEntities()
can I generate a yml?
duckduckgo says https://www.spigotmc.org/wiki/config-files/
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Server.WORLD_PARTICLES) {
@Override
public void onPacketSending(PacketEvent e) {
Player p = e.getPlayer();
WrapperPlayServerWorldParticles packet = new WrapperPlayServerWorldParticles(e.getPacket());
if (packet.getParticle().getParticle() == (Particle.REDSTONE)) {
Location particleLoc = new Location(p.getWorld(), packet.getX(), packet.getY(),
packet.getZ());
for (Location loc : ParticleTrail.overworldTrails) {
if (p.getLocation().distanceSquared(loc) >= 10) {
e.setCancelled(true);
}
}
}
}
});
Hey, I have this code. I have a trail plugin, which generates lots of particles aka a particle trail. The thing is, i want to achieve so you only render parictles less than 10 blocks away from you. But this code here checks if im 10 blocks away from any of the particles and then it completely stops rendering any of my particles. How could i optimise the code so it will check if its 10 blocks away from any particle and then stops rendering only the specific ones?
It loops over ParticleTrail.overworldTrails and if any of them are out of range it cancels the event.
You need to check if the particle is in ParticleTrail.overworldTrails, if it is you need to check its distance from the player, then cancel IF its over 10 distance.
Hello, I know that this is not some kind of a development question, but in this channel there are more ppl that may have their own website and faced similar problem. Is there any SpigotMC branding to be used on websites? Thanks.
wdym by SpigotMC branding
i don’t think anybody cares really
why would you need a branding thing
cant you make a button href="https://spigotmc.org"
I don't think that you can use the spigotmc logo everywhere
how can I cancel that players can move items to the bottom inventory? They should be able to move items above. I canceled InventoryDrag and ClickEvent when
if(event.getInventory() != event.getView().getBottomInventory())
return;
or in the click event:
if(event.getClickedInventory() != event.getView().getBottomInventory())
return;
but the problem is that players can still hotkey the items in the bottom inventory and the players can sometimes move the items to the bottom inventory? It doesnt always happen but it sometimes does???
a return is not cancelling the event
your return comes first. it will never reach the cancel
yes
You are comparing object instances you should be using .equals
okay but that probably wont fix the issue right?
You might want to look into using #equals though, I got some concerns using instance comparisions, though I think that won't matter here (though it would explain to why it works sometimes)
I mean I could change it but I dont think it will change anything
Well #equals is a lot more reliable than instance comparision
== is for primitives and enums
Hey, how to add effects to my custom Enchant CustomEnchantment extends Enchantment?
As well as semi-singletons, such as threads
yep
Let it implement Listener and listen for the events in which you want it to do stuff
enum != primitive lenny
ehhhh
What?
Did not fix anything as I thought
yes
Enums are semi-singletons (they will not be cloned arbitarily)
As such instance comparision can be made use of
https://paste.md-5.net/ovetohowac.cs I dont have any inventory checks or anything. its just for testing
It's not limited to enums, everything else that mimics on how on enums work (i. e. one instance per property set, never any duplicates) will behave as intended with instance comparisions
i upload nlogin and when i restart the server he tell plss choose you favourite plugin plss jelp
i upload nlogin and when i restart the server he tell plss choose you favourite plugin plss jelp
.
We weren't talking about primitives having methods before though . Meh, who cares ¯_(ツ)_/¯
Can help me
?
i upload nlogin and when i restart the server he tell plss choose you favourite plugin plss help
@quaint mantle nlogin have depends?
Your code looks fine
k
seems like getShooter isnt a thing
Cannot resolve method 'getShooter' in 'LivingEntity'
What version?
1.16
((Projectile) event.getEntity()).getShooter()
getShooter is under Projectile
Player player = (Player) ((Projectile) event.getEntity()).getShooter();
seems to not give errors
test before casting to Player. It could be a mob or a dispenser
ok
also it wont really matter since I check for a permission after that
I need a anti grief plugin
it will matter because you can;t cast a mob or a dispenser to a Player
it will throw a ClassCastException
I need best anti grief plugi
so Entity isnstead of player?
no, getShooter() returns a ProjectileSource
you then instanceof to see if its a player
ProjectileSource shooter = ((Projectile) event.getEntity()).getShooter();
if (shooter instanceof Player) {
//code```
ok
okay I found out that the inventoryclickevent is not called when i click in a inventory and quickly move the cursor away from the slot. The item will be set in the slot since the event will never get fired???
InventoryDragEvent
Always detects the click and where https://paste.md-5.net/ubeyomuvuv.cs
How do I check what inventory the user dragged the item to? getInventory() always returns the top one
through the slot ids iirc. it can be dragged across both.
Its when I drag an item ^^
how do you mean drag? when you hold a block over a slot and right click?
even with left click and dragging your mouse slightly while still being on the same slot will fire drag instead of click iirc
Hello, I am trying to do something with a HashMap, I saved in a HashMap of <Player,Player> I saved 1 entry, but for some reason it gets removed when I use map.containsValue(player), any help?
the drag event does not fire untill you release the mouse
I'm suggesting you to use UUID instead.
Actually its more complicated than that. The client will not leave the ground when jump boost is > 128, so it’ll never send a “jump” packet. The server can calculate the velocity just fine, but it never uses it because the client never sends a packet saying they jump.
Had an issue on my server when the player was applied knockbac, it would send the jump packet and the server would calculate y velocity just fine. Player would launch into the air.
Ah yeah I remember that
Hmm
I guess you could cancel velocity events with really high values
Yes if you drag at all the event fires a drag event
getInventory on the drag event always returns the top inventory
however event.getInventorySlots() returns a Set of affected slots which could be in the upper or lower inventory
which is literally what i said
I have a big problem:
public List<Mail> getMails(Player player)
{
List<Mail> mails = new ArrayList<>();
for(String uuid : this.plugin.getMySQLConnector().getColumns("mails", "uuid"))
{
if(uuid.equals(player.getUniqueId().toString()))
{
String identifier = (String) this.plugin.getMySQLConnector().getColumn("mails", "identifier", uuid, "uuid");
String name = (String) this.plugin.getMySQLConnector().getColumn("mails", "name", uuid, "uuid");
String sender = (String) this.plugin.getMySQLConnector().getColumn("mails", "sender", uuid, "uuid");
String subject = (String) this.plugin.getMySQLConnector().getColumn("mails", "subject", uuid, "uuid");
String message = (String) this.plugin.getMySQLConnector().getColumn("mails", "message", uuid, "uuid");
String type = (String) this.plugin.getMySQLConnector().getColumn("mails", "type", uuid, "uuid");
String date = (String) this.plugin.getMySQLConnector().getColumn("mails", "date", uuid, "uuid");
mails.add(new Mail(identifier, uuid, name, sender, subject, message, type, date, this.plugin));
}
}
return mails;
}```
I have this. And....
uuid = 123
player.getUniqueId().toString() = 123
And. The list is empty after calling this
I dont know why
Please help
I know. Just an example
have you debugged all the getColumns and ensured they are actually returning something
This shows correct every time for click or drag https://paste.md-5.net/didudeleqo.cs
This is false
So.... No new Mail is created
what the hell is this kind of query
I dont know what you mean.
whats wrong with a good ol' select and iterating over the resultset
Please dont evaluate my code
lmao
You didnt saw the resultset so dont critc me
if u dont want help dont ask for it kek
have you printed uuid and ensured its returning correct
Just help me please. I promise you, that this isnt the issue
you can't post in a help chat and not expect critique
Yes. 1 to 1
if i had the effort to scroll up i would criticize your ass to fucking uzbekistan
means something isn't matching
this.plugin.getMySQLConnector().getColumns("mails", "uuid")
I'm trying now to output this
Or the size
this.plugin.getMySQLConnector().getColumns("mails", "uuid").size() = 0
This is crazy
If you look on there
Right.
means your sql connector is bung
But I have something in that line...
It must...
But it always worked correct
public List<String> getColumns(String table, String column) {
try {
ResultSet resultSet = MySQL.query("SELECT " + column + " FROM " + table + ";");
List<String> results = new ArrayList<String>();
if (resultSet.next()) {
while (resultSet.next()) {
results.add(resultSet.getString(1));
}
} else {
this.plugin.getLogger().info("No results available!");
}
return results;
}
catch (SQLException ex) {
this.plugin.getLogger().info("§cError.");
return null;
}
}```
Isnt there something correct?
Is it possible to add a base64texture config option for guis in 1.12.2?
im shit at SQL
but i think its
SELECT column FROM table WHERE uuid EQUALS ?
not sure tho
not for skull textures iirc
No. Thats because I want to get the whole columns
How does deluxe hub and deluxe menus etc do it then?
would be a select * thing then
You can use base64 skulls in 1.12
look into GAmeProfile, there should be a method for it
Oh:
results.add(resultSet.getString(1));
}```
I think its this
I always getting the column index from 1
Not increasing it
@drowsy helm
I'm testing some stuff of my plugins does anyone have an idea on what would be a good way to make my server tps to go down to like 16/17
Sorry. I thought you are interested
very broad question, what is your plugin doing exactly
Just loading data
can we see code snippets
List<Player> Players = new ArrayList(Arrays.asList(Bukkit.getServer().getOnlinePlayers().toArray()));
is this right?
Send code.
use a sampler or paper's timings to investigate what is using excessive tick time
would help a lot more
I don't have any issues with my plugin
or a profiler
I never said my tps is going down
Is it possible like I can have a separate class for a subcommand?
I want to make my tps go down
Whats your problem then?
I want to test how my plugin reacts with some lag
Bukkit.getServeR().getOnlinePlayers() returns a list of players
Okay
It returns a collection actually
yeah that timer task would work
that's an impl detail though, iirc the return type is collection<player>
can anyone tell me is this right?
List<Player> Players = new ArrayList(Arrays.asList(Bukkit.getServer().getOnlinePlayers().toArray()));
a hundred square roots is literally nothing
the server does like a dozen for every entity every tick or some shit
List<Player> Players = (List<Player>)Bukkit.getServer().getOnlinePlayers();
few hundred
was example lol
repeatedly set a big cube of blocks to stone and then back to air
new Timer().schedule(new TimerTask() {
@Override
public void run() {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}, 0, 1);
I don't need toArray();?
I'll try this
no in java we have to do everything in one class.
no, the method returns a collection
casting that isn't technically safe
which can be cast to a list
obviously you can have separate classes lol
oh thx
that the returned object is s a list is an implementation detail
the return type is Collection
which may not be a list
true
it could be a set, it could be any arbitrary class that implements collection
can put it in the constructor for arraylist
I mean how to connect them to the main command? so I have to do main command in main class?
List<Player> Players = new ArrayList<>(Bukkit.getServer().getOnlinePlayers());
done
ezpz
What does .sendRawMessage do?
Probably says in the javadocs
javadocs just says 'sends raw message'
its part of the conversation API
sendMessage also calls sendRawMessage. sendMessage just respects the conversation API.
the conversation api is cancer
I've never used it myself
never found any use for it
Why this isn't working .spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
define not working
ChatMessageType isn't a thing, is this for an old API? What should I replace/fix it with?
it is a thing
import net.md_5.bungee.api.ChatMessageType
how are you depending on spigot
probs spigot-api
yes, but through maven or through your ide as an imported package
change your dependency from spigot-api to spigot
spigot-api should include the bungee shit
?
show your maven dependency tree
waiting for the "what is maven" lol
no, the pom is not the dependency tree
You probably imported TextComponent from java.awt
⬆️
run mvn dependency:tree in your ide console
eclipse moment
what?
you're depending on the javadoc artifact
So?
which is just a bunch of HTML, CSS and JS files to display the Javadocs
I am new. I don't understand
use maven then you wont have as many issues someboodi2
How do I use maven?
one step at a time, please
depend on spigot-api-1.16.5-R0.1-20210424.223940-54.jar, not the one that ends in -javadocs
Also, that's a sus name
@worldly ingot I used this https://www.spigotmc.org/wiki/creating-a-blank-spigot-plugin-in-eclipse/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
that's fine, you can use that, but you're depending on the wrong file
It's my spigot name. I can't change it
What's the correct file?
doesn't work
Where do I download it from?
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Your issue is you are tying to use the sendMessage from a CommandSender and not a player
ElgarL can you help me too?
How to fix?
((Player)whoClicked).spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("Test message"));
that's not the only issue
if he can't import the class he won't be able to use the method that requires an object of that type as a parameter regardless
like i guess he could pass null but then bukkit explodes
its in Spigot-API. He just needs to add the import is all
not using maven?
he's using maven yeah
i've tried to get him to show his dependency tree but he's not responding
IJ or Eclipse?
ij
How?
he shoudl just invalidate caches
worth a try I suppose
there's a maven sidebar on the right
expand it
click open the dependencies
fixes most dependency issues
I have a problem "an internal error occurred while attempting to perform this command"
how would i fix this
look up the error in your console
that's, uh
are you importing it as a referenced library in your ide
or through maven
thats a manual import in that image
yeah
use maven
remove all libraries. They shoudl all be provided through maven/your pom
where is maven I can't see it
What is your problem?
How to run?
you're not using maven are you
I compiled RedisBungee but when I start my Bungee server I keep getting this error
Caused by: java.net.UnknownHostException: 6e773f50-17da-40d4-b7b7-22344193287a: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:929)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1324)
at java.net.InetAddress.getLocalHost(InetAddress.java:1501)
... 17 more
You have the wrong library. you are using the javadoc not the api
choco already told you, that you are using the javadocs and not the api
he's been at this for days
He only comes here to see me. He's in love
sounds kinda gay
This is the full error
https://ghostbin.com/paste/aqU7K
Ghostbin is a website where you can store and share text online.
to be gay is okay
you are trying to look up an uuid as if it were an ip address/hostname
@eternal oxide @hybrid spoke where do I download the API?
I'm not thats the thing
I don't know what to search on Google
well something is
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
@quaint mantle ⬆️
Follow the tutorial Choco linked you
now he's going to download the buildtools jar and add it as a referenced library 
i'm calling it
final String redisServer = configuration.getString("redis-server", "localhost");
System.out.println(redisServer);
final int redisPort = configuration.getInt("redis-port", 6379);
String redisPassword = configuration.getString("redis-password");
String serverId = configuration.getString("server-id");
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
redisPassword = null;
}
// Configuration sanity checks.
if (serverId == null || serverId.isEmpty()) {
throw new RuntimeException("server-id is not specified in the configuration or is empty");
}
if (redisServer != null && !redisServer.isEmpty()) {
final String finalRedisPassword = redisPassword;
FutureTask<JedisPool> task = new FutureTask<>(new Callable<JedisPool>() {
@Override
public JedisPool call() {
// Create the pool...
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(configuration.getInt("max-redis-connections", 8));
return new JedisPool(config, redisServer, redisPort, 0, finalRedisPassword);
}
});
Getting the string of the host which is localhost in the config
@hybrid spoke I'm stupid I don't know what to do
and is put as default to "localhost"
the TUTORIAL on the WEBSITE says it all
well is that set to an uuid
you just need to follow it
and i'm using that variable in the constructor of JedisPool
Where is it?
lmao
?bt
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
.. xD
To get the jar you run BuildTools.java
it's not
I just don't get it it's not an minecraft uuid
on that page he linked Prerequisite It assumes that you have the Spigot-API jar file (obtainable with BuildTools or on The Nexus) which we will use.
and I'm not creating any uuids in this code
imagine if there was like a dependency manager that'd let you just specify where the dependency is and what it's called and it downloads it for you automagically
unfortunately he doesn't seem to be capable of following a step-by-step maven guide with screenshots
someone will probably have to mail themselves to him with fedex and show it to him in person
I already have
You can even install the Minecraft plugin for IntelliJ
it will just create the whole maven project for you including dependecies
then when run it will have made you a spigot jar
What should I do after I made a project using maven?
Actually i fixed it by just cancelling the jump packet when a player has jump boost. Works wonders.
and it shits out you a jar you can load
This is so weird
i suppose you will have to add the spigot dependency information to your pom first
14:52:52 [INFO] [RedisBungee] Successfully connected to Redis
did you follow the guide I linked
But it's still throwing that exception
it tells you how to do that
Can I delete these folders in src
anyway if it connects it connects
No
no
Dont delete those lol
main.java is where your code goes
main.resources is where your config.yml and other files like that go
you can telete the test directory if you want i guess, tests are gay
it will autorecreate anyway
ok
And i think maven will just regenerate that folder anyways
XD
are you afraid of the homos
So I put my package inside main.java?
yea
ok
yeah, like the guide I linked says
We should stop helping if he refuses to read the thing
we should stop trying to help
we should stop trying
we should stop
Should we stop?
what did i just say
Just making sure
hey elgar do you remember if the towny trie impl is self sourced or are you depending on some library for it
I didn;t add the trie, that was someone after me
Start over and use maven
remove the ".java" in your import
How do I do that?
with your keyboard
by... removing it...?
there's a button over your enter key
I'm stupid
5*
5*
i guess that's true
stop being sonic @glossy scroll
.
remove the javadoc dependency jar
How do I use Maven?
you are already this far
Link
This?
we are not turning back now
LOL
@hybrid spoke
it will take 5 more days if he needs to learn how to read and follow a guide
http://prntscr.com/12b2kgh click it and press del
or change some numbers in a pom
That doest make a difference
have you considered giving up yet