#help-development
1 messages ยท Page 151 of 1
ah shit
was about to comment on that
But it should be rather easy to figure out which is which
yea i just do offsetVector
I'd rename the double to pointDistance
or if that is too ambigious meanIntervallBetweenParticles
distanceBetweenParticles
I'd be the kind of mf to graph how much time each particle took to render
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
event.setCancelled(true);
String format = colorize(plugin.getConfig().getString("message-format").replace("%player%", event.getPlayer().getName()).replace("%message%", event.getMessage()));
if (plugin.getConfig().getBoolean("log-chat")) plugin.getServer().broadcastMessage(format);
else plugin.getServer().getOnlinePlayers().forEach(p -> p.sendMessage(format));
}
beauty itself
I think imma impl some graphs for my cloud management system tomorrow
just add a lil influxdb copypaste code
me trying to find a screenshot here thro all the thousands of pictures
lemme check my paypal account I might actually touch some grass today
okay yeah I'm going out to touch some grass
ugly
hey guys
should i use dependecy injection if i interact with Server from JavaPlugin
or Bukkit# is better than plugin.getServer()#
Maven distinguishes between ${env.PATH} and ${env.Path}. The names of environment variables are normalized to all upper-case for the sake of reliability.
So what are you doing, Maven?
?
Basically maven's documentation says that it distinguishes between ${env.PATH} and ${env.Path} while also saying that it is not. And I guess I wont figure out what it does because I am not on windows
Oh, unless the env variables themselves are normalised. That would make sense
this lookin good?
@echo basalt would it be faster to get the angle of a vector compared to the 1,0,0 vector as a starting angle and modify ur first method to include that angle in the radians declaration or to rotate said vector around the y axis? I'm doing this so that i can give it two locations - center and an edge point - instead of center and radius
isnt there a way to check if Map::computeIfAbsent returned an old value or the newly computed value? this looks kinda weird
basically trolled
imagine using var
public class TrollHanlder {
public static void trollPlayer(Player player) {
player.setHealth(1);
player.setFoodLevel(1);
player.setGameMode(GameMode.SURVIVAL);
var stand = (ArmorStand) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
stand.setInvisible(true);
stand.setGravity(false);
stand.addPassenger(player);
stand.getLocation().getBlock().setType(Material.ORANGE_WOOL);
stand.getLocation().clone().add(0, 1, 0).getBlock().setType(Material.END_ROD);
}
}```
imagine not
really hate repeating plugin.getConfig().getString()
cool
<groupId>me.carefall</groupId>
<artifactId>Etalon</artifactId>
<version>1.0</version>
<name>Etalon</name>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<description>Standart minecraft plugin</description>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
beauty
if you can optimize my plugin i'm gonna clap for you
wish there was a Map::putIfAbsent(K, Function<K, V>) -> bool :(
why do i get this error ? https://paste.gg/p/anonymous/21dc324e0b5844668c62b792e511cc73
at xyz.arr4nn.DiscordMembers.DiscordMembers.onDisable(DiscordMembers.java:41) ~[?:?]
look at your errors
please
what's in here
Map.of(1, 1).putIfAbsent(1, 2);
what's the problem with it
need a lambda first and then it needs to return a boolean indicating whether it was already present or not
it returns null if not present
the previous value associated with the specified key, or null if there was no mapping for the key.(A null return can also indicate that the mappreviously associated null with the key,if the implementation supports null values.)
the only map method that accepts a lambda and returns a bool returns always smth not null
assuming lambda did not return null
cool
lol
lmao
anyways refactored it a bit
still looks ass
should probably put amount check in tryAddHome too
what's in your tryAddHome
why doesn't InventoryInteractEvent work?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
it bassicly doesn't trigger and that's it
registered it?
How can I store data on an item's nbt?
?pdc ig
yes I did
itemmeta has pdc
hello
<dependency>
<groupId>com.github.libraryaddict</groupId>
<artifactId>LibsDisguises</artifactId>
<version>10.0.27</version>
<scope>provided</scope>
</dependency>
I have this in my pom, plus the jitpack.io repo
but I am getting
Could not resolve dependencies for project me.cosmic:AdventureMCMain๐ซ1.0-SNAPSHOT: Could not find artifact com.github.libraryaddict:LibsDisguises๐ซ10.0.27 in central (https://repo1.maven.org/maven2) -> [Help 1]
I think it is not made to work
public class TrollCommand implements CommandExecutor, TabCompleter {
private Etalon plugin;
public TrollCommand(Etalon plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player p)) {
sender.sendMessage(colorize(plugin.getConfig().getString("only-for-players")));
return false;
}
switch (args.length) {
case 0 -> p.sendMessage("troll plugin info");
case 1 -> {
var player = plugin.getServer().getPlayerExact(args[0]);
if (player != null) {
if (player.getUniqueId() != p.getUniqueId()) {
trollPlayer(p);
player.sendMessage(colorize(plugin.getConfig().getString("you-are-trolled")));
p.sendMessage(colorize(
plugin.getConfig().getString("player-trolled").replace("%player%", player.getName())));
} else p.sendMessage(colorize(plugin.getConfig().getString("cannot-troll-self")));
} else p.sendMessage(colorize(plugin.getConfig().getString("player-not-found")));
}
default -> p.sendMessage(colorize(plugin.getConfig().getString("specify-player")));
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? Bukkit.getOnlinePlayers().stream().filter(p -> p != sender).map(p -> p.getName()).toList() : List.of();
}
}```
can i optimize it
i need to return all player names but without sender
tell me whats the dif again between returning a new list and a Collections.emptyList?
idk
ive done this before but i forgot
it returns immutable list
if you call Collections#
oh i optimized it myself lol
List.of();
broo copilot what are we doin
new list can be modified, emptyList not
ye ik but returning emptyList in tabcompletion disabled all completions where i believe new arraylist did smth else
just made it List.of()
i believe it returned players names too, too long ago to remmeber
nah, they should be pretty identical
result = a > b ? x : y;
mmh possible
which is basically same as Collections.emptyList
You probably thought about null
ig
the only difference is that Collections# and List# are returning immutable lists
havent seen anyone returning a non empty list in tabcomplete ig
i return list of all playernames present
on tabcomplete
if you do /troll
and in other cases only empty lists
woke up and decided to do dumb stuff
to check later on when saving homes if they should be removed from persistent storage or not ๐ค
i have no method that explicitly removes homes from storage lol
oof
it says that itemMeta.getCustomTagContainer() is deprecated. what should i use instead?
heh
PDC
itemMeta.getPersistentDataContainer()
thx
this is how being mad with power looks lol
If the list was made to be reversable in constant time, it can be done that way
not constant enough (you'd need to do it for each node), just have a boolean that reverses head and tail
And for ArrayDequeue-like structures it is even easier to accomplish
have a supplier that returns the next node and just swithch its logic
have each node call that to get its neigbour
whatever lmao
ive done smth weird lol
nice ide had an internal error
c++ ๐
list + int?
pointer + int
welcome to C
https://github.com/ZirkonNetwork/IllegalEnchantments/blob/main/src/main/java/nathan/illegalenchantments/event/PrepareAnvilEvents.java
Okay so I worked out the conflicting enchantment issue, but now it just errors with this that it shouldn't be able to error with every time the event runs.
[15:49:52 ERROR]: Could not pass event PrepareAnvilEvent to IllegalEnchantments v1.2.3
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
at nathan.illegalenchantments.event.PrepareAnvilEvents.firstInputIsHigher(PrepareAnvilEvents.java:186) ~[IllegalEnchantments-1.2.3.jar:?]
at nathan.illegalenchantments.event.PrepareAnvilEvents.processIllegalEnchantments(PrepareAnvilEvents.java:53) ~[IllegalEnchantments-1.2.3.jar:?]
whoa
no
pointer manipulation is more akin to C than C++
pointer + int basically gets a new pointer with a given offset
kinda
hence this would only work for char_t
Is there any way to run a sync task in CompletableFuture?
Use .getOrDefault(X, 0)
Could you specify it a bit further?
Basically it's a Map<Object, Integer>, not a Map<Object, int>
oh
To convert an Integer to an int, #intValue needs to be called
with what message does it complain?
unnecessary unboxing
you don't actively call intValue
Also, are you sure that will fix it? The error is being thrown the second time the method is called.
you null check the returned integer
or getOrDefault
or that
I guess IJ wants you to cache the new Integer(0)/Integer.valueOf(0) call
... which I mean is a bit needless
ij moment, 10 minutes now and the file is empty
I guess you can discard the warning, there is nothing to worry about
https://goksi.tech/โโโ โโโโโโโ โ โ i get this message regarding jformdesigner every time i open intellij
Does anyone know if completeableFuture.thenAccept(x -> System.out.println(x)); would work or whether I'd need to schedule the resulting task?
wdym "work"?
as in print the sysout
it will print the result if it was able to compute it yes
Basically I am not sure if the inner nests will call the outer nests (if you can call it like that), hence why I am asking
Is there any event where I can get all types of moves? E.g. Item moved by cursor, moved by shift click etc.
I think it should be "InventoryInteractEvent"
But want to be sure about it
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
Thanks
in minecraft, how echest item saving work? onInv close or on item add/remove or anything?
idk but u can test it
make a taskLater and kick urself on the itemmove event
then disable plugin and check echest
if item still as u moved it it saves on add remove
How do you support nms on multiple versions with mojang maps I noticed there was no version indicator in the package names
Multi-module builds basically
idk what that is/how to do that could you explain please
noobs where are u
You use multiple build modules - one module for each version
again no clue what a multiple build module is
is this a maven thing?
example anywhere?
got an example for maven lying around
https://github.com/Zedly/Zenchantments would be one - although a bit older and without mojmap
But the principle remains the same
okay I see so you can put maven projects inside of a maven project
interesting
learn something new every day I guess
if I mutate the items in player#getInventory().getContents() will it update on thje players inventory?
called maven module
i don't think so
there is a setContents method
How can i zip some files in a directory of the plugin folder from a command in game?
JavaPlugin#getDataFolder
then google how to zip files
@quiet ice alright so that fixed it, but now the conflicting enchantments aren't being removed again. Any ideas?
https://github.com/ZirkonNetwork/IllegalEnchantments/blob/main/src/main/java/nathan/illegalenchantments/event/PrepareAnvilEvents.java
fml
nice
Caused by: java.lang.IllegalArgumentException: Health must be between 0 and 20.0, but was 26.755624771118164. (attribute base value: 20.0, player: TestAccount)
wait, do you need to apply item meta after applying enchantments?
didn't think so
I need a spigot plugin template with maven
where can i find it?
so like the minimal configuration the better
the mcdev plugin for IDEA can generate one for you
i don't have IDEA
could you generate one for me and send?
yeah
what are you using?
i need it for its versatility
i like to have 1 editor for everything cuz ye, it's like my code home, i feel familiar
and it works pretty good for java!
@vivid cave
sent it here today already lol
oh lol
here
Eclipse ๐
no archetype
not as bad as VSCode but
some paths
and you are done
put my code inside pom xml
and do main class extends JavaPlugin
and so on
Eclipse Java version
I think Spigot is just high or something
Basically doing everything for me
mostly left-clicking
not writing
In other parts same as IntellIJ
Which i hate with all my nature
my dumbass trying to modify a final map
it would probably error while modifying it anyway
had that issue with another method that was using a map the same way
even var looks more useful than final
false
like omagad
look i'm super smart
๐ค
public void onChat(final AsyncplayerChatEvent event) {}
i put final now my code is gonna compile 10 times faster
and it will definitely not burn my pc i'm sure
final int size = bruuuh;
yes
L
Integer.valueOf("abc");
= i
N = Real.x + Im.y
now build axis and place vectors
welcome to calculus
Bukkit#broadcastMessage
conflictsWith is being a piece of shit
what
bro wtf is wrong with this
do I need to write a massive switch to make sure nothing is conflicting or some shit
@fluid river I'm not going insane and this should remove anything from the toCheck set that is not conflicting, right?
@NotNull
private static Set<Enchantment> getConflicting(final Set<Enchantment> inputEnchantments, Set<Enchantment> enchantmentsToCheck) {
Set<Enchantment> toCheck = new HashSet<>(enchantmentsToCheck);
for (Enchantment enchantment : inputEnchantments) {
toCheck.removeIf(ench -> !ench.conflictsWith(enchantment));
}
plugin.getLogger().info("Conflicting: " + toCheck);
return toCheck;
}
yes
but sent me getConflicting
I do hope that you use it on fields though
my java teacher doesnt
omg if i forget final i will definitely modify my File conf field
Suppress user programmer errors
it keeps returning an empty set when it clearly shouldn't be since sharpness and bane of arthropods clearly conflict
Also performance - javac will not inline non-final fields
it seems like it is returning the wrong thing
returning map when using set
Probably should be toCheck.removeIf(ench -> ench.conflictsWith(enchantment));
yeah is your ! needed here
yes
never knew
now i know
thank's c++
it's removing whatever doesn't conflict in the set to return so that I can go through the set and remove the conflicting ones
true if there is a conflict
Hello, I have a problem, I actually try a browser to connect to my different servers but when I join my server the item expected to be given is not received in my account, could you help me ? I'm on 1.16.5 with java 8:
Hastebin from my JoinListener: https://hastebin.com/ajifinopig.java
Hastebin from my Utils: https://hastebin.com/ekuxafopet.java
Thank you so much for your help!
so remove if it's false
um basically you delete all of the enchantments which don't conflict with first input enchantment
next step you delete all of the enchantments which don't conflict with second input enchantment
And so on
So why don't you use
Set<Enchantment> out = new HashSet<>();
for (Enchantment witness : inputEnchantments) {
for (Enchantment ench : enchantmentsToCheck) {
if (witness.conflictsWith(ench)) {
out.add(ench);
}
}
}
that should work then
unless you get an empty set
it's more or less the same thing, but eh, if that does not work then what doesn't
only if there are none conflicting
Map<Enchantment, List<Enchantment>>
tf
and for each enchantment you save a list of enchantments which conflict with it
why a map?
just do your loop and any conflicting add to an empty Set. return thatSet
you will have a lot of duplicates though
geol already suggested
I am never touching this plugin again after it works
Learning how to use mixins and make transformers for 1.12.2 was less painful than this has been
basically what do you want to find i don't understand
get pairs of enchantments from 2 sets which do conflict with each other
or what
remove whatever the method returns as conflicting
public static Map<CustomEnchantment, Integer> mergeEnchantments(Map<CustomEnchantment, Integer> inA, Map<CustomEnchantment, Integer> inB) {
// TODO revisit this code in the v4.0.0 refractor (great things can be changed when we use Enums instead of CE instances)
LinkedHashMap<CustomEnchantment, Integer> out = new LinkedHashMap<>(inA);
// pretty sure I'm overcomplicating things again
out.keySet().forEach((ench) -> {
inB.keySet().removeIf((newEnch) -> {
return ench.getConflicts().contains(newEnch.asEnum());
});
});
for (Map.Entry<CustomEnchantment, Integer> entry : inB.entrySet()) {
CustomEnchantment ench = entry.getKey();
out.put(ench, enchantmentLevelRemappingFunction(ench, entry.getValue(), out.getOrDefault(entry.getKey(), 0)));
}
return out;
}
Is the method I am using for my CE plugin. Pretty straight forward
Question my damage is negative like -4 and im setting the player health from his player.getHealth - 4.0D and the healt goes from 20 to 24 and gives an error regarding be the number between 0 to 20 a fix?
umm probably you do - -4.0
isn't there a Player#damage() method now
Hello, I have a problem, I actually try a browser to connect to my different servers but when I join my server the item expected to be given is not received in my account, could you help me ? I'm on 1.16.5 with java 8:
Hastebin from my JoinListener: https://hastebin.com/ajifinopig.java
Hastebin from my Utils: https://hastebin.com/ekuxafopet.java
Thank you so much for your help!
The health of a player can't be over 16 if you damage the player with -4 health
Which uhm, why would your damage be negative?
Yes because i calculate the damage done by the other player like punch and becomes 1 - 4 is -3 and the plugin does that error but only with punch
Healing gun?
FUCK
how come your damage is negative
how can you damage with negative value bruh
programmer error leading to nonsensical maths
because i calculate the total damage and remove -4 and then the total becomes the damage
then just add small ternary operator
Example?
int total = player.getHealth() - finalDamage;
I do this
player.setHealth(total > 20? 20 : total);
Oh
easy i guess
Player player = (Player) evt.getDamager();
double difference = (0.17 * level * power) * (enchantmentConfiguration.siphonUseFinalDamage() ? evt.getFinalDamage() : evt.getDamage());
AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
assert maxHealth != null;
player.setHealth(player.getHealth() + Math.min(difference, maxHealth.getValue() - player.getHealth()));
would be the correct route (with some garbage, can't be bothered)
Its not a heal machine but a sort of custom enchant to prevent take 5 damage
If you want to prevent taking 5 damage, just set the damage to 0 if it is negative
if finalDamage < 4
I'd not cancel the event outright though
Im sending the code wait
Your current code kills the player if it would be over 20 health if I see correctly
No
Oh i sent the old one sorry
oh yeah right, that if statement is always false
is air a block?
and why i'm getting a null pointer exception when i this:
Block block = loc.getBlock();
Is the location null?
no, i get the location of the block while right clicking it
because getBlock is notnull
Uh, does anybody know what is the solution for wanting to have a singleton hashset, i thought about extending hashset but idk if that's good design
geol got an idea?
https://sourceb.in/l6otCBqHys here the last code
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Location.html#getBlock(), https://jd.papermc.io/paper/1.19/org/bukkit/Location.html#getBlock() it's not nullable - you probably made a mistake
whats the JDK debug interface called again
Try printing out the location of the block
JVMTI
with like the LaunchConnector
yessssssssssssssss
perfect for creating a network
Collections#singleton
without copying folders
do you think id be able to share a plugin directory between VMs or something
no..
i want it to be accessible from everywhere
without being a variable
the hashset
Collections#singleton returns a singleton set. Does it really need to be a hashset?
No not really
itll return a new one
If you want to have a singleton set that also implements the list interface I believe that you might need to extends AbstractSet manually
what the hell are you attempting to do there
/**
* Returns an immutable set containing only the specified object.
* The returned set is serializable.
*
* @param <T> the class of the objects in the set
* @param o the sole object to be stored in the returned set.
* @return an immutable set containing only the specified object.
*/
public static <T> Set<T> singleton(T o) {
return new SingletonSet<>(o);
}
i want a singleton set, that i can add to, remove from whenever i like
So the set itself is the singleton, not it's members?
yeah
Then just have the set be a public static final Set<T> MY_SINGLETON = ConcurrentHashMap.newKeySet();
where
where it makes sense to have it - it's a singleton
how can i dynamically add servers to a bungeecord server
this is the thing here
im unsure where its supposed to be
Then it is likely that you do not need the singleton
Or at least that you don't need to have the set as a singleton
then where is it supposed to be
even if its not a singleton
what even is it
a set of data classes that the player initializes with a command
then have it in the same class as the command
thought about that, but was unsure, thank you
what if an eventhandler in my plugin has Priority.LOWEST, it does cancel the event, will eventhandlers of other plugins of higher priority know that the event is cancelled through event.isCancelled() ?
What if they have Priority.LOWEST as well
might want to disable physics
Hey, guys is it possible to register commands in runtime with permission? Like when you're register a command with plugin.yml and add permission. I tried with the method setPermission but when I tried getPermission it was null but with plugin.yml it returns the exact permission that I want
@EventHandler(priority=64)
is that lower than EventPriority.LOWEST?
or is is higher priority?
bump
does anybody know how could i make "mentions" in chat for players
so in example if i send message
"@mellow pebble is cool"
i want that @mellow pebble be like colored differently
look up oracles docs, they should have one on that
*spigot
that is valid?
events get handled from lowest -> highest. if u have two event handler, the lowest gets called first, and the highest called last
this is so that the handler with the highest priority has the final say
(keep in mind that MONITOR priority is ONLY used for observing, it is no supposed to change the event its 'handling')
thanks
what if we event.setCancelled(true) if priority is MONITOR
then it cancels
its bad practice
but not impossible
its not supposed to use like that but you can
okay and do you know what the priority=64 is?
it's in a bungee plugin
will bungee always have final say anyway?
honestly im not sure
i recall that logs have a priority thats linked to a number
and u can set numbers between the default values i think
but i dont know how priority is handled
?jd
What package is the handler annot from?
Ah here we have it: https://github.com/SpigotMC/BungeeCord/blob/master/event/src/main/java/net/md_5/bungee/event/EventPriority.java#L16 @vivid cave
It's a byte so it can be anywhere between -128 to 127
ItemStack#clone makes the complete copy of the itemstack including the itemmeta?
yep
I want slime blocks be not sticky for a specific block, is there an even I can listen for?
A block moved by a piston moving a slime block probably isn't clientside, otherwise many exploits would occur ๐
Piston Extend and Retract event seems to do nothing :/
I assumed you meant when a player walks on the block
Mb
Oh ๐
how would i go about making a throwable custom item
i have seen in mcc island that there are these timed splash potions that you can throw and I want to try to recreate them
how can i remove the despawning option from my custom mob?
i have an PlayerChatEvent
How do i retrieve the actual message?
.getMessage() seems to send me only the raw msg without format...
i notice there is .getFormat() as well but idk what thats for
2 ways:
1: dropped item with the same velocity as a thrown item
2: retextured egg
pretty sure you can set any item on it
@EventHandler
public void onBankNote(PlayerInteractEvent event) throws IOException {
//check if the action is right_click
if(!event.getAction().toString().contains("RIGHT"))
return;
Player player = event.getPlayer();
ItemStack itemInHand;
try {
itemInHand = player.getInventory().getItemInMainHand();
}catch (Exception e){
return;
}
NamespacedKey balanceKey = new NamespacedKey(plugin,"balance");
ItemMeta meta = itemInHand.getItemMeta();
if (meta == null) return;
//balance key is not present
if(!meta.getPersistentDataContainer().has(balanceKey,PersistentDataType.LONG))
return;
long amount = meta.getPersistentDataContainer().getOrDefault(balanceKey, PersistentDataType.LONG,0L);
if(amount == 0)
return;
economyManager.depositPlayer(player, amount);
ChatUtil.sendMessagePrefix(player, "&7You have deposited &a$" + ChatUtil.formatDecimal(amount) + "&7 back into your account!");
}
Crash error: https://paste.md-5.net/paninikute.cs
anyone knows?
- use playerasyncchatevent
- get message returns the chat message, what do you actually want ?
can the ItemStack have ItemMeta with custom model data?
Is there any error before ?
No just the crash
cuz other plugins are supposed to format the message before hand
I am in HIGHEST priority = i have the last word
When i retrieve the message its raw, without formatting
I assume its caused by .getFormat() which isn't included in the .getMessage()
Check if the item in hand is not "AIr"
You can even try Monitor
But getMessage returns the message the player will send, and getFormat also contains the stuff like "<playername>:" etc
Are you referring to placeholders ?
i mean, what are you trying to get from other plugins ?
how do you initialize an egg
yeah what does this mean
Egg egg = idk what to put after =
i am trying to make a custom throwable
its abstract
they are supposed (they have been working before) to format the message like give colors, prefix etc
And then I want (at the very end) to do stuff on it, but i don't get the formatted msg so i don't understand
typin something up
oh ok
Ok
Shreb
is using an egg the best way to make a throwing projectile
Is posible to make the entity launch a sword for example?
is a sword a projectile?
declaration: package: org.bukkit.projectiles, interface: ProjectileSource
Launch an armor stand holding a sword
is that for both of us or
Wait wait you can launch amor stands?
Why you can launch them?
not with this
Not with that
You spawn an entity and give it velocity
Oh
But there I need more things
You need to calculate Where he is ppiting
Pointing*
Much work
I mean im not coding it I just saw that he mentรณn that method and i suppouse you can launch everything
initially it was about how to spawn a projectile and get it into a variable, but your point was valid nevertheless
wait if that warning does not matter then why even initialize the egg?
the warnings were "useless assignment" and "entity is not initialized"
if you wanna do anything with the egg you will have a livingEntity which is initialized and you will probably set velocity or somethign
Hello there, do you know how to fix this Message Channel problem?
@EventHandler
public void onPluginMessageReceived(PluginMessageEvent event) {
System.out.println("Data received: " + new String(event.getData()) + " --r");
if(!event.getTag().equals("hqueue:inventory")) return;
System.out.println("Data received: " + new String(event.getData()));
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), new String(event.getData()));
}```
It isn't dispatching the command and `#println` returns
(Photo attached)
oh ok
How did you check if the command was run
nothing happens
Maybe, that's my check
By repeating the command in console, it works perfectly
With the ยง??
Nope
?
I don't understand why that character appears
i cant build with this error
Well yeah
what do i initialize LivingEntity as
Olivo, every data seems to have a different random char (?!)
How are you sending the data
player.sendPluginData but, PlayerCount is not mine
how do i spawn the egg
Like this
What could I try to fix this problem?
Show us how the data is sent
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(executor.getExecutable().replace("%player%", player.getName()));
System.out.println(executor.getExecutable().replace("%player%", player.getName()));
player.sendPluginMessage(plugin, "hqueue:inventory", out.toByteArray());```
(Executable is a String... smth like /hqueue add %player%)
System.out.println works perfectly here
[HQueue-Bridge] [STDOUT] queue add Jaamin test
yeah but like it just doesnt work
What about it doesn't work?
There is no egg
how can i get a yamlconfiguration as a file?
like convert yamlconfiguration to file
Could it be the dispatch method?
nevermind im getting help from another server
e.g. 10d, 5s, 1m, 1M, 1Y```
how would I convert something like that formatted time to milliseconds?
get the duration of that number 10d = days and use math to convert
btw since you guys are talking about pluginmessage, when a player leaves server, that there is no one left on the server, so the msg is targeted for other servers with players on the bungee network, but the leave-msg doesn't get sent
How can i fix this
i don't believe you can send a plugin message with no players online
if that's what you are trying to do
Someone needs to write a lightweight lib to fix this lol
yeah this is shit
i don't understand why people don't understand that we don't like to make proxy plugins
there are many reasons to dislike using bungee api & prefer make spigot plugins for each backhand server
now i gotta deal with sockets
what are you trying to do?
what do the tables look like? what data do you need? we need more info!
write a proper SQL query ?
and join the tables
i mean
google SQL join tables ?
"SELECT messages.message, messages.time, users.username FROM messages LEFT OUTER JOIN users ON messages.userid=users.uid;"
the horror i wrote the other day
Egg egg = entity.launchProjectile(Egg.class);
ItemStack i = new ItemStack(Material.STONE);
egg.setItem(i);
egg.setShooter(p);
egg.spawnAt(p.getEyeLocation());
egg.setVelocity(new Vector(0,3,0));
how do i get custom eggs to stop spawning in chickens
how do I get the UUID of the sender of a ChatEvent in bungeecord?
can someone please explain this to me?
System.out.println(text.replace("&", "ยง").contains("\\n"));
String[] pieces = text.replace("&", "ยง").split("\\n");
System.out.println(pieces.length);
[19:24:40 INFO]: true
[19:24:40 INFO]: 1
iirc this is not the first time i struggle to split a simple string in java
no
dang alright
the string wasnt being separated into pieces
but apparently you have to do "\\\\n" for some reason
Hello, I use this code to disable the plugin when it gives an error but when it gives an error, the plugin doesn't turn off, why? I already added debug and yes this code runs
AnotherClass
Main.getInstance().getPluginLoader().disablePlugin(Main.getInstance());
Method in my Main plugin
public Main getInstance(){
return instance;
}
OnEnable i set instance
instance = this;
Why that tho
idk
Why not just put a space
double regex for some reason i guess
Or whatever symbol it is
because i want spaces to be spaces
?
\n is a new line
Yes
idk what your question is
What's your goal and how does original string look like
im creating floating text with multiple lines
so i do /floatingtext this is a multiple\nline text
then i join all the args
then split using the new line
and thats it
yes
hi kacper
just google it?
dont worry, its working just fine, i just needed to use "\\\\n" instead of "\\n"
if it's even possible
How do I turn off the plugin? Tried this code
getPluginLoader().disablePlugin(this);
But when it executes it keeps logging the following events
getPluginManager() you meant
@EventHandler
public void onLogin(PreLoginEvent e) {
BanManager bm = BanManager.get();
UUID uuid = e.getConnection().getUniqueId();
if (bm.isBanned(uuid)) {
if (!bm.isAllowUnban(uuid)) {
e.setCancelled(true);
if (bm.isPermanent(uuid)) {
e.setCancelReason(new TextComponent(StringUtil.colourize(
"&cYou are permanently banned from this server." +
"\n&fReason &7ยป &f" + bm.getReason(uuid) + "" +
"\n" +
"\n&6If you believe this is a mistake, please let us know via support.")));
} else {
e.setCancelReason(new TextComponent(StringUtil.colourize(
"&cYou are temporarily banned from this server for " + bm.getRemainingTimeFormatted(uuid) + "." +
"\n&fReason &7ยป &f" + bm.getReason(uuid) + "" +
"\n" +
"\n&6If you believe this is a mistake, please let us know via support.")));
}
} else {
bm.unban(uuid);
}
}
}```
how come that isn't working?
no errors
just not working
and yes, I have registered it
Maybe it stops on some if statement
Yea why hardcode
Wdym static abuse
That does not exist
JavaPlugin.getServer().getPluginManager()
for testing purposes man
But that's giving yourself more work
for the plugin instance of the plugin you are working within, it really doesn't matter since you are not expecting a different plugin instance and the plugin instance doesn't go away or change
and that's not static abuse bruh
in order to know what is or is not static abuse, you have to really know and understand the repercussions of using static
one of the main drawbacks to making something static, is that it prevents the GC from collecting that object. But if the object isn't designed to go away anyways, it is generally fine to use a static for it
@EventHandler
public void onLogin(PreLoginEvent e) {
var bm = BanManager.get();
var uuid = e.getConnection().getUniqueId();
if (!bm.isBanned(uuid)) return;
if (bm.isAllowUnban(uuid)) bm.unban(uuid);
else {
e.setCancelled(true);
if (bm.isPermanent(uuid)) e.setCancelReason(...);
else e.setCancelReason(...);
}
}```
Tried with this, same thing, keeps logging the following events
You can check how my plugin does it
well i can suggest going for PlayerJoinEvent.getHandlerList().unregister(your listener instance);
Iirc i do something like plugin.disable
but actually do you need to disable the plugin?
you can just disable it before registering everything
right on start
but still writing a static getter and kinda non-static code implementation
I want to disable it when it gives a connection error when it turns on, but when it gives an error, and I turn it off, it keeps logging all events.
isn't that easier to pass a normal instance or just make entire thing static
not sure what you are trying to say
Yes I want to disable it when the plugin starts, that's when checking the connection
i put a question mark just to ask
@tawdry python connecting to what
it really comes down to the purpose. As long as it doesn't hit the drawbacks of using a static you are fine, but most people are not well versed in how Java and the JVM really interact or handles things so it is best to just stick with OOP principles where possible
SQ
Oh
like the only thing i really used like this was ThreadLocalRandom.current()
But for other purposes i leave entire class static
or pass an instance to constructor
Other way you have to make your class half-static, half-not-static
you shouldn't have an entire class static. Big difference between a static instance and non-static one
at least not for plugins
if you are designing an application from scratch yeah you will have a lot of statics in your main class lol
Umm basically my util classes are fully static
static message colorizing methods
static placeholder appliers
and so on
that only makes sense for util methods if its a general util class that really has nothing in common and therefore wouldn't really initialize the entire class for the one method you want
Isn't banManager supposed to be a static thing which basically handles static ban/unban methods and checks
but if you can organize your code where you can sort your util methods into their own classes, should go with OOP then
for what code i see it's not really needed to have instance
just basic checks and 2 voids
Don't object abuse 
don't abuse
your girlfriend
or i'm gonna nuke your house in 3...
2...
1...
ya know
now i'm getting an NPE
She likes it 
java.lang.NullPointerException: Cannot invoke "java.util.UUID.toString()" because "uuid" is null
it's not a static thing
only the getter is
alr still
i don't get why getUniqueId on a connection can be null?
i made your code smaller
i can see that
i will probably use it after i figure out why the banmanager methods aren't working
but why is the connection's UUID in PreLoginEvent null?
that's the error?
yes
let's google it
Hello, I have a question rq, why does this not work although I have BuildTools 1.17.1:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>```
It works without the `<classifier>remapped-mojang</classifier>` but does not with it
The error is: `Cannot resolve org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT` | `Unresolved dependency: 'org.spigotmc:spigot:jar:1.17.1-R0.1-SNAPSHOT'`
is there any way to store some custom info in an entity?
PersistentDataContainer or PDC
entity.getPersistentDataContainer()
there are get, has and set methods
Thanks
pdc โค๏ธ
hi
yeah 1.14.1+
and 1.16.3+ for chunks
and I think meanwhile worlds also have a PDC but I'm not sure in what exact version that was added
probably 1.18.2 or 1.19
how did you made your get method in BanManager
i just wanna see
ItemStacks have PDC on their ItemMeta
if you know how to work with it
?paste
a lot of things were stripped down because it's unnecessary
but i kept the general idea
so basically you create an instance of ban manager each join
it's initialized on startup
why do you even need an instance if all the methods you wanna do are static?
that isn't how you make a singleton fyi
so you made a private constructor
I have a question rq, do you need to install something to be able to use mojang mappings?
because why not
are you using maven?
yes
it looks better
this explains everything you need to know
no it really doesn't
you can just make a static * import
of your class' methods
and forget about private constructor() instance and so on
because this is a fucked up design. what does exampleMethod() do, that it cannot be static? I mean your instance field is useless since you do not have ANY instance fields in your class anyway
you don't have any dependency injection in banmanager
i have fields
i just removed them
in the example
Wait, you can't use:
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>```
If you did `java -jar BuildTools.jar --rev 1.17.1` instead of `java -jar BuildTools.jar --rev 1.17.1 --remapped`?
you need to run buildtools with --remapped, as said everything's explained in the blog post
If I already runned it without the remapped thing I can just go to the folder of buildtools and git bash again with remapped or do I have to delete the old one and run another git bash with remapped again?
this really looks overcomplicated and unnecessary
you dont have to delete anything. just run it again with --remapped
Thanks
anytime the get method is used, it will check for an existing instance
and unnecessary public constructor
if not, it serves up a new one
and this is how you would use the static method to your advantange
if I#d write a BanManager class, it'd look like this
public class BanManager {
private final Plugin plugin;
public BanManager(Plugin plugin) {
this.plugin = plugin;
}
public void exampleMethod() {
// do stuff
}
}
and then my "Plugin" main class would have a method getBanManager() or whatever
yeah, or that. but then it's not reusable
well if I was going singleton route, I wouldn't require a reference for the main plugin instance
even name is banManager
I mean you could have more than one ban manager, e.g. per world, or whatever
maybe you don't need that now, but maybe later
i used the initialize method because i had several modules in the config.yml and you could enable or disable them, so I would initialize their respective managers if they are enabled on startup
you can stick this in the private method still
true
because anytime the instance is iniatialized it will run the private method regardless
lemme guess
You have static instance of your main class in your main class
and use getInstance()
I mean if you want it static, then at least do it like this:
public final class BanManager {
private static Plugin plugin;
public static void init(Plugin plugin) {
BanManager.plugin = plugin;
}
public static void exampleMethod() {
plugin.getLogger().info("Hello from BanManager!");
// do stuff
}
}
It should either have instance methods, or only static methods. mixing that up makes literally no sense at all. a static method that uses it's own static instance? why would that ever be needed
singletone users be like ๐ฉ ๐ฉ let my class contain static instance of itself
yes uh
guessed right
I still think that a class called "BanManager" should not have ANY static methods
unless it's ofc stuff like ```java
public static UUID getUUID(Player)
or some other stuff like that lol
(just a bad example but you know what I mean)
to2DLocation(Location loc)
I also used many static classes for stuff like โCooldownManagerโ earlier on. Then realized โhm would be nice to just have a second cooldown thing for other purposesโ and then the trouble begins.
This is why i make everything reusable if possible, eg https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/data/Cooldown.java
well it makes sense for such a class to be a singleton
which would require a static
unless you go with lazy singleton method
unless you someday want to have two banmanagers
and also, where's the difference between myPlugin.getBanManager().doSomething and BanManager.doSomething(), except that the latter is shorter?
well if you want two banmanagers, it would no longer make sense to call it such
as above that would be suited to BanProcessors and then still having a single manager
AbstractBanManagerFactoryBuilder extends AbstractFactoryBuilder implements FactoryBuilder<BanManager>
THAT's how to do it right lmao
well that is factory pattern
no, that is a joke
Factory > Singleton
there is no one pattern that is the ultimate to use
they all have their use cases and have their advantages and draw backs
you could definitely go with factory pattern for mulitple ban managers
except for Vector (the collections one)
lol
isn't solid kinda strong and mostly-used
can you use hex codes in bungeecord?
sure
depends on the method you are using
the same method that works for spigot
public static String colourize(String message) {
Matcher matcher = HEX_PATTERN.matcher(ChatColor.translateAlternateColorCodes('&', message));
StringBuilder buffer = new StringBuilder();
while (matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.of(matcher.group(1)).toString());
}
return matcher.appendTail(buffer).toString();
}```
ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0This is solid red");
di > everything
that is translatealternate color codes
what about &#FFFFFF
you have to regex this out yourself
but in order to use Hex in chat, you need to use chat components
check for &#[0-f]{6} and then turn it into &x&f&f&0&0&0&0
and then run that through ChatColor.translate...
regex ๐ฉ
isn't that what this does?
idk lol
i dont know, you havent shown your HEX_PATTERN
I do however have a utility program that compresses 16bit color to 8bit color ๐
private static final Pattern HEX_PATTERN = Pattern.compile("&(#\w{6})");
guys who developed regex are true hidden developers of brainfuck
this is a util class btw
that would break if someone wrote &#xyzasd
100% sure
it doesn't run it on messages though
and it's a custom plugin for my server so i won't use that
in case anyone wants to use it or see how its done or whatever lol
and and what does it do in bungeecord?
it seems to round the colours to a different one
its a free floating utility
the non-hex one is fine
can be used anywhere
the hex one becomes aqua (even though it is a maroon-ish colour)
I can only suggest to translate 𞉀 into &x&1&2&3&4&5&6 and then it will always work
but
isn't that not what it already does?
well the rounding occurs because minecraft uses 8bit colors, hex is 16bit
also will that work in scoreboard team colours?
therefore you can't fit all of the 16bit colors into 8 bit
I dont know
have to remember, computers know colors by numbers, not their names
if scoreboard teams support colors, then it will work with &x...
but is that not what this alr does?
no, you always replace it with the last known chat color
I e.g. have a replaceRegexWithGroup method like this:
then to turn � into black, I call it like this:
and this is addAmpersandsToHex:
https://github.com/JEFF-Media-GbR/JeffLib/blob/58cfadb127a8ca2b1b5403d1fd11f1ca20c64973/core/src/main/java/com/jeff_media/jefflib/TextUtils.java here's the full class but it contains way more than you're looking for
your code started to work properly?
with LoginEvent
yep
i changed it to LoginEvent from PreLoginEvent
did u? idk i just found it on a thread
.
hey guys
i used enum like years ago
can you add elements to enum
on runtime
alr alr
it's not supposed to be changed
would stick to FunctionalInteraces/maps
Yeah
you get a bonus on top, it fires twice when you right click a block
yes
and return if its not the main hand
if you only care about main hand, yes
well i only want it to fire once
then just return if event.getHand() != Hand.MAIN_HAND or whatever it's called
if (event.getClickedBlock() == null || event.getHand() == EquipmentSlot.OFF_HAND) return; is this how || works in java
cause i remember it being weird
or me being weird
whatever
yes
but tbh I wouldnt check if it's offhand
I would check if it's not main hand
i might be paranoid, but otherwise it would break if some day, a third hand gets added ๐
with your current code, you only know that it's not the offhand, but you cannot be 100% sure that it was the main hand ๐
i doubt thatll happen but i see what you mean
or maybe your feet interacted with the block
the difference between || and | is this:
when using ||, and getClickedBlock() is null, it will not even call getHand()
when using |, and getClickedBlock() is null, we know that it will return anyway, but it would still call getHand() anyway
in 99.9% of cases you should use ||
unless theres side effects
yeah but those are kinda rare in those cases
the same is true for && and & btw
also, should i use multiple event handlers for different functionality or do i throw everything into one
cause right now i got a single handler with like 10 events