#help-development
1 messages · Page 272 of 1
ahh lol
bruh
it says is c++ 11+
I forgot I blocked nukerfall
I was wondering like
"did one of these bots get in the server how many blocked messages are they sending2
Player#teleport does not work when the player has a passenger, but Enderpearls and the vanilla command still works for teleporting, is this intended? 😅
lmao
i was going to dm you, but i realize you were ausent so i didnt do it
you have memory leaks
I want to block nukerfall too
yes
And your issue is you checking if they clicked a block with their offhand ?
for some reason
you can't tp entity with passenger
remove the passenger, teleport the entity and add passenger again
y?
Ooof 😅
I cannot add directly the condition of OFF_HAND inside the first if, cuz if not it blocks the block placing/breaking events
cuz idk
Thats a conclusion i taken
I'll figure out a reason
wtf lmao
give me a bit here pal
thast stupid hang on
lmao i will take some time out while you stop discussing
And i can paciently ask for help while no one disturbing*
} else if (event.getClickedBlock().getType() == Material.AIR && event.getHand() == EquipmentSlot.OFF_HAND) { here is your issue right?
hot
i'll try to switch from struct to another class
In all of the contidions i think
So if I understand properly, you're condition for building gets overwritten instead of the interaction because a player is holding a block in their offhand ?
Because i testing right? And having the permission or the mode active and being member block placing/breaking events
lol i didn't
I think im lost lol
wait
Let me write a full msg
So its better for you
yes please lol
when I do Player player = Bukkit.getPlayer(entry.getUuid()); I get null. When I do a System.out.println(entry.getUuid()); I get the uuid of the player. Any ideas?
do #getOfflinePlayer()
bro i swear, nms isn't abstract enough
I would like it to be as abstract as the Minecraft Protocol
this looks hotter too
and possibilities to turn Entities into the Metadata format for the minecraft protocol
they want to send a message to that player
do a null check
right but they aren't checking if the player isOnline
its also better practice to do getOfflinePlayer() so..
#getPlayer assumes the player is online
is your getUuid() returning an actual UUID or a string of the UUID?
Ntdi:
Im doing a mini game, where you have a mode called build which should allow you to (while having mode active):
(Always being inside the region of course)
- Place/breaks blocks
- Not interact with anything (which contains storage, neither blocks nor entities)
I success with the interaction block, when i realize that i need to disable off hand all isues came, because i want to disable putting items on it so that started to cause issues with my conditions.
Because as far as placing blocks is know as Equipment.OFF_HAND, then my onInteract listener override the block placing/breaking
I think a string what is the best way to check. this api is documented like trash
then you will never get a player
you need to use UUID.fromString(entry.getUuid()) or something close
goddamn java
So the issue is that people can not place items with offhand, making them interact. Correct?
I couldnt udnerstand the question, sorry my english is not really good
Oh, my bad let me rephrase
But i just want to block putting items in the off hand, which was added in 1.9+ the one used for putting the shield. But ppl use it for what ever
That the issue, Of hand, is used for placing blocks and also for that slot
I see, what's wrong with that?
You don't want players to be able to place blocks with their offhand.
No i dont want to use that slot
this worked Player player = Bukkit.getPlayer(UUID.fromString(entry.getUuid())); thanks for the help
So why don't you cancel inventory click event for that slot?
Its better right?
In my case i use that one, because ppl suggested me to use the PlayerInteractEvent
You can use that and check if they are interacting with OFF_HAND right?
Do i need to use both of them? InventoryClickEvent and InventoryDragEvent
Yes,
PlayerInteractEvent allow you know the hand using, but OFF HAND is for too things the one for placing blocks and also for that slot, so that cause all my issues
You can check the action they are using in the PlayerInteractEvent
Yeah i did that, but then its started to override the block placing 🤣
That makes no sense 🤣
Yeah
That why im messed up and came to ask it here
All problem is that OFF HAND is not just that simple slot
I think that OFF hand you should only be slot hand mean to be used with the shield
Because if not its confusing asf
yes -;
That why we are mixed now 💀
thats so confusing
yeah, also thanks for understanding me, no one beside you, Fourten and yk2 understand
yeah know i will have to see how to fix this poroblem 😮💨
🤣
yeah its funny until you need to finish fast a comission
oh its a comission??
yeah i just need that to be done and its finished
oh man I don't take comissions for projects im not fully capable of understaind 
hot
haha happens to me, but i try to do my best
good luck 🤷
Can i add you, you look like really friendly
Yeah for sure
thanks man
i fucking made it
Is there any way I can include the "*" character in my yml configuration?
The same happens if I use apostrophes...
why would you anyways
I've read that I should use apostrophes instead of quotation marks, but that doesn't help anyway
back slashes?
I am trying to make it as user friendly as possible. The back slashes may confuse some people
The "*" is important though, because this text is meant to be sent by a Discord bot so it has to support Discord formatting
Ah I see now i understand,
I'm using Waterfall 1.8-1.19(Bungee) and Spigot 1.8(Lobby) using ViaVersion. But the blocks of 1.19 transforming in stone, how fix? Thx
I tried change Spigot to 1.19, but plugins no work in the version
Only 1.8
more of a general thing but how can i clean this
is there a better way to lay it out
like what do you guys do
What the best option, for disable the slot 40 from player inventory using Bukkit?
ah yes thats what happens when you add new stuff
for none programming questions, pleas euse #help-server
i never use the power operator Math.pow is my go-to
(i dont know why, but it fixes things for some reason so i dont ask)
yeah u need to convert to rad
thats not the issue
stackoverflow
classcast
etc
time to debug
looks like multiple parameters seem to break
Hi I thinking how in spigot source I can add method from plugin (if I add method to source spigot and I get error ClassNotFound)
what is this theme?
one dark
Make your variables private and I like to have getters and vars divided (only vars first then only getters)
And if its just used to hold data, make it a record
Ok sorry, thx
how could i copy a text file from the java resources folder to the plugin data folder?
JavaPlugin#saveResource
thanks
How to update texture change NMS for the player itself
If all attributes are final, make it a record.
What is considered a ConfigurationSection?
Mysection:
My option: falsee
My option 2: 05
section:
a: 1
b:
- 1
- 2```
If an armorstand is on a player's head. Is it normal for the EntityDismountEvent to constantly be called even though it's still on the player's head?
Is 'a' a section?
im trying to make something to set a lot of blocks quickly with no lag i have https://pastebin.com/M5REDzC4 which works kind of, it has a lag spike when starting but after it starts it works with minimal lag, could anyone give some advice on how to make this not lag or another way to set a lot of blocks with no lag & fast
Like if I try to check if a is a configurationsection, will it return true or false?
I'm having issues with it and I'm getting confused 🤨
Is My option a ConfigurationSection or only Mysection is considered a ConfigurationSection?
a is a key to an int and b is an int list
So section is a ConfigurationSection but both a and b are not?
can anybody help me why this isn't work I'm trying to make a plug-in where you can only have 24 apples in your inventory at a time
th for the help
oh my god this is the worst thing I've seen in a while
why are you doing it like this
AtomicInteger too my lord
just use events
InventoryClickEvent, EntityPickupItemEvent
I've seen wrose.
ok lol
ofcourse like my code
don't blame the AI that wrote it
The AI is a tool for people who know how to already use and fix the code it writes.
It is not yet at a part where you can simply use it.
ye
I got to be honest I don't know a lot of coding
I would totally pay but I don't have any money
then oyu better start learning :}
Yes
bump;
spread placing them apart
I can probably make the thing you want later, give me about 30 min ish. Ill show the code after
? because im placing them in waves kind of, 80 blocks per tick instead of 500 blocks in 1 tick
i dont understand sorry, i want to place blocks fast with no lag
im just trying to find the best way to place thousands of blocks fast with no lag
mcedit
ive found forms which say to use schedulars to spread the placement apart
whats that?
Well on the pure theoretical and technical part, would it not be the fastest to only a chunk, modify the data in the file itself and then load it again? lol
id rather have placing 3000 blocks take 1 second with no lag instead of 1 tick with a lot of lag
https://bukkit.org/threads/set-1000-blocks-without-causing-lag.301577/ i found this which says spread out blocks using shcedular
Yes
plz
thank you so much
How many spigot plugins are out there rn
and if I try and tab complete 100k values or so, how much lag would that cause
if i use this and the player isn't online will it return null Bukkit.getEntity(UUID)
yes
so use getOfflinePlayer
on the spigot site there is 58,405
Well you make 2 methods, one for name and one for UUID
^^
I have this SELECT tokens FROM tmtokens WHERE uuid = %s
but it returns Unread result found
Python
Ah ok
Oh
Making a discord bot hook into a MySQL db so users can see their stats via command
oh wait
I need to check if "" are required
Why use name then?
Can't you always use the user id?
It's for a discord bot
this is painful lol
Doesn't python have prepared statements?
I saw an image earlier that explains it well
sec
rip can't find it
but there was an image with a grass block
showing everything
XYZ position etc
unsure
found the error
got it
I always hated trigonometry
You are confuse, what he wants is called work distribution
sometimes
is there a way to get the id of modern materials?
im using it for this
but i cant do #getId()
There is no longer any ids for items.
so how would i do this then
They have an id on the global palette, but not tied directly and is not dependent on the item. No clue how to get the palette or what that is all about
Can you use the remapped jar? For better function names
?nms
yeah i can
ome moment
just converting my code rq
okay so
i got this
public static void setBlock(World world, int x, int y, int z, Block block) {
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
LevelChunk nmsChunk = nmsWorld.getChunkAt(new BlockPos(x, y, z));
BlockState state = block.defaultBlockState();
LevelChunkSection cs = nmsChunk.getSection(y >> 4);
cs.setBlockState(x & 15, y & 15, z & 15, state);
}```
but now how do i convert a material into net.minecraft.world.level.block
why are you using nms to set a block
faster way of setting them
I need SerializationUtils from Apache, but even though I'm using maven to get the spigot API it seems like I'm not depending on apache, how do I? (haven't touched spigot, java, or maven in a long time)
theres no way nms can be much faster than bukkit
considering, bukkit does similar calls internally I'm assuming
its a small difference
nms is much faster than spigot from experience though
(like c++ vs python, most of spigot is reskinned bukkit, but some is its own thing)
ive got this error in my plugin and I have no idea how to debug it (no info in either client or server log) and no, this isnt a client settings issue
uhm it depends
^
i think it might be related to EntityDismountEvent, as a post I found also mentioned that and the behaviour started happening after I added it to my code
but both should be completely unrelated + the error should be just a clientside thing
I am cancelling entitydismountevent
and when player 1 (thats riding player 2) disconnects, player2's "esc" menu pops up and the "Chat disabled in client options" occurs
How can I change the player's game language item name in a string?
oh I realised im like completely desynced with the server
maybe player2 has like a null passenger
Why the heck while debugging, the event is giving, is cancelling the event while i have: permission: true, build: false, region user: true
event.setCancelled(!player.hasPermission("region.bypass") || !profile.isBuild() && region.getUsers().contains(player.getUniqueId()));
Im feeling really stupid, because i cannot understand what happening
of course
It’s in your settings change chat form “Chat: Hidden” to “Chat: shown”
Oh
This is dev
im tryting to set a lot of blocks with minimal lag and fast speed, im using https://pastebin.com/4jF8QrQL which is from 7smile's guide and its very laggy, when it starts, my game freezes for like 2 seconds but after that it works fine, anyone know how to fix this?
i already said this is not a client settings issue
its some sort of weird desync with entitydismountevent
apparently if a player is riding another player and the event cancels
whenever the player thats riding leaves the server
it desyncs the other player from the server
to a state where the world basically breaks
You’d be amazed at the stupidty of people on here. So even if you say that we’d usually have to send a screenshot of you checking.
Also that is one weird issue.
the lag is probably the part where you load the data from config
ive found a thread about this specific issue (i think)
and it kinda makes sense
but theres no debug message
is there a better way to do it?
Well, it’s not an intended use
load async
which is not allow the player to leave the player theyre riding
Can’t u just unride them on PlayerQuitEvent ?
whats ur mc version btw
wouldnt that trigger the event
1.19.2
also
also is there a guide or smthn on how to load it async
whenever the player leaves it has to do something to remove itself from entities it used to ride
which is what triggers the event, but spigot/bukkit/minecraft cant handle it
its as simple as running your load code in an async task
?scheduling
and it leaves the other player in a weird state
Oh
Why do you cancel it if the player is leaving?
how do i detect if the player is leaving
afaik no values get set when the event fires, no matter the EventPriority
(stuff like .isOnline())
How can I change the translation property in a tellraw message in a string for example; replaceAll (%material%, part to change:",{"translate": "item.minecraft.creeper_spawn_egg"}.)"
@civic apex Can u check which order the EntityDismount and PlayerQuitEvent runs in?
@dry forum btw Block#setType is also a really slow method. i could give you a method that runs faster if you like?
i can change the order with eventpriorities
yes please
i made it so entitydismount runs first (LOWEST)
That’s not how that works.
id need nms though?
yes it is nms based
nvm
ahh um
maybe but then id need to do nms for every version
wait i think i know what you mean
for every version you'd like to support yes
@civic apex Well it kindof is, but isn’t
it isnt
If it runs before
i do have them for 1.16, 1.17 as well if u want those. or just stick to #setType :d
You can easily set a value, and if it’s set do not cancel the dismount.
ill probably do nms
first it calls the event
then it does stuff
and in that stuff is the "bugged" code that causes the state
not in the event call
its not my code
was thinking of that
Submit a bug report on the jira and wait until someone decides to fix it, or work around the issue.
but still its not a solution i specifically like
idk if this is a bukkit /spigot bug or a minecraft one
Try riding a player in vanilla and canceling the event there
You don't.
@dry forum well if you want em heres the other 2 versions i got https://paste.md-5.net/unasacanit.java
and yes the bug affects vanilla clients
Work around the issue. Post to Spigot JIRA how to replicate it.
again idk if its spigot or minecraft
ty 😄
Again, what are you using to cause the issue?
spigot
So, what is causing the problem other than your code?
So i'm trying to make it that a certain type of palyer(custom player type) can deal more damage with bows but for some reason it doesn't do that ive been trying to fix it and I think i'm not setting the damage output correctly
@EventHandler
public void damagee(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Arrow) {
Arrow arrow = (Arrow) event.getDamager();
if (arrow.getShooter() instanceof Player) {
Player player = (Player) arrow.getShooter();
if (playerclass.containsKey(player.getUniqueId())) {
if (((customPlayerAttributes) playerclass.get(player.getUniqueId())).getPlayerclass().equals("ARCHER")) {
arrow.setDamage(arrow.getDamage() * 2);
}
}
}
}
}```
but the code for removing passengers when someone leaves is present in vanilla
and that might or might not contain the bug
if it did, and spigot reuses the same, well its a minecraft bug
So i m trying to make it that a certain
I haven't touched maven in quite some time now, and I'm trying to depend on apache commons, xml <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-configuration2</artifactId> <version>2.8.0</version> </dependency> is saying Dependency 'org.apache.commons:commons-configuration2:2.8.0' not found, am I missing something?
ur missing the repository im guessing
correct, thanks, what would the repo be?
it's in the maven repo
?
yea just noticed that
where is it saying that
can u show ss perhaps
In my IDE commons-configuration2 is red
did u reload maven
would i put all of it in the async task? ``` new BukkitRunnable() {
@Override
public void run() {
ConfigurationSection section = configuration.getConfigurationSection(key);
double x = section.getDouble("x") + center.getX();
double y = section.getDouble("y") + center.getY();
double z = section.getDouble("z") + center.getZ();
runnable.addWorkLoad(new PlaceableBlock(player.getWorld().getUID(), (int) (x), (int) (y), (int) (z), Material.valueOf(section.getString("material"))));
}
}.runTaskAsynchronously(Mines.getInstance());``` ive never really used async tasks
xd
sorry I didn't wait long enough lol
as long as your workload runnable is sync that will work
since ur editing blocks in there that needs to be synced
if i leave the workload out it makes me convert the doubles to lists
uhh idk what u mean
double y = 0.0;
double z = 0.0;
new BukkitRunnable() {
@Override
public void run() {
ConfigurationSection section = configuration.getConfigurationSection(key);
x = section.getDouble("x") + center.getX();
y = section.getDouble("y") + center.getY();
z = section.getDouble("z") + center.getZ();
}
}.runTaskAsynchronously(PersonalMines.getInstance());
runnable.addWorkLoad(new PlaceableBlock(player.getWorld().getUID(), (int) (x), (int) (y), (int) (z), Material.valueOf(section.getString("material"))));``` says the doubles need to be arrays
u can add the workload in the async task i believe
but where are u starting "runnable"
public void onEnable() {
Bukkit.getScheduler().runTaskTimer(this, new WorkloadRunnable(), 1, 1);``` on enable
ah ok
ok ty
I'm following this https://www.youtube.com/watch?v=3OLSfOkgPMw?t=667
it says ObjectInputStream is protected
(timestamp on purpose)
I'm trying to create assists but I'm having major issue where when an existing assister leaves I'm getting weird error. It only happens when an existing assister leaves the game, when every assister is still in the game when a victim dies everything goes normally. Idk how to fix it. I'd appreciate if someone does know. Thx
Here's my current code:
for(DamageStamp stamp:profile.getDamageLog()){
if(stamp.getTickStamp()-event.getEntity().getWorld().getFullTime()<100){
assisters.merge(stamp.getDamager(), stamp.getAmount(), Double::sum);
}
}
assisters.remove(killerProfile);
for(Profile assister:assisters.keySet()){
if(assister!=null&&assisters.get(assister)!=null){
double assistPercentage = (assisters.get(assister) / 20);
Bukkit.getPlayer(assister.getUuid()).playSound(Bukkit.getPlayer(assister.getUuid()).getLocation(), Sound.NOTE_PLING, 0.5F, 1.5F);
assister.incrementCredit((creditsPerAssist*assistPercentage),true,"Assist");
assister.upgradeExperience(PlayerGainExpEvent.Type.ASSIST,
(int) (WargroundsMain.getInstance().getRankConfig().getInt("PLAYER-EXPERIENCE.DEFAULT.EXPERIENCE-PER-ASSIST") * assistPercentage)
);
}
}```
please highlight your code by putting java after ```,
like this: ```java
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
'ObjectInputStream()' has protected access in 'java.io.ObjectInputStream' Am I importing the wrong thing?
thats because u did not input a parameter yet
the empty constructor is protected
the other one is not
Check the imports
did you make some InputStream class
not even by pressing some hotkeys?
or by creating the class instead of importing :d
like, at all
but it didn't really show an error for that
package com.cjendantix.project.commands;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.io.Serializable;
import java.util.spi.LocaleNameProvider;
public class LocationInfo implements Serializable {
private double x;
private double y;
private double z;
private World worldKey;
public LocationInfo(Player player) {
this.x = player.getLocation().getX();
this.y = player.getLocation().getY();
this.z = player.getLocation().getZ();
this.worldKey = player.getLocation().getWorld();
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
}
package com.cjendantix.project.commands;
import org.apache.commons.lang3.SerializationUtils;
import org.bukkit.persistence.PersistentDataAdapterContext;
import org.bukkit.persistence.PersistentDataType;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.InputStream;
public class LocationDataType implements PersistentDataType<byte[], LocationInfo> {
@Override
public Class<byte[]> getPrimitiveType() {
return byte[].class;
}
@Override
public Class<LocationInfo> getComplexType() {
return LocationInfo.class;
}
@Override
public byte[] toPrimitive(LocationInfo complex, PersistentDataAdapterContext context) {
return SerializationUtils.serialize(complex);
}
@Override
public LocationInfo fromPrimitive(byte[] primitive, PersistentDataAdapterContext context) {
try {
InputStream is = new ByteArrayInputStream(primitive);
ObjectInputStream o = new ObjectInputStream(is);
return (LocationInfo) o.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
return null;
}
}
How do I make it actually work with storing locations?
I got the basics of custom persistant data types, but I need it to actually work
what doesnt work
ur tryna add a location
yep
while ur type is made for LocationInfo
?
^
is there something stupid I did
again
that reminds me i was gonna add custom pdc to my lib
you missed the world
i said
😢
might as well just use mfnalex's https://github.com/JEFF-Media-GbR/MorePersistentDataTypes 😄
that where im gonna steal it from
right, right hahaha
yeah I'll just use that, thanks.
No point in reinventing the wheel, although it feels wrong accepting defeat
I'm trying to create assists but I'm having major issue where when an existing assister leaves I'm getting weird error. It only happens when an existing assister leaves the game, when every assister is still in the game when a victim dies everything goes normally. Idk how to fix it. I'd appreciate if someone does know. Thx
Here's my current code:
for(DamageStamp stamp:profile.getDamageLog()){
if(stamp.getTickStamp()-event.getEntity().getWorld().getFullTime()<100){
assisters.merge(stamp.getDamager(), stamp.getAmount(), Double::sum);
}
}
assisters.remove(killerProfile);
for(Profile assister:assisters.keySet()){
if(assister!=null&&assisters.get(assister)!=null){
double assistPercentage = (assisters.get(assister) / 20);
Bukkit.getPlayer(assister.getUuid()).playSound(Bukkit.getPlayer(assister.getUuid()).getLocation(), Sound.NOTE_PLING, 0.5F, 1.5F);
assister.incrementCredit((creditsPerAssist*assistPercentage),true,"Assist");
assister.upgradeExperience(PlayerGainExpEvent.Type.ASSIST,
(int) (WargroundsMain.getInstance().getRankConfig().getInt("PLAYER-EXPERIENCE.DEFAULT.EXPERIENCE-PER-ASSIST") * assistPercentage)
);
}
}```
why don't u remove players from the maps when players quit
how do I use the custom persistant data types, I imported them into maven
doesnt he show that on his github?
I don't really understand
what
good idea, I'll try
thanks
since when did we have bounding boxes
Works
pretty sure thats been a while
public void onPlayerQuit(PlayerQuitEvent event) {
for (Profile assister : assisters.keySet()) {
if (assister != null && assisters.get(assister) != null) {
assisters.remove(assister);
}
}
}```
Something like this EpicGodMC?
i said that before i fully looked at the file lmao
not sure why ur getting the same exact assister from the map again to check if thats not null
and it wont work like this
this will cause an exception
well I have to null check it and check if the player is in assisters in the first place
what is "assisters" ?
public class CommandManager implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
NamespacedKey key = new NamespacedKey(Project.getPlugin(), "player_location");
if (!(sender instanceof Player)) { return true; }
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("set")) {
PersistentDataContainer data = player.getPersistentDataContainer();
Location playerLocation = player.getLocation();
data.set(key, DataType.LOCATION, playerLocation);
}
if (command.getName().equalsIgnoreCase("go")) {
PersistentDataContainer data = player.getPersistentDataContainer();
Location location = data.get(key, DataType.LOCATION);
player.teleport(location);
}
return true;
}
}
``` trying it now, but theoretically this would work, right
yes
:d
I am
hashmap where assisters are saved
im guessing uuid, profile ?
yes it's profile, like from plugin's profile manager
huh
HashMap<Profile,Double> assisters = new HashMap<>();
ur current implementation wont work
as ur looping though the list ur removing something from
that cannot be done
personally i would make the hashmap Key a UUID
(concurrent modification exception is why)
if your hashmap key were to be a uuid u can simple do a Map#containsKey(uuid) check in your quit listener and remove it if that returns true
yh I've done similar but with profile
idk if it will work, I'll test
if (assisters.containsKey(profile)) {
assisters.remove(profile);
}
}```
yea that should work as well
as long as the profile is present in your profilemanager :d
I mean the same profile is saved in hashmap
so it should work the same like it's uuid
right?
I appreciate the help, thx
when ur processing the assisters u should be able to just check if the player is still online
and else skip it
well just try this i guess
Thank y'all so much, I've been trying to learn about pdcs for soooo long
its quite simple once you understand them
getServer().getPluginManager().registerEvents(new RightClickEvent(new GUIShop()),this);
i created a constarcot of GUIShop in RightClickEvent
will that work??
constractor*
Please i really need help with the next code, for some stupid reason which i cannot realize, the event is being cancelled, when i tes it like this:
Permission: true, Mode: false, User: true, cancel the event, while it should cancel it only if you dont have the permission
event.setCancelled(player.isOp() || !profile.isBuild() && region.getUsers().contains(player.getUniqueId()));
please someone help me
Must be pacient and must wait as everyone
Answering to?
i dont know what to put in there i made a constractor in RightClickEvent
@terse ocean
ok, you confused me bro
what does you need in the right click event
a plugin instance or a gui shop instance
this doesnt do anything with permissions tho
when you create a constractor in an event you need to put something in there when you register it and idk what to put tjere so i am asking for help
What?
Im really messed up bro
cuz i need to acces a getter in the class
I cannot understand wha thappens tho
in which class
ur saying "permission: true" but that code checks no permissions
the getter is in the GUIShop class and the constractor is in the RightClickEvent class
I mean sorry, that is the old v1 version which had op, know have the same code just changing op checking with permission, and is not working as it should
what class is GUIShop, is it your main class
can you make an instance of it in the event
Because you should only be able to break while having the permission or the mode is true and you are a member of the match
But dont care, that is not the point, the point is that is being cancelled, when it shouldnt
did you debug
nvm
ur absolutely sure the values you posted are correct?
Let me send full listener tho
yea sure
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockBreak(BlockBreakEvent event) {
Region region = this.regions.getRegion(event.getBlock().getLocation());
if (region == null) return;
Player player = event.getPlayer();
Profile profile = this.profiles.getProfile(player.getUniqueId());
if (profile == null) return;
player.sendMessage("[Break-1.9+] Perm: " + player.hasPermission("build.region.bypass") + " Build: " + profile.isBuild() + ", Region: " + region.getUsers().contains(player.getUniqueId()));
event.setCancelled(player.hasPermission("build.region.bypass") || !profile.isBuild() && region.getUsers().contains(player.getUniqueId()));
}
ples fix formatting :<>
Sorry man
Today al is worst man, that code was suppoused to be working and not works, discord too tho
ok
and its being cancelled right?
yikes
right now its cancelling when the player has "build.region.bypass"
u gotta invert that defo
try event.setCancelled((!player.hasPermission("build.region.bypass")) || (!profile.isBuild() && region.getUsers().contains(player.getUniqueId()))); @sterile token
?paste
do you use gradle or maven?
same msg
Paste your code there, and send it in channel, please dele it
maven
Delete the wrong msg
?paste your pom
... k
@quaint mantle did u open ur jar with something like winrar to check if its there in the root.
i went to the "Ideafolder"
how you building
and it was in there.
wdym how am i building??? im only building it one way??
ok, my goal is: to cancel, only if you dont have the permission or build is not active and not contained in the area
there is many ways to build lol
are you using the maven panel on the right?
or are you not on intellij
so let me get this straight here. u want to cancel the event Only IF
The player does not have the bypass permission OR the player's Build is Not active AND not contained in the area
right
Exactly that
im on intellij idea,
So player = has perm = access to build if not then cancel building? is what im understanding you want help with?
here is though my plugin.yml if you guys want it:
if (player.hasPermission("build.region.bypass")) return;
if (!profile.isBuild() && region.getUsers().contains(player.getUniqueId())) event.setCancelled(true);
try this
press control twice then type mvn clean package, for future builds press the green play button top right
hmn i cannot do that, because the permission is not mandatory
I must do: setCancel(false) when the conditions mentioned before are not okay, because they will be another protection plugin which be able to block it
I have the green play button at the top right want me to just click that instead? Also keep the @ mention on for me,
then do this
if (player.hasPermission("build.region.bypass")) {
event.setCancelled(false);
return;
}
event.setCancelled(!profile.isBuild() && region.getUsers().contains(player.getUniqueId()));
you can try it, no idea what command its gonna be running for building
i mean i got the green hammer going on, as well
but sure
ye but the green hammer aint what u wanna be using when you use maven
oh why?
that would use intellij build system
but i always use it? xD
then your not using the pom then lol
🤷♀️ it's always worked for me including the pom, but ill see what it shows for me now using the green play button
well its fixed now
so tysm
Why not put it like mine code, all in 1 line? Its wha intellij recommend me
did u try it
are u sure its not the "other" plugin messing with it then
no, atm i dont have it
I removed everything for test reasons, was the first thing i did to test
Let me send you all the trys and how i do them
are you trying to work with worldguard?
No no, its all custom made
Yes, lp
- Permission: true, Mode: true, Users. true, result: event cancelled
- Permission: false, Mode: true, Users: true, result: event not cancelled
- Permission: true, Mode: false, Users: true, event cancelled
idk what mode is
mode is a method to know if the player can build or not, its part of minigame events
I mean, if they have the permission OR have ability to build AND are members of game, they must be not cancelled, unless the conditions are not true (so they are cancelled)
Idk why im being so stupid for not doing that alone, im feeling really ussesless
try this
event.setCancelled((!player.hasPermission("build.region.bypass")) || !(profile.isBuild() && region.getUsers().contains(player.getUniqueId())));
why putting the others 2 conditions together?
cuz thats what u want
bro, same issue
If i have the permission, still being cancelled
ok
Permission: true, Mode: true, User: true = okay
Permission: false, Mode: false, User: true = okay
Permission: true: Mode: false, User: true = not okay
Permission: false, Mode: true, User: true = not okay
Permission: true: Mode: false, User: true = not okay cancels the event. correct?
ok give me a few minutes to wrap my head arround this
can u add the results to those 4 lines ?
like "cancelled", "not cancelled"
yes
Permission: true, Mode: true, User: true = not cancelled
Permission: false, Mode: false, User: true = cancelled
Permission: true: Mode: false, User: true = cancelled
Permission: false, Mode: true, User: true = cancelled
@sterile token i think i got it
?paste
Is there a way to prioritize onJoin event? I think something overrides my teleport and places it somewhere else. Interestingly only for firstjoin
ok
why is hashmap hash
does it allow different values on one key
and use hash function for collision treatment
https://paste.md-5.net/daxekedoro.bash for some reason this.jda is null but yet i set it up correctly,
its most like this that is causing it to be null,
getCommand("newticket").setExecutor(new DiscordTickets(jda));
``` *It tells me to put jda in it, so yeah..*
try this event.setCancelled(!(profile.isBuild() && region.getUsers().contains(player.getUniqueId()) || player.hasPermission("build.region.bypass")));
have a getter in your main class and pass in a plugin instance instead
ok
ex?
which
no it actually does not
what's the point of map being HashMap
uses hash methods for collision treatment
well let me show u what i got going on, and u tell me if its right or not
?paste
isn't it a problem for arrays, not maps
i just made my own hashTable on c++ with chain hashing
like how collisions would appear in a hashmap
it uses hashing to for example "get" an object
in a fast way
You can code plugins in C++?
if you really wanted to yes
yeah why don't you just get it by it's int key
no need for hashing here rly
thats only the case if ur key is an int tho
alr i can have Object or T extends Object
what's the problem
Still the same issue
goofy thing I made the most cursed type of map
thats legit impossible. i tried all ur scenerios
one moment
public class ClassName {
private final MainClassName plugin;
private JDA jda;
public ClassName(MainClassName plugin) {
this.plugin = plugin;
}
and for main class
public class MainClassName extends JavaPlugin {
private JDA jda;
@Override
public void onEnable() {
this.jda = jda stuff i dont remember;
}
public JDA getJDA() {
return this.jda;
}
}
they are probably using /reload lol
if i use strings instead
nothing would change i guess
TypedMap<String> map = new TypedMap<>();
map.put("one", 2);
map.put("two", true);
int one = map.getTyped("one");
boolean two = map.getTyped("two");
It's lovely
autocasting
then use plugin.getJDA to get the jda instance
we are talking about HashMaps rn and why does Map use hashing
Yeah, that why its pretty weird everything
because duplicates are not allowed
pretty sure the hashes are for O(1) contains checks
and have the side effect of not allowing duplicates
and?
you can use hashcode of object
not a hashfunction on the map
of object yes
Yeah that why its pretty weird
it took me a while to learn that the hashcode of an int... is itself
but there is literally only one pool in java for strings, no other objects use it
you are under the impression that Objects are unique when really the value of objects are what are unique and thus you can't always use the hashcode of an object for what you are claiming
Only if u could remember the on enable stuff... :/
equals is not ==
Anyways, the hashing for map, is faster for detecting duplicates as well as faster for performing a contains check
hashFunction doesn't do anything with that ig
hashcode1 == hashcode2 -> 1.equals(2)
I am not sure what exactly you are trying to arguing here NukerFall
if two of your objects have the same hashcode, then it's not the problem of the map
where is HashList or smth
one moment, ill get my old project up
HashSet comes to the chat...
If the map was better using hashcode of objects, it would have been implemented as such
but that is a flawed method that you simply don't understand and thus it isn't used for Maps
like i literally worked around hashing today
whole day
used it for storing things like employee numbers
to ARRAY
but here is something you haven't considered where your method would be flawed
two different objects can have the same hashcode
remember the map doesn't allow duplicates
if they have just replace
the map would see that as being a duplicate when they are both different
two different objects
can't replace one object that isn't the same as another
especially if you want both of them
hashFunction would not help solving this issue, cuz it's just storing elements own way
you will have to go for some better EQUALS check
Well this is why hashcode of objects are not used for the map
the objective of a hash is to literally
not allow duplicates
but provide O(1) contains
That's literally the caveats
That's why there's no HashList
this is the part where using hashcode of an object would fail as I described with the scenario above that two different objects can have the same hashcode
public class MainClassName extends JavaPlugin {
private JDA discordBot;
@Override
public void onEnable() {
try {
this.discordBot = JDABuilder.createDefault(token).setActivity(Activity.watching("stuff")).build().awaitRead();
} catch (InterrupedtedException ex) {
ex.printStackTrace();
}
getCommaned("ticket").setExectutor(new CommandClassName(this));
}
public JDA getJda() { return discordBot; }
}
My question is how does map check that objects are not similar
If they share same hashcode
In my test program i had a hashFunction key%100;
I figured out the problem before hand,
i was being stupid and not including the JDA jda = plugin.getJDA(); part in the class file
ah
So for my program NUMBERS 111222 and 345622 were the same
And i used chain hashing to store second object in first object's field next_one
Which is basically a pointer
And for 789622 i made the same thing
Saving a pointer to the third object in the second object's field
But hash function was used just to decrease amount of array cells
From 999999 to 100
what do you mean?
And then(same as in java's HashMap) i made a rehashing on .75 coefficient
Literally what i wrote i guess
hashcode isn't used to check if an object is or is not similar
What IS used?
when it comes to the map, it only cares that the appropriate type is used for key and values
pretty sure the hash is only relevant for the key
So it's hashing object with own hashing system
as long as the type is correct, it will accept it, and then it checks if the key being put in is a duplicate
as I stated can't use the hasCode for such things
seems kind of obvious at this point
if its not using the hashcode, then it has to be something else lol
now it's time to figure out what exactly does HashMap use
Im like sure that c++ map is not using hashtables
I think they meant the buckets
as in the internal hashing the map uses to identify the buckets it contains
I guess i need to write own HashMap on c
To figure it out
Or try to do it on java itself
Im almost god in chain hashing
Idk how open hashing works tho
How should I approach getting a plugins version, description, and authors from the plug-in.yml?
And a few others like sha256 dependencies and soft depends
Without running the file? I scraped every single plug-in off spigot I could get and some of its data, I just need a efficient way to do this
My python script has been running for like 4 hours and it’s almost done, I don’t know python so it’s not very optimized
why do I keep finding myself learning all my complex systems at 4 am
do you have the file?
because you could just get the data from the jar file
How do I set the strength and duration of an ItemStack potion?
potion meta
potion data?
Do I need to set CustomEffect?
if you want to add an effect i would guess so
Thank you :)
It remains me about something..
How do you make potions with custom colors?
PotionMeta.setColor()
yes
just check the plugin.yml then, it stores all the data you need
Ok ty
how can i use the spigot build tools to send packets
ohh ok
Would it be very heavy to run code executing each 50 server ticks that would display actionbar message to people on X world
how can i send packets
which you are required to do use packets, run buildtools and then follow this guide
?nms
or use protocol lib
no
i would probably recommend protocol lib
thanks i try this
ok i compiled the build tools but how do i use this in my plugin
remove the -api from the spigot-api inside your maven/gradle
you might have to add someething abt local to the repos
I want a plugin that allows players to respawn every 2 hours but still works if the player is offline is there anything like that, that already exists
Error: https://paste.learnspigot.com/okudipevif.rb
PluginPortalPlugins.yml: https://paste.learnspigot.com/ocuhixiqeh.js
ConfigUtils: https://paste.learnspigot.com/unibizaniy.java
PluginManager: https://paste.learnspigot.com/ahulayizuz.java
Anyone know the solution?
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
Do you know how to code? pretty simple if you do. I dont know of any popular plugin out there that will do this but im sure theres some 1 life plugin that will allow it
I have some knowledge of java but haven't made a plugin
Making a plugin is going to be semi easy if you have some java background, plus its always fun to get into plugin development
it worked and how to i send packets now
Plugin development for me is really fun, Worked on 1 project for 19 hours in the past 2 days, only downtime was hanging out w friends and sleeping
sorry i forgot i know how
all good
its the file
it cant get the file
iirc its new File(JavaPlugin.getDataFolder(), "filename.yml")
It can btw
so
uhm
stupid issue
a configuration section cannot end with .:
Why tf would this cause a huge issue? Dont know
line 340 of my plugins
I sure hope you didnt look through hundreds of different plugin names
i didnt, if it was a problem with that i would have just said do the split in half
Is there an event that runs when a player touches a world border?
https://www.spigotmc.org/threads/world-border-help.47167/ might give you some ideas
What are the chances of downloading malaware by downloading every single plugin on spigotmc
ran a small test and downloaded 127 before my server completely crashed
they got some long names too
Now that is a quality name 👌
I want to implement that using spigot's api if that's possible
Do not think there is an event that does that sadly, one sec
depends when optic last went and downloaded them all for anti malware
only downloaded plugins with iirc 30k+ downloads to prevent downloading tens of thousands of plugins
only like 30k left to go
I could instead check for which plugins are 1.16.4+ and 1.12.2 since those are the most used paper versions by far
you should run them through antimalware
Yea imma just run them through virus total with their api
Ah ty
why use virus total when you can even find stuff just bad for servers in general
True, could always make my own AI detection too, never used AI in the past though
something like https://isthisarat.com where it detects malaware for minecraft forge mods
AI powered .jar RAT classification
as long as they are all in a plugins folder
drop aw in the folder outside
and go
finds pretty much all malware including mc related
There we go, ill decompile them tmrw
damn
someone please help me with my authme plugin i want players to spawn in a room before login and spawn at lobby after /login
Goto authmes discord
If it’s your own plugin then do player.teleport(location)
i realaly hate it when my intellij does this to me
if i want to run some code when plugin is instantiated do i need to override the no-args constructor of JavaPlugin or the protected one?
or should i just use an initializer?
Why when instantiated?
so i can set private final fields
then use a code block {}
ok
btw i would like to ask
if i use runtime reflection to register all listeners in the plugin package, would it be too performance intensive?
so that i dont have to register them manually
i jsut wanna avoid having to modify main class every time i add a new listener
because i constantly forget to do it
okay thanks
Hello , i have a bit of a problem , so when server restart it should remove old entity [armorstand , lootbox]
but it dosen't do that
i have 2 types of lootboxes :
1- normal lootbox
2- preview lootbox
am i doing anything wrong with nbt-api?
what is the point to this
this one to remove old armorstand , so it won't spawn on top of each other
this one to spawn the preview Lootbox
1.8
ofc
smh
is there another way?
Well, when you spawn the stands, add them to a List
And then remove all from that list at disable
Ahh ok
Then you may do some debugging when you execute some test command, request if the list does even contain any stands
Alright i will do that