#help-development
1 messages · Page 2017 of 1
are nms versions for 1.18 and 1.18.2 different?
probably
Yes
Ok it's been long enough without me saying anything so I gotta ask
Why the stonetoss pfp
The what
Looks like stonetoss
A webcomic artist who is a known nazi
And that is not an exaggeration
if i wanted to make 2 different types of beacons
like 1 that has blue particles and one that has red
how would i do that?
listen to block place event, then add it to a list?
@waxen plinth Some help: Im trying to be able to make it so that a value updates in my Confirm thingy when clicking confirm or deny, but I cant see to ever get it, any reason why?
amogus
- I can't really tell you without you sharing code and some more specifics
- Please don't ping me for help
ill send code if i have to
k
how
sorry, I have been at this for an hour XD
scoreboardManager.getMainScoreboard().getObjective("Time").getScore(cardStand).setScore(10);
invClickDetector
Confirm.getMap().get(event.getClickedInventory()).Finish(true);
``` (yes static abuse dont cry)
Confirm thingy
```java
public static HashMap<Inventory, Confirm> map = new HashMap<>();
private Inventory gui;
private AtomicReference<Boolean> allowClose = new AtomicReference<>(false);
private AtomicReference<Boolean> optionResult = new AtomicReference<>(null);
public Confirm(Player p, ItemStack confirmItem) throws InterruptedException {
gui = Bukkit.createInventory(this, 9*1, ChatColor.GREEN + "Confirmation");
map.put(gui, this);
allowClose.set(false);
init(p, confirmItem);
}
public static HashMap getMap(){
return map;
}
public void Finish(Boolean result){
optionResult.set(result);
allowClose.set(true);
}
public Constable getResult(){
return optionResult.get();
}
this bit of code throws an error because cardStand is an armor stand
^
Scoreboards are weird and use strings for everything
ok
any reason why its not letting me get anything?
Why are you using AtomicReference
auto suggested
i have 0 idea why id be using them otherwise
Also not sure what you mean by "not letting me get anything"
I cant get Finish
in the invClickDetector
I'm querying db on a join/leave event, would I do it on a new thread or not?
Probably a good idea yeah
Do it async
New
If it's sqlite then you can get away with sync queries if you do enough caching
@waxen plinth help when opening the ui this happens:
13.03 06:47:27 [Server] Server thread/WARN Task #14135826 for EmeraldsPlugin v1.0.0 generated an exception
13.03 06:47:27 [Server] INFO net.minecraft.server.CancelledPacketHandleException: null
invClickEvent
}else if(holder instanceof Confirm){
Material itemType = event.getCurrentItem().getType();
if(itemType == Material.LIME_STAINED_GLASS_PANE){
Confirm.map.get(event.getClickedInventory()).Finish(true);
}else if(itemType == Material.RED_STAINED_GLASS_PANE){
Confirm.map.get(event.getClickedInventory()).Finish(false);
}
}
confirm ui
public void Finish(Boolean result){
this.optionResult = result;
this.allowClose = true;
}
private void init(Player p, ItemStack confirmItem) throws InterruptedException {
ItemStack[] menu_items = {
confirm,confirm,confirm,nin,confirmItem,nin,deny,deny,deny,
};
this.gui.setContents(menu_items);
p.openInventory(this.gui);
Bukkit.getScheduler().runTaskTimer(EmeraldsPlugin.jp, t -> {
if(!this.allowClose && !p.getOpenInventory().getTopInventory().equals(this.gui)) {
p.openInventory(this.gui);
}else if(this.allowClose){
p.closeInventory();
map.remove(this.gui);
t.cancel();
}
}, 1, 1);
}
But for mysql you can't
all the code you need rlly
Again, please do not ping me for help
it errors at the scheduler
I am already in the chat
There’s a AsyncPlayerPreLoginEvent that exists for you as well
crap sorry
i keep forgetting
but i have 0 idea why its doing this
Aight thanks, yea it's mysql so I'll do it on new thread thanks!
Did I even do the ui right?
Oh forgot about that one 😓 I'll use that then ty
13.03 07:03:05 [Server] Craft Scheduler Thread - 62/WARN Plugin EmeraldsPlugin v1.0.0 generated an exception while executing task 14733871
13.03 07:03:05 [Server] INFO net.minecraft.server.CancelledPacketHandleException: null
Did i do msth wrong or smth
does BukkitScheduler#getPendingTasks() return a list of tasks from all plugins or just the plugin it was invoked in?
Yeah it's nearly 4am and I ran out of steam for helping people
There's only so much of the same stuff I can help people with over and over before it drains me
Why does no one ever have cool algorithms questions 🙃
I'm trying to implement an asynchronous BukkitTask that will loop infinitely (yes, i know BukkitTask#scheduleAsyncRepeatingTask exists, however I'm planning to add random delays)
scheduler.runTaskLaterAsynchronously(main, new Runnable() {
public void run() {
if (hasGreaterThanDrunkPercent(player, 0)) {
randomMove(player);
scheduler.runTaskLaterAsynchronously(main, this, 20L);
}
else {
}
}
}, 20L);
I'm just wondering if the line:
scheduler.runTaskLaterAsynchronously(main, this, 20L);
will cause any infinite recursion errors
Pretty sure that's gonna endlessly schedule itself and crash the server or something
I'm gonna add some logic for that dw
it's supposed to be repeating though
Should still work
alright
Kinda funky
hey I dont know if anyone has any experience with this but i am aware that you can make custom items via the custom model data so does custom block data work for custom blocks aswell ?
no
is it public?
k ty
Show code please
scheduler.runTaskLaterAsynchronously(main, () -> {
if (hasGreaterThanDrunkPercent(player, 0)) {
randomMove(player);
scheduler.runTaskLaterAsynchronously(main, this, 20L);
}
else {
}
}, 20L);
just a few questions
so are the blocks like armor stands or something
alright
What do you mean
but the code i had before won't cause recursion issues correct?
It shouldn't
alrighty
For some reason, it always returns as none. Any idea why?
public Confirm(Player p, ItemStack confirmItem) {
gui = Bukkit.createInventory(this, 9*1, ChatColor.GREEN + "Confirmation");
this.optionResult = "none";
map.put(gui, this);
init(p, confirmItem);
}
public void Finish(Player p, Boolean result){
this.optionResult = result;
map.remove(gui);
p.closeInventory();
}
public Object getResult(){
return this.optionResult;
}
Confirm result = new Confirm(clickedPlayer, tempItem);
int set = Bukkit.getScheduler().scheduleSyncRepeatingTask(EmeraldsPlugin.jp, () -> {
clickedPlayer.sendMessage((String) result.getResult());
if (result.getResult() != "none") {
clickedPlayer.sendMessage(result.getResult() + "!!!!!!");
}
}, 0, 0);
this is very intersting btw ty for sharing
I still don't know what you were asking about it
Me?
Ill give detail rq
Basically, tryna make a confirm or deny gui
but its not working as intended
Not you
Sorry I'm not in the headspace to look through big code blocks with a vague description of what's wrong with them and figure out what's wrong with them
you're setting one variable to both String and Boolean 🧐
where?
this.optionResult
o
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (e.getCurrentItem().getItemMeta().getDisplayName().equals(ChatColor.YELLOW + "Center")) {
Location main = new Location(Bukkit.getWorld("world"), 139.5, 8.0, 75.5, 180, 0);
Player p = (Player) e.getWhoClicked();
p.teleport(main);
new Beast().giveKit(p);
return;
}
e.setCancelled(true);
How do I refer to a certain armorstand in this event? I have different armorstands one called Beast, one called Runner n one called Axeman (for ffa kits).
Like i need an if statement (if the armorstand is called beast or something like that)
that depends on where you want to access it and what for I guess
I'm making an FFA plugin with ArmorStand kits system. I have an as for each kit.
like, you're inside an InventoryClickEvent, what armor stand are you even talking about?
Because
I need to check
If it's the 'Center' item from the inventory that belongs to the beast armorstand that has been clicked
Or if it's the center item from the inv that belongs to runner
or axeman ^^
i see, so someone is clicking an armor stand which pops up an inventory?
So when you right click the as u get an inventory where u can chose the spawns
Yes
Indeed
Now i want to check which of the as so i can give them the right kit
As you can see this line
new Beast().giveKit(p);
well, you could try creating a map where you would write the clicked entity when a player clicks it
and then you may retrieve it later by their name or uuid or sth
Bukkit.getScheduler().runTaskTimer(plugin, t -> {
// do stuff
if (shouldCancel) {
t.cancel();
}
}, 1, 1);
Can you make a looping task?
So it loops til its cancelled?\
am I able to use Player in a TreeMap?
private TreeMap<Player, TreeMap<Behavior, BukkitTask>> playerBehaviorTasks = new TreeMap<Player, TreeMap<Behavior, BukkitTask>>();
I would advise to use uuid
Bukkit.getScheduler().scheduleSyncRepeatingTask() and use cancel()
i'm getting an error when trying to access the treemap using Player
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer cannot be cast to class java.lang.Comparable (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer is in unnamed module of loader java.net.URLClassLoader @18769467; java.lang.Comparable is in module java.base of loader 'bootstrap')
so i'd assume not
You sir are casting something very wrong
im not casting anything
Show your code and change from player to uuid
TreeMap<Behavior, BukkitTask> behaviorTasks = playerBehaviorTasks.get(player);
this is causing it
where player is a Player
yeah i can just use UUID then
That way of doing it works, but they’re using the right variant/better, runTaskTimer
how
there is no way to use cancel
also as @ivory sleet stated
im tring to use the better way, but I want it looped
but cancelable
god I BADLY need help
somebody PLEASE
@quaint mantle maybe create a thread n u'll get helped faster
no cause nobody is on rn
I need this fixed now however
Use a BukkitRunnable in case you want it to be cancellable outside and inside
?scheduling does take this up
Give it a read (:
question, if i make a class extend Event, can another plugin implementing it listen to that, and where in the event's execution would it trigger, also, do i manually need to do a check if the event is disabled?
@ivory sleet Okay, but can I loop it?
Guys sorry im bad at this, Is this static abuse
I think thats normal practice though i just skip the null check since i know i need it anyways
- Yes
- For every listener they have declared and register would it trigger given (you need to use PluginManager::callEvent)
- By disabled you mean cancelled? Yes you do
Moterius
No but it’s bound to give you an error
so how do i handle the cancelled? first line do if(this.isCancelled()) return
Oh ok, thanks, Im not exactly knew to this (3 years) but I never really understood static abuse, or more like what isnt
As there can ever only be one instance of PluginMain, but since you call new PluginMain(), you’re creating a new instance of it
Moterius basically
Well
when it cancelled it should just stop right
nvm Ill stay out of it sorry
In principle yeah
?event-api moterius did you read this?
ah no
im not aware yet of all the resources on spigot
mainly because half of the time i cant even access it
Lol no worries
Ah, anyhow I believe they go through it how to use custom events there
class MainPluginThing extends JavaPlugin {
static MainPluginThing instance;
static getInstance(){ return instance;}
@Override void onEnable(){
instance = this;
}
}```
@wheat abyss do it like this
In this way you’re not creating any new objects/instances/samples of MainPluginThing
Lol
Ah yes! Thats what I say my friend use in one of their plugins actually lol
Myeah, static abuse is sometimes subjective tho
Actually wait thats what I use to do before the thing I do now
dang now i feel dumb lmao
me whos guilty of static abuse
Honestly if it doesnt break anything I dont see anything wrong with it
extremely guilty of static abuse
WOA
dataNotStatic do be vibin’
Tru
At that point I would suggest not static abusing just to not look dumb
But yeah, Skygamez it’s worth looking into a more robust approach in the conceivable future
Uh Conclure, where is the method body? I only see getters & a constructor
But hey if it works
honestly i dont really see a reason to fix it though because nothing has broken (yet) and i havent noticed any preformance issues
plus i have a large list of stuff i need to do before this server releases
I used to do that, but honestly I just feel better/cooler when not doing it lol
isnt static less performance heavy than having a getter?
Context?
thats a fair point
no
what you linked me
static isn’t less performant in terms of speed at all
thats what I said
there's not said which method gets executed
lol
is it the constructor?
In fact static is usually faster than non static
because that would be wreally weird
double negation there
ill fix it once being guilty of static abusing puts me in java jail
javail?
aka when all my crappy coding finally catches up to me and starts causing issues on my server
But given that static stubs out all possible abstractions
It’s pretty bad most of the times
i dont rlly have time to fix it either lol
i have about 7 custom plugins i need to get done
seems like youre guilty of accepting too much work at once
cause i dont have time to refactor about 10 different classes
What plugins im bored
im the sole developer of this entire server
an entire network
I do that too lol
I can’t find it, looks alright to me when reading it just right now
and i need to get done a reporting system, revamp my basics plugin, fix the slashhub plugin, configure a ton of plugins, figure out how to use webhooks in java, make a discord bot, and a bunch of other stuff
which method gets executed when callEvent(new ExampleEvent("Name")) gets called? For me it only shows, in the example code, the handler getter and the class constructor
aswell as fixing the issue with tabcompletion
hence my confusion
so yeah i have a lot of work to do
May I dm you Sky? I could try to help if you would like
i am. but when your the only developer for an entire network things add up
sure
pog
but i dont exactly have the money to pay for developers at the moment
Oh thats fine
I dont exactly have a bank account
Given that ExampleListener is registered
thats not what i mean
it says this is the entire implementation
but there's only constructors and getter methods
there's nothing for the event to execute
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class ExampleEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final String playerName;
public static HandlerList getHandlerList() {return HANDLERS;}
public ExampleEvent(String playerName) {this.playerName = playerName;}
@Override
public HandlerList getHandlers() {return HANDLERS;}
public String getPlayerName() {return this.playerName;}
}
What would it be to execute?
Event objects are just bundlers that have references to other objects
They don’t have any logic inside them (mostly)
The procedure then goes by passing the event object to the plugin manager
Which calls the registered listeners
so, you mean that the purpose of events is to give the ability to manipulate specific things in code through no direct interaction?
Well idk what you mean by direct interaction
But yes
Sort of
It’s a way to have a collection of observers that gets called when something happens
In this case each observer is a listener
And it just so happen to be the case that when we call the listeners we also pass an event instance which the listeners can use
And sometimes this event instance is cancellable, so it would allow further manipulation in other words
But does necessarily not have to do anything at all with manipulation
what'd be a good naming way for wrapper classes containing the logic that runs after a event is called?
like
I would only call a event if something specific is happening, how would i name a class handling the event?
Bukkit has a CraftEventFactory iirc
a what now?
is there a method to add i value to y location?
well github is broken
Location::add I think?
location.add(new Vector(0,i,0)) iirc
the world name is
so it's the same if I use
- "world"
- world
oki
By the specifications they must be the same
Sounds yummy
ctrl shift r
Any library ideas?
@Override
public void onEnable() {
this.instance = this;
if(this.thread == null) {
this.thread = new TCPServerThread(instance, clients);
this.thread.run();
}
}``` ```java
public void run()
{
try {
this.sock = new ServerSocket(42068);
} catch (IOException e) {
e.printStackTrace();
}
while(true) {
try {
Socket client = sock.accept();
ProxyServer.getInstance().getConsole().sendMessage(new ComponentBuilder("[CommunicationPlugin] Connect: " + client.getRemoteSocketAddress().toString()).create());
DataInputStream in = new DataInputStream(client.getInputStream());
DataOutputStream out = new DataOutputStream(client.getOutputStream());
TCPServerReader reader = new TCPServerReader(in, out, client.getRemoteSocketAddress().toString(), this.clients, client, instance);
reader.start();
instance.addClient(client);
ProxyServer.getInstance().getConsole().sendMessage(new ComponentBuilder(clients.toString()).create());
} catch (IOException e) {
e.printStackTrace();
}
}
}
public TCPServerThread(CommunicationPlugin plugin, List<Socket> clients) { this.instance = plugin; this.clients = clients;}```
public void run()
{
while(running) {
try {
Scanner input = new Scanner(inStream);
String temp = input.nextLine();
System.out.println("[SocketResponder] (CLIENT/" + ") >> " + temp);
plugin.broadcast(temp, client);
} catch (NoSuchElementException e) {
ProxyServer.getInstance().getConsole().sendMessage(new ComponentBuilder("[CommunicationPlugin] Disconnect: " + this.clientAddress).create());
clients.remove(client);
System.out.println(this.clients.toString());
this.running = false;
}
}
}
public TCPServerReader(InputStream inStream, OutputStream outStream, String clientAddress, List<Socket> clients, Socket client, CommunicationPlugin plugin) {
this.inStream = inStream;
this.outStream = outStream;
this.clientAddress = clientAddress;
this.clients = clients;
this.client = client;
this.plugin = plugin;
}```
any ideas why this would freeze when running the thread
it seems that the ```java
while(true)
but its in a thread so why would it matter
oh yeah lol tx
dont even have runnables
maybe cause its a bungee plugin
Calling Thread::run instead of Thread::start yummy
oh bruh
ty
How can i spawn a coloured particle of type SPELL? i'm not able to figure out how to add the colour for it
the offset numbers become rgb
I think
🧍
so in the method i just use the offset params as my RGB?
yes
Wait it's a float from 0 to 1.0
@sweet pike
And the amount has to be 0
I couldn't find any resources that are updated on spell particle colouring
I found this
I guess just use the regular rgb and then divide each number by 255
If you want 255,0,100 it would be (1,0,0.39)
okay i'll try that out
@smoky oak so basically
in simple terms
Its just something for other people or you to listen to
and you have to call the event yourself, then the code that's in the listener for the event will run
The logic should be when you are calling the event
Not the event itself
is there anyway i can change the maxstacksize of a material
Yes but that will always be a bit jank
when i spawn an ender dragon, it doesn't move, why?
my code is
Location dragon_spawn = new Location(p.getWorld(), -670, 82, -275);
Entity entity = p.getWorld().spawnEntity(dragon_spawn, EntityType.ENDER_DRAGON);
entity.setGlowing(true);
entity.setCustomNameVisible(true);
entity.setCustomName(ChatColor.GOLD+"ENDER DRAGON");```
ender dragons are generally weird
Did they remove #getDataWatcher from the Entity class in 1.18 NMS?
hmm
When summonning Ender dragons in the overworld by command they don't move either
best guess i got is it was renamed
if it was you can always try to get the field instead with reflections, since i guess that's still there
Mob class
has the getNavigation method
if you need a PathNavigation
oh btw thanks to you i have discovered something fun while testing to make a player's screen black
you can show the demo menu to a player or freeze the client if you force the client to show the end credits menu
didn't discover anything about making the screen black tho :c
oh really
how?
oh that's smart
too bad you require the resource pack
¯_(ツ)_/¯
Ayo ^^ Anybody got a clue how to tinker together the CPU Usage in % based on
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
double usage = (threadMXBean.getCurrentThreadCpuTime() - threadMXBean.getCurrentThreadUserTime() / 1000000);
? I cant get this to work, my math is too stupid and I fear Ive run into a hole of being too stupid to program after a 12 hour shift xDD
like beforehand I tried it over
double calced = 0;
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
if (operatingSystemMXBean instanceof UnixOperatingSystemMXBean) {
UnixOperatingSystemMXBean bean = (UnixOperatingSystemMXBean) operatingSystemMXBean;
calced = bean.getProcessCpuLoad();
}
double cpuTime = calced * 100;
and it worked but sadly that isnt supported in Java 17 it seems 😦
do all entities on the server have a different uuid?
or is there a way to sneak thro that?
Yes, well they should
'they should' ._.
You can spawn two with the same UUID with some hacky stuff
it's better they do else behavior could be pretty messed up
Assume that there will only be one
i was wondering if i could compare players based on their uuid
i don't know if you've ever seen some videos about duplicate minecraft accounts
yes lmao
actually they don't have the same uuid but just the names break a lot of stuff
There are also rare accounts with special characters like . in them
so should i use uuid's to compare players? :)
yeah that's a mess
Yes
Player#equals does that
ok 🌝
actually i think thats the case for any entity
Player#equals also checks the id
the server gives each entity a id (int)
not persistent
hey do anyone know what is this ava.lang.NoSuchFieldException: modifier
also weird enough, ServerPlayer doesn't have an equals method
it means that the field you are looking for doesn't exist at runtime
i see you are a fellow user of the Ava™️ programming language
not many of us around these parts
It is Avast actually 😎
😱
😮
avantastirivus
is (a || b && c) the same as ((a || b) && c)?
or do they evaluate from the left to the right?
What does .getMount return?
left to right
which is why you can do if (object != null && object.someMethod())
is npe-safe
I want to make some "custom mob ai", is it easier to just use armor stands to let them move to a specific location?
Can we detect if an inventory is not a default inventory in spigot with packets or else ? (an inventory created on the client side)
this is returning true so if it was left to right it would return false
true || false && false
Short circuiting
As soon as it sees true, it stops
Idk how that would ever be expected to return false, it has true hardcoded into it
true || false -> true && false -> false (left to right)
i don't see the issue
false && false gets executed first
then true || false
basically this is true || (false && false)
which is true
mine too
anyone know how to remove the wrapper ("<Username>") around ur name
like it says ```
<PetarPotato> hello
but I want it to say ```
PetarPotato Hello
no <>
listen for the AsyncPlayerChatEvent and replace the default format
this stuff does big damage to my brain too lol
@lime jolt Do you know what an event is
1st thing do you have basic knowledge of java
not entirly sure
-> %1$s %2$s
2nd, a listener is something spigot came up with to modify certain things that happen in-game
Do you know how to code in java
here we go again 🌝
like chat messages sent, block placements and breaking
nnonono, but I think one of my plugins is overdidng the name display
I learnt off of CodedRed
the <> is vanilla minecraft
I am using spigot
coded red is not bad but i'd not follow any of the java language things he says
i've noticed some of them not being very accurate
yeah he doesn't explain it well
not good either in terms of storage solutions
api wise pretty solid
Yes spigot is just vanilla with extra steps
oH
Okay, so this is going to be an interesting one. I'm working on an ability where any players that are looking at the activator are forced to look at that player for 10 seconds, so if that player moves then the players that have seen the activator have their set locations constantly adjusted to be looking at that player (via a Runnable). How the heck would I calculate the yaw/pitch to set? 🤔
a lot more extra steps
oki
search up coded red on YouTube
you can replace it lol
so you want to change a player's yaw and pitch to make them watch a point?
may i introduce you to my great friend trigonometry
his tutorials are for 1.15 and 1.16 but they should work in 1.18
Yeah that's right
I suck at trigonometry
they don't know how to program spigot
do you know what sin and cos are
its all in 1.15 I am in 1.8.8
ha sike
Do you mean without a plugin
unless
that's the worst version to start
1.8.8 is above
Most stuff will apply
Just materials
some enums have different names
use modern api to learn please and then if you decide to go through the pain go to legacy
Used to get angles and can somehow be used to get the position of a perimeter of a circle
open a thread and i'll explain a bit
Is it possible to play the attack speed animation in the off hand? 🤔
Animation via mining fatigue, attack speed via attribute
@EventHandler
public void onGasp(PlayerInteractAtEntityEvent e) {
Player p = e.getPlayer();
Player clickedEntity = (Player) e.getRightClicked();
if(p.getInventory().getItemInMainHand().equals(Material.NETHER_STAR)) {
p.openInventory(clickedEntity.getPlayer().getInventory());
}
}``` this event is not triggering somehow, no errors on log
i think he means forcing the animation to play
did you register it
oh i know why
registering what
you are comparing a materual with an itemstack
Try just the PlayerInteractEntityEvent
dont cast without checking
That too
he's using equals with a material
dont compare itemstack with material
on an itemstack
and also blind casting is bad
you noob i already said that
if you need help with trigo open a thread and i'll help u a bit
That would affect the main hand too, just want to swing the off hand 🤔
i dont
don't want to spam the chat with a math lesson
do you want to force an hand animation?
you do
p.getInventory().getItemInMainHand().equals(Material.NETHER_STAR)
You literally do
Yes, I want to force it, and it should be on the off hand, not the main hand
do i need to use isSimilar
do null check and getType() after that
wait no you can check for null with == and its an enum
afaik, there is a packet sent, called playerarmswing or something similar and the outcome of the packet is handled by the client
i don't think you can specify what hand to swing
You'll need to use the interact entity packet https://wiki.vg/Protocol#Interact_Entity
it's based on what does the playerhave in its hand
Trigonometry
tnaks
Seems like you can.
Using the PacketPlayOutAnimation does play a swing animation, but not the cooldown animation (The slow raise of the weapon)
Thanks, now I don't need to use packets. Probably should look into the api first before running to nms next time.
But there's still no slow raise of the weapon, maybe it's not possible?
does it matter if i hide myself for myself?
this method is called when the player click in a living player?
are there also dead players?
It’s called when the player right clicks any entity
Is it possible to work with persistent data in blocks that don't have a tilestate
like dirt or something
Thanks!
is there any naming convention for static methods that return a new "empty" instance of a class
basically this object is meant to store some game data and if you call the static methods it will create an object without any data
up
Anyone know why this wouldn't work?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Im trying to detect when a player has 1 blaze powder, every ten ticks. Im running that in the main class on startup. When I set it to check for at least 1, it doesnt work. When I set it to 0, it constantly runs. No error.
why are you creating an itemstack if you never use it?
I was trying something you can ignore it
dont use that method, it's deprecated and i think it doesn't even work nowadays
Shouldn't it be a SYNC repeating task
use runtasktimer or similar
Also u should use that ^^^
hi
scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
// Do something
Bukkit.broadcastMessage("Dont Forget Join Our Discord Server! type /discord");
}
}, 0L, 300 * 1000);``` in this code how to add more broadcast message?
like it will give serial by serial after 5 miniutes?
?paste
Use that pls for code
ok
I dont see why that wouldnt work
learn java please, this question is pointless
its working
i want to add more message
like it will broadcast a message then after 5 miniutes then a different message
oh you want to cycle through messages
you could store an integer in the global field of the Runnable you create
and add 1 to it each time the thing runs
Development at its finest
https://cdn.discordapp.com/attachments/711980654983905401/952568536100900874/unknown.png
then get a message based on the number
nice but add a space between Total and Worth
and so on
no
never do new RUnnable
Its a Minecraft plugin made with discord JDA with placeholderapi support
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
oh
it could be useful to do it sometimes
why not?
^
with runnable not much
not really for schedulers
yeah
scheduler.runTask(plugin, task -> { task.cancel(); })
what about the global fields
why fields?
they could be useful
cuz you may need them?
Yeah like if you needed to access a timer int to count it down every sec or smth
yeah
how many chances are there that 2 random UUIDs are the same?
i just make an inner class which extends bukkitrunnable
private LivingEntity getTarget(Player player) {
Vector direction = player.getLocation().getDirection();
Location eyeLocation = player.getEyeLocation();
for (int i = 1; i < 3; i++) {
Collection<Entity> entities = eyeLocation.getWorld().getNearbyEntities(eyeLocation.clone().add(direction.multiply(i)), .3, .1, .3);
entities.removeIf(entity -> !(entity instanceof LivingEntity));
entities.removeIf(entity -> entity == player);
Entity entity = entities.stream().findFirst().orElse(null);
if (entity != null)
return (LivingEntity) entity;
}
return null;
}
Is there a better way to check for the entity a player is looking at?
Hey guys, what would the best way to store a method and then run it later be?
runnable?
hm?
oh sorry I didnt phrase my question good
what would the best way to store a method in a var be?
runnable
runnable
there is not a set time between when I store it and when it runs
dude
you don't need to create a task
save the method as a runnable
and call .run when you want it to be run
oh yeah smart thinking
Runnable runnable = () -> Bukkit.broadcastMessage("hi");
runnable.run();
invoke run() when you want it to execute
or just make a method
raytrace
RayTraceResult result = player.raytraceEntities(...)
it will probably result the player to use the predicate to your advantage
Performs a ray trace that checks for entity collisions.
Yeah it grabs the direction, takes into account the bounding boxes etc
any hologram generator api already made
i know IkeVoodoo is making me one but it's taking forever ;((
Just use whatever plugin works
I already tried using this, but it only accounts for entities which collide apparently
What type of entities are you looking for?
Any LivingEntity which can be damaged
i want an api and i don't know one that exists
If it can be damaged, it has a boundingbox
Yeah, but raytraceEntities still only accounts for entities which collide right now apparently.
Or I did something wrong with the range
RayTraceResult result = player.getWorld().rayTraceEntities(player.getEyeLocation(), player.getEyeLocation().getDirection(), 5.0, (entity) -> !(entity.getUniqueId().equals(player.getUniqueId()));
You probably messed up the range
result can be null, so can hitEntity sometimes
I even tried 320 as range
But 32 is also not doing anything, except if I'm currently colliding with the entity
Or 3.2
Okay
Weird 🤔
Now it's working. Probably messed up something when I tested it.
But if it returned myself, I'd have taken damage
Thanks though 👍
is it possible to give a bossbar a hex colour in 1.17?
The bar itself not. But the text above it should work.
hmm i was going for the bar itself
Still defined by an enum 🤷
ye unfortunately
anyone know a good tutorial for making something like this?
i guess get string from the config and replace things
Configs should be your least concern. Write everything in memory and worry about serialization later.
im not understanding your question completely
i wanna make it so i can easily input stuff for the bot in a config file though
or a better solution than a config file if u have any
Then the best way is to have a proper object oriented approach
wat dat mean
What is your overall goal?
i wanna make a sort-of custom language for it
like a place where you can input an input and an output for the bot, and whenever the input occurs, the output is sent
and with custom expressions
Then before you do anything else you have to define your language.
idk how to do that
Its also quite complicated if you havent fully mastered an existing language yourself.
i'm learning my own way cause i have a learning disability
this is my way of learning, asking, watching tutorials and trying myself
You would have to define a background compiler pipeline.
Lexing -> Parsing -> Type Checking and then depending on your specs one of [Code generation, Interpretation]
In your case its def Interpretation
i don't understand any of that and i think you know that
you are acting like smile knows exactly what you know and don't know
They are explaining it as someone with full java experience will understand, which is good
he's seen me quite here quite a few times, i think he knows that i have no understanding of those words
I just think that even i would have to put weeks into this to come up with a proper implementation. And ive dabbled with
implementing my own jvm language already. You are attempting something that can be potentially very difficult.
i don't want to make a whole language, i just want to know how to split the message
look at the example i made in the original message
String#split
but i guess if you want an actual language you'd need a proper tokenizer with parser
and an interpreter or AST walker
actual langs are a nightmare lmao
i need to know what the input means, like the one from my example. how would i do that?
Why i have a problem with placeholderapi dependency??
no actually
you forgot the version
what version i need?
if you use some language for initial compiling (such as js) and ten bootstrap it, it can be very nice
to put
thx
yeah thats fair, from my experience in Java it ain't nice lol
you can forget any language like java for making a language lmao, its so messy
in js you can make a really nice ast
like
remove the v more than likely
{type: 'NodeType', something}
But parts of the message mean something.
And you would have to define actual codeflow for those elements:
@lean gull
i tried
what side is this?
yes
lmao
Looking at their example I guess it would be v2.11.1, but thats interesting
you are refreshing maven correct?
the errors are refreshing
?
invalidate caches and restart
💀
ok, how do i do that
i don't know where to start
i am pretty sure i could make wiser use of generics here
i am quite sure you can't pull it off atm, try something easier now and get back to it later
can't I
Lexing and parsing.
You can also try and just code away using a prefix tree but either way it will be hard.
For once you could put your method annotation not in the middle of the declaration but above it, where it belongs.
lul
do you have a good tutorial on lexing and parsing? i also need to know what they are*
Also you do nothing with those generics. So you can just use wildcard anyways XD
oh tell me i have not been doing this wrong since forever
Ah nvm
The consumer is typed
yeah, i kinda need to use them
because i need to put the bi consumer as the way i want data to be put in the document
let's say the value is an enum, i'd call entry.getValue().name()
example
bold of u to think im awake at midnight
But this still looks a bit weird. I feel like there are better approaches
i have 3 maps with enum keys and int values i need to save so i do this
yeah i know
i have never used generics much to be honest, im messing around
it would be cleaner to just put the for in the place where i need it
Btw. You can also just throw an Object into Gson and then translate it to a document.
Saves you all the serialization work.
anyone?
wait so if i slap an hashmap into it what happens?
?bing
Bing your question before asking it:
https://www.bing.com/
as the value
It will be perfectly serialized
and if i call .get and cast it to a map with the correct generics it will just go back to be a normal map
This goes through every thing you might need to know about language development, including lexing (scanning) and parsing.
man's tryna code skript 2.0
You get the doc as json and then just let Gson deserialize it again
wow i wish i knew earlier
this saves a lot of time
so let's say i call .get("myMap") and the object i inserted with .put("myMap", ...) was a Map<Enum<?>, Integer>
Here is an example where i just used Jackson to serialize whatever object i wanted:
public <T extends IndexableObject<?>> void persist(final String collectionName, final T object) {
final String json = JacksonProvider.serialize(object);
final Document document = Document.parse(json);
final MongoCollection<Document> collection = this.database.getCollection(collectionName);
collection.createIndex(Indexes.hashed(object.getIndexedField()));
final ReplaceOptions options = new ReplaceOptions().upsert(true);
final Bson filter = Filters.eq(object.getIndexedField(), object.getFieldValue());
collection.replaceOne(filter, document, options);
}
The IndexableObject is not needed but i wanted to index keys for performance.
And T can be literally anything you can serialize with Jackson or Gson. As long as you register type adapters for things like Location, ItemStack and whatever
why is everything breaking when i put this variable in here
oh
wrapper class for long :c
also yeah why the fuck are you using the primitive wrappers lol
Long?
adapters? like wrapper classes for them?
dont know, im just translating someones code from kotlin to java
and i make the wrapper class implement the interface
Using wrappers everywhere is slow
(Fun fact: Kotlin also does not use the wrappers, it has Int, Long, etc. which map directly to Java primitives when used on the JVM)
i'd rather learn kotlin lol
oh probably because of this
Long
leave the wrapper in the map
Yeah type parameters are like the only situation where you have to use the wrappers
Stuff like this
java auto packages and unpackages primitives to their wrapper class when needed
(i think it's called packaging)
It's called autoboxing
Autoboxing was added back in Java 5 iirc and it literally automates the conversion between int and Integer, and etc/vice-versa.
oh i had something similar but it was just from the object to a bson document
For instance, passing an int to a method that takes Object is valid because it does a Integer.valueOf(i) beforehand.
(Meanwhile, Integer -> int AKA unboxing, is integer.intValue())
This is just needed for objects that Gson cant serialize while traversing. Everything else doesnt need it
as Gson just recursively goes through the object.
autoboxing used to confuse me when i started, didn't know why stuff changed by itself so i just ignored it
(Oh yeah this is all also compiler logic)
yes
Are you sure this is done on compiler level and not at runtime?
Yes, the compiler has specific AST elements for handling autoboxing.
There are internal "let expressions."
Which ones? never seen them
can you send me the maven import for the json lib you use
Just use Gson. Its in spigot already. I find custom serialization with Jackson much harder.
Isn't Jackson also just slower?
aight
I've seen charts that say so.
Thought it was the opposite
The problems with having an ultra-extensible system :)
One moment ill give you some code boostrap to start with
would anyone know what the java equivalence of .iterator() would be?
Well, Java has an iterator method.
For maps though? I think there's something like mapIterator lemme check.
aight thanks
Nah you'll have to do uhh
.entrySet().iterator()
i'd just run an enhanced for, i think it's cleaner
Well sometimes you need to do .remove() calls so
I dunno what Wally's use-case is
readibility wise, at least
hm yea
also what do I see? main class named Main and static getter?
All hail the ConcurrentModificationException
never
:)
i remember i used to clone the object i was iterating to work around it
not sure how efficient it was lol
With ConcurrentHashMap you will never see it
i've been developing for a while, yet i still make the same mistake as i used to
underestimating the time something will take to code
Btw just a note, val is final, var isn't.
whys this bad?
And uhh
In Kotlin, the default access modifier (AKA which one applies when none are specified) is public, not package-private
Kotlin's version of package-private is internal
naming your main plugin class Main is considered bad because 1) a plugin main class is not code that can run by itself, so naming it main is not explicative and 2) imagine if every plugin named their main class Main and you needed to call some methods from a plugin main class, it would be painful to find the right Main class
and static abusing... do i really have to talk about static abuse
Not to mention that
Isnt it for the whole module then?
you can probably dependency inject there
anyoneee?
Yeah, but it's the closest equivalent
someone sent you a link before
to a book, that'll make it 100% harder
I am getting
invalid target release -> 1.18.2
Even though this morning I successfully installed multiple times
Name collisions require specifying the fully-qualified class name when used.
There's an online version :p
i need a video tutorial with words that are for beginners
there is not a video tutorial for everything
what you want to do is not for beginners
Yeah
then what do i need to learn for it
Lexing/parsing is difficult
from what i understood, you want to code an interpreter
Search online. This is something quite specific and you will most likely not find step-by-step tutorials but
rather trade readings that go into the technical details but not implementations.
I mean, in a lang like Java it's easier
You can find step-by-step tutorials. I sent him one of the best.
java has some useful tools yes
Anyone can point me to a solution? :)
i'm currently watching this and i only understand like 25% of what he's saying
https://www.youtube.com/watch?v=4m7ubrdbWQU&list=PLGNbPb3dQJ_5FTPfFIg28UxuMpu7k0eT4&ab_channel=DmitrySoshnikov
such as matchers
Thats because you still need more experience with programming itself.
Either way, CraftingInterpreters is one of the best guides for... well, crafting interpreters.
i'll check it a bit later, thanks
what do i need to learn for it
what is your pom/build.gradle file?
you need to accept your limits and go back to code something easier
There is quite a bit of meta knowledge like tree data structures that is mandatory for this and there is
transitive knowledge like reflections that will def help you understand but is not needed.
i can't make a language parser nor i want to learn to right now so i can't guide you
i've seen you very often come here and asking things out of your reach and then asking what should you learn
you need to ask it to yourself not us ;-;
I would suggest you to lay this plugin down for now and write some more approachable plugins.
Can i put questions for a scoreboard plugin thingy here too
Why not?
is there any ways to declare multiple variables on one line like in python or kotlin?
If you are programming it or using its api then sure
int x = 10, y = 0;
Well im not programming one, but ill probably need one and i dont find anything
private final int x, y, z;
i have no idea how to do that
then it is #help-server you need to ask
alright
Remove .2
how to reduce jar file size? my plugin size becames 10 mb with only 14 jar file
Download dependencies on runtime using the plugin.yml
inb4 "I use 1.8.8"
Hello! Found that 1.13 have teams (https://minecraft.fandom.com/wiki/Commands/team). What is that and how to get player teams? Or even check if two players have same teams?
Hi! how can i make a bossbar?
declaration: package: org.bukkit, class: Bukkit
Hello! Does it matter how many event listeners I register? Is it better to have just a couple large ones or I can make a bunch of small listeners?
then it will reduce?
Yea don't shade every dependency
I would exclude every dependency you can depend on at run time eg vault
An example of something you would have to shade would be guice
ty
Doesn’t matter at all
Is there a way to make gradients in strings other than Minimessage or lots of ChatColor.of()?
ok, thank you
just maybe it was a thing, in other api's it happens
Normal ChatColor::translateAlternateColorCodes can be used
But it gets rather verbose
Make a method to do chatcolor.of unless you hate yourself
Thx
how do i do a chance of something? like 25% chance to run some code
?(
you can make java get random int
That’s in regards to scoreboard
Look up how to do random chance in regular Java on stack overflow the method will be the same with spigot
Through code Team::hasEntry can be used to determine whether a player (by name) is contained within a team
if(random.nextBoolean() && random.nextBoolean())
iirc that should be 25%
Use ints :!
Yup
So I should get Main scoreboard (For example), iterate all teams and check if that team contains both players, right?
and the chance of getting both true is 25% iirc
I mean a nextInt(4) == 0 works as well
Because /team command not seems really connected to scoreboard
What if you want a 23% chance in the future or something along those lines
then they simply just change the implementation
Ah conclure am I allowed to post a premium plugin that depends on a free plugin I feel like I should be able to but the rules are weird
I'd assume the line would be depending on another payed dependency
Yeah
Ahhh ok thx
I got listener and scheduler for player movement event but problem is when i type something in run() it shows error ( block.setType(type); )
https://pastebin.com/JX1yf2Kk (scheduler)
https://pastebin.com/4h7NcMSP (listener)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
wat
String splitMessage = message.split("\"");
String[] splitMessage = message.split("\"");
isn't that an array
yes, when you split a String you get multiple Strings depending on how many matches of the splitter you have
ooo riet
You probably are looking for message.substring(message.indexOf('\"') + 1)
or message.substring(0, message.indexOf('\"')), depending on what you want to do
i wanna make it so you can make the "bot" say something, with an input like this:
derpbot say "hello"
though i just realised, that means the player can't use quotation marks in the message
how do i fix that
Escaping, html entities and whatnot
huh
i found a server where you can use the command /feed and you get heal effect and saturation but theres no minecraft "effect" like blc and lunar dont show potion effects when you use that command
how does that work?
try reformulating your question, I am not sure that I understood it correctly
i think they mean that they're currently using a potion effect to feed the player
focus, you can just set the player's hunger
with player.setFoodLevel?
yes
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/HumanEntity.html#setSaturation(float) read the documentation
declaration: package: org.bukkit.entity, interface: HumanEntity
ty
The player is only healing fast if it is saturated, see HumanEntity#getSaturatedRegenRate
how to put 1.8 attack speed pvp
i mean
AttributeInstance instance = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
if (instance != null) {
instance.setBaseValue(WHAT DO I PUT HERE);```
Anything from quite a bit to a lot should do it
Integer.MAX_VALUE?
this doesn't make a new line?
prefix.replaceAll("\\n", "\n");
string.unescape exists iirc
