#help-development
1 messages · Page 584 of 1
public class TestZombie extends Zombie {
public TestZombie(Location loc) {
super(EntityType.ZOMBIE, ((CraftWorld) loc.getWorld()).getHandle());
this.teleportTo(loc.getX(), loc.getY(), loc.getZ());
this.setCanPickUpLoot(false);
this.setAggressive(true);
this.setCustomNameVisible(true);
}
}
How do i make this thing spawn with armor on?
is s your own function?
im using mojang remappings ill try find it ig
you are using spigot tho..
well yea but the s function doesnt exist
what ver u on?
1.20.1
?
its the class
im guessing zombie
TestZombie ig
this = TestZombie
cuz it's an old feature and doesn't work here
you need an expression evaluator?
so what I need to do?
yeah
write own evaluator 😉
I did that, but it gave me error
ask @tardy delta
try this.getEquipment
you need to get rid of JS engine
doesnt exist
bro get a snipping tool
can i get some help rq, i made a plugin to add a custom recipe "bonemeal on a stick" and i want to be able to apply bonemeal to a sapling that i right click with, i searched alot but i couldnt find any plugins that are new or any help threads that are new to learn from their source and answers. i was able to make crops like potatoes wheat etc grow but that one didnt require the use of bonemeal, the method i used on crops didnt work on trees but i hope the method im thinking of for trees also works on crops which is just simulation of the bonemeal event but i still dont know how. if any of u know please point me in the right direction and/or link me anything that helps wether its docs or open source code etc...
Does the array need to be sorted to do a bubble sort?
declaration: package: org.bukkit.block, interface: Block
what are you talking about
ty, ill check it out and see
basically you can listen to PlayerInteractEvent.
Check if the item is your custom item. If no, return.
If yes, check if the action is RIGHT_CLICK_BLOCK. If not, return.
Then, get the clicked block, call applyBoneMeal on it, and pass in the clicked blockface
Using the Big O notations you know? Trying to sort an array using a bubble sort implementation
if the array would already be sorted, then why would you need bubble sort?
yeah
Am I missing some context here?
why do you even need bubble sort
we all do ig
But yeah, bubble sort is the wrong sort in every case except homework
#help-development message this is all they asked
what the heck is this question
does an array need to be sorted to sort it again
yo @tender shard u are smart, how do i make custom NMS entities spawn with armor
?mappings
shit
ah yeah, I guess noone is much wiser
?remap
?nms
use world.spawn which accepts a consumer
But NMS?
is this the right function?
why nms at all?
just add the equipment in the constructor
see thats what i was looking for
thanks
np
unless you are doing your own AI why are you creating yoru own Zombie?
you didnt find that method in the mappings because you only looked at the zombie class, but setItemSlot is declared in the Mob class, since it applies to all mobs
well i wanna make it like this now so i can add ai stuff later
if i wanna add bosses or sm shit
yes
what the hell is a ichatbasecomponent
and how do i create one out of a string
here's a method to sort an already sorted array:
public static void sortAlreadySortedArray(Object alreadySortedArray) {
if(!alreadySortedArray.getClass().isArray()) {
throw new IllegalArgumentException("Not an array");
} else {
// Do nothing - array is already sorted.
}
}
thanks!
just what I needed right now
is the default world name always gonna be "world?"
If you don't change it
alr
the spigot-mapped name for mojang's net.minecraft.network.chat.Component
is running a server on my own pc risky?
you can change it in properties
why
no
i mean for testing no
no
for hosting a network bruh
the default world's name is Bukkit.getWorlds().get(0).getName()
no
that's a weird name for a world. Mine is named "world" :/
Why
and the default world itself is
Bukkit.getWorlds().get(0)
im sure Component.literal(""); works
cuz why are you sorting a sorted array
bruh having [1, 2, 3] and sorting it
Maybe I wanna sort it after to 3,2,1
what kind of sort do you want to do?
Bubble
if you're overly cautious you can definitely, always, get the correct default world name with NMS
((CraftServer) Bukkit.getServer()).getServer().getProperties().levelName;
array reverse
Collections.sort(Comparator)
You could improve a bit more the code:
ㅤ
ㅤ
Thats not bubble sir
then why don't you apply your bubble sort to an unsorted array
I guess I could
a bubble sort is pointless
then just do it
why are you sorting an array 2 times
if you can sort it once
you can just quick sort + reverse
or just quick sort
how do i spawn those custom ones again
How would I unsort the array since it's already been sorted due to a binary search?
shuffle
public static void spawnMyCustomZombie(Location location) {
ServerLevel nmsWorld = ((CraftWorld)location.getWorld()).getHandle();
nmsWorld.addFreshEntity(new MyZombie(nmsWorld));
}
Class?
Collections.shuffle
Any other way?
hundreds
Build your own shuffle method using random
public static <T> void shuffleArray(T[] array) {
List<T> collection = Arrays.asList(array);
Collections.shuffle(collection);
for(int i = 0; i < collection.size(); i++) {
array[i] = collection.get(i);
}
}
uhh
<T> void that is a new one for me 😯
what's CustomEntity line 25
how else would you make it accept a generic array
i havn't seen it before
public abstract class CustomEntity extends Entity {
final Location location;
public CustomEntity(Location loc, EntityType entityType, String displayName) {
super(entityType, ((CraftWorld) loc.getWorld()).getHandle());
location = loc;
this.teleportTo(loc.getX(), loc.getY(), loc.getZ());
this.setCustomNameVisible(true);
this.setCustomName(Component.literal(ColorUtils.translateStringWithColor(displayName)));
}
public final void spawn() {
ServerLevel nmsWorld = ((CraftWorld)location.getWorld()).getHandle();
nmsWorld.addFreshEntity(this);
}
}
TestZombie extends that
never seen it before idk
Are you registering the entity?
what's CustomEntity line 25
nmsWorld.addFreshEntity(This);
how does one do that
?paste
The plugin is having a stroke, a little help?
https://paste.md-5.net/torinudicu.css
As it does not "exist"
how do you create your custom entity? Why does your CustomEntity take an EntityType in the constructor? Which did you use?
also you must extend an existing Entity class
i'm mindblowed by this
https://docs.oracle.com/javase/tutorial/extra/generics/methods.html
This Java tutorial describes generics, full screen mode API, and Java certification related resources
this is the testzombie class i created, the entity type is so i can make child classes with different entity types
public class TestZombie extends CustomEntity {
public TestZombie(Location loc) {
super(loc, EntityType.ZOMBIE, "%%COLOR_GREEN%%Zombie");
setItemSlot(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(new QuacHelmet().getItem()));
}
@Override
protected void defineSynchedData() {
}
@Override
protected void readAdditionalSaveData(CompoundTag compoundTag) {
}
@Override
protected void addAdditionalSaveData(CompoundTag compoundTag) {
}
}
The plugin is having a stroke, a little help?
ERROR
https://paste.md-5.net/torinudicu.css
CODE
public class PointsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
String replaced = PlaceholderAPI.setPlaceholders(p, "%playerpoints_points%");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYou have &f" + replaced + " &apoints!"));
} else {
sender.sendMessage(ChatColor.RED + "You must be in-game to use this command.");
}
return false;
}
}
as said, you must extend an existing entity class, e.g. Zombie
Shouldn't that copy the file with contents into the plugin folder? All I get is an empty file. When I do change the path however I get an exception that it can't find the file so the path seems to be correct. And the file definitly has content. I even checked inside the jar
plugin.saveResource(filename, false);
oh so i cant do it how i wanted to?
Your placeholder is not liking you
try and see
it cannot handle totally new entity types, you always have to extend an existing one
Because you're calling new WhateverMyPluginIs
wdym?
it'd be much easier if the nms entity class just had an CraftEntity createCraftWrapper()
but people not doing that because they'd need to patch 50 different classes
it should
but basically i cant use my custom entity class
hmm
you could if that would also just extend an existing entity type
can i make it dynamic?
like make it extend EntityType<T> or whatever
the plugin isnt even starting i dont get it?
CustomConfig:
https://paste.md-5.net/asisuwogor.java
Language file implementation:
https://paste.md-5.net/opolevujij.java
Call in a function called in onEnable:
languageConfig = new LanguageConfig(this);
Am I missing something? Either it does not work or I'm pretty blind
well I load it before I actually create it. That's one thing.
Maybe that's the issue - even though I wouldn't expect it to be the issue. I'll test it anyway
anyone?
hi , nop question .. idk if its my brain stoped working or is it skill issuse .. anyway ..
if i add break statment ,it will add the item to the gui only first item , and it will give me the item only 1 time , and that is the correct thing ,
but if i remove the break statment , it will add all items , and it will duplicate the item that iam receiving xd?
oh nvm it actually is the reason. Because my load method creates an empty file. Woops. I can solve it then :)
got it to work
base class:
public abstract class CustomEntity extends PathfinderMob {
final Location location;
public CustomEntity(EntityType<? extends PathfinderMob> entityType, Location loc, String displayName) {
super(entityType, ((CraftWorld) loc.getWorld()).getHandle());
location = loc;
this.teleportTo(loc.getX(), loc.getY(), loc.getZ());
this.setCustomNameVisible(true);
this.setCustomName(Component.literal(ColorUtils.translateStringWithColor(displayName)));
}
public final void spawn() {
ServerLevel nmsWorld = ((CraftWorld)location.getWorld()).getHandle();
nmsWorld.addFreshEntity(this);
}
}
return
ahhh ?
here ?
i mean
under the additem method for the player?
Is this the proper way to do a bubble sort java public void bubbleSort(int[] array) { for (int i = 0; i < array.length - 1; i++) { for (int j = 0; j < array.length - i - 1; j++) { if (array[j] > array[j + 1]) { int temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; } } } }
hat didn't work :p
why are you so obsessed with bubble sort?
I would just use Arrays.sort and call it a day
because bubble sort is slow af :/
There's a reason that java uses Tim-sort, an adaptation of merge-sort
quickSort can be faster at times. Or super slow, depending on the list
i just started making it but it looks like its only in the never versions while my plugin is for 1.19.4. what can i do?
also when does one actually have to sort an array of a huge number of integers, besides for homework lol
any ideas please :p?
hey, trying to register a command in a bungee plugin, but it's not properly registering?
// in my onEnable() method
getProxy().getPluginManager().registerCommand(this, new ReloadCommand());
// command class:
public class ReloadCommand extends Command {
public ReloadCommand() {
super("reloadpacks");
}
@Override
public void execute(CommandSender sender, String[] args) {
sender.sendMessage(new TextComponent("§aReloading eee..."));
if (reload()) {
sender.sendMessage(new TextComponent("§aeeee has been reloaded!"));
} else {
sender.sendMessage(new TextComponent("§cThere was an error reloading eeee!"));
}
}
}
what am i missing? :/
it was added in 1.16.2
hey guys How can I make my plugin available for multiple minecraft versions?
there's no issue in that code. Probably in one of the methods you are calling
cuz I notice some plugins just work weather im using 19.1 or 19.2 or wtvr
how can i do that?
It depends
If you want to make your plugin compatible from 1.8 to 1.20, avoid using +1.9 API
You should be also be carefull because some API methods have been deprecated and removed in modern spigot
what i just wanna make sure it works for that major update
So you should check whatever the method still exists in the latest spigot version
i used 1.20
I just want it to work in 1.21 too
Then your plugin should work in any >= 1.20 version, but might not work on 1.8 version
It completely depends on the API you are using
oohhh
i only call the additem only once and in that place only ..
Like, if you are just using the plugin to spawn an ArmorStand, it will work on 1.8
okay that's cool
Even though you are using 1.20 API
But if you try to spawn a Warden, it won't work on 1.8
If you want to strip your plugin to 1.20, then in api-version, (plugin.yml) set it to 1.20
Well since you set the event twice, you also have the listener twice. Doublecheck your list
sir. I dont care about 1.8
I just wanted to make sure does the API work on sub updates
of the same major update
like 1.20 and 1.21
Well yes, they should. md_5 won't remove API methods without deprecating them first
So you should be good if there's any major API change
No thanks, gimme $50
oky
Generally deprecated methods don’t get removed at all
Unless they just become impossible to maintain
is it maybe because of this 2 for loops?
no you still only return one itemstack. Just print your list and check if the content is fine
What damageModifier is used when you hit someone/something without your attack cooldown being fully reset
do i just paste my code here if i need help
the content is fine ..
?paste
or like is there a way to check if u are on that cooldown? even using nms
Player#getAttackCooldown
then add a println inside your loop and print the item that gets added every time. Check if it's called twice for each item.
Also put a print above the loop to see if your function is called twice.
does that return the amount of time of the cooldown?
using EquipmentSlots
where u add the attribute u can set an equipmentslot
Where u used break and why?
hate to do this; but any idea on why this command isn't registering?
Check the javadocs
got it already
where would I get help with mojang's Brigadier api?
just pass in an EquipmentSlot into the AttributeModifier's constructor https://hub.spigotmc.org/javadocs/spigot/org/bukkit/attribute/AttributeModifier.html#<init>(java.util.UUID,java.lang.String,double,org.bukkit.attribute.AttributeModifier.Operation,org.bukkit.inventory.EquipmentSlot)
declaration: package: org.bukkit.attribute, class: AttributeModifier
it works since like forever
Did you somehow accidentally install it twice
Can’t really tell ya much without more info
@SuppressWarnings("deprecation")
@EventHandler
public void onClick(InventoryClickEvent e) {
if (e.getClickedInventory() == null) {
return;
}
if (e.getClickedInventory().getHolder() instanceof RPChat) {
e.setCancelled(true);
Player player = (Player) e.getWhoClicked();
UUID playerUUID = player.getUniqueId();
if (e.getCurrentItem() == null) {
return;
}
if (e.getClickedInventory() == colors) {
if (e.getSlot() == 0) {
RPChat.getInstance().primaryRoleplayColors.put(playerUUID, ChatColor.BLACK);
player.closeInventory();
player.openInventory(colors2);
}
can someone help me figure out why e.setCancelled isn't working? I'm able to take out the items and I have no clue why
how can I add a comment to a config file?
like essentialsX does alot
wdym
like a description to my config setting right above it
you just insert it into the default config
put # in front of the line?
there's a function for this?
don't you include a default config.yml?
yea but that wouldnt generate the same comment to anyone else who uses my plugin
yea.. wait..
ohhh, in your ide open the yml file and put the comment in there
// CONFIG FILE
config.addDefault("PlotMargin", 1000);
config.addDefault("PlotSize", 50);
config.addDefault("PlotAmount", 5);
//
config.addDefault("PlotAmount", 5);
//
config.options().copyDefaults(true);
saveConfig();
anyone has an idea of how to create custom entities that follows a path formed by a type of blocks, like following a path created by concrete?
in resources
you just add the comments to your default config?
you can also do it like this but what's the point, you don't generate your config from code, you just save the included one
getConfig().setComments("whatever", Arrays.asList("This is a comment", "This is another comment"));
is RPChat impl InventoryHolder?
yes it is, hold i'll put the whole class in a paste
I assume if I publish my plugin. those comments wont appear to my users
why with this, it may?..
why would they magically disappear?
they will, if you put them in the resources yml file liek alex shows
thats also how I add config options to my config xD
everything in resources gets compiled with the plugin
if you call JavaPlugin#saveDefaultConfig(), it saves the config.yml exactly as it's included in your .jar
do I include them in the build?
including all typos and comments and whatever and what not
of course, why else would you write that file
what ide are you using
intellij
with the mcdev plugin?
I just never made a config file that's all
then its already included
yea
all resource files will be included
your config must be in /src/main/resources
is this the syntax I'll use?
yes
ahhhh
so now in my onEnable() I need to saveDefault("AllTheMods9", true);
btw alex do you know any good ways to update these files, like if I make an update to my plugin that adds options, is there a good way to not destroy all comments when generating the new files?
Read the bundled and existing file
I'M using my config updater library but it's not documented at all
Copy any missing keys from the bundled file to the saved one
I see
you have a lib for everything it seems
how long have you been makig plugins for?
2018
PDC != Async Safe? or is it?
ill see if I can use it or take inspiration from it
np but the config updater is not very good, it e.g. can't do nested keys
because I never use nested keys lol
I think u should check inv in InventoryDragEvent instead. And InventoryClickEvent will do the rest.
and the slot for that is EquipmentSlot.FEET
so check inventory with the drag event but still use e.getslot?
private fun requestPlayerCount(player: Player, server: String) {
val out: ByteArrayDataOutput = ByteStreams.newDataOutput()
out.writeUTF("PlayerCount")
out.writeUTF(server)
player.sendPluginMessage(HubPlugin.instance, "hub:plugin", out.toByteArray())
Bukkit.broadcastMessage("Black nopox")
}
override fun onPluginMessageReceived(channel: String, player: Player, message: ByteArray) {
Bukkit.broadcastMessage("is it even getting sent? $channel")
if (channel != "hub:plugin") {
return
}
val `in`: ByteArrayDataInput = ByteStreams.newDataInput(message)
val subchannel: String = `in`.readUTF()
if (subchannel == "PlayerCount") {
val server: String = `in`.readUTF()
val playerCount: Int = `in`.readInt()
if (servers.containsKey(server)) {
servers.remove(server)
}
servers[server] = playerCount
}
}```
does anyone know why it just doesnt get sent? It doesn't broadcast `is it even getting sent? $channel`
im calling requestPlayerCOunt btw
is it possible for BungeeCord plugin to send player from 1 bungeecord to another?
if I know the IP
yes
Maybe yes, but not with IP
how so?
no, what'd be the purpose anyway?
public HashMap<String, Integer> serverCount = new HashMap<>();
public void getCount(Player player, String server) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerCount");
out.writeUTF(server);
player.sendPluginMessage(this, "BungeeCord", out.toByteArray());
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("PlayerCount")) {
String server = in.readUTF();
serverCount.put(server, in.readInt());
}
}
public int getServerCount(Player p, String server) {
getCount(p, server);
if (serverCount.get(server) != null) {
return serverCount.get(server);
}
return 0;
}
This is how you do it.
homie that's what i did
you just changed the channel name to bungeecord
but that wouldn't work since you need a :
we have a trial developer on our network
and he has console and stuff
but we don't want him to be able to modify stuff on bungee and other servers
so we are making another bungee, but still want him to be in Staff List and stuff
? xD
It works to me
What do you mean it wouldn't work?
then give him dummy rank
above 1.13, you need a : in a channel name
he still has console
he can give himself * in seconds
Funky since I use 1.18.2 🤣
Then dont give him console?
can't do dev stuff without it :D
anyways, that's exactly what my code does though..
what are you talking lol
give him console on his own proxy, and give him dummy rank on the main
for channel name in sending plugin msg
First off: as far as I can see, it never calls the void "getCount", which would eventually get the playercount. For other good reasons, I use a hashmap to store the playeramount for each server, so it won't even break.
Something is wrong with your code, but I can't really read it as of as I see it is written in Kotlin.
if you look below that message, it does.
I just didnt paste the code that did it
Also
using "BungeeCord" as channel name works fine
"Channel must contain : seperator"
Instead of broadcasting in the message in the message void, broadcast it when you request the playercount
🤣
I do
What kind of shit are you using? 🤣
it broadcasts it
if(channel.equals("BungeeCord")) ...
ah ok
I made a broadcast method in onPluginMessageReceived and it didnt broadcast
but it broadcasts when I do requestPlayerCount
from my experience, bungeecord messaging is extremely shitty anyway, I'd rather just use redis pubsub
please tell me you don't print sth similar to console lol
oh jesus
phew
💀
my config already wastes over 100 lines before it even starts lol https://paste.md-5.net/hagilevevo.shell
Does anyone know how to install and use the world edit api?
worldedit maven
You just add it as a dependency and follow their guide
I can't find anything. All I see are command wikis
whats the diff between .stream().toList() vs .stream.collect(Collectors.toList())
How do I set a sword's attack damage in 1.8.8 spigot?
toList returns an unmodifiable list and it's java 16+ only
the collector returns a modifiable list and is java 8+
toList() seems very weird to me lol
I would always rather use the collector, toList() literally creates an array, turns it into a list, turns that into an arraylist, and turns that into an unmodifiable list
the collector creates a new arraylist and then calls add for each element
asList should definitely be faster
but it still looks very weird
.
https://www.spigotmc.org/wiki/setting-up-the-worldedit-api/
https://worldedit.enginehub.org/en/latest/api/examples/local-sessions/#getting-a-localsession
those should get you started
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
dang I always use .toList() because it's shorter. That looks horrible
Might swap to the collector then. Also has the benefit of getting a mutable list
oh oof
the collector adds each element individually, so the list has to be resized sometimes
the thousand arraylist calls in toList probably do an array copy which should be faster
but tbh it probably doesn't matter at all in 99.999% of cases, I'd just use the collector since it works on all java versions
Could it not create the list with an initial size
well yeah it probably won't matter most of the time. Might still run some tests when bored. My current project won't let me get bored for this year though
Do note it's not guaranteed to be modifiable
So don't rely on that
oh right I just read that yesterday and then used ArrayList::new as a custom collector
yeah
I'll benchmark toList and collectors.toList() now, then let you know, it might take half an hour though lol
Add me to the mailing list too
I suppose you test it with different sizes aswell then?
Might be asleep in half an hour but I'll take a look tomorrow as I use streams quite often
Fixed
not sure if the for the UUID field, just create a random UUID
totemMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier(UUID.randomUUID(),"attack", -1*0.1, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.OFF_HAND));
wdym, error on UUID?
Maybe i misswrote smth try using this
totemMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier(UUID.randomUUID(),"attack", -1*0.1, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.OFF_HAND));
Why no intellij Idea
look at me being a professional 😎
Screenshot?
Woah I am making plots too
import it
what are you making?
A minigame creator
oh shit. I was planing on making my own as well
My minigame uses plots
maybe I can use urs uwu
Well 'technically I am'
payed plugin?
really I can't even get the blocks to generate atm
xD
No its a private plugin
ur not coding it?
How can I add the script that I use on one server, which is the plugin of the script that is used in spigot, to bungee to work on all servers and with the same data.
ohhh
get out of help dev
you already asked in help server
have patience
Hopefully if it turns out well it will be like minehut-
if you need help with terrain generation im here
I wish you the best luck/skill
Each of my plots generates a completely random X*Z plot
and makes lava slowly rise
last to survive wins
ooh
Oh thats fun
Yeah 😎
Reminds me of thoose build to survive gamemodes
Its on github rn but not completely done
Yea the one with techno
if you need help lemme know
Yo
wats ur github, you dont have it linked to discord
yes
Please
example
"PlayerDieEvent"
I have a problem with my custom enchant plugin when i remove the enchants with the grindstone i can only remove the enchant lore when i don't rejoin after rejoining i can't remove the lore anymore...
Yea ima work on em
I do shit quick right away cuz I got dire ADHD then I sit down and fix and organize after Im done
I cant do both at the same time
also commenting
and other stuff
and name spaces
yeah all will be fixed
i mean access scopes
does anyone know why this happens?
[17:50:32 INFO]: [Citizens] Enabling Citizens v2.0.32-SNAPSHOT (build 3147) [17:50:32 INFO]: [Citizens] Loading external libraries [17:50:33 ERROR]: [Citizens] v2.0.32-SNAPSHOT (build 3147) is not compatible with Minecraft v1_19_R2 - try upgrading Minecraft or Citizens. Disabling...
latest citizens build fails to load in 1.19.3, tried with a couple of other versions and didnt work either
maybe you should ask the developer of citizens?
seems pretty clear why that build doesnt work
citizens is latest build, tried with older and didnt work either
i dont think its a build issue
what makes you think that
i think its a me problem, thats why i ask here
the compatibility error is an error given by the plugin itself its not like a spigot error
so its a build issue
and you gotta contact the dev(s) for that
oh man bedless still going at it
Idk why you’d stay on .3 anyway
does anyone else's intellij at times just freeze and then spike at 100% cpu usage
specifically when selecting text
does this have anything to do with development?
it's probably the mcdev plugin
any other plugins?
i guess i got a theme plugin but thats about it
hm then no clue, which version are you on?
i just recently updated so community edition 2023.1.2
2023.1.3 should be latest
i had the exact same issue, they dont know what the problem is https://intellij-support.jetbrains.com/hc/en-us/community/posts/10844199123730-Intellij-randomly-uses-100-of-cpu-and-crashes-eventually
for some reason the cpu usage goes to 100% on no particular reason
i have the crash report: http://pastie.org/p/2EqVvNyC0QmFW4HcAv9fB6
my pc stats:
cpu i5 12400f
32 gb ddr4 3600 mhz
gpu 1660 super
use vscode
@somber scarab Here, i reformated it, created a master class, where you can handle all of your event
package Events;
import Utils.Tools;
import floorIsLava.FloorIsLava;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerJoinEvent;
public class GameEventManager implements Listener {
public GameEventManager() {
Bukkit.getServer().getPluginManager().registerEvents(urInstance, this);
}
@EventHandler
public void onPlayerJoinEvent(PlayerJoinEvent event) {
if (event.getPlayer().getWorld() == FloorIsLava.VOID_WORLD)
if (event.getPlayer().getBedSpawnLocation() != null)
event.getPlayer().teleport(event.getPlayer().getBedSpawnLocation());
else
event.getPlayer().teleport(Tools.getHighestUsableBlockAt(Bukkit.getWorlds().get(0), 0, 0).getLocation());
}
@EventHandler
public void onPlayerDeathEvent(EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player)) return;
Player player = (Player) event.getEntity();
if ((event.getDamage() >= player.getHealth()))
if (Tools.checkPlayerInGame(player)) {
e.setCancelled(true);
Tools.getGameFromPlayer(player).remove(player, true);
player.setHealth(20);
}
}
@EventHandler
public void onPlayerQuitEvent(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (Tools.checkPlayerInGame(player)) Tools.getGameFromPlayer(player).remove(player, false);
if (Tools.checkOwnerInLobby(player)) Tools.getLobbyFromOwner(player).removePlayer(player);
if (Tools.checkPlayerInLobby(player)) Tools.getLobbyFromPlayer(player).removePlayer(player);
}
}
Whooww
If all of the events are handling the game, you can create a "master" listener
huh
Like i did there
that's cooll.. i didnt know that
Since when did you not need to use {} for ifelse?!
you dont
yikes. why does it register itself in the constructor? that's not good at all
I made a whole as 3d engine and i didnt know about master classes
i just use the term master class, if you combine a bunch of things into one
it handles all of the events for the game
I dont like typing 'Bukkit.getServer().getPluginManager().registerEvents()' for every event i wanna register
so i just put in in the constructor
God class
ok so just make like a little util method that does that
You know i could
but im to lazy xD
theres this https://github.com/lucko/helper , for events its really useful
Oh also, talking about naming conventions @somber scarab
InviteLobby.java:24
You shouldnt capslock OWNER, it should be owner or ownerPlayer, you should only capslock in enums
Static constants
"god class" is an antipattern
Dont like using apis that are uneccesary
Which is basically what enums are
and a listener also shouldnt not reponsible for registering itself
wdym, i have
new listerName();
in my onEnable
you did it correctly with your other variables
It's a strange design pattern
The constructor should seldom be changing state beyond its fields
If you're writing code like new MyListener();, you're doing something wrong
does anyone know how to modify the player count of a server, as seen when the server is pinged?
and I'm not talking about max players
yeah that's bad
Why 😦
I have a problem with my custom enchant plugin when i remove the enchants with the grindstone i can only remove the enchant lore when i don't rejoin after rejoining i can't remove the lore anymore...
for example it violates the single responsibility principle. a listener is there to listen to events. not to register itself with the plugin manager. that's the job of your main class.
also doing new Something(); without saving it somewhere already gives a hint that you're doing something wrong - a constructor should construct an object, and nothing else. your constructor has side-effects, it shouldn't have any. doing new Something(...) without using it later on is literally always a hint that you constructor is doing more than it should
Hello. How do I get obfuscated field name from nms? Im just trying to get private stuff
#help-development message heyo; any idea what i am missing here so the command would work?
what happens when you enter that command
it doesnt even seem to exist
tried with and without a permission; nothing... weird part is that registering events a line above works just fine; registering the command doesnt
there is no PlayerAsyncPreLoginEvent
It’s AsyncPlayerPreLoginEvent
Afaik it blocks login indefinitely
No
It’s async, it’s not on the main thread
wdym with "never finish"?
while (true)
aight mister
How Oraxen/ItemsAdder creates custom inventories?
Login isn’t on the main thread
they use "custom model data"?
Resource pack, custom fonts
i dont think if it exists for inventories
yeah i know, but...
How to apply this into an inventory?
Use the font in the title
ooh does sense
Pretty much
Why are you infinitely blocking it :p
The main use of that event is to block login until you load their data
.
Whenever there is an inventory event, I want to analyse the InventoryView (again, it's whatever inventory, container, being viewed by a player) and then send a fake 'inventory update' (purely visual) packet to the client with modified stuff/items
What is the packet name ?
im searching the protocol but i'm unsure
Set Container Content ?
Does that cover for all inventory events ?
it'll hang on "Encrypting..." for the client
@EventHandler
public void onLogin(AsyncPlayerPreLoginEvent event) {
try {
System.out.println("LOGIN EVENT");
Thread.sleep(5000);
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_FULL, "Calm down, imbecile. Wanna buy some " +
"alprazolam?");
System.out.println("DISALLOWING");
} catch (InterruptedException ignored) {}
}
I waited 5 seconds and the client will also be waiting 5 seconds before it either connects or gets kicked
I'm trying to overwrite texture using bitmap \uE001 (version 1.19.4) but it's not working why?
30 seconds
well, more or less 30 seconds
Reasonable
Its 30 seconds but its less due to tick loses
breh what
i moved registering commands up, so it's in front of the registration for the event listener..
now i can either register the command or the events. wha-
it's client sided, it doesn't care about any ticks
XDDDDDD
are you sure you don't get any errors anywhere lol
that is very weird lol
https://mclo.gs/rZxj6Ve nothing
i was an idiot. lol
anyone knows ?
I see two packets that may potentially interest me:
SetContainerContent "Sent by the server when items in multiple slots (in a window) are added/removed."
SetContainerSlot "Sent by the server when an item in a slot (in a window) is added/removed."
Which leaves me the following questions:
- does "updated" count (as removed/added)?
- is the cursor slot included ? (is it a slot?)
- does it cover all inventory event scenarios ? (if i send those packets 1 tick after to "fake update", after whatever invetory event, shoudl it work?)
Should work for any inventory
I want to make an effect that changes the color of 8 glass panes starting from the first to pink then turns the second into pink and the first back to normal and so. How do I schedule this every 500ms while being able to cancel it when the inventory is closed?
I've got everything setup, I just need the timer shit
?scheduling
Use a repeating task, you can easily cancel it with the close event
Those don’t change tho
Is there a way to make this a one-liner on initialization other than a static block :((?
yeah true, just wanted to keep constructor empty for this example but, myeh im not switching it over to static just for that xD
use spigot api
Any guide to create a tablist?
Question:
Why don't you just define the Hasmap with all blockfaces in it?
So instead of creating an empty one, you do:
protected... allowedFaces = new ConcurrentHashmap( {{
put(<face>, true);
...
}}) ;
yeah thats the opposite of what i wanted xD
True, but... not in the constructor XD
thats true as well
I mean if you really don’t want it in the constructor
Hashmap blah blah = methodThatReturnsAHashMap
Also, shouldn't that map be final?
i just opted for this design in the end imo
The class is mainly just serving as an example for those whos using it
prolly i normally go through a finalize everything at the end if its not/if its able to be final
Hello. I asked chatgtp to write me code that makes a lifesteal smp plugin but where players dont actually loose health if they die and idk if this is good or how to make the plugin work and all that.
also idk how to show code in discord
Ask someone to modify one for you
It’s probably just commenting out a few lines of code so I’m sure you can find someone to do it for free
can you pls modify it for me? lol
what plugin are you currently using?
if its open source ill do it rq
lifesteal
Ah ye that narrows it down
ye
if the player dies they dont loose health but if the player kills someone they still gain health
Wouldn't that just lead to 2 players continuesly kill each other and gain infinite hp?
Probably
thats a mc limitation
minecraft limitation
health cant go over 1024 iirc
U can set to higher
i could of swore in modded you eventually hit some limit with mc
idk why people would need more than 1k health lmao
hypixel:
lmao
ike why tf is there no config.yml smh
was gonna PR it as a config option but bro dont got a central config
what does that mean? tbh I have no experience with coding or anything like this so idk any of what yall are saying when it comes to code lol
tbh your gonna have to contact the author ( IkeVoodoo ) and see if he would add it to the plugin himself, or see if another plugin maybe gives you the configuration option
As, the project doesn't load for me when cloned the build file is missing repos/dependencies
alr ill see if I can find another lifesteal plugin
no way
@rough drift
https://www.spigotmc.org/resources/1-8-lifesteal-version-1-1.101004/ would this one work?
it would actually be kinda fun to have lifesteal in 1.8 combat lol
without loosing health ofcourse lol
seems like the GitHub pom he has is specialized for his pc, even the clean/output folders point to his test server haha xD
https://www.spigotmc.org/resources/depixa-lifesteal.104937/ wait that doesnt even seem to exist lol. would this one work instead and potentially make it 1.8 compatible too?
1.8 compatible too would be a big hard nope
in fact i wont touch anything older than 1.16 :p
seems this plugin works though
Ye
1.17 is the furthest back i would go
whats 1.20
I think I’ve heard of a 1.19 too
i only know 1.20.1
this code base is dookie ngl but ill do it xD
Ty!
if ike comes back definatly switch back to his this ones uhh questionable xD
Lol 😂
is it package private
?
what in FUCKING TARNATION
Oof hardcoded color character
Damn
for this plugin go into config and make hearts-lost-on-death = 0
for the health limit what limit do you exactly want just match spigots 1024?
Ye
Well can u possible do the hearts lose on death? Lol 😂
dot
it has a config
Oh so I just do it in Mc
yee, idk why ike didnt think of this for his it must of slipped his mind xD
lol 😆
yeh this plugin does everything you want just change it in configs and restart
Hey it works
it definatly does i give them credit for them
No user will ever notice or care
im 100% sure its a first time plugin which tbh is fine
but just seeing that slightly huts 
Lol 😂
i need me a can of flex seal in my life
i remember when i first started coding i would catch npes
He doesn't know how expensive Double instead of double is
might of used an outdated ide/java version too
because hes using explicit types when initilizing stuff like lists and maps
HOWEVER
BIG BRAIN
they shipped the gradle container with source code
so like + 1
ye
for not making me downlod that weird jre they were using
how come people version configs?
why dont yall just outright add the new value if they dont exist
Idk
like so many plugins use config version maybe somethings going over my head here
What if old stuff changes
Like something goes from a string to an int
For some reason
Too hard
i wish everyone just understood json so we can use pojo classes
Just make the same for yml
yaml is a subset of json ¯_(ツ)_/¯
can potion effects show infinite in spigot 1.20?
Should be able to
The constant reads better
Yeah Mojang added proper support for infinite
Not super hard
Get a nice custom model, slap it on an armor stand/display entity and spawn particles as it flies
Then do some fun maths to give it a nice curve
Say I wanted to develop a plugin to be compatible with as many versions of Spigot and possibly Bukkit as possible, does anybody have any advice on this? Like I have the option of developing things using the 1.8 Spigot API, but as far as I can tell, Spigot did exist prior to 1.8, and Bukkit also existed for prior versions. Does a compatible API version exist for versions prior to 1.8, or am I best just sticking with 1.8+?
if you want to support 1.8+ bukkit just dev for the 1.8 bukkit api
but literally no one runs plain bukkit anymore
No api versions before 1.8 are still publicly available
And if anyone is using a version that old they are on there own in every way possible
other than choco
If that's the case, then that's all I really wanted to know
@umbral pendant @glad prawn @noble lantern There is a config, it's just auto generated
What?
maxHealth: 20 # Hearts, ik dumb naming
useMaxHearts: true
```plugins/LifeSteal-Smp-Plugin/config.yml
also @remote swallow there are some deps you need to clone from other repos
that are not on central
I know I know let me be
ah so its not an embedded resoruce then i was expecting it to be
Nope! And don't look at how it's generated
you'll kill me if you do
LOOK AT IT

geez my entire config library isn’t even that big
I added enums, lists, serializing child types if that type is also a config type
it's a whole of a lot complex
and made by stupid 2 years ago me
I got a plugin with almost 150,000 downloads and only 53 people are using it on 1.12, 33 people are using "another" version (which is, at worst, 1.8.X). Everyone else is using 1.16 or newer.
So why bother with ANY version below 1.8? Even 1.8 is dead
I wouldn't care about anyone who is on pre 1.16
shit even on my plugin most users use 1.20
How would I config it?
wdym
@umbral pendant
I want to develop a plugin and if it can support as many plugins as is even possible, then that's ideal
@Config("playerScore")
public class PlayerScoreConfig {
public static int level = 0;
public static int xp = 0;
}
@Config("players")
public class PlayersConfig {
public static List<PlayerScoreConfig> scores = List.of(new PlayerScoreConfig());
}
it's dumb ik
but why bother with, let's say, craftbukkit 1.4.6 if NOBODY uses it
Why not
should've used arrays
because it's unneccessary work for you
What command is that in-game?
Creating the plugin at all is unnecessary work, I'm fine either way
no matter what its 10x better than the other plugin we were looking at
actually?
and users of recent versions will be annoyed because you e.g. cannot add a certain 1.20+ feature because you're stuck on 1.4.6 API
It's not an in-game command
@rough drift yep
that ones dupixa iirc
If it's what I am thinking of they claim mine is shittier than theirs
imagine rockstar would still stick to windows 98 API and directX 5, I doubt GTA 5 would be a great game then lol
if you really wanna go for old versions, at least use 1.8.8 instead of going even older
Ah, I have just thought of at least one thing that my plugin might need to consider that wasn't added to the game until somewhat later
i.e. stripped logs
So yeah, that makes sense
found it
Thanks for pointing that out
np. which version even added stripped logs lol
1.13, apparently
ah yeah that's good, the 1.13+ API is great because of the new material stuff etc
1.12 <> 1.13 has breaking changes
When you use an older API version, can you just not reference newer block types at all, or?
yeah well you can in theory also use XMaterial instead
that should work on all versions
its easier to manage it in modules that way each module can use the version of api your devving on
I guess maybe you can do at least run-time checks like .name == "WHATEVER_BLOCK"
oh yeah xmaterial forgot about that
Then idk how to do it at all lol 😂
https://www.spigotmc.org/threads/xseries-xmaterial-xparticle-xsound-xpotion-titles-actionbar-etc.378136/ This is definitely better than just comparing materials by name
You know what, give me tops 1hr and I'll release a new ver just to add this command for you ❤️ lmao
(I use ❤️ as funny joke, dw about it)
I am actually doing it fyi
oh no not saying your not 😛 i just find it funny there was supposed to be a command xD
I think I'll just make my plugin using the 1.19 API and then see if I can backport it later if I'm bothered about it
how can i stop my plugin overwriting the config.yml file when it restarts? im using this.saveDefaultConfig();
💀 i think i forgot to actually save the config
its saveConfig(); for config.set isnt it?
yeah, config.set then save or save on shutdown
alright thanks
Thanks! The clock is on 🕰️ lol 😂 no pressure though
Since that message I've been writing one arg 💀
Sus
i hate this so much who gave me this idea last night smh
what are you doing
and why the fuck is IFluidStorage not an interface
it’s not even an abstract class
what is "energy"?
ignore fluids
is power
eletricity
whatever you want
but a type of energy
I want to make EnderIO as a spigot plugin I think
its like vault, how vault as an economy but you dont know what it is
yep im working to make soe type of API that allows plugins like this to be made, just challaning a tad 😛
Im using alex's block PDC lib for it as well
an API for what
its how you do power in forge
forge provides abasic power impl that makes all power mods work friendly with one another
similar to like vault
that way if you make an enderio thing, and someone makes like mekanism, both of your machines would work 🙂
?paste
that’s neat
yee, even in forges source they express that a lot xD
Dudes who made that original power api were nuts
one sec lemme find the comments cause im using forge as like a referance
Shoutout to king lemming
i wonder why forge doesnt provide BlockFace methods for extracting energy though
ig they expect mod devs to make that a feature on theyre end
ie
/shrug
For some reason this doesnt work with the crafting 2x2 in the players inventory
Inventory inventory = player.getInventory();
for (int slot = 0; slot < inventory.getSize(); slot++) {
ItemStack itemStack = inventory.getItem(slot);
if (itemStack != null && itemStack.getType() != Material.DIODE &&
itemStack.getType() != Material.CHEST && itemStack.getType() != Material.SLIME_BALL) {
inventory.setItem(slot, new ItemStack(Material.AIR));
}
}```
btw, will there be a way to make it so people can decide if others loose a heart or not? that would also be useful
wdym?
just a question
I don't understand it
can u add a command that lets u not loose a heart when u die as well?
for ops though obviously
data/minecraft/functions/give_stone_tools.mcfunction
scoreboard players set @s joined 1
Give stone tools
give @s minecraft:stone_pickaxe
give @s minecraft:stone_axe
give @s minecraft:stone_shovel
give @s minecraft:stone_sword
is that actual java code
chatgtp sent me it
The plugin is having a stroke, a little help?
ERROR
https://paste.md-5.net/torinudicu.css
CODE
public class PointsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player p = (Player) sender;
String replaced = PlaceholderAPI.setPlaceholders(p, "%playerpoints_points%");
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&aYou have &f" + replaced + " &apoints!"));
} else {
sender.sendMessage(ChatColor.RED + "You must be in-game to use this command.");
}
return false;
}
}
No it’s not
then what is it?
Datapack
no thats a datapack
oh nvm im dumb. I asked it for data packs LOL
You probably have multiple classes extending JavaPlugin
Show both
Main basically has this on enable:
getCommand("points").setExecutor(new PointsSystem());
show your plugins folder sounds like you got it uploaded twice in there prolly
its right there
ooof
You’re initializing your main class, can’t do that
wdym?
new PointsCommand() instead of new PointsSystem()
Here
tbh how did that even compile
JavaPlugin implements CommandExecutor
out of the many years ive done this ive never known that wow
you learn something new everyday
i have a question
how do I rename the plugin entirely
plugin.yml?
Yes
thanks y'all
Can someone help me with this ive tried 3 different versions and it never fixes it. How do you clear the contents of the player 2x2 crafting inventory
