#help-development
1 messages ยท Page 1402 of 1
This can actually just be
String winMessage = plugin.getConfig().getString("win-message").replaceAll("%outcome%", String.valueOf(outcome)).replaceAll("%wonamount%", String.valueOf(wonamount));
๐
I am a math NOOB ok like math NOOB NOOB. say the int is 6, how do I get 4, 5, and 6 but then if I change the number to 10 5, 6, 7, 8, 9, 10 and so on
int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));
if (outcome < outcome / 2) {
String winMessage = plugin.getConfig().getString("win-message")
.replaceAll("%outcome%", String.valueOf(outcome))
.replaceAll("%wonamount%", String.valueOf(gambledAmount * 2));
economy.depositPlayer(player, gambledAmount * 1);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', winMessage));
return true;
} else {
String looseMessage = plugin.getConfig().getString("loose-message")
.replaceAll("%outcome%", String.valueOf(outcome))
.replaceAll("%wonamount%", String.valueOf(gambledAmount));
economy.withdrawPlayer(player, gambledAmount);
wonamount = (int) (gambledAmount);
player.sendMessage(ChatColor.translateAlternateColorCodes('&', looseMessage));
return true;
}
this is context if you need it
what do you want to do
your question does not make sense
you want the numbers from the number/2 to the number?
so I generate a random number between one and six right
if that number is 4, 5, or 6
then do smth
else
1, 2, 3
well you could just say if the number is >= 4 to encompass everything 4 and up (in this case 4, 5, and 6)
so you're not generating a number between one and six
yes
just say x instead of 6
now explain the problem again
also generating a randomInt will generate from 0 to the number you give it - 1
if x is 4, 5 or 6 then run the first method (but for example if its set to 10 then it would be 5, 6, 7, 8, 9, 10)
else for the first half
well 5 6 7 8 9 10 is not half
and 3 is half of 6
yes
why didnt you say 3 4 5 6 then
because its out of 10
for the first case
u know what I mean
in any case, you will be generating from 0 to the number - 1
so generating with config value 6 will give you either 0, 1, 2, 3, 4, or 5
ik
luckily enough you can divide by two
well you're comparing the outcome to itself
you want to compare it to the actual number in the config still
the outcome is the config
int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));
so if you get 4 youll just get 4 < 2
lmao
which will pretty much always be false
me math noob ok 
you want to use the original number that you used to generate the random choice
got a laf lol sry im mean but i laffff
aight
but I do
no, you use the outcome (the random choice itself)
the original number is the config value
I'm just reading this channel, can I see your code Zoi?
its at the top
here
ty
quite a ways up
so to simplify that code
int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));
if (outcome < outcome / 2) { } else { }
plugin.getConfig().getInt("gamble-between") is what you want to compare the outcome to
cant just delete it - ik
yes
right so
but instead of copying the retrieval over, set it to a variable first so you can use it twice
plugin.getConfig().getInt("gamble-between") @crude charm what does this return? what is its purpose?
#The max gamble amount in 0-value in this case, 0-6
gamble-between: 6
great so it's the max gamble amount right?
yes
and random.nextInt picks a random number from 0 - that number
so say the max is 10
and I want to get the last half of that number
outcome = rnd(10)
5, 6, 7, 8, 9, 20
let's say that results in outcome = 2
so you're comparing if(2 < 2/2)
it doesn't matter what the numbers are rn
ok
so what are you comparing with the max gamble?
so you're comparing the max gamble to the max gamble?
yea /2
why / 2?
oh im dumb
lmfao
if (outcome < outcome / 2) {
yeah ok
still dont know how to fix it, knew it was wrong because it wasn't working how I want
no its the random number
i see
the max number
so it's like rolling a die?
yes
and the "max number" is the number of sides
yup
and you were doing / 2 because you want the value to be higher than the half of the die
yes
exactly
but what you're doing is you're:
rolling a number from 0 to MAX, and assigning it to current
and then comparing if current is less than the current / 2
do you see where you're going wrong?
yes? it can only check for 3?
but isnt it just either win or lose? Random#nextBoolean()
Here zoi
you're a dealer
you win if i roll above half
i roll a 6 sided die, it returns 2
is 2 less than 2 / 2?
ik i'd do that but it need to be like so they can see how close they came to winning
1
is 2 less than 2 / 2? @crude charm
0
is 43 < 43 / 2
now pause
is that the correct question you want the computer to evaulate?
or do you want
is 43 < 100 / 2
what is the difference between:
is 43 < 43 / 2
is 43 < 100
I feel like coding math is a whole different thing, theres school math and then computer math
is there a way to get the actual enchantment name rather than the key such as the pic below? So instead of DAMAGE_ALL it would be sharpness
Using a lambda expression to loop through the enchs
item is an itemstack
enchants is a string ArrayList
You can use TranslatableTextComponents they're quite neat
only ever used it for chat formatting to add click actions etc
how would I use it to convert DAMAGE_ALL or another enchantment key to a display name?
You get the Namespaced key iirc
and then put that together with enchantment.minecraft so you get enchantment.minecraft.sharpness for example
@candid galleon how can I do it so that as I said before 4, 5, 6 and 1, 2, 3
like the other way compared to what I have rn
have you changed your code at all?
yes
can we see the new code?
is it not?
using just .toString returns this. hmm
doing substring feels kinda hacky
:/
should check if it doesn't start with minecraft:
did getkey and it returns "minecraft:sharpness"
so doing a substring on that is better imo
you meant substring on this mess of text xD
.replace("minecraft:","") lmao
how the tf #NMSPlayerInventory.setItem(int index, ItemStack newItemStack); updates the inventory inside the client while there's no code for that inside the method???
also is there a good way to capitalise the first letter of a string?
@mortal hare this.f looks like it holds inventories?
yes
its a list
which holds inventory slots
but there's nothing inside them
that cause client update
its just a nonnull list
where did you get that code?
ah
intellij
i'd look for references of this.f
there's probably an event being called or other method that sends the packet to the client
that or it doesn't update the item til the player interacts with it
can you make a test case?
it can't be that some kind of netty handler updates it since i injected one before packet_handler vanilla one handler
and prevented it from chaining
what are you trying to do exactly?
me?
yes
this is getting more and more strange
nmsViewContainer.getSlot(int slot).setItemStack(ItemStack itemstack);
sets item inside slots
sends the packet
but causes client not to update
even tho it sends the packet PacketPlayOutSetSlot
I have a doubt
Someone know a trick to convert an array string to array player ? ``` ArrayList<Player> list = new ArrayList<>();
String query = "SELECT * FROM " + ReportDatabaseSetup.Reporttable;
try (Statement stmt = BanDatabaseSetup.getConnection().createStatement()) {
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
list.add(rs.getString("Username"));
}
Inventory bangui = Bukkit.createInventory(player, 45, ChatColor.BLUE + "Report List");
for (Player value : list) {````
Why some of my commands returns just the usage D:
because their command executors are not registered
oh no that better not be a sync database request
it is though
code?
Make sure you return true in the command exectutor
this is my main
`public class Main extends JavaPlugin {
@Override
public void onEnable() {
ItemManager.innit();
getCommand("detector").setExecutor(new commands());
getServer().getPluginManager().registerEvents(new Listeners(), this);
}
@Override
public void onDisable() {
}
}`
oo
*```*java
```
ArrayList<String> to ArrayList<Player> I good understand?
You can't change the type of array
Yeah you'd need to call getOfflinePlayer on each of those names
correct
you can only copy the array with predicate
i tried to do it like this
everything mayor will be on uuid but its just displaying name
Still you should never use a username from a database
why
Fetch the username from the mojang servers with the UUID
I don't support cracked server
So I have no intention of helping writing code for them
also mojang api has a request limit
so i would better use the db to store player names
You can just Bukkit.getPlayer() right?
just like all of the plugins do
Using UUID.
that works if its online player
600 requests / 10min should be more than enough
this is my command executer https://paste.myst.rs/l1cmctqs
a powerful website for storing and sharing text and code snippets. completely free and open source.
Just add some caching to prevent requesting the same user too often
return false
at the end
you're returning true in the both ends
return true means that something interrupted
.
It's the oposite
true if a valid command, otherwise false from Javadocs
i've used the commandexecutor long time ago
mkay ill go with UUID.
since i use my own handler
hey how do i check if the server is fully started like when it says this in console "[08:46:52 INFO]: Done (15.216s)! For help, type "help" or "?"" how do i check for it in plugin
What are you trying to do
or like not how do i check for the message i mean how do i check if the server is started
just change motd
from STARTING to STARTED
changing the motd multiple times isn't that easy if i remember correctly
it is
then that was a bungee only issue, nvm
@quaint mantle
public static List<Player> convert(ArrayList<String> list)
{
return list.stream().map(s -> {
return Bukkit.getPlayer(s);
}).collect(Collectors.toList());
}```
its not still working
if there's not a method like #isStarted() you could use a reader to see if there's the done... line in the latest.log
I made a plugin for myself that is capable for printing a formatted time string based on the tick count of the server. I can display that when the server is pinged.
I would like to:
a) print that onto a sign and update it periodically. how would I do that?
b) display it if a clock is in a frame and the name tag is displayed above the item. can I even do that?
Any references where I can read how to accomplish that?
okay
you probably would have to remove the time on line-start, but yeah, thats the first idea that i have
declaration: package: org.bukkit.entity, interface: ItemFrame
What RealRivex says does work but the easier approach is to use a BukkitRunnable scheduled for the first tick
set display name of the clock
@quaint mantle
public static List<Player> convert(ArrayList<String> list)
{
return list.stream().map(s -> Bukkit.getPlayer(s)).filter(Objects::nonNull).collect(Collectors.toList());
}```
This better
wdym by first tick
i mean, you could also check for the latest loaded world, that's probably the last event that is fired
or idk if there's a pluginLoadEvent
could you tell me some example?
and use runnables/sign editing @hidden torrent https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Sign.html
declaration: package: org.bukkit.block, interface: Sign
PluginEnableEvent ?
here
declaration: package: org.bukkit.event.server, class: ServerLoadEvent
that looks like its perfect
oh ill try it
new BukkitRunnable() {
@Override
public void run() {
//Code when loaded
}
}.runTask(plugin);
Also yeah I saw that event but I'm not sure when it is fired
This event is called when either the server startup or reload has completed.
looks good
no i dont have that event in 1.16.5
so basically I create a threadpool to periodically work the updates, not on a tick event?
1.12.2, i'm out
very useful thanks ๐
does spigot have an api to queue tasks?
well im just working for a server
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
didn't know that. my heavy time in old bukkit development was 8 years ago
ok wtf
yeah, i would suggest to suggest the owner to update lol.
nmsInventory.setItem(hotbarSlot)
updates the slot to the client
while if its not hotbar slot
sidojg
it doesnt
gecko, thin ice lol
waah
yeah we use like different versions like 1.16.5, 1.12.2, 1.17 (when it will release)
you should use 1.8
1.17.1 - 1.17.2
1.8 is the best version!
please no nononoonno
xdd
when an item is on a frame, it displays its name (if renamed) right?
it is least lag!!
yeah but... lmao
yes isfirs
okaay
thanks =)
just get a decent host
i wait for people saying but 1.8 has best pvp!!!!111111!!11
peevpn
yeah, there's not so many plugins to fix this
I would probably have to store which items I want to update, right? is there an instance ID on items to know which item I want to update?
those that do are garb anyway
Do I have any additional license that I have to fulfill for my plugin to be on spigotmc?
could store the uuids of the item frames in a set and maybe have a Map<Block, Set<Integer>> to store sign locations and lines to put the times
So yeah even Cubecraft had to shutdown 1.8 because they only had 0.7-1.2% users running 1.8
It's time to move on from 1.8
1.16/2 = 1.8 = 1/2 the lag
oh god
rip hive too
hive has moved to bedrock right?
yes
entirely?
yeah
1.16/2 = 0.58 = you have it wrong - meet me in class
its madness that there is no bedrock for mac
their java-servers are just online to show the message
they literally have education edition which is bedrock code running on mac
there's no trash bin emoji lmao
but yeah, i think when 1.20 or smt comes out, it's the last update... they are near to the border of opportunities on java
thats why they delayed the 1.17 part 2
then we can go back to 1.8
@sullen marlin why does NMS method #PlayerInventory.setItem() doesn't translate slot while sending new PacketOutSetSlot() packet?
then I understood it like this:
- listen on events when an item is placed in a frame and store the location in a list
- for safety, register an event and check if that frame is destroyed and unregister the location
- have a task that updates the clocks name tag with my time string periodically
oh god, md5 ping
idk use the api
unless its hotbar item
youll also need to check for this stuff in chunk load/unload events, unfortunately
you can use PersistentDataAPI to give the item frames special tags to have the clocks
if he's not on 1.12 xd
The first time i saw the holder-api, i thought smt like god, that looks complicated af
its not tho xd
it's really fuckin annoying to work with is what it is
but then again storage between restarts without external files, can't complain
me? 1.16.5
yeah, then use the persistentdata-api
I assume I can query that to get my items from it?
that's not obfuscated these are just method names removed
yeah, 1.16.5 client
this.jaw
server is a singleton, right? so if I pass the server to some object it should always be the same server
yes
thanks. :)
a wild md_5 pokemon has appeared on the server
anyone know why this doesnt work
BukkitScheduler scheduler = getServer().getScheduler();
scheduler.runTaskTimer(this, new Runnable() {
@Override
public void run() {
System.out.println("task has run");
for(Player player : getServer().getOnlinePlayers()){
//PlayerInventory playerinv = player.getInventory().getContents();
player.sendMessage("checking...");
Inventory inv = player.getInventory();
ItemStack stackToRemove = null;
for (ItemStack stack : inv.getContents()) {
if (stack.getType() == Material.BARRIER) {
stackToRemove = stack;
break;
}
}
if (stackToRemove != null) {
inv.remove(stackToRemove);
player.sendMessage(ChatColor.RED + "Illegal items were removed from your inventory!");
}
it only removes stuff from the hotbar
You only have it remove 1 item
hello just wanted to ask does a paper server works without IP4 adress
even if i only have one barrier if its not in my hotbar it wont notice
soo yeah can anyone ans
I found this player.getInventory().getStorageContents()
how do i change server motd without using ServerListPing
You break the loop when it finds the first barrier...
^ also that.
if that code is expected to work, I would try this because I am lazy:
final PlayerInventory inventory = player.getInventory();
Arrays.stream(inventory.getContents())
.filter(stack -> stack.getType() == Material.BARRIER)
.forEach(inventory::remove);
Iterate over all elements and remove only barriers
boolean found = false;
for (ItemStack stack : inv.getContents()) {
if(stack != null && stack.getType == Material.BARRIER) {
inv.removeItem(stack);
found = true;
}
}
if(found) {
// send message
}
This works to but I was keeping your loop
oops
how do i change server motd without using ServerListPing
this mostly works but when a barrier is in the offhand found is set to true but it doesnt get removed
check getEquipment()
does that give the offhand itemstack?
can i convert EntityEquipment to Inventory or can i work with it like i would with an inventory
could u show the error too?
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'You have an error in your SQL syntax' at line 1
hold on let me check if desc is reserved
okay
private void sendTabPackets(PacketPlayOutPlayerInfo.EnumPlayerInfoAction action){
List<GameProfile> removeList = new ArrayList<>();
for(Player pl : Bukkit.getOnlinePlayers()){
GameProfile profile = ((CraftPlayer)pl).getHandle().getProfile();
removeList.add(profile);
}
Packet<?> packetRmv = TabListHelper.getPlayerInfoPacket(false, removeList.toArray(new GameProfile[0]));
//Packet<?> packetAdd = TabListHelper.getPlayerInfoPacket(true, profileList.values());
//Get subset of packets to not go over buffer limit
List<Packet<?>> addPackets = new ArrayList<>();
List<List<TabListProfile>> subLists = Lists.partition(new ArrayList<TabListProfile>(profileList.values()), 1);
for(List<TabListProfile> subList : subLists){
addPackets.add(TabListHelper.getPlayerInfoPacket(action, subList));
}
for(Player player : Bukkit.getOnlinePlayers()){
sendPacket(player, packetRmv);
sendPacket(player, addPackets.toArray(new Packet[0]));
}
}``` I'm using this method to update tab packets every so often, and when player joins, which works 100% fine. However, after some time (not sure how long exactly) when I try to join the server it tell me the packets are too large?
I am partitioning them into just 1 profile chunks and it still seems to give me this error have no clue how to reproduce, without having to wait 30 mins
do you mean check the offhand or can you get the whole inventory with that
how to glowing player plugin in 1.8 and make it work on viaversion for 1.9+
^^ cant as effect doesnt exist
pl
[10:26:35 INFO]: Plugins (2): BileTools*, dynampclaims
b unload dynmapclaims
[10:26:41 INFO]: [Bile]: Couldn't find "dynmapclaims".
Why is it not detecting my plugin? In /pl it shows green
wtf is bile
BileTools is the newer version of Plugman
unload, uninstall plugins on the go
no restarts or reloads
biletools is a newer better fork
"you are using 1.12.2 and lower very outdated get out of my life i never want to see you again i hope you (redacted) you (redacted) 1.12.2 and under person"
^ -everyone
I am also not using 1.12.2
what version
1.16.4
no wonder its a 1.12 and under plugin
ok
there is no reason it would not work
well, it does trigger legacy mode
and it works fine on my 16.5 server
which is like 6 seconds of slowdown
in a development environment I am fine with that
Help me
what
How would you get Player's online time
Not by counting the login twith the system time
if theirs any other way
theres no other ways
wdym?
can I somehow hide the entity including its hitbox so that I can't hit it? I tried
for (Player players : Bukkit.getOnlinePlayers()) {
PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(slime.getEntityId());
((CraftPlayer) players).getHandle().playerConnection.sendPacket(packet);
}```and the slime hides, but I can still hit it and kill it
At that point it is something that is done serverside; you'd need to do the raytracing on your own (for Player Interation)
When I want to add a file named "Name" and then want to add a file named "name" it says that this file already exists. How can I make that this file is created?
p.sendMessage("ยง4This already exists");
} else {
file.setValue("name", name);
file.save();
p.sendMessage("ยงaSuccessfully added " + name);
}``` My code
Bruh
what
We're not just going to spoonfeed you a plugin
This is for help not getting people to write things for you
Olivo can you help me?
player.setVisible(Player)
Might have to create your own check for this one.
how about at tab? or command
i am new at coding either
remove them from player list. and what do you mean "or command"?
i mean at /vanish command how to do it
just watch a tutorial
so...?
Create a command via the spigot api, then loop through all players setting the player that ran the command as invis.
ima just watch an tutorial
๐
Can you give me an example?
Get the file location and list all files then check for the exact name.
ok
Hello how to code an Vanish plugin
@primal vortex
Depends what kind of vanish plugin you want
k
You can do packet one where hacked clients cant see it
And you can do simple one
With potion effects
i
Or with player.hidePlayer()
public class SettingsCommand extends Command {
private static HashMap<String, Setting> settings;
public SettingsCommand(String name) {
super(name);
}
@SuppressWarnings("deprecation")
@Override
public void execute(CommandSender sender, String[] args) {
if (!(sender instanceof ProxiedPlayer)) {
sender.sendMessage("Dieser Befehl kann nur von Spielern ausgefรผhrt werden.");
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
if (args.length != 0 && args[0].equals("show")) {
sender.sendMessage(Utils.MapToString(settings));
}
ProxyServer.getInstance().broadcast(sender.getName());
Setting setting = settings.get(player.getName());
if (setting == null) {
settings.put(player.getName(), new Setting());
setting = settings.get(player.getName());
}
player.getServer().getInfo().sendData("bungeecord:spigot", setting.getArrayOutput("Settings"));
}
public static void setSettings(HashMap<String, Setting> s) {
settings = s;
}
}
This is the code to one of my Proxy commands. When I execute it, the spigot plugin gets the wrong reciever. it always send the first online player as reciever to the spigot plugin. what is wrong?
i did
dont know about BaseComponents
Hey guys! I want to make a pickaxe, which shoots arrows. I made it work. BUUT, I want that the the block breaks, which gets hit from the egg. Here's my code:
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Egg egg = p.launchProjectile(Egg.class);
egg.setFireTicks(Integer.MAX_VALUE);
egg.setBounce(true);
p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
}
}
}
I wonder if you could restrict nether portals to locations where these nether structures spawn.
can someone help me?
don't you have to listen for some kind of collision event?
an egg is no vehicle, right?
it is a projectile which iirc is an entity. and entities can collide afaik
so, a collision event is my best bet.
store the ID if you egg in some list so you know that is an egg you spawned. and on hit compare it if it is in that list and then do your action
idk if there is a more elegant way of doing it
@hidden torrent it isn't working ๐ญ
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Egg egg = p.launchProjectile(Egg.class);
egg.setFireTicks(Integer.MAX_VALUE);
egg.setBounce(true);
p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
}
}
}
@EventHandler
public void onHit(ProjectileHitEvent e) {
if(e.getEntity().isOnGround()) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1);
}
}
why is on ground check o.O
sounds wrong, somehow
yea. I said to check if this is your projectile.
private final List<UUID> projectiles = new ArrayList<>();
@EventHandler
public void onClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Egg egg = p.launchProjectile(Egg.class);
egg.setFireTicks(Integer.MAX_VALUE);
egg.setBounce(true);
projectiles.add(egg.getUniqueId()); // this
p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
}
}
}
@EventHandler
public void onHit(ProjectileHitEvent e) {
final Projectile projectile = e.getEntity();
if (projectiles.contains(projectile.getUniqueId())) {
e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1);
projectiles.remove(projectile.getUniqueId());
}
}
Like I said, no idea if that is the best way of detecting if that ID is yours.
important, or else you store too many invalid IDs
Idk if storing the actual object might be better. having a List<Projectile>.
but since its about identifying if the projectile is managed by your code, I think this is fine.
@quaint mantle still there? :D
yea. you will not know if that egg is yours if you don't have a way to identify it
p.getItemInHand() is deprecated. maybe consider using the inventory. Idk which API you are using, but I can't resolve neither ENCHANTMENT.VASER or Sound.SHOOT_ARROW, the enum for me was ENTITY_ARROW_SHOW
concerning that it is part of isSimilar that seems rather complex
especially with the inheritance based nature of item meta
you could do some reflection shenanigans and temporarily store itemmeta a's pdc in itemmeta b, then compare and revert after that
well yes
the durability is stored on the item meta
don't know what would change then tbh
is there a not deprecated method instead of ProxiedPlayer.getUUID();?
getUniqueId
thanks
how to get uuid of uuid.toString() back?
UUID.fromString
stupid question but my ide says to me "integer number too" im writing this "1622113500000" how do i then put it into new Date()
use a long
i do use it
oh plug a L at the end
oh ty
๐
oh so thats what the L means
long xD
yeah xd never knew what it meant
smth to learn everyday more
How to get player by UUID on the bungee?
ProxyServer.getInstance().getPlayer(uuid);
thhanks!
someone can help me?
?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.
just ask m8
i need to make a glowing entity (llama) with rainbow colors
but I'm not getting it, it is only white
sorry for bad english, im using translator
Wdym by this?
Why?
i dont understand
yeah
i dont speak english very well, sorry
i can send my code here?
yea
i'm usign this:
Random random = new Random();
List<ChatColor> colors = new ArrayList<ChatColor>();
colors.add(ChatColor.DARK_BLUE);
colors.add(ChatColor.AQUA);
colors.add(ChatColor.LIGHT_PURPLE);
colors.add(ChatColor.YELLOW);
colors.add(ChatColor.GOLD);
colors.add(ChatColor.GREEN);
colors.add(ChatColor.DARK_AQUA);
colors.add(ChatColor.DARK_GRAY);
colors.add(ChatColor.DARK_GREEN);
colors.add(ChatColor.DARK_PURPLE);
colors.add(ChatColor.DARK_RED);
colors.add(ChatColor.GRAY);
colors.add(ChatColor.RED);
colors.add(ChatColor.BLACK);
ChatColor team1 = colors.get(random.nextInt(colors.size()));
team1_color.add(team1);
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
Team lhama = board.registerNewTeam("pinhata");
lhama.setColor(team1);
lhama.addEntry(llama.getUniqueId().toString());
but, dont work
team1_color code:
private static List<ChatColor> team1_color = new ArrayList<ChatColor>();```
Why u makin the llama colorful doe
oki one sec im lookin at the docs to see if something could work here
right, thanks
im on mobile might take abit sorry
no problem, thank you
how to get player UUID in PreLoginEvent?
Are you trying to make the entity itself rainbow or an entry on the scoreboard?
I'm trying to get on the scoreboard to be able to let her rainbow
rainbow with glowing
oki
You understand that setting a scoreboard colour is not going to affect the entity in the world. Also only Players can be members of Teams
But, i can set the only color of those to llama in the scoreboard teams
but, rainbow I am not getting at all
@weary fossil https://www.spigotmc.org/threads/change-glowing-color.402831/
I'm not able to get on my pc and test out shit rn but this will probs help you
Your current code picks a random color and sets your team to that color. It has no in game representation to the entity
thanks the same way, thanks, this can help me a lot
i have others methods to represent a entity
i show examples for you
now my code show me this:
i want to change a glowing for rainbow
i already read this post, but for my case does not work
oh welp one second lemme seee somethin
right
I'm going to guess (as I've not done it) you are going to have to cycle the colors for the team in a runnable
teams have a single color. There is no rainbow setting.
@lost matrix hey, you still have that code for the color map stuff?
yea, i know
did you get it working?
so to have the color flash different colors you are going to have to set teh color on a timer
i have a question how do i get the main world like the one thats written in the server.properties?
either read teh properties or Bukkit.getWorlds().get(0)
oh ty
i understand
but how i do this?
new Bukkitrunnable
If I have a Map like this, does the Map in the value need to be intialize? idk what im saying but I'm kinda confused.
Map<UUID, Map<String, Integer>> somethingMap = new HashMap<>();
111java
you could probably use Team#setColor(ChatColor.WHATEVERCOLORHERE);
as glowing colors depend on teams and their color @weary fossil
i try to do this
new BukkitRunnable() {
@Override
public void run() {
//code in here to change color of the Team.
}}.runTaskTimer(plugin, 0, 20L);```
but with my random, it's not changing the color
course
thanks
?paste
paste the full code
afterward this i only using in the entity method
llama.setGlowing(true);
cant you paste the full code?
Table (:
pls
wher r ur import statments?
sorry, i forget to put in paste
what table? can you give me reference? all I found is JTable.
brb
Can somebody help me figure out a weird server crash?
this a #help-server problem?
no its not
show me the crash reports
one sec
https://pastebin.com/LqJDbJcL is the error
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
are the imports from google.common?
whats the need for a tabl when its in it's own class
me.konstanius.konstanius.commands.claim.onCommand(claim.java:98)
show me line of code
testcoordz = resulttest.getInt("z");
that exists
I can describe when it happens for you
Ye
please
So the code basically is:
You do /claim (description text)
It checks through 2 databases if there is a position in a given radius or a radius specified in the data entry
If there is no other position in radius (aka the spot is valid) it creates a new database entry
the first claim worked fine
couldn't you show us the code
then claiming inside the first claim worked fine (prevented it)
one sec
and claiming outside of the first claim causes the crash
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
thats the code
alright thanks, it's basically the same as the Map that I sent above and it's easier to manage yeah?
apart from my main thats the only instance there is
don't do database queries on the main thread
i only have the create table there
that is still a database query
it works fine and is not the issue
they can be slow and take up to several seconds or like 30 seconds if the control connection times out
and doing it on the main thread means that your server will be doing literally nothing for all of that waiting time
since my plugins are basically core plugins of the servers they are being used on thats the point
I can see why your server crashed lmao
that has nothing to do with not doing database queries on the main thread
all those while(true) statements
on top of the database shit all on the main thread
even if your database query only takes 50ms, that is one entire skipped tick
the query takes 0 ms
๐ฎ
because I only use localhost connetions
but it isn't guaranteed to take 0 ms
in one in more than a million pings maybe one takes 1 ms or 2
that doesn't mean that you should be doing database queries on the main thread
your server noticed your code was hanging and since it was on the main thread
it crashed
@dusty herald u can help me?
no
and why does the code hang?
have u seen how many while statements u have
Wait why do you why true statements
they dont execute at the same time
have u tho
i have 5
and doing it on the main thread means that the entire server halts and waits for it to exit
and if it never exits, the watchdog terminates your server
the first one does have a break built in
does while statements care if breaks are in try blocks I'm not sure
also you can just.. while(ResultSet.next())
someone can read?
also prepare your damn statements
and don't do queries on the main thread
unless you want injection then don't do that
is there a way to check if a BukkitTask has already been executed?
I need a safety measure on a BukkitTask field which means:
public void setScheduledPointTask(@NotNull BukkitTask scheduledPointTask) {
if (this.scheduledPointTask != null)
cancelTask();
this.scheduledPointTask = scheduledPointTask;
}```
I am not sure what happens when you try to cancel a task that has already been executed. Does it have an effect?
*for context:* The task is a delayed task. When registering a new task, I need to prevent that task from running when the delay ends.
Another way to do it would be to set `this.scheduledPointTask` to null as soon as the delay ends but that would require some hacky workaround which i would like to avoid
so you just want to have a delayed task
and whenever you schedule a new instance of that delayed task
you want to check if there is a delayed task that has been previously scheduled
but not yet executed
correct
and if so, you want to cancel the old task from running
yep
iirc bukkittask has a hasRun method or something to see if it has been run yet
or not, apparently
in the class that schedules the task, have a field for the BukkitTask
i can cancel it just fine, im just not sure whether or not .cancel() is safe to call on a task that has already been executed. Cause if it is safe, I can just call cancel whether it has ran or not and be on my merry way
when you schedule a new task
check if that field is not null
if it is not null, cancel the task and replace its value with the newly scheduled task
when the task runs, set the field to null
if you're doing it concurrently, make the field volatile
if (task != null) task.cancel();
task = Bukkit.getScheduler().runTaskLater(plugin, () -> { task = null; }, delay );
u can
thats the thing. The same class generates multiple tasks for different players so I would like to avoid having to store it in the class that generates it. There can only be one task/player which is why I am storing it in my player wrapper class.
The documentation doesn't say anything about calling .cancel on a task that has ran already so I guess I can just try.
well, it won't explode
meh true
Whats the best way of making a command with optional arguments identified by things like "p:(player)" or so like this:
/forceclaim <description> p:(Player) x:(X) y:(Y) r:(Radius)
So that I can get the variables from it
but description can be multiple arguments long and the order of arguments can be arranged in any way
wouldn't the command will be too long? and maybe it'll reach the max characters on the chat.
i limited description to 32 characters
String[] split = args.split(" ")
for (String string : split) {
switch (string.substring(0, 1)) {
case "p:" :
//trim the "p:" and work with the trimmed version
break;
case "x:" :
//trim the "x:" and work with the trimmed version
break;
}
}
args.split doesnt work
You would need to do a lot of checking that arguments have at least 3 characters etc so you dont get out of bounds errors but this is the basic pattern I use sometimes
why is that?
I dont have anything edited yet I only have what you gave me and a bunch of non involved code
and I have String[] args
okay
and with the min length of the arguments does that apply to description aswell?
do you understand what my code does?
alright, then you need to do a check before you run the chunk of code that the string.length() > 3
What the switch/case statement does is it evaluates whatever is in the switch statement (here string.substring(0.1)) and it "jumps" to the label (the cases) that is equal to the value in the switch statement.
So lets say you do:
int nr = 5;
switch (nr) {
case 1:
System.out.println("foo");
break;
case 5:
System.out.println("bar");
break;
}```
"bar" will be printed (cause nr = 5 = case 5)
ok
for (String string : args) {
switch (string.substring(0, 1)) {
case "p:" :
string.replace("p:", "");
Player owner = myplugin.getServer().getPlayer(string);
break;
case "x:" :
string.replace("x:", "");
int x = Integer.parseInt(string);
break;
case "z:" :
string.replace("z:", "");
int z = Integer.parseInt(string);
break;
case "r:" :
string.replace("r:", "");
int radius = Integer.parseInt(string);
break;
}
}
So thats how I have it now
Whats the best way of making a command with optional arguments identified by things like "p:(player)" or so like this:
using a command framework that does that
i don't remember if acf does
I have my own framework ๐ not public yet but it will be at some point xD
and how do I get the description from that now?
writing your own framework for things is good practice
personally I would use a regex
it'd let you grab the user input with a capture group ez
the string.substring() will throw an indexOutOfBounds error if the indices are invalid. So before calling that method, make sure the argument has enough characters
hint:
you want to block players from doing:
/forceclaim <description> p:
manually writing switch blocks for the different parameters seems uninspired
Can I come back to you in like 15 mins? I need to go do smth
i'd oop'ify it and create a Parameter class and then a String -> Parameter -> Input mapping
just drop it here, there are plenty of helpful people here ๐
would work indeed but is kinda meh if you just have 1 command that takes this kind of args
would still imply the intent that not all of the parameters may be present
and that they may be in any order
thats what the switch/case does too though
Definitively use regex challenger (as NNY said), I donโt know but that would cut the most verbosity it feels like making it clean.
the man doesnt know switch case ๐ I doubt he can write a decent regex ๐
lmao
no offense
Then he may be able to learn something extra, canโt see the downside
meh true
and we might be here 4 more hours explaining what a capture group is
๐ฅฒ
eeeuuh I gotta go do important stuff SSEEE YYAAAA xD
Ok I think I'm going crazy.java @EventHandler public void onCreatureSpawn(CreatureSpawnEvent event) { event.getEntity().setGlowing(true); }No glow effect when spawning mobs (used Spawn Eggs. code is running, listener is registered)
uh
What if you try adding the glowing effect instead
My thoughts exactly
try spawning them via summon, maybe spawn eggs are weird somehow
that definitely shouldn't be the case but you never know with bukkit
The event fires adn the code runs, just no glow
myeah my guess was that the spawn egg code is doing something dumb with it after it's added to the world
I'll stick it in a delay but its behaving very oddly
dunno though I don't think I've ever used glowing on anything
I even tried manual spawn loc.getWorld().spawnEntity(loc, hatchingType);
still no glow
Well I'm baffled ```java
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
System.out.println("Set Glow!");
event.getEntity().setGlowing(true);
}
}, 50L);
}```No Glow
i'm more baffled by the anonymous runnable with an override instead of a lambda
Elgar did u try with LivingEntity::addPotionEffect
Hey
what does setFallDistance mainly do?
does this cancel the fall damage
when set to - values
I havn;t as I'm aiming for other non Living entities too
it's probably set to 0 every tick while the entity is onGround
Ah well weird then
and incremented by some value while it's not
fall damage does depend on it iirc but i'm not sure
Ik theres an event for that
I was actually messing around with an idea someone else had earlier, but in testing I can't get teh basic glow to happen
There isn't some client setting that can disable glow?
Afaik no
Damn it! it was seus shaders
i was going to suggest checking the entity data next
to see if it was a client issue
ping?
0
Looks like its an Optifine issue
Still open ticket from 2020
when cancelling PlayerInteractEvent and changing the item in the players hand, the interaction will be run despite being cancelled - any idea what i can do about it?
useItemInHand(Event.Result.DENY) mb
that will still run the interaction
.setCancelled on PlayerInteractEvent is just short for setting both useInteractedBlock and useItemInHand to DENY
Oh yeah I was unsure whether setCancelled works anymore
what is it like being Async conclure?
the interaction will only be executed if the item in the players hand changes
Fast as fuck
Jochyoua youโre pretty async also lol
thank u
Actually Aqua, it might be a different event
mh?
PlayerInteractEvent does get called and cancelled, i can 100% confirm that - for the replaced item, no PlayerInteractEvent is called, however if the item has its own event (e.g., PlayerBucketEmptyEvent), that one will be called
Oh you mean like that, Idk what item are we talking about specifically then?
Worst case scenario would be that you have to setup a packet interceptor hopefully you can skip that
bucket events are fucked
there was a patch on paper that made them slightly less fucked
but even their bucket events are still somewhat fucked
it happens with all items that have an action, replacing the item in the players hand with a fishing rod will cause the player to throw the fishing rod (not only on the client, the server actually does it instead of what the original PlayerInteractEvent intended), or when replacing it with a water bucket it will place the water
yeah, i specifically have to deal with the bucket events because i'm trying to cancel the event for a bucket, but set some metadata on it
sadly cancelling PlayerBucket*Event will still replace the item in the players hand with a fresh bucket, instead of keeping it, losing all metadata
so i wanted to cancel the interaction before, but the changed item in the players hand will still run the bucket event
i don't really know what i can do about it - my first idea was replacing it with a fishing rod instead and setting a variable to "the next fishing event is actually the bucket", and replacing the item inside PlayerFishEvent instead - but in very rare cases PlayerFishEvent will not be called after PlayerInteractEvent, resulting in the player losing their bucket^^
@weary fossil Did you get it working?
public void onBedPlacedEvent(BlockPlaceEvent event){
Bukkit.getLogger().info("test");
if(event.getBlock().getType().equals(Material.LEGACY_BED)){
Bukkit.getLogger().info("test1");
Bukkit.getLogger().info(event.getPlayer().getName());
}
if(event.getBlock().getType().equals(Material.LEGACY_BED_BLOCK)){
Bukkit.getLogger().info("test2");
Bukkit.getLogger().info(event.getPlayer().getName());
}
if(event.getBlock().getType().equals(Material.BLACK_BED)){
Bukkit.getLogger().info("test3");
Bukkit.getLogger().info(event.getPlayer().getName());
}
}```
how can i check if a bed is placed? the only one working is black bed
Tag.BED.isTagged(event.getBlock().getType())
Will tell you if its a bed of any type
that works thank you
im just testing
i need to know wich one works or not
for tests you might as well use stout
i usually use getServer sendmessage
theres not that big of a difference..
its literally the same thing with different words
stout has autocompletions in most IDE's so it's more ez to write
but for any actual logging and messages, you 100% should use plugin.getLogger
because that indicates that the message comes from your plugin
anything else is haram
aight ig
there is nothing more fucking annoying than a plugin that pours dumb shit into the console and you have no clue which plugin it is because it uses the wrong logger
i only sysout when I am debugging something
and I know it's my plugin doing the debugging
posible create packet ProtocolLib with constructor?
a now I try make other project
yes, you can instantiate packets with protocollib
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Points' in 'field list'
How to fix this $hitty problem i was trying to fix it about 3 hours
public static void createTables()
{
if (isConnected())
try
{
con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS PSQL (Playername VARCHAR(100), Level INT(100), XP INT(100), Points INT(100))");
}
catch (SQLException e)
{
e.printStackTrace();
}
}
i already added the Points on the Table
' ' ?
try checking mysql logs of the server
there's syntax error somewhere in codeprobs
(1) Found the .NET developer
(2) Your database clearly says otherwise 
no
yes
java.lang.IllegalArgumentException: Don't know how to serialize io.papermc.paper.adventure.AdventureComponent@15bc7e69 as a Component
How is this possible when I try to serialize ServerPing's?
This line: serverPingJson.add("description", jsonSerializationContext.serialize(serverPing.getMotd() == null ? motd : Class.forName("net.minecraft.server." + TvheeAPIPlugin.getInstance().getNMS() + ".IChatBaseComponent$ChatSerializer").getDeclaredMethod("a", String.class).invoke(null, "{\"text\": \"" + serverPing.getMotd() + "\"}")));
i already checked the log of the server
public static boolean exists(String playername)
{
ResultSet rs = MySQL.getResult("SELECT * FROM PSQL WHERE Playername='" + playername + "'");
try
{
if (rs.next())
return true;
}
catch (SQLException localSQLException) {
}
return false;
}
public static void createPlayer(String playername)
{
if (!exists(playername))
MySQL.update("INSERT INTO PSQL (Playername, Level, XP, Points) VALUES ('" + playername + "', '1', '0', '0')");
}
the biggest problem is here ^^
why does this work? ```
Main.get().getConfig().set("test", 123);
Main.get().getConfig().set(event.getPlayer().getUniqueId().toString(), event.getBlock().getLocation());
Main.get().getConfig().set(event.getPlayer().getUniqueId().toString(), event.getBlock().getLocation().toString());
does?
saveConfig()
oh so i have to set it and save it
Though there's a setLocation() you might want to use instead
Yes
saveConfig() writes it from local memory into file
Location::toString doesn't do what you expect it to do
is it possible to lock specific object, not a codeblock from accessing in another thread, like synchronize but for the object instance and not the codeblock
wut
synchronize(object) {
}
would lock the object instance to not access this code in another thread
is it possible to do this for all of the code, not only for synchronized codeblock
yo, does anyone know how can i change particle render distance?
is this code is true?
so if im 5 blocks away from a particle it disappears
Everything that wants to access that "Object" must sync on it
and if i come back it reappears
Youโd probably need to check the players distance and just not spawn them if they are too far
i repeat wut
what if the code is outside the synchronized block who tries to access it
synchronize (x) just grabs the monitor of x
then its not synchronized and could break
only one thread can lock on x at the same time
yea and im asking if there's any way to synchronise that particular instance not only that particular codeblock