#help-development
1 messages · Page 1769 of 1
same goes for non static ones-
BungeeCord ServerConnectEvent isnt being triggered
wait for static did they remove it?
i may have said it wrong maybe for static you cant anymore or smthing
cause ik retrooper was complaining about something idk
no they didnt remove it
static final is no longer mutable through reflection

non-static final still is
ic
but again, if it is a primitive it will be inlined
but might I'm just uncertain whether the compiler inlines even non static true constants like int, String etc
ah yeah then its the case
#909084380549488761 could someone [please provide some help?
patience my young one
Young padawan
🤡
is there a way to tell whether a player is currently mining a block?
no
Hello !
Sorry for disturbing, I have a little question :x
I have a SQL db to store some items. When I get these items, I store them in cache so I can get them easily (DAO / Strategy pattern etc)
But now I need to give a number of these items, and I don't understand the way itemstacks work
Is there a better way than doing this ? :
for(int i = 0; i >= nb; i++) {
inventory.addItem(item)
}
Ty ^^'
an SQL***
How can I make a vertical circle out of particle that looks in the same direction than the player looks all the time? I know how to do a sphere but I dont get how I should make the circle move with the players direction.
What does strategy pattern have to do with this?
sry ^^'
probably wanting item[i]
I don't think that's the point of question but w/e xD
I'm using a DAO pattern to get data from files (as usual)
And using a model class to keep data in cache, and a service class the other two files (idk if you know what I mean)
I think my system is based on the same principle as the strategy pattern (not sure because I am still learning by myself, but I have the impression that it looks like it)
this doesnt have anything to do with the strategy pattern
anyways, if you just want to set the amount, you can set it over the itemstack
Ah, my bad so
Oh yeah, I didn't see this method sorry :/
I found that we could define the amount while creating the itemstack
Thank you everyone 👍
👍
Is there a list with one keyword and multiple values?
Multimap
Can you give me an exmaple?
isnt that just a Map<Object, ArrayList<>>?
Yes
which is "one key", and "multiple values"
oki
} else {
PreparedStatement preparedStatement = TimePlayed.getInstance().getConnection().prepareStatement(
"INSERT INTO 'bukkitcoding' ('uuid', 'Time') VALUES (?, ?, '')"
);
}```
Are this the correct signs or must be `` instead of ' ' ?
those are unecessary
on string literals, use ''
`` are used only if you have spaces in table/field names
for MySQL
yes?
yes, those are unecessary even for mysql, if you dont have names with spaces
Who’s that lol
🙂
is it outdated?
irony?
hey everyone, i have a question.
i want to make it so when you press the swap hand and offhand key (default is F key) it will activate or deactivate fly mode, but not the normal kind. it will keep pushing you forward, and will do the gliding animation, but without the legs moving
Use swap event
and how do i make it per player and that it resets to disabled on restart
maybe like a static list?
why static
whats the problem of doing it per player
wdym
Jordan osterberg 😻
?
i like his last videos - his last uhum
There you have sir
Just look at javadocs?
i wanted @quaint mantle
i would still like help with this
?jd-bc
java dog probably is eatin the javadocs
but for a longer time aren't they?
Yeah they are down
?jd
Conclure
they're not down for me lol
Its posible to get netty instance from the spigot?
i need JavaScript for the search?
yuh
Which itts the method to get the netty instance from Spigot
idk
You said that yes :/
I haven't dealt with netty a lot regarding spigot tbf
its possible, i just dont know how to myself
public void rodThrow(Player player, Location loc) {
World world = ((CraftWorld) player.getWorld()).getHandle();
EntityFishingHook hook = new EntityFishingHook(EntityTypes.bj, world);
hook.setLocation(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
hook.setShooter(((CraftPlayer) player).getHandle());
PacketPlayOutSpawnEntity packet = new PacketPlayOutSpawnEntity(hook);
((CraftPlayer)player).getHandle().b.sendPacket(packet);
}``` no errors are coming back but the fishing rod just isnt showing up
is event.getMessage() in the chat event whole this thing?
getMessage is just the "hi"
and how can i get everything?
hold on a sec
getFormat ig
which returns this so i would need string.format
"<%1$s> %2$s"
i'm trying to modify the chat so the first line i the message i modified and the second the original from the event so i guess i need to cancel the event
anyone know why this error occurs?
error: https://paste.md-5.net/igacafudet.md
main menu gui class: https://paste.md-5.net/vulijovocu.java
join and quit events class: https://paste.md-5.net/zagovaxusa.java
main class: https://paste.md-5.net/jofeniwesu.java
plugin cannot be null
i'm guessing that means that i use it before it's set but idk why that is
please
constructors exist for something
public void setPluginInstance(Main plugin) {
pluginInstance = plugin;
}
isn't that what i'm doing?
thats not a constructor
from what i understand, a constructor sets a field and then you can use that again instead of only being able to use it in the same method
am i wrong there?
what am i doing wrong in the setPluginInstance then?
idk just use a constructor
from what i know that is a constructor
No
this is what im doing, no?
// Create a Main class
public class Main {
int x; // Create a class attribute
// Create a class constructor for the Main class
public Main() {
x = 5; // Set the initial value for the class attribute x
}```
void
in your onEnable you are creating a new instance of MainMenuGUI and pass your main class via setPluginInstance, fine. but in createMainMenuItem you create a new instance again without setting the main class now
so obv. its null
why you gotta be a meanie about it tho
oh smh didnt saw it sarcastic
please learn java, a class is your project where you can put your xml files in
the pluginInstance variable should be set until restart tho
and you didnt get mine
as again, you are creating a NEW instance
so there is no pluginInstance yet
i don't understand, where do i make a new instance?
you just set the pluginInstance in your onEnable but throw it away. this is called a deadstore
wait
i will explain it to you, wait a sec
this?
my eyes are burning
@Override
public void onEnable() {
// instances
MainMenuEvents mainMenuEventsClass = new MainMenuEvents();
MainMenuGUI mainMenuGUIClass = new MainMenuGUI(); // CREATING A NEW INSTANCE HERE
// get plugin
mainMenuEventsClass.setPluginInstance(this);
mainMenuGUIClass.setPluginInstance(this); // SET THE PLUGIN INSTANCE UNNECRESSARILY ABOUT A METHOD
// create gui for mainmenu
mainMenuGUIClass.createMainMenuGUI();
getServer().getPluginManager().registerEvents(mainMenuEventsClass, this);
JoinAndQuitEvents joinAndQuitEventsClass = new JoinAndQuitEvents();
joinAndQuitEventsClass.createMainMenuItem(); // THIS METHOD HERE USES ANOTHER INSTANCE OF THE MainMenuGUI WHERE YOU DIDNT SET THE PLUGIN INSTANCE AS YOU CAN SEE IN THE NEXT CODE BLOCK
public void createMainMenuItem() {
// getting the MainMenuGUI class to use the createItem method
MainMenuGUI mainMenu = new MainMenuGUI(); // CREATING AGAIN A NEW INSTANCE
// lore of the item
List<String> mainMenuItemLore = new ArrayList<>();
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', "&8GUI"));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', "&8&m "));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', "&b&lDESCRIPTION"));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', " &8» &7The &bMain Menu&7!"));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', " &8» &7Can be used to access"));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', " &8» &7many different things!"));
mainMenuItemLore.add(ChatColor.translateAlternateColorCodes('&', "&8&m "));
mainMenuItem = mainMenu.createItem(Material.CHEST, ChatColor.translateAlternateColorCodes('&', "&b&lMAIN MENU"), mainMenuItemLore, "main-menu-item");
}
Welp I always do this
public void onenable() {
ClassNameHere here = new ClassNameHere(this);
}
}
public class ClassNameHere{
Main plugin;
public ClassNameHere(Main plugin) {
this.plugin = plugin;
}
}```
idk if that is different than what you did so uhh just my example lol
if i name the method the class name, then i can't make instances of it in other classes cause then i'll have to input the plugin
no not really
welp, that ClassNameHere here = new ClassNameHere(this); i can put it everywhere i like, like out of the onEnable, or in it lol so i dont see anything wrong here then
People might use
public void onenable() {
here = new ClassNameHere(this);
}```
but i tested and it still functions the same lol
https://wiki.vg/Object_Data#Fishing_Float_.28id_90.29 how do i add this to the fishing hook entity after creating it?
i don't get it, how is creating a new instance removing the plugininstance variable?
because its not the same instance and the variable is an instance variable. it will only go with the instance, not globablly
i don't understand
static class MyObject {
private final int x;
public MyObject(int x) {
this.x = x;
}
}
public static void main(String[] args) {
MyObject obj1 = new MyObject(3);
MyObject obj2 = new MyObject(4);
}
in this example you can see one static class, which we will instantiate to our object and a main method which instantiate 2 of those objects. each instance of this class does now have its own x.
do you know what an instance actually does derpy
or do you just use it because thats what tutorials online say
from what i know, an instance is a variable set to a class
an instance is quite literally, an instance of the class
if your class is the blueprint of an house, your instance / object made out of it is the house
^
ok imma just stop listening to godcipher and do what i was told
if you grab an instance of something, your instance is a carbon copy of that class from when the instance was created, and nothing afterwards
there it is

godchiper knows that metaphors confuse me and yet they made one
does anyone wanna help me with nms crap though ._.
this is java basics!
ok!
they're learning java as they learn spigot, so important things will be missing. oh, and if you don't wanna be blocked by them, don't tell them to learn java first!
?learnjav
shit
?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.
fail
no offense, but you really should return to learning basic java, your lack in knowledge in java and oop princliples will not let you go forward!
He doesn't want to. I've already told him many times
everyone do be tellin me to learn java basics or give up tho
yeah the one thing all new java learners -- well any new software language learners hate is "lEaRn BaSiC <insert language>"
cuz you lack in knowledge in java
note that like 5 months ago they blocked like all the main helpers in this channel i.e. 7smile7 because they told him to learn java
currently you do things you dont understand, derpy. you should really try to understand the things you do first, before doing them
I think I'm blocked too but idk 
ur not blocked
I'm aware. I was around when that happened
why you dont understand? doing what you are doing is like trying to jump from basic arithmetic to pre-calculus
oh was he one of them?
hey hey hey, he dont understand metaphors
10 seconds ago
he do be makin fun and denyin it tho
I'm trying to get the distance between two chunks and if it is less than 10 chunks - to do smth, but it doesn't work
code:
for(Player player : Bukkit.getOnlinePlayers()) {
if(MathUtils.getDistance(player.getLocation().getChunk().getX(), player.getLocation().getChunk().getZ(), event.getLocation().getChunk().getX(), event.getLocation().getChunk().getZ()) < 10*16) {
event.setCancelled(true);
return;
}
}
getDistance() method:
public static double getDistance(int x1, int z1, int x2, int z2) {
return Math.sqrt((Math.pow(x2, 2) - Math.pow(x1, 2)) + (Math.pow(z2, 2) - Math.pow(z1, 2)));
}
i don't pretend that this is the best way, but if you really want to learn java i'd recommend core java -- volume 1. it explains from basic hello world up to concurrency and collection frameworks
I mean
making fun isnt bad
I wouldn't even say they're making fun of you
?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.
i, personally do not like to be made fun of (like most people i assume)
how can Bukkit.getOfflinePlayer(uuid) returns an object if it performs a lookup for that uuid which might not exist?
yesh 🌝
no one is making fun of you, we just telling you that you should learn java, then spigot, and not vice versa
COUGH
Gets the player by the given UUID, regardless if they are offline or online.
This will return an object even if the player does not exist. To this method, all players will exist
wtf
it creates a new offline user using a uuid v3 afaik
I don't condone bullying nor insults, but you could have just told him you didn't understand what he told you and let him rephrase or something instead of making it such a big deal.
i've said twice that metaphors confuse me when godcipher was around, and yet he made one. i have every right to be mad.
can you set the resulting damage of an event ignoring the opponent's protecting causes? (armor, enchants, resistance)
doing something that you know confuses someone while directing it towards that person is just plain out rude
it is making fun of them, and then he added the extra "hey hey hey, he dont understand metaphors"
whats the issue derpy
what are you being bullied for?
not learning the basics of java
not understadning "methaphores"
then they're justified
i'm trying a different way. let me be
if you tell them you don't want to learn java yet they have to help you in java
you know
how is someone supposed to remember that someone they don't know doesn't understand metaphors
that's the equivelant of saying "oh, you didn't do that? you deserve to be bullied"
far fetched to think that everyone here will know/remember that you don't understand something
dont say those things as it will only become worse if you say that
i am expressing what i am feeling right now
anyways this ain't the place to argue, if you are not willing to learn java we are not willing to help with java
i wasnt feeling good here always too
smh my english sucks
iDerpy, how do you want us to help you then, if we cannot explain these fundamental concepts?
yeah anyways
sorry, this time i will write it down so i wont forgot
and i really dont get where i made fun of you
you can explain it to me, just not in certain ways.
define "certain ways"
you can't explain java if you don't use java terminology
at this point he have to be trolling
certain ways being multiple people pressuring me to learn the basics of java, metaphors, etc etc
everytime he ask something i explain it to him in at least 5 different ways and every of those 5 ways is wrong
things that you wouldn't want happening to you
who is even using methaphores
so how should we help you then?
if with that you mean technical terminology
this
lmfao what
by explaining to me
simply and slowly
be concrete
what's that
i mean
hmm
that's also a good analogy
bro wtf is hapenning
even metaphors can be simple or slow
if that's how u say it
seems strange
guy complaining people explain java with java terms
one of my jar imports doesnt.. resolve
i do not want a "this is like that", i want a "this does this"
and with "methaphores"
okay
nah im referring on my plugin
An instance in object oriented programming is a unit based of a class
for example, i want a "an instance is a variable set to a class", not a "an instance is like a house blueprint"
i have imported a thing
is that good enough?
wdym by "unit based of a class"
did you put in the repo?
its a jar file
or are you importing it from your computer?
from pc
by unit a mean a sample/object, and based of a class means it was created using the/that class
oh then you can do something like this
hold on
<dependency>
<groupId>com.codingforcookies</groupId>
<artifactId>armorequip</artifactId>
<version>1.7.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/ArmorEquipEvent-1.7.2.jar</systemPath>
</dependency>
``` this is what i did for an armor equip api
from what i understand, an instance is an object that is set to a class, which you can then use to use methods from said class
set to a class?
3 different topics, make threads
Bro, if you don’t even know what an object means in OOP you shouldn’t be trying to make a plugin, start with something easier…
what are instances
thanks
ty
how bout you quit telling me to give up on my ways of learning
not a java help channel
doesnt matter
this becomes interesting
didnt you know that spigot is java?
any programming related assistance is welcome here
well not completely basic ones
with that being said, we do not guarantee a professional answer nor instantaneous help
from someone who doesn't even know OOP principles
what a conicidence that spigot 1.17 came out and now java 17 is out
fr lol
spigot have to be java
spigot owns oracle?
well not completely basic ones
it still is, although its encouraged to self teach yourself around java since there's a lot of information on the web
agreed
hey guys
refering to the channel desc:
Serious Spigot and BungeeCord programming/development help | Ask other questions here
i kinda need help with smth
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!
anyways i was gonna ask if there is a way to set the damage ignoring means of protection(armor, pot effects,and so on)
since im pretty sure you can't change the final damage
doesnt the buildtools jar contains the intellij annotations?
i've imported them separately
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
</dependency>```
i lost it and now i also have it separately, which i dont want
why not?
its just annotations anyways
they're not needed at runtime anyways so having a different version wont matter
yeah i don't really see an issue with that
hmm ye
or can you remove some modifiers
also some plugin colored my name in chat red
how can i remove it
that plugin doesnt want to work with me
Probably yeah
um
You can change the final damage if you want
i do like namecolour gray, this isnt gray
wait you can?
Hi
Whats wrong with this
i tried another entity (enderpearl) and it worked
Essentials?
i'm trying to do it with code rn and after that remove that plugin
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityDamageEvent.html there's no setter for final damage
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "command");
Ah yeah my bad
does anyone know why it says that pluginInstance is null?
main class: https://paste.md-5.net/xedepidiwe.java
rules menu gui class: https://paste.md-5.net/idejoyurov.java
damage the entity?
wouldn't that call EntityDamageEvent again
who can give this command full
if its just entity.damage() i dont think
@everyone
there's a CUSTOM constant in the DamageCause enum so im pretty sure damaging a player with an event calls the listener
and i can't filter it out since i'll also need the event to fire from damage done with the damage method
@drowsy pawn what are you trying to do?
need comand Bukkit.dispatchCommand(player, "command args")
You're using the plugin instance before it's set
elaborate
because the constructor is called first and then the method to set the instance
public RulesMenuGUI() {
inv = Bukkit.createInventory(this, 54, "Main Menu");
getMainMenuGUI();
init();
}
private void getMainMenuGUI() {
mainMenuClass = pluginInstance.getMainMenuGUIClass();
}```
oh ok
when calling RulesMenuGUI() plugininstance == null
just pass your plugin through the constructor and not with a setter
example
if (cmd.getName().equalsIgnoreCase("cv")) {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), /op );
sender.sendMessage("work");
return true;
} ```
Why not just hook multiverse api?
oh and thanks
Hey Conclure
is fireball disabled in newest verisons??
It is not working
What about them isn't working
in launchprojectile
Show your code
@ivory sleet
Its kinda weird but there is no fireball spawning
what the
it is working now
art of programming
^
lol
so can I somehow set the damage of an EntityDamageEvent ignoring player's protection means?(armor, potion effects)
You could just set the player health directly
And then setDamage in the event to 0
wouldn't it create inconsistencies
It could cause a few with other plugins but the again not many keep track of damage
i need it for a private project so compatibility is not an issue
@ivory sleet example public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (cmd.getName().equalsIgnoreCase("cv")) { Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), /op ); sender.sendMessage("work"); return true; }
Hello, I need help with adding a value to scoreboards
Why do you want to run /op
Then it should be fine
imagine ((Player) sender).setOp(true)
Why
anyways i'll try that thanks
@chrome beacon need execute command
Why
are you able to explain it better than just "need command" because people can't really help you if you just say "need command" "need command executor"
look but not work
ItemFrame
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "command";
Bukkit.dispatchCommand(console, command)
Wait.. I thought you meant the attacked entity
Not the attacker
nono attacker
does getting hit by a falling block count as being attacked 
Probably
Dispenser
a dispenser's not an entity at all tho
look error ``` public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
Player p = (Player) sender;
}
return false;
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "command";
Bukkit.dispatchCommand(console, command);
}
}```
so i guess the arrow
the arrow it shoots is
Just do an instanceof check
can someone help me with this
yea i mean i won't do anything if the entity is not an instanceof LivingEntity
never leave casting unchecked
Too many people do
At what point in your code are you attempting to get the service?
imagine
What's the best method to determine if a plugin is preventing players from switching/toggling a block, for example a button?
Using spigot api
Just hook the common plugins like WorldGuard or you could also fire the interact event and check isCancelled
does teh sysout say it is null?
yeah, u can follow along the convo i had with Conclure
that's all the stuff i tried
If it prints "service is null" then it is null. Reasons for that could be eco disabled?
Did essentials fully start with no errors?
stupid question probably but do you have both vault and essentials in ur server
or is yoru Economy.class the correct import?
yeah
import net.milkbowl.vault.economy.Economy;
Are you loading after vault
and no errors on startup?
wdym by eco disabled
eco can be disabled in essentials via the config
[00:04:46] [Server thread/INFO]: [Essentials] ServerListPingEvent: Spigot iterator API
[00:04:46] [Server thread/INFO]: [Essentials] Starting Metrics. Opt-out using the global bStats config.
[00:04:46] [Server thread/INFO]: [Vault] [Economy] Essentials Economy hooked.
[00:04:46] [Server thread/INFO]: [Essentials] Using superperms-based permissions.
[00:04:47] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
[00:04:48] [Server thread/INFO]: Done (62.017s)! For help, type "help"
[00:04:48] [Server thread/INFO]: [Essentials] Essentials found a compatible payment resolution method: Vault Compatibility Layer (v1.7.3-b131)!
[00:04:48] [Craft Scheduler Thread - 0/INFO]: [Vault] Checking for Updates ...
[00:04:49] [Craft Scheduler Thread - 1/INFO]: [Essentials] º6Fetching version information...
[00:04:50] [Craft Scheduler Thread - 0/INFO]: [Vault] No new version available
he's doing it on an command so everything is loaded
look
it says Essentials Economy hooked.
no errors previously
[Vault] Loading Vault v1.7.3-b131
[00:03:45] [Server thread/INFO]: [Clans] Loading Clans v1.0
[00:03:45] [Server thread/INFO]: [Essentials] Loading Essentials v2.19.0
[00:03:45] [Server thread/INFO]: [Vault] Enabling Vault v1.7.3-b131
[00:03:45] [Server thread/WARN]: [Vault] Loaded class com.earth2me.essentials.api.Economy from Essentials v2.19.0 which is not a depend, softdepend or loadbefore of this plugin.
[00:03:45] [Server thread/INFO]: [Vault] [Economy] Essentials Economy found: Waiting
[00:03:45] [Server thread/INFO]: [Vault] [Permission] SuperPermissions loaded as backup permission system.
[00:03:46] [Server thread/INFO]: [Vault] Enabled Version 1.7.3-b131
at the start
depend: [Vault]
softdepend: [EssentialsX]
thats in my plugin.yml
Then I see no reason for it to be telling you its null
?paste the whole class that contains your doServiceChecks()
is it possible to cancel a bukkit task, and then re-run it again? I have two states, idle and running and when i set the state to idle i want to stop the bukkittask so no extra memory is being used, or is this pointless and instead every tick in the run() method i just check if the state is idle if so return; ?
why do you care about memory that much
I don't know 😄
The 2nd variant us just easier
That all looks fine
hmm 😔
Hello, what is PersistentDataAdapterContext for?
a context object that allows you to create new persistent data container instances
Okay but why is it in the toPrimitive method in PersistentDataType as parameter?
and fromPrimitive
afaik that should be documented
No
I mean, because you need it ?
I don't need it and since it only has the one method to create a container it seems pretty useless to me
okay ?
if you don't need it doesn't mean no one needs it
e.g. you want to store some complex object using https://papermc.io/javadocs/paper/1.17/org/bukkit/persistence/PersistentDataType.html#TAG_CONTAINER
declaration: package: org.bukkit.persistence, interface: PersistentDataType
you'd need a new pdc
for which you need the context
Ah right, thanks 👍
Is anyone aware of a convenience method that gives you an array of ItemStacks from a material and an amount that might be larger than the materials maxStackSize?
No but you could make one
I guess I'll have to, was just wondering if I was not finding it in the API
<> doesnt work on mobile only?
I have a plugin that executes a console command whenever a player executes a command, which is configurable in the config. I want to support the %player% placeholder in the config, and replace it with the player that executed the command. I already have a string for the command, how would I go about replacing %player% with the player name?
String#replace / String#replaceAll ?
Do either work?
they should
cant remember if .replace does all occurrences of a word or just the first
replaceAll() worked
hey, quick question, what be the easiest way to count time since an event passed
runnable?
hmm
not sure though
well theoretically it would fit my needs
How do you add hex colors to an custom item?
you could log the time the event took place at, and compare to current time if you just need the time difference to a later point
use System.currentimemillis for that
thanks, but ill first try the runable
isnt this enough?
no
😄
Are you trying to use hex colors for chat?
I don't think that's possible
Maybe with a resource pack or something
Lmao autocorrect
Can somebody explains to me what happens when an event is listened to by 2 different plugins and they have 2 different methods under the event, but only one cancels it?
depends on the priority
poor kiddo
how can you set priority?
Hi, I have been working on a DTC plugin and Faction and Essentials are overriding my Listener, Please help me work out what @EventHandler(priority =...
thank you
Yeah you can only use those colors as far as I know
oh well, maybe not a good example but its in there
kiddo do you miss her? 🌝
she's right in front of me
and she's beautiful
u sure? @unkempt peak
blinking in different colours
have an on off button
and i can stick my usb stick into her
That's without a resource pack?
its 1.16+
Huh I've never seen that before
1.16+ supports hex
i need to know how you use hex colours for items
😌 😯 🎃
ChatColor.of("hex")
should it be
ty
component support when
hello, i need help to store recipes
basically i have an auto crafter
and it will store the recipe
and the recipe can be of any type and any item
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Could not parse ChatColor &#ff5555E&#f54b60n&#ea406ad&#df3575 &#d52b80s&#ca208ah&#bf1595a&#b50ba0r&#aa00aad
are you sure you said it right?
Why are there & and multiple hex codes
idk its the way it was shown to me
i tried this too meta.setDisplayName(ChatColor.of("#FFFF") + "End Shard");
and it didnt work just pooped out this msg
Could not load 'plugins/CraftingRecipeDM.jar' in folder 'plugins'
13.11 21:36:39 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Could not parse ChatColor #FFFF
That hex color is too short
ok wtf
can you give an example?
white = #FFFFFF
this.idMap.computeIfAbsent(id, k -> Collections.newSetFromMap(new IdentityHashMap<>()));
im stupid then.
should create set inside hashmap right?
but guess what
whenever i try to output the result to console
java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.Map.get(Object)" is null
What map implementation
IdentityHashmap<Integer, Set<>>
another identityhashmap works properly
with the same method
IdentityHashMap does not work with Integer
Ya so that might be why
Because integer is a value based class where Integer(6) and Integer(6) can be different instances thus different keys
No there isn’t
However afaik Integer provides an O(1) time complexity
For containsKey etc
get
Int2Object Map btw??
Yuh that too
Believe there’s an open hash map implementation for that with fast util
idk about spigot but paper provides fastutil maps n collections
If you care about performance.. I'd use guava multimap in your case tho
the Map<?, Collection<?>> is just bulk to work with. A multimap is a fancy wrapper around
Actually I don’t know if a HashMultimap<Integer,V> or if OpenInt2ObjectHashMap<Set<V>> is faster
but i need memory comparison hashmaps
Don’t remember the exact name for the latter but it’s something like that
like, as i said before, if you care about performance use fastutil
if i ask Integer == Integer i mean 0xFF00 == 0xFF00 without any exceptions
IdentityHashmaps doesnt allow integer type. I need to store entity ID's in there for quick search times
that's the problem
Why do you need an IdentityHashMap
because its faster than vanilla hashmap?
It works similarly to an IdentityHashMap with int as a key
lemme see
Yeah put it up in some benchmarks
uhm... Who said that? It can be used in specific cases,but that really depends on equals impl
I use the same object references thus i don't need map impl which calculates hashes based on object's value, i would like to use memory address as a key
Well ints are stored somewhere, right
directly
even on stack it haves memory addresses
Actually dovidas, I believe the jvm allows the Integer cache size to be increased as a jvm flag
But really Int2ObjMap is probably your goto here
what i would do is to convert base 16 (HEX) to base 10 (Normal int system) and then add up and convert back to base 16 (HEX), but im pretty sure there's algorithm to add these up directly
u got link?
ty
impl something like this in your code
and you're good to go
although you can pirate code from stack overflow
Tbh that sounds like
"I just found out what identity hash map is lets abuse it anywhere if possible because fsdt optimization"
Premature optimizations are evil
This class is not a general-purpose Map implementation! While this class implements the Map interface, it intentionally violates Map's general contract, which mandates the use of the equals method when comparing objects. This class is designed for use only in the rare cases wherein reference-equality semantics are required.
@mortal hare you are very picky about the slightest performance
I like it
im just prototyping
you know what
fine
im gonna use vanilla hashmap
but only for set
thats just waste of time. Better do some elegant design that would be easier to work with and maintain in future rather than fucking with map implementation
Well, Multimap is your friend
I swear if i were in a some sort of dev team, i would nag everyone that someone just wasted something on resources
i can't control this..
i feel like im coding on commodore 64
Just optimizing to its very extent isn’t always optimal as a whole, sure optimizations are fun. However, optimization isn’t just speed, clean code optimizes maintainability etc. Anyways if you end up optimizing speed, I’d advice you to make it a functional requirement because obviously a non functional requirement is a fast software. Making it a functional requirement can be done by for instance putting a requirement on it such as "this is going to be able to index 3,000,000 users in 10 seconds" or something.
Probably a dumb question, but what is a quick way to check if a material is a block (i.e. it can be set/placed)?
ah, thanks
How would u make a while true statement that will always run and would work when restarting the skript. if u just put it to like skript start event then it wont change if u reload the skript
this is java development channel
seek for skunity's discord server
oh sorry wrong server
np
@mortal hare You cannot access the memory address of a stack type without Unsafe usage, but at that point the value is no longer on the stack, and instead allocated somewhere in off-heap memory, and requires manual deallocation (freeMemory).
is there an easy way to change from spigot to paper apis? im using the mc plugin development plugin if that helps
Actually, as a general rule, you cannot access anything's memory address in Java (unless it's via foreign memory in Java 17+) without Unsafe.
ik, i'm just used to C/C++ pointer stuff
i miss those
but eh
kinda not at the same time
I mean I understand ya considering I too love manual memory but
set your depenency to paper
Java isn't the kind of language for that.
yes, the spigot server is definitely the appropriate place to ask how not to use spigot
True
||Helping people get away from spigot||
im trying to make a plugin with nms (the mojang mappings) and im getting this noClassDefFoundError. Does anyone know what might cause this?
probably
and if it didn't, you know there's a bug tracker where you can put feature requests
this was for you @near shoal
oh i think so
yeah you need to remap it back to the unmapped code when distributing it outside of a dev environment
pretty sure cause im using things that are only in the mojang mappings i think
mojang mappings aren't used in MC's production jars soo the names conflict when placed in a prod. environment
ok so how would i remap it back to the unmapped code then
also that seems like a pain to do that every time u wanna test if it works
im using maven
what about Gradle, markdown_fifth?
make sure to change to 1.17.1, the commands are still 1.17
any special source gradle alternatives?
alright thanks looking through it now
📰 🏋️
any way to automatically update the built jar to an ftp automatically? kind of annoying to keep dragging the jar over to the ftp client
Ik a gradle plugin that can do it
maven moment
does vannila mc use maven or gradle or anything like that?
so ive added the example maven config to my pom.xml and replaced the 1.17s with 1.17.1 but im still getting the same error
java.lang.NoClassDefFoundError: net/minecraft/world/entity/player/Player
Could you show your POM
Good question, not sure anyone knows
post the entire thing here?
should i add "final" before my method parameters when possible
did you build with maven and not your ide
<outputFile>C:\Users\shada\OneDrive\Desktop\1.17 server\plugins\terminator.jar</outputFile>
this probably breaking it
try removing that
so where will the output file be then?
in the target/ folder of your source dir
if it works you can change the target in the specialsource goal instead
ok so theres 4 . original, normal, remapped and remapped obf
normal
those were there before and after building
yessssssss no errors
now to test if the plugin actually works
and the plugin works too!
thank you so much for helping me
no worries
I’ve been stuck on this for a few days and probs would have quit soon
in intelij is there a way to automatically change my output file location on project creation
For maven theres a param
player.sendMessage(ChatColor.valueOf("#9874d3") + "The Bank Heist Has Begun!"); How do you make this text into hex it
since this is wrong.
I have tried ChatColor.of(Color.("hex") btw
it doesnt work for text
use Bungee in spigot?
I think you have to listen to EntityDamageEvent and cancel if the damaged entity is an item
itemMeta.getLore().add("test"); should add "test" to an items lore correct? regardless of what lore the item previously had
Think getlore may return a copy
ChatColor.of
The ChatColor bungee component is built into Spigot
how do i create a item entity that isnt stackable
ChatColor.of
make sure it’s the bungee one tho
gives me error
oh? so how could I add to a lore regardless of if it has lore or not?
post error
Store getLore to a variable and if it’s null set it to a new arraylist
Then use setLore
is there a better way to do this?
// get number of occurrences with percentage and times ran
public int getOccurrences(int timesRan, double percentage){
int occurrences = 0;
for (int i = 0; i < timesRan; i++){
if (Math.random() <= percentage)
occurrences++;
}
return occurrences;
}
please @ me
getting this error with my ServerConnectEvent: java.lang.NoClassDefFoundError: org/bukkit/entity/Player
note, this is bungeecord
bungeecord doesnt have bukkit i dont think
its proxiedplayer
@wild grove
Sometimes java make me nuts REEE
i were sitting and wondering why my List keep running null on first load
doesn't work
Hello!
Why since 1.17 the versions of NMS classes packages are no longer specified, but the names of CraftBukkit packages still contains server version?
List = Config.getList(VAR_Path); Before Gives Null
List = (List<?>) Config.getList(VAR_Path); Now
can't believe this was actually my mistake
that's kinda how nms works....
oh shoot
i misread
tbh it's kinda one step into the right direction imo
hello, how to manage the bidding of residents and the loss of totems from casters on version 1.16.5
hi)
how can i prevent an item from being picked up
item.setPickupDelay(-1); this didn't work
Set it to Integer.MAX_VALUE
@young knoll
how to manage the bidding of residents and the loss of totems from casters on version 1.16.5
that sentence seems like it only serves the purpose of sounding sophisticated
Actually looks like Short.MAX_VALUE
What
oh
The wiki says it will not count down if set to 32767
Also keep in mind hoppers will still work
how can I change
trade
villagers
and
totem drop
the translator is bad(
public void SetUp() {
List<?> list = getList(DefaultFile(), "Noob", (List<?>) Arrays.asList("Fairy","Joe","Jiff"), true);
Bukkit.broadcastMessage("List:" + list);
}
public static List<?> getList(File File, String VAR_Path, List<?> VAR_LIST, boolean Do_Set) {
YamlConfiguration Config = getConfig(File);
List<?> List;
List = (List<?>) Config.getList(VAR_Path);
if(Config.getList(VAR_Path) == null) {
if(Do_Set == true) {
SetList(File, VAR_Path, VAR_LIST);
List = Config.getList(VAR_Path);
} else {
List = (List<?>) Arrays.asList("");
}
}
return List;
}
why does this run null on first run?
хз
I'm missing something?
Yamlconfiguration.isSet
Same thing
some code must be wrong
it only seems to work second time
So then i do getList(DefaultFile(), "Noob", (List<?>) Arrays.asList("Fairy","Joe","Jiff"), true);
2 times it runs perfectly fine
i could if null repeat itself?
on set
np any way thanks for giving information
Does anyone know how to reverse this? ```
{
ItemStack item = new ItemStack(Material.AMETHYST_SHARD, 4);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.of("#9874d3") + "End Shard");
List<String> lore = new ArrayList<>();
lore.add("Fragment off a burning planet");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK, 1, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
ItemStack endshard = item;
//actual shapeless recipe
ShapelessRecipe sir = new ShapelessRecipe(NamespacedKey.minecraft("endshard"), endshard);
sir.addIngredient(1,Material.DRAGON_EGG);
Bukkit.getServer().addRecipe(sir);
}
ItemStack item = new ItemStack(Material.AMETHYST_SHARD, 4);
ItemStack degg = item;
}
```
so the lore item turns into dragon eggs
does BlockDamageEvent apply to bedrock
it only gives me the string version like this; valueof(string arg0)
chatcolor
ArrayList 1_Item_Lore = ItemMeta.getLore();
2 Item:
Item2Meta .. setLore(1_Item_Lore)
Item2.setMeta(Item2Meta)
Not valueOf
of
how can i edit entity hitbox size?
i said it exact same >of<
.
yes ty very much
glad to help 🙂
i can pretty much most all the simple java stuff and some basic spigot
mns is too hard for me
how do I check the nbt data of a tool used in the playerinteractevent ?
i have one simple question
Do you guys use protected keyword often? If so, do you feel bad for breaking encapsulation?
or you're the i'll encapsulate as much as I can guy
What NBT data
for example CanDestroy
that doesnt even makes sense
first of all, you mostly use the protected keyword to share a variable or method via inheritance
second, with protected still encapsulation is possible and useful but in some cases unnecressary
i wonder how anonymous classes access outer anonymous class fields
do they access it directly, or they store reference variable inside it
not they, you. anonymous classes just have or access what you give them to access
well if you use ClassName.this you can access outer class variables
yeah like you already said
im just wondering how anonymous classes store the references inside
or do they access the fields directly via this keyword
anonymous classes are just normal classes within your code. they act like if you would implement/extend another class with it
they dont have any really different behaviour
as i said, there are many ways to access the field.
and also you can store the reference
thats a design thing and totally up to you
well yes, but whenever you extend class in new .java file you don't have access to class field, while anonymous classes have this functionality by default
im not asking for a design opinion, im asking how that field passing works internally
no matter what field is it, private or public it could access it
when you instantiate an anonymous class within another class its still a part of the other class so you can access the fields
im just curious
its like nested classes
you are still inside your class but within another class
better said they still underly the class you instantiate them in, even if they are an own class
How can i change nms entity hitbox size?
you can't, unless you are creative and decide to add other entities
like slimes
and combine their hitboxes
but it will do nothing
mhm
since the client has its own definition of the hitboxs size
I mean
well you can, but you need to do pathtracing
You could reimplement combat server side
there's no easy way to do this
just a hacky way
hmm, ok thx!
To be fair path tracing is pretty easy now
Used it to let players swing through grass and stuff
How to update BossBar for players, I use setProgesss(), but it doesn't update
well path tracing concept is simple. Do something until it detects something along the path
The API has methods for it
yea i saw it
How do I detect the following actions in order to prevent them?
- Break a block
- Place a block
- Open a check
- Hurt player (or any entity)
- Redstone usage
- Spawn of entity (other than player)
actually to properly ray trace stuff manually you would need to get NMS bounding boxes
events are a thing
BlockBreakEvent, (I believe) BlockPlaceEvent, PlayerInteractEvent, EntityDamageEvent, (idk), CreatureSpawnEvent
Yo I did it :))
i fixed my Config setList Mothed
anyone know how i could have 2 separate vault economies
e.g. "tokens" and "money"
without using, plugins which require /<pluginname> <econame>
When you get a UUID from lets say a Skeleton, does the UUID for that mob ever change?
EntityID
getUniqueId()
Check if Entity is not Player
Store the UUID of the Entity
put a Check if the entity contains list for each Event
if it contains in list setcancel
remember to save the list to a config
You can store the Entities how ever you want and get Entity
i believe you can also store the Entity itself
is there a built in method or something to check if a string contains only alphanumeral characters?
Is there any way to create a double echest ( like double chest )
you could make a double chest gui and store every item in every slot
i have a quick question about maven, lets say i add an api (jda) for example. is the .jar file supose to be bigger?
probably
yes
place first chest and place second chest near -1 or +1 of a block like X or Z
Not really but you can compile a regex pattern if you want
wdym
private static final Pattern PATTERN_ALPHANUMERIC = Pattern.compile("[A-Za-z0-9]");```
is regex an external api i'd need to import?
No, native Java
ah ok
what do i do with this?
So this UUID would persist through a restart?
Can use that expression with PATTERN_ALPHANUMERIC.matcher(string).matches()
Just wherever you need
The Pattern? Yeah. It can be a field so it only has to compile once
awesome
@foggy estuary
you first choose a Location
you set first chest at that Location
you take the Chosen location and minus it by - 1 or + 1 at Neither x or z
then you place another chest at the new location
I mean that won’t magically make a double ender chest
well if it is a double ender chest not possible
but he could make a Double Chest GUI and save it to a file
i miss it 😅
the enderchest part
why does my config not save my comments, I use saveDefaultConfig(); to generate the config when enabling my plugin
First set
then save
Not Sure if saveDefaultConfig() override itself on creating agein agein (i have not tested or look at it)
else... check if file is not existing
snakeyaml doesn't support comments, only the one at the very TOP (header) iirc if you overwrite the config it'll remove every comment except the header, or smth like that
bruh BlockRedstoneEvent cannot be cancelled...
been a while since I've done a config tbh
that weird hmmm
EntityMoveEvent?
Sad only paper has EntityMoveEvent
No but you can setNewCurrent(0)
Or at the very least, setNewCurrent(getOldCurrent())
wait i faund org.bukkit.event.entity.EntityEvent
Yes. All entity-related events extend from it
It's a base event
You can't listen to it, if that's what came to your head lol
You can't use Listener?
i gotta test
No, you can't use Listener. EntityEvent has no handler lists
You cannot listen to that event ;p
i saw..
It exists solely to supply an Entity to child events
There exists also PlayerEvent, WorldEvent, ServerEvent, and BlockEvent
@worldly ingot what would you do to block Entities Moves?
Slowness 255 or something lol
AI False lel
Or add a modifier to their movement speed attribute
Yep, disabling the AI as well is also an option
oh nice!
got the idea
disable AI on Spawning XD
for the specific mob 👍
im trying to install jdk17, but its giving me jdk11
this is the link im using: https://jdk.java.net/17/

