#help-development
1 messages · Page 2036 of 1
alright then
does name replace id in gradle?
İm seeing the discord cod messages white on mobile. How can i fix it
wouldnt that not matter as you will never have 2 diff threads accessing it at the same time? Or does async runnable use multiple threads for some reason
my plan would be just read from database in onEnable method
and async timer to save every minute or sum
yeah
its only in onEnable
so once
Diff for every use case
I want all the values to be read
bc that means in my case, a lot of requests in a couple of seconds
can i run .setDamage() twice in an EntityDamageByEntityEvent?
like if i want to set the damage to 0 and then 1 tick later set it to 15 or seomething
I just get an unmodifiable copy of the cache in a tick then save that asynchronously
one tick later, modifications to the event are useless
oh ok
would that be fine? I'm sure it is
Yea but the player dies one tick later
like, one tick later you can manually respawn the player sure
but mutating the event yields nothing
im trying to set a damage value in a mapp and hten get it in the same tick
is that even possilbe
two different listeners
I mean why?
If your cache is thread safe just using that directly isn’t gonna hurt
if i wanted to modify a message (like a caps filter or smth) how would i do that with %s
cant u just .toLowerCase() for a caps filter
it's pretty much the same as using a concurrent hashmap but faster at the cost of little memory
ig
it leaves nothing pending
well then split with spaces and
Nah it’s really not
Usually reads from chm isn’t gonna be much more expensive than from normal hm
then concat or stringbuild or whatever and then output
It’s writes that are expensive
By copying the hash map to an immutable copy would scale quite badly
@ivory sleet If i would have an async timer that reads from hashmap every so often and save that to database. Would i still need a concurrent hashmap?
Especially since you have to copy the entire backing array
Well
ConcurrentHashMap/a thread safe map is needed whenever you manipulate the map from multiple threads
If you don’t use one there’s a big change you’ll end up running into concurrent update problems
huh, what if values are added to the hashmap while you're saving it?
An iterator is at most just a view of the map
Yes but usually your design is flawed in the first place if you have to save all the data at once
yes ofc
org.bukkit.plugin.IllegalPluginAccessException: java.lang.NullPointerException
at org.bukkit.plugin.SimplePluginManager.getEventListeners(SimplePluginManager.java:709) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:661) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at net.plexpvp.core.Main.onEnable(Main.java:65) ~[Plex-1.0-SNAPSHOT-all.jar:?]```
```java
Bukkit.getPluginManager().registerEvents(new LevelListener(), this);```
And ftr just having a normal map wouldn’t guarantee any more safety at all daVinki
lol what
are you not saving the cache?
Depends
But like it’s often avoided because there’s a lot of issues coming when bulk operating
delay is before it runs, period is time between runs afterwards
delay initial delay before execution starts
period is the interval between each execution once the runnable has reached the delay
when you're saving the cache, do you have a buffer of any sort so the server doesn't end up waiting on the hashmap to become unlocked?
guys is like generic people now
Wat
assuming that I do have a sync buffer
Than I just invoke the thread pool and read the concurrent hash map
Not that complicated
so you aren't saving async? I'm lost
I am
But it’s called a sync buffer when you’re syncing all data at once
You have to remember the concurrent hash map doesn’t always lock, it’s fundamentally trying to avoid locks by doing compare and set operations and such
how would it avoid locks then? what happens if there's a write during a read?
You don’t need to lock whenever a write and read happens concurrently
First of all it may not that important that the read is 100% up to date, secondly atomicity is a thing
Locks are devastatingly slow
Concurrent Hashmap does a lot of concurrency magic under the hood
But if you truly need a synchronized hash map Collections::synchronizedMap might help
^
.
https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentHashMap.html has an explanation @ancient jackal
I'll read this, thank you guys for the explanation
public static final int PORT = 25566;
// ...
try {
server = HttpServer.create();
server.setExecutor(exec);
server.bind(new InetSocketAddress(PORT), 0);
server.createContext("/carbon/rp_d", exchange -> {
if (!exchange.getRequestMethod().equals("GET"))
return;
OutputStream out = exchange.getResponseBody();
exchange.sendResponseHeaders(200, Files.size(resourcePack));
InputStream fis = Files.newInputStream(resourcePack);
fis.transferTo(out);
out.flush();
out.close();
});
} catch (Exception e) {
e.printStackTrace();
}
}
``` why is the server not responding bruh
no errors
also sorry for the humongous message lmao
@ivory sleet I use Long2objectopenhashmap for better performance, would it be good to manually lock the hashmap and unlock it when the task is done?
Bc the async timer runs like every 1 or 2 minutes
So using a slower hashmap would not be beneficial for that or?
For loop over the hashmap and store the values in the database with batches
So i dont need to use concurrenthashmap for that?
Not for that
Let’s say you read extremely often from multiple threads as well as writing to it from multiple threads
Then a CHM will be necessary more or less
k thanks
Also should be said
the lock would be useless if you'd merely use it in the task timer
as you'd in principle have to lock and unlock when doing most operations with the map
thus why locking is usually avoided if possible
deplorably slow
line 65 is ``` Bukkit.getPluginManager().registerEvents(new LevelListener(), this);
what if u'd just load it by restarting the server
in other words not using plugwoman/plugman
do u have the code on github?
yessir
mind sharing? :3
oh well my gh name is Conclure
alr
gh should add
private to all BUT:
e.g if u wanna show someone a private repo without them changing code
nah my problem is just i dont have perms to invite others since another dev on my server is the owner of the github
and they're being stingy with the access
ik
uh wally its quite strange
Wally
CombatCore seems to be the issue
assuming its still line 65
Maths isnt my strong point so i may need a bit of spoonfeeding here:
Im trying to make a damage calculator that will calculate the amount of damage to deal, given an input damage, a minimum value and a maximum value, and a distance.
I want to make it so the damage dealt to the player will scale depending on how far they are to my explosion (distance), but with a minimum and maximum value in which it will scale inside
i dont really know if i explained that well
explaining is also not my strong point lmao
combat core hasnt been changed in a while though i dont think
can I compile and run for myself?
is that on startup?
also sure
well the error gets yield on startup doesnt it?
For example:
if the player is 5 blocks away from the explosion (the furthest i have it set to), and the minimum damage is 10 and the max is 20, it should scale the damage with the distance 0-5 and set the damage corresponding to that distance between 10-20?
If you know that the longs actually two ints, where as the two ints are close to a certain origin point (i .e. nothing widly random like the current time but rather something like coordinates) then https://github.com/Geolykt/Presence/blob/main/src/main/java/de/geolykt/presence/common/util/RegionatedIntIntToObjectMap.java could work better. It has pretty shit iteration time but given that it should be pretty safe to use in concurrent environments it may pay off. I know that it can reliably deal with around 1 million direct read calls (sync however) per seconds without making any dent in server performance while being on pretty shit hardware
since redlib commands also is mentioned in the log
ow damn thanks, ill defo give it a look
Is there any advantage to using the enchantment wrapper instead of lore?
what do you want to do?
Custom enchantments?
Yeah
using lore sucks
Why?
its unreliable
I personally use Lore + PDC or just lore
how so?
and just a cutting corners way
But from experience I can say that lore can break from time to time
a lot of shop plugins change the lore and other types of plugins
dont you want other users to use your enchantment in their plugin, I assume with pdc you couldn't apply it
Yeah, but either way you need lore to show the enchantment is there
I would just use the implemented way, no need to make your own over complicated curvy way
you can use it to show it but not rely on it to detect if it has the enchant
^ yea
ok, thanks
And then how are you going to create the lore after that?
The bukkit enchantment api is incomplete at best and it is very visible that custom enchantments are a hack with it
spigot doesnt add the enchant automatically? I thought when creating a custom enchant when applying it, it's added to the lore
not at all
Or actually I do not know given that I never used it, but that is what I heard
It is not
That is done client side
But the client will not have a valid entry for that enchantment
I personally attempted multiple conversions from my lore/pdc+lore to a bukkit enchantment system but always failed doing so
@ivory sleet im confused how it could be caused by CombatCore, according to my ide, LevelListener is on the 65th line
yeah
sorry
I was away for some time
clicked on one of those scam links by mistake so had to reset my token and backup codes
anyhow let me download the deps first
@patent horizon did u push latest
just did
altho idk if it'll show up on fork
i just fetched
should be fully updated
java.lang.NullPointerException: Cannot invoke "org.bukkit.craftbukkit.v1_18_R2.CraftWorld.getHandle()" because "world" is null
at com.sk89q.worldedit.bukkit.adapter.impl.v1_18_R2.PaperweightAdapter.createWorldNativeAccess(PaperweightAdapter.java:355) ~[worldedit-bukkit-7.2.10.jar:?]
at com.sk89q.worldedit.bukkit.BukkitWorld.<init>(BukkitWorld.java:119) ~[worldedit-bukkit-7.2.10.jar:?]
at net.plexpvp.core.combat.CombatCore.<init>(CombatCore.java:35) ~[Plex-1.0-SNAPSHOT-all.jar:?]
at net.plexpvp.core.Main.onEnable(Main.java:65) ~[Plex-1.0-SNAPSHOT-all.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:501) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:559) ~[paper-1.18.2.jar:git-Paper-265]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:473) ~[paper-1.18.2.jar:git-Paper-265]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[paper-1.18.2.jar:git-Paper-265]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.18.2.jar:git-Paper-265]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[paper-1.18.2.jar:git-Paper-265]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-265]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-265]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
thats what I get
but its because I dont have a world named ul_world
oh yeah
I meant ul_plex
let me re launch if I have a world named just that
oh
im getting the error now as well
@patent horizon
try changing
@JvmStatic
public HandlerList getHandlerList() {
return handlerList;
}
to
public static HandlerList ...
for BlacksmithExpChangeEvent and GlobalExpChangeEvent
hmm
well i mean at least the error message is different this time
oh nvmd just two errors now
ah
FarmingCore
public FarmingCore()
{
Bukkit.getScheduler().scheduleSyncRepeatingTask(new Main(), task(), 0L, 5L);
}
you're creating a second Main object
use Main.get() over the new Main()
actually wally
can I push my changes?
it will work then
and you'll see what I changed
yeah
oml
one of my devs keeps doing that instead of Main.get()
ive caught most of them
smh
if only error messages could be a little less vague
yes
well
actually
FarmingCore
MiningCore
use new Main();
and then make sure to read
?event-api
breh
ok
^
look how it uses custom event
specifically the static HandlerList
might not need to pr
not needed
Hey guys!
I need a little help in the spigot development, I need to get a part of the item lore into a string
For example
Owner: {PlayerName}
I just need the player name of the item lore, how do I do that?
loop through each line of the lore, find where it begins with the "Owner: " string and then get the rest of the string
then you could use Bukkit::getPlayer to transform the string to a player object
altho may I ask why you do not use the persistent data container api?
^ using lore to store data is fragile and unreliable
what about metadata/nbt
as is using a container name to identify it but i still see it a ton
i know pdc best but what about those
yes
yeah i changed it to Main.get() and its error on that line
make the task() return void
and then pass this::task
instead of task()
in the constructor
in the scheduleRepeatingTask?
myes
alr
Ewwwwww storing player names in lore
What is this 1.8
Don't know what that is but I'll take a look at it rn.
?pdc
Just ask if you need help 🙂
If you could, would you give me a quick example of how would someone make a use of it ?
🕶
awesome it's fixed
look at the link I provided you with
tysm
how can i make a sound only play for one player? other players on my server say they can hear this player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0f, 0f);
hmm fairly certain Player::playSound is player exclusive
lol
DateFormatter :>
actually it might be called DateTimeFormatter
how can i edit the sent chat message if i have to use %s for formatting?
I mean
you set it
but it need to have two %s
in the new string
first one is the name, the second one is the message
"<%s> %s" is the default iirc
@ivory sleet looks nice now
😌
yes but how do i set "%s"
you do
you dont really set it
its just arguments
the first one will be the player
unchangeable in principle
and the latter can be changed with AsyncPlayerChatEvent::setMessage iirc
yes
alr
or in kotlin:
"<%s> %s".format("a", "b")
you're not supposed to pass the arguments as already said
...
then how do i set the second %s to the new value
go ahead conclure
ah k
is there a String.replace() function that allows me to input multiple parameters to get the same output replacement
message.replace("&k", "").replace("&l", "").replace("&m", "");
does someone know how I can make the links clickable in a JOptionPane?
so like message.replace("&k" "&l" "&m", "") kinda
wdym
oh
no
there aint
:(
iirc you can use a jtextfield which supports html components
thx, I'll take a look
i don't think you can in a JOptionPane
you can technically check when a user moves their cursor/clicks and check bounding boxes of links to make your own sorta clickable link
lol no way too complicated 😄
is it possible to detect a right click on an entity such as a dropped item?
maybe a ray trace? idk
how did you create that? i'd like to know
i dont have much experience with runnable jars, where do i put the method/run it?
I'm using a JEditorPane now where can just throw HTML at it 🙂
wrong sentence
I meant I am using the editorpane now, because that's where I can just throw HTML at to get my links
nvm
foreach does not return a boolean
your main method can be whereever you want, as long as it's a public static void main(String... args)
then just define the main class in the MANIFEST file
in bytecode, String[] and String... is the same
Figured
whats the equivalent to a forEach that returns a boolean
wdym?
.
well forEach takes a Consumer, if you wanna return a boolean, you want to have a BooleanFunction
im tryna iterate over a list and return true if one of the values matches the condition
Function<YourObject,Boolean>
what
no it's in a if statement
or if you simply wanna check if your list contains something, use a stream -> filter
ah anyMatch is what im looking for
I'd just use this
ArrayList<Object> list = null;
Object objectToFind = null;
boolean isObjectInList = list.stream().anyMatch(o -> o == objectToFind);
or use an anyMatch
oh you already wrote that
second part of the question
how come i cant join something after collection a filter?
how did u listen for jar opening
like executing the jar
just curious
just a normal public static void main() method
with a MANIFEST file
or anyMatch(objectToFind::equals) i think
wdym? You already collected it to a list
they want to apply some custom logic to it
do u rly want to check by instance
well yeah but you can join a list can you not?
wher eis that?
i get invalid target release: 17.0.3 when running mvn package
mvn -version output:
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /opt/maven
Java version: 17.0.3, vendor: N/A, runtime: /usr/lib/jvm/java-17-openjdk
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.16.14-arch1-1", arch: "amd64", family: "unix"
java -version output:
openjdk version "17.0.3" 2022-04-19
OpenJDK Runtime Environment (build 17.0.3+3)
OpenJDK 64-Bit Server VM (build 17.0.3+3, mixed mode)
im using maven-compiler-plugin version 3.10.1, and exec-maven-plugin 3.0.0
setFocusable(false) to the JButton btw
Plugin devs seem to forget normal java apps use public static void main :p
didnt think that it would work for a bukkit plugin
yeah
totally not me
what does it do?
isn't that just so that you can instantly dismiss it with return?
so it's preselected
the box surrounding OK
hm I'll check it out
ye but it ugly
haha this is smart
what are you trying to do
basically theres a list of color codes i dont want users that can use color codes to use
like &k, &l, &m, etc.
it just seems redundant to repeat the .replace() function over and over again
especially since im replacing them all to the same thing
i mean you can put them into a set
for(String entry : setOfCodes){
message = meesage.replace(entry, "");
}
dont use contains just replace it
meesage.replace(entry, "");
Lol ty for the notice
hey how do i create a manifest file
META-INF/MANIFEST.MF
generally speaking it will always be your build tool generating those for you
Main-Class: me.imaginedev.somepackage.Main
so google <your build tool here> generate manifest.mf
with a trailing eol
bruh
Name it MyMainClassClass.class
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
jcenter()
maven{url = "https://repo.unnamed.team/repository/unnamed-public/"}
maven {
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
// As of Gradle 5.1, you can limit this to only those
// dependencies you expect from it
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
}
```Is this how you correctly declare repositories in gradle?
I was bored once again https://github.com/JEFF-Media-GbR/StandalonePluginScreen
jcenter no longer exists iirc
but yes
There's probably no way to check if a player is holding left click except when mining a block, or is there?
Always links to your discord
Time to shove it in every plugin and flood you with support requests
whoever is stupid enough to double click a plugin .jar definitely needs help
Plugin#getLogger#warning
or Bukkit#getLogger#warning
or just simply
System.out.println("asd")
That works too
how? that would print in consol.e?1
can anyone help me with my server i got a super annoying dupe glitch i dont know how to fix
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Gradle's giving me unresolved dependencies, I think my repo format is wrong?
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
maven("https://repo.unnamed.team/repository/unnamed-public/")
maven {
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
// As of Gradle 5.1, you can limit this to only those
// dependencies you expect from it
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
}
```I added in the repo as it states in its documentation like so (The repo.unnamed.team one) But it still gives me the errors
no i know java and all
i just assumed that since System prints to the console where you ran it from it might not print into server
nvm
how can i do autofill for booleans? so true or false in the arguments?
do i have to make my own custom autocomplete or is there an easier way?
I don’t think there’s any built in one in spigot
There is a brigadier tho
Yes that would be your own custom autocomplete
Is it still impossible to teleport a player in a PlayerQuitEvent? @quaint mantle
@ivory sleet can u help me out
?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. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
got my plugin to run as a standalone program as an easter egg lol
how would it not?
teleport from PlayerQuitEvent
maybe dont teleport
just set their location in the world file? im not sure if thats easy to do or not
would anyone wanna help me debug this snazzy little snippet
String condensedMessage = message.toLowerCase().replaceAll("[^a-zA-Z]","").replace(" ", "");
player.sendMessage(condensedMessage);
if (filteredWords.filteredWords.contains(condensedMessage) || filteredWords.filteredWords.stream().anyMatch(s -> condensedMessage.contains(" " + s + " "))) {
event.setCancelled(true);
player.sendMessage(u.f("&3&lPLEXPVP &8» &7You cannot say blacklisted words &b" + filteredWords.filteredWords.stream().filter(s -> s.equals(condensedMessage) || condensedMessage.contains(" " + s + " ")).collect(Collectors.joining(", ")) + "&7."));
for (Player p : Bukkit.getOnlinePlayers()) if (p.hasPermission("staff")) p.sendMessage(u.f("&3&lPLEXPVP &8» &b" + player.getName() + " &7tried to say blacklisted words &b" + filteredWords.filteredWords.stream().filter(s -> s.equals(condensedMessage) || condensedMessage.contains(" " + s + " ")).collect(Collectors.joining(", ")) + "&7."));
}```
oh god
heh
tf
wtf
Would anyone happen to know what causes YAML to be saved with these lol
are those pointers 😂
why tho 
It puts them there at random
Sometimes they there, sometimes not.
And they get placed in different spots 
^ it appears when types that yaml doesnt know how to handle gets added
it's kinda like extra info for parsing
afaik
idk
It's just on drugs I guess
It's fantastic that it saves it like that though and has no idea how to read it back in lol
Maybe if u saved it how I gave it to u it'd be readable 
event.setFormat(u.f("&8[&b" + level + "&8] " + prefix + "&7%s &8» &7") + (u.f("%s"))); how come i cant allow people to use color codes with this
I mean why dont you just use ChatColor::stripColors
u.f() is a shortcut function for translateAltColorCodes
so much easier
whats that do
it strips away colors
oh
just use
event.setMessage(ChatColor.translateAlternateColorCodes('&',event.getMessage())) then
perhaps
thatd be the same exact thing
well thats what Id do
no clue whatsoever what u::f does
and like, the setMessage method is just so much more convenient here
Shouldn't you be using event.getMessage() instead of "%s" in the u.f() call
For me it looks like it is translating colors in "%s" first and then replacing it.
myes
thus this would be needed
well ima try then
String condensedMessage = message.toLowerCase().replaceAll("[^a-zA-Z]","").replace(" ", "");
if (filteredWords.filteredWords.contains(condensedMessage) || filteredWords.filteredWords.stream().anyMatch(s -> finalMessage.contains(" " + s + " "))) {
event.setCancelled(true);
String triggeredWords = filteredWords.filteredWords.stream().filter(s -> s.equals(condensedMessage) || condensedMessage.contains(" " + s + " ")).collect(Collectors.joining(", "));
player.sendMessage(u.f("&3&lPLEXPVP &8» &7You cannot say blacklisted word(s) &b" + triggeredWords + "&7."));
for (Player p : Bukkit.getOnlinePlayers()) if (p.hasPermission("staff")) p.sendMessage(u.f("&3&lSTAFF &8» &b" + player.getName() + " &7tried to say blacklisted word(s) &b" + triggeredWords + "&7."));
}``` so my filter works pretty well
except for the fact that players can say blacklisted words at the beginning and ends of sentences
and idk how to make flags for those without tripping over words like
battlepass
filtering is hard
its extremely easy to bypass with special chars
and empty spaces
spaces and extra chars are filtered out
and then there's this issue, what if a word used in a special context makes it a non curse word
where it would normally be a curse word
:(
have a good Thread.sleep Conclure
Cause you need to assign the query to a variable
You can’t do queries without assigning them to variables
so change it to
p-> spaceAbuse = p.length() > 2 ? spaceAbuse + " "+p+" " : spaceAbuse + p
also should probably use StringBuilder rather than String if ur gonna add strings together
ah ok
When you go to set a value in the config it asks for a path
How do I make the path the whole file?
I dont think you can do that with the builtin YAML stuff
with plain SnakeYaml it'd be no problem I guess
help me with some logic here pls
@Override
public void render(@NotNull MapView view, @NotNull MapCanvas canvas, @NotNull Player player) {
Location center = new Location(player.getWorld(), view.getCenterX(), 0, view.getCenterZ());
Location location = player.getLocation();
game.getShoots().forEach((time, shoot) -> {
if (System.currentTimeMillis() > time + Configuration.gameShootTime || shoot.distance(location) > 10)
return;
canvas.setPixel(128 - Math.abs(center.getBlockX() - shoot.getBlockX()), 128 - Math.abs(center.getBlockZ() - shoot.getBlockZ()), (byte) 16);
});
}```
basically, i want to show red pixels at where a shoot happened
like pubg
but the 0 of the canvas is the top left
not the center
whut? when I added cursors, 0,0 was the center
weird, then they use different coords for pixels and cursors
yes it does
but where's the problem? can't you just
- get the x and z offset of the location you wanna mark from the center offset
- add 64 to both numbers
- done?
?paste
tried that
worked until some point
this is my code rn
im in the center
but the red pixels are at my left
the max coordinates for maps, is 0-127 for both x and z
ik
64,64 should be the center of the map
yes
so I don't see the problem....
do you know the math for getting chunk coords from world coords?
don't you have to switch center with shoot?
if you're left of the center, the number should be negative, not positive
if you do, then the principle is the same for translating world coords to map coords
basically you have to compress the coords
there is no negatives with map coords
have to normalize all the values too
there are when using cursors, which he does
ah
Well, as far as translating the coords from the world to the map, you basically compress it in a similar way you would to get a chunk coord from a world coord
yo
it seems that negative numbers are the problem
in the first code you sent you were also using Math.abs
do you still use that?
doesn't seem right
nop
simply do x = playerX - centerX
shouldn't that work for cursors?
everything there is working fine
hey guy esixt StartAler in spigot plugin development?
just in case you are curious for the math
you divide by 16
2048x2048 blocks fits in a map view when zoomed all the way out, you can get the xCenter and ZCenter of a map which helps knows the area of coords the map will cover
to apear an allert on the game ex:THE START IN 1.... (not in chat)
helps if you make yourself understandable
what?
no one knows what you are talking about
do you know a bedwars game in minecraft?
I have to do like those servers that when you enter it appears the game starts in 1 minute ..
and you don't want it to be shown in chat?
you have a few ways you can do it
you can use the title bar, boss bar or broadcast it
OH TANK YOU
i did not understand the math
ok, Xcenter and ZCenter refer to the coordinates in the world that the map represents
since we know 0,0 is top left and corresponds to Xcenter and ZCenter
and we know that a map can represent 2048 blocks for x and z
128x16 = 2048
hm
so to get the world coord to the map coord, you would dived the world coord by 16
divide*
also you have to use absolutes since there is no negatives in the map coords
?
yes, but then the additional check is to ensure the location you are grabbing is part of the map, not sure if your map is dynamic or static
if its just an area where people can't go outside of that isn't really necessary
Anyways, that is the math explained. Isn't all that hard 😄
it did not worked
you need to make sure BlockX is not a negative if it is, make it positive
Anyone know how to avoid the WorldChangeEvent trigger on player deaths?
wait, i forgot to use setPixel
that would happen if they died and where they died is not in the same place as the server spawn
thus when they respawn a worldchange event has to happen
Yes, but it happens even before the player clicks respawn
It happens when their health reaches 0
well yeah, they are dead. So before they hit respawn the server automatically sets them back at server spawn
even if visually it hasn't happened
not like they are coming back to life unless they hit that button 🙂
Ah, interesting. And I'm checking their health, but that isn't a good indicator either since their health is auto-reset back to 20
so how do I ignore the event for this instance?
why do you want to ignore it
well a death event would have been thrown first
listen for death event, set boolean, check boolean from your changeworld event if its because they died
if so, ignore
Is there a way for EnchantmentTarget (getItemTarget) to return a target of only axes, instead of all tools?
where did it plot it on the map?
some place outside the map
did you ensure you didn't have a negative in there?
yes
lol
I'm doing this, but now my respawn location is being overwritten by the server spawn location. Still not working
I don't know what it is you are trying to accomplish really nor can we see any code
are you trying to make it to where they respawn in the same world they died in?
is there a plugin to become a werewolf, vampire, or human for spigot/paper?
was in Performium towny a while back
sorry, forgot lol
yes, I have a respawnevent setup where it sets their respawn location to the same world they died in
but the world change event is still being thrown
Probably because the flow is death -> server spawnpoint -> what would be my spawnpoint
but weirdly I'm not seeing that last part even happen ^
ok, not sure why changeworld event is important
if you are listening to the respawn event and setting the respawn location, that is all that should be needed o.O
Hola necesito devolopers que me ayuden a hacer una Network md porfavor
In the worldchangeevent I am teleporting the player to the server spawnpoint... That's the issue
Whenever they leave a certain world I want them to be tp'd to the server spawnpoint
so it seems like that's overriding my natural respawn (because before they can click the respawn button they're automatically respawned by the other event)
so instead of doing anything in the respawn event, record their location and set a boolean, check that object in world change event. Teleport them to the location.
then you don't have to worry about anything being overridden
help again with maps
i want to draw a square
i give it the size of the square
then it will draw the square based on the center
this actually worked, tysm
good thinking
example:
well don't always have to go against the system 😉
what issue exactly are you having?
i dont know how to do it 😭
that is everything i have for now
now i just need to fill the arrays
if you know how bounding box's work, it is similar to that
idk
alright I will wait to see if you figured it out 🙂
sweet, now I can show you the math to do it easily
that works, I will show you how I would do it here in a bit
frostalf are you writing a book? :D
so tell me... where did you guys learn bitwise operations
How would I get the location to the left of a block if I know the direction its facing? (Im shit at vectors)
what would i do:
convert the blockface to degrees
takes 90°
convert the degrees to blockface
success
legends say frostalf is still typing
int BoxCenterX = MapX;
int BoxCenterZ = MapZ;
int BoxMaxX = BoxCenterX + TotalBoxHeight/2;
int BoxMaxZ = BoxCenterZ + TotalBoxWidth/2;
int BoxMinX = BoxCenterX - TotalBoxHeight/2;
int BoxMinZ = BoxCenterZ - TotalBoxWidth/2;
for (X=BoxMinX; x < BoxMaxX; x++) {
for(Z=BoxMinZ; Z < BoxMaxZ; z++) {
canvas.setPixel(x,z,(byte) 32);
canvas.setPixel(BoxMaxX - X, BoxMaxZ - Z, (byte) 32);
}
}
Ok I don't have my IDE, but this should work. My Primary HDD went down the other day so haven't quite setup everything yet so this is off the top of my head lol. You can further condense this if you want as the math basically revolves around mirroring so you are not running extra loops. Basically you only need to do it for half the box, then using math apply to the other half in the same loop.
Alrrr let me try that
This is why it helps to know math 😛
declaration: package: org.bukkit.block, enum: BlockFace
if you know the direction the blockface you have is facing, then you can get the other sides of the same block and get adjacent blocks using relative locations
I have been trying to create a custom mob class but it seems like the mobs revert to their parent class whenever the chunk unloads and reloads. .setPersistent(true) does not seem to help. Anyone has any idea how this should work?
You could try this @hardy swan
ah ok
Otherwise, you need to use PDC and basically reload the entity if it's got some sort of flag that you set.
I registered on enabled
if you get Coll's idea working btw lmk 
lemme try
so i have a mathf question. i have a formula with some exponentional growth. its used to determine how much an "upgrade" should cost. now if i want to calculate how much it will cost the player to upgrade 1000 levels at once. will i need to loop 1000 times and add up the cost each time to determine that cost or would there be a better way to achieve this?
Yes, custom entities revert back to normal ones when they are unloaded in a chunk, this is because technically the entity dies and gets respawned when the chunk loads again with its data that was saved. So a way around this is to save the locations of your custom entities for when chunks unload as well as server restarts and then when the chunk gets loaded again, use your location list for that chunk to get the entity that is supposed to be yours, kill it spawn your custom one again.
if it is exponential you should be able to just use math to multiply how many times to get your final upgrade level. Using a loop would work but inefficient
not sure how you mean just multiply
I don't know your formula or how you calculating how much an upgrade costs to begin with
this is what i use
private double quadraticBezier(double progress, double min, double max, double total) {
return quadraticBezier0((progress / total), min, max, min);
}
private double quadraticBezier0(double t, double start, double end, double intersect) {
double scalar = (1.0 - t);
double firstToIntersect = scalar * ((scalar * start) + (t * intersect));
double intersectToSecond = t * ((scalar * intersect) + (t * end));
return firstToIntersect + intersectToSecond;
}
bassically it can create an exponentional curve between 2 values
but if someone wants to upgrade like 5k levels at once
thats alot of calculations with a loop
this basically the formula for exponential growth
x(t) = x0 * (1 + r/100)^t
yea but that aint what i am working with
i need to be able to have a min & max and generate a curve between those 2
do you have a max limit?
yes
for example
and that works fine. i just need a way to calculate multiple upgrades without looping
but im not sure im gonna be able to get arround that
That's sounds like it is prone to oversights. I think there could be another way with datafixers, but I will have to do more research on it.
And yea, I think this is right too
what do you mean prone to oversights?
That is just the way entities work, their data gets saved and they despawn when a chunk unloads. You could see if you can use PDC to set custom data on those entities to make it easier to know which ones were your custom ones
but essentially when the chunk loads and the entities respawn, all you have to do is either kill the entity that is the normal one or I don't remember if there is a spawn event for entities if the chunk loads, cancel the event for those entities that were originally yours and spawn your custom ones in. In either case, custom entities don't get saved because the MC doesn't use your entity class to spawn the entity.
not sure if you will be able to get around the looping. I will have to work out the math or ponder on it to see if there is a way you could simply not do that. However, what you could do instead is pre-calculate all the known values of your curve up to the max denoting the levels
in this manner you don't necessarily need to loop, you already know what it should be
there could be millions of upgrades though
you said there was a max
so the max is arbitrary then
yea i probably shoulda mentioned that
well, I recommend running this function in another thread
this way, if it takes a bit of time, at least the main thread can still do its thing lol
I do know for fact there is a function you can use to figure out all the known points between your two points, just not sure if the function can be done without a loop
so I will have to research a bit to figure it out, will let you know if I come up with something 😛
ah, thanks i appreciate that
Think I have something for you
// t is a value between 0-1 to represent percentage and thus will always be a fraction between the start and end points.
t = 0.5;
x = (1 - t) * (1 - t) * p[0].x + 2 * (1 - t) * t * p[1].x + t * t * p[2].x;
y = (1 - t) * (1 - t) * p[0].y + 2 * (1 - t) * t * p[1].y + t * t * p[2].y;
this should give you any point as long as you always know the max AKA the end point regardless of what it gets set to, and the start point
p[0] is start point, p[1] is your control point, p[2] is your end point t is the parameter going from 0-1
maybe not be code per-say but, if you know how to turn your levels into percentages this should work
also hopefully you understand the math too XD
lol
I don't want a decompiler because I don't want to see Java source code
Java isn’t assembled
Lol
You just want to look at the bytecode
So any bytecode editor would work
Okay if you wanna get pissy about the semantics
What is the best
JVM BYTECODE DISASSEMBLER
with a GUI?
It’s not semantics
It’s not a Java anything you want
You just need a standard bytecode viewer
Java bytecode isn’t special
A disassembler is something specific
A Java Reverse Engineering Suite. GUI Java And APK Decompiler, Editor, Debugger And More.
Is that gonna decompile it for them lol
it will do whatever it is they are wanting
it will decompile or let you just look at bytecodes
and its a GUI
Fair enough
I'm still gonna call it a disassembler :p
I mean, something doesn't need to be assembled to be disassembled either
You just need to convert it to an assembly language
You can assemble JVM bytecode
There are tools for it
And there are tools to disassemble it too
I prefer the term "disassembler" as
well
for one
THE FUCKING JDK USES THE TERM
A disassembler turns machine code back into assembly
The javap command disassembles one or more class files.
And that's not entirely true
“A disassembler is a computer program that translates machine language into assembly language—the inverse operation to that of an assembler. A disassembler differs from a decompiler, which targets a high-level language rather than an assembly language.”
You could very well disassemble bytecode as bytecode is just a specialized machine language.
Literally I googled the definition
The only thing that makes bytecode and machine code different
is that machine code is passed to the hardware processor/CPU
instead of a VM
I don't consider that difference great enough to warrant completely separating the terms
Suit yourself ¯_(ツ)_/¯
Also "machine code" is just vague as well, as there's multiple instruction sets (x86, x64, ARM, MIPS) and multiple executable formats (PE, COFF, ELF)
(Although the OS would handle the latter)
And actually
If you really want to keep arguing that JVM bytecode can't be disassembled because it's not machine code
Jazelle DBX (direct bytecode execution) is an extension that allows some ARM processors to execute Java bytecode in hardware as a third execution state alongside the existing ARM and Thumb modes. Jazelle functionality was specified in the ARMv5TEJ architecture and the first processor with Jazelle technology was the ARM926EJ-S. Jazelle is denoted...
A Java processor is the implementation of the Java virtual machine (JVM) in hardware. In other words, the Java bytecode that makes up the instruction set of the abstract machine becomes the instruction set of a concrete machine. These are the most popular form of a high-level language computer architecture today.
^ JVM bytecode is technically machine code too as some hardware processors can run it
Anyway:
- Krakatau and Jasmin can assemble JVM bytecode using the Jasmin assembly language (Krakatau modifies it slightly).
- Krakatau can disassemble JVM bytecode to the Jasmin assembly language.
- The JDK tool
javaprefers to itself as disassembling classfiles (thereby making it a disassembler)
- OpenJDK has an internal project called
AsmTools, that, well..."AsmTools consist of a set of (Java class file) assembler/disassemblers"
So, yes. It is semantics :)
Those are no longer used as processor speeds have since increased where it became unnecessary and thus was wasted space to keep the instruction set around
while in practicality you are correct that there was hardware that could execute bytecode directly
they have since been obsolete
Yeah and Itanium is discontinued but do you invalidate its existence as a processor?
No, but it is no different then there being Java OS's that existed. But again are now obsolete or no longer used. These all came about because processor speeds were still in the mega hertz and not in the giga hertz where it doesn't make a difference
But I have already stated you are correct about there being hardware that could execute bytecode directly
however in modern times, to make your assembly/disassembly definition fit, we could just pretend the JVM is the cpu for the purposes
as long as we pretend there isn't something in between then the definition works 🙂
I mean that was just with the definition of "machine code"
And, you gotta argue semantics to win against semantics
Anyways....we can move on now lol
Yep
I have claimed my victory
I am satisfied... for now
wow my internet is slow af
İm seeing the discord code messages white on mobile. How can i fix it
No fix, that's how mobile works
Fuck it, i disabled the dark mode 🥵🥵
jvm bytecode is run on a virtual, hardware like architecture so i count it as machine code
WHY
why does generics have to fuck me over again
the registry type is
the exact thing it wants
Wildcards are dangerous @glossy venture
If you want read-only wildcards are good, otherwise don't use them
yeah
I think ModElementRegistry<? extends CarbonItem> might work but idk
Also I'd use diamond operators
i hate how the compiler requests a generics class which isnt even constructable
That is because you Tell it to use it
yeah but theres no way to get the generic type without the type parameters
That's generic ersure for you
But there are ways of working around this. I might Help you on this when I'm free especially because I Just scrapped my mega-project I Had been working on
what is capture of ...
im so confused
ive never understood capture of
what the fuck
ok i kinda hate this but it works
what's the event for a player dropping an item?
PlayerDropItemEvent
hi guys, can you help me please? my friend set a plugin when a player enter to the server. a large writing appears with the name of the player for all player online. how can i remove it?
@glossy venture damn bro, you looking for contributors?
on the server there's a folder called plugins. go in there and remove the plugin @prime harness
of the api
also this question should rather be asked in #help-server
i need to do some javadocs
otherwise it will be a mess
Plugins (18): SimpleTpa, LuckPerms, WorldEdit, SpaunPlugin, SuperVanish, InvSeePlusPlus, UltimateHomes, SIR, CustomBansPlus, WorldGuard, GSit, ProtectionStones
How can i compare iterator.next with an int
i can only tell you that luckPerms, WorldEdit, SuperVanish and WorldGuard arent the cause of that text. You need to find out which plugin causes it and disable it
cause like, you're making a thing that I was just planning to start making lmao
My guess is “SpaunPlugin” personally
alright sure but ill still need to implement some framework
shrugs
bleugh
I remove it and i replace with simplespawn
Why don’t you just ask your friend what plugin he installed and ask him to remove it
also @worn tundra idk how to host the resource pack, im trying to use an http server hosted on the minecraft server but its not working
because it needs extra ports
he is stupid and doesn't know what it is
Remove plugins one by one until you figure it out
like @glossy venture you cant have both your server connection port and the resource pack host site port
work at the same time
i know
is that port open tho
what exactly isn't working there
.
heres the issue
are u making a custom server jar
I assume the resource pack is zipped?
nah its a plugin to load content mods
How can i get the output from iterator.next
yep
i checked it the zipping works
Isn't the url supposed to end with ".../file.zip" in that case?
Since you need a straight link to the file
Yeah, minecraft needs a link that downloads the file right away
returns like an outputstream
oh that would make sense
You'd also have to create your own HttpHandler
it wasnt working in the browser tho
Look into that interface
yeah thats the lambda
creating the context
Oh
Right
Something like this
Which I assume you're doing something similar already
i find it. it is the s.i.r. plugin
Hello guys is forge simpler than spigot
no
unless you do it with one of the half-working mod creators
but then you have to still do a lot manually
Arguably it can be almost as simple as spigot
Once you learn Minecraft’s code that is
Forge is way more complex than spigot
It’s a bit more intricate sure but with good tools it becomes quite easy to work with
Forge has much less documentation. You'll be spending a lot of time reading and understanding vanilla source code. You need to have a full understanding of how tags and the like work and interact with registries. Etc etc
It's Wildcard. Capture of X means everything that is an instance of X. ? extends X means everything that is an instance of a class that extends X (theoretically this includes direct instances of X but idk)
Sure will, though you’re given quite readable and almost ready-to-use code if you for instance use mojmaps and parchment.
So solving most problems (if you have a good knowledge about Java (and partly Minecraft I assume)) shouldn’t be too complicated
what happens when a static method gets called by multiple threads, and what happens if a non-static method gets called by multiple threads?
ie
what is important to be aware of
If you have state mutation you might run into concurrency update problems
are there any problems if it runs with separate locations as args but the same instance of an event for example
I have a huge mod I work on. A lot of errors are complicated and a pain. You tile entity won't be updating because you missed a method call to something. You'll create a tile entity and it works in singleplayer fine but adding it to a server causes a nuclear war. For a simple tile entity you need
Block
Screen
Container
Tile
Which need tonnes of jsons and pngs
No not really, Moterius
i ain't an engine conclure
Better? :3
ye :D
Haven’t experienced that personally
Just don't use Mc creator or I'll hit you with a stick
