#help-development
1 messages · Page 278 of 1
hehe
just spawn more threads ezpz
Now, for minigames and all
I'd rather go for the i9-12900k
With a higher ram frequency
damn i got the ryzen 7 5200 iirc
less disk
Ryzen 9 3900X on da gaming/dev pc
originally i did mean to do a lot more dev/work than gaming on it tbh
But you always end up Gaming with it
tomorrow im customizing my pc lol
xD
its not my fault i have an RTX card!
this ui scale sucks
some games just... look so good
but its an RTX2060 so i can only get like 40 fps most of the time with RTX on
gimmick for now
Yeah
void@void-PC
y Manjaro and not TurboLinux tho
Debian >
Debian is Good but i use arch btw
i might use arch now that archinstall makes me less scared to do stuff
manjaro arch based
manjaro is the least Arch arch distro imo
But not the Real Feeling of using Arch
Neofetch needs to display memory in GB
@echo basalt
Was running this onDisabled java.util.concurrent.CompletionException: org.bukkit.plugin.IllegalPluginAccessException: Plugin attempted to register task while disabled
and Maybe Screwing Everything up without Knowing
lemme see what shit is all starting up by default
i thought that it wasn't disabled yet though
tf is matray
ah shit
Google your question before asking it:
https://www.google.com/
fun thing is that both mike and xavier are names in dutch
theyre both Names
yeah I forgot you can't really run tasks on the main thread with the executor n all
whats up with the taskbar tho
its something
cool
yeah i was then looking at that
i am 👍
what a fucking Chad
touchpad aint even enabled
server hung
for how long
ah and it has just joined a future
hmm
I see
saveAllClouds -> System.currentThread()
pass that instead of the MAIN_THREAD_EXECUTOR for running stuff
Thread is not compatible with Executor
just broke me ui
good
I think you'll need to do some kind of lock system 🤔
like a recursive lock
this is getting complicated
yknow
think like
setting scale to 125%
now my taskbar is broken
for what i just saw
whats the formula for chunks loaded with X view distance?
pythagorus?
use wayland for scaling
@echo basalt
was thinking about:
public class CurrentThreadExecutor implements Executor {
public void execute(Runnable r) {
r.run();
}
}
``` but that seems to just submit it on the thread that called it
so a stackoverflow is the result of that
thanks
How would I create world-specific commands?
Example: /bal in the main game, while in the hub it doesnt exist.
It's usually per server, not per world
permissions
You can't really make it doesn't exist, you can just pretend it doesn't exist
you gotta make a weird scheduler system like an infinite loop with a lock somehow
With messages etc
can i hide tab completing commands?
are permissions world or server based
world
ok ill just give anyone who joins the world a permission to use the commands
and in the main one niot
Answering me?
yep
everyone has those days
Now yes i removed that for not neccesary
have a concureent hashmap with runnables
in the thread
and a while(true) {
if map has runnables
map.getrunnable.run
}
something like that ig?
PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
String name = UUID.randomUUID().toString().replace("-", "").substring(0, 12);
container.getIntegers().write(1, 0);
container.getStrings().write(0, name);
container.getChatComponents().write(0, WrappedChatComponent.fromText(player.toString()));
container.getSpecificModifier(Collection.class).write(0, Collections.singletonList(player.getName()));
container.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', nametag)));
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(visibleTo, container);
} catch (InvocationTargetException e) {
Bukkit.getLogger().info("Unable to send packet to " + visibleTo.getName());
e.printStackTrace();
}
```Would anyone know how to change the player's username with this packet? Or is that not possible and do I send a different packet?
I need recomendations for using JDA, via spigot plugins
Do i need to initialize it in another thread?
Also please make suggestion
How effieciency is PurPurMC ?
Try and see
Action azione = playerCoinvolto.getAction();
Player giocatore = playerCoinvolto.getPlayer();
Material bloccoDiSmeraldo = Material.EMERALD_BLOCK;
if(azione == Action.RIGHT_CLICK_BLOCK) {
if(playerCoinvolto.getClickedBlock().getType() == bloccoDiSmeraldo) {
giocatore.sendMessage("hai cliccato un blocco di smeraldo");
}
}
} ```u guys know why this isnt working? i'm trying to send the player a message when it right clicks an emerald block
did you annotate the method with @EventHandler ?
did you register the event?
if both are the case. what is bloccoDiSmeraldo ?
bloccoDiSmeraldo means emeraldBlock in italian, sorry if i couldnt translate
yeah i annotated it
yea the name doesnt rlly matter
what is it been initialized to
oh wait
im blind
sorry
did you register the event?
then it should work
one sec
How can I get the Distance between 2 entities?
declaration: package: org.bukkit, class: Location
do note this method can be quite heavy
thank you, it is now working i forgot to register it bruh
yea thats what i thought 😄
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Location.html#distancesquared(org.bukkit.Location) this one is much less heavy. but it gets the squared distance
declaration: package: org.bukkit, class: Location
the only problem is that it sends the message twice bruh
i mean
thanks!!
im rightclicking
im not using 2 hands ahah, if i click with my second hand it does it one time
yea im trusting you but im very new and idk how to do it
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand() compare that
declaration: package: org.bukkit.event.player, class: PlayerInteractEvent
ty
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
I'm trying to change the max live of a firework on 1.18 but there is not such a method only setFireTicks and setFreezeTicks
Does anyone know why?
is this timing good? https://spark.lucko.me/39Jr3wn1qT
declaration: package: org.bukkit.entity, interface: Firework
u can use that
yeah no
that's what I mean
there is no .getMaxLive()
only .getMaxFireTicks or .getMaxFreezeTicks
whatever that means
declaration: package: org.bukkit.entity, interface: Firework
does that not exist in 1.18?
looks like it doesn't
u might need to call detonate urself then https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Firework.html#detonate()
declaration: package: org.bukkit.entity, interface: Firework
I want to delay the time until the detonation
pro tip: name your variables in english
the entire developer community will thank you
waht is this?
** [WARN] Install JVM debug symbols to improve profile accuracy**
the last thing I want to do is work on someone else's code and see tons of variables named in chinese
pardon
ahahahah
¯_(ツ)_/¯
Does anyone know what this means? 😂
[WARN] Install JVM debug symbols to improve profile accuracy
My server keeps sending this to the console.
The last Timing https://spark.lucko.me/39Jr3wn1qT
Is posible to get default mc scoreboard using their name via spigot api?
Name?
Yeah, have you seen that now on 1.19 you can create scoreboards via /scoreboard command
I want to get those scoreboards
scoreboard api 😭 I'm sorry for your loss.
yeah i want to use them on 1.19, but i cannot find the docs about them
Uh scoreboards or criteria?
shouldn't you beable to do getMainScoreboard maybe?
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/scoreboard/ScoreboardManager.html#getMainScoreboard()
declaration: package: org.bukkit.scoreboard, interface: ScoreboardManager
I want to know if posible get the Set<Scorebaord> from those scoreboards
yeah but i need to get the object of the scoreboard, so then i can send it on discord
maybe you should check NMS internally first to make sure it exists
can't you just do Scoreboard#getObjectives ?
I mean I don't see why not
Wait let me explain
or even Scoreboard#getObjectivesByCriteria
Soomeone told me if i can do a plugin wich takes the vanilla mc scoreboards and sent their objetives to discord via JDA on every scoreboard update
So far i have been looking in the docs to see how i would get them tho
I mean you probably could? getMainScoreboard is the main scoreboard afaik
Gets the primary Scoreboard controlled by the server.
is in the docs
I'm not sure tbh, the scoreboard api internally in NMS is kinda a mess and that also translates to spigot I couldn't tell you anything honestly
Remember that im wondering to get the list of created scoreboard from the /scoreboard command
ohhhh Ic
look internally in NMS
you've got my curious so I'm going to rn lol
yes its something new they added since 1.16 if im not wrong
I'm just gonna build 1.19.3 remmapped and give it a look
Why does my ReGEX not match this? ReGEX: ^((-?[0-9]+,\s?-?[0-9]+,\s?-?[0-9]+)) String: (3, -30, 3)
what are you trying to get everything inside the string besides the commas?
do you use regex101?
are you trying to get all these numbers into their own group?
nope
just the full string
if you need the full string, then just do (.*) lol
right but I want to assure its numbers, 3 of them to be exact
comma seperated and all that
^ it copied weird, each space in the regex is actually \s in my code
IJ weird 👍
couldn't you just do this?
(-?[0-9]+)
y2k? Still alive?
are u escaping the parentheses
I dont think so..
\(
I seee
\)
discord removed the escape char
\(
yea my internet is slow
https://regex101.com/ when in doubt
BT just finished
i always make there before i use
oh rip
I didnt do anything, but still: you are welcome
ah ok no problem, just tag and dm in case of not answering
you told me I had to!!
that was very helpful
alrighty lol
and you fucked discord
I did?
W in my book
yes
last time I remember, I fucked s/o else, but not discord
I found it
what from the Scoreboard command are you trying to mimic
I hvae the code up
weak? it has 35%
35.99%+ or go home
I already am at home, what's your point
go fly a plane or smt
i see
or maybe it's 0.5‰, I don't really know
depends on the unit
0.05% is the same as 0.5‰
‰wtf
first one is "per hundred" and second one is "per thousand"
Never seen that in my life
nice nails
my friends always have nice nails and mine are just a mess lol
relatable
stop chewing on them and make your female friends paint them from time to time, then you will look fabulous lol
easier said than done
‰
permille yeah
BAC and permille is mostly the same thing.
Permille can be used for other things though.
for some reason I can't get the Ticks until detonation of a fireworkrocket and also can't change them. Does anyone have an idea why?
What do you mean cant get
I can't do firework.getMaxLife() or firework.setMaxLife()
error?
It's just not there
1.18
coulda been added post 1.18 then
then just use that method
no I checked the docs
declaration: package: org.bukkit.entity, interface: Firework
yeah a lot of this stuff seems like it was added later as I said
Just sets the entity on fire
Why not update?
1.18.2 at minimum
yeah but is there a way to change the time until detonation in 1.18?
NMS maybe?
Why not update?
just use NMS 🤷🏽♂️
would have to update everything including all my other plugins on the server
How can I update the version of a plugin with IntelliJ?
hell no, I hate nms
pom.xml 😭
nothing else I have to change?
nope
i mean plugin.yml isnt required to be changed
oh api-version in plugin.yml
I always just set it to "1.13" and then it's fine lmao
Same haha, but shh
Sorry if the question is stupid but don't I have to replace the 1.18 file with the 1.19 file?
anyone know how i can compile this
with maven
how
mvn package idk
the maven commands to compile
I'm a big maven install guy
he def wants maven install
mvn deploy
is the best though
because it does maven package, and install for you
and then there is the third extra step it does
no point to use instal unless you are also going to code other plugins
deploys?
mvn package
deploy or bust
lol he is just trying to get around a paywall I'm having a little fun here my guy
all or nothin
is all you need to build a project
git clone it, then do mvn package
bruh
just buy the plugin
my ass got no money
plus the source code is there
jus gotta figure out how to compile it
mvn package
how many times can we gonna say mvn package challenge
I'd go for "roughly 20 times"
im pokijg fun at the fact that like 4 of us have said the same thing tbh
might be a cache miss or something try deleting ur local maven repo (~/.m2 ?) or something idk
or is mvn clean package / mvn package clean a thing
maybe that could do it
lmao Y2K stop messing with noobs
TIL (more like a week ago rather than today) that minecraft has a command to open a lan server on a specific port
/publish
its existed since circa 1.13
isn't that the same as doing Escape -> Open to LAN or sth?
now it is
since 1.19.3 added port option to the menu
I'll go to sleep now, have a nice day everyone
I woke up at 22 o clock
well
smh
probably the bigger one idk
original tends to be incomplete (without shadings)
This is a relatively simple technical question. Does spigot need chunks loaded to change blocks from one block to another?
yes
Blocks are stored in chunks
I mean technically if you're really sure you can somewhat change the world file itself
but that's a lot of hassle
Currently working on multilang support for my plugin. I'm looking for ideas on how I should implement them
just write to the region file ezpz
currently, the messenger has a sendMessage method which takes a CommandSender, MessageKey and Placeholder varargs
what i'm wondering about is how Locale should work
hm
public static final char SEPARATOR = '_';
private String lang;
private Set<String> countries;
private Map<MessageKey, String[]> messages;
probably an enum LANGUAGE
this is what im thinking now
or actually a registry
like
I feel like the message handler itself should handle all the lang stuff
The end result would look like
LanguageHandler#sendMessage(CommandSender, MessageKey, Placeholder... placeholders)
type deal
there's so much spanish
i dont want users to have to make 7 files to support each es
that's the issue im currently having
you could make an inheritance system
I was doing something simmilar in past and this implementation works fine to me
hm.. no
I made a brilliant system for this... 3 years ago
i can do this
so one file can be used for multiple country locales
and the Map<String, Locale> in LocaleManager class will just have en_US, en_AU and en_UK all mapped to the same locale
actually
i think this works
haha typing it out solved my problem
public class LanguageRegistry {
private final Map<String, Language> languages = new ConcurrentHashMap<>();
public LanguageRegistry(JavaPlugin plugin) {
load(new File(plugin.getDataFolder(), "langs"));
}
private void load(File folder) {
if(!folder.exists()) {
boolean created = folder.mkdirs();
if(!created) {
// uh... IO error?
return;
}
}
Map<String, String> dependencyMap = new HashMap<>();
for(File languageFile : folder.listFiles()) {
if(languageFile.isFolder()) {
// We don't want nested folders, this is an invalid state
continue;
}
FileConfiguration configuration = YAMLConfiguration.loadConfiguration(languageFile);
String languageId = languageFile.substring(0, languageFile.lastIndexOf(".") - 1));
Language language = new Language(configuration);
register(languageId, language);
String dependencyId = configuration.isSet("dependency") ? configuration.getString("dependency") : null;
if(dependencyId != null) {
dependencyMap.put(languageId, dependencyId);
}
}
for(Map.Entry<String, String>> entry : dependencyMap) {
String languageId = entry.getKey();
String dependencyId = entry.getValue();
Language source = getLanguage(languageId);
Language master = getLanguage(dependencyId);
if(master == null) {
// This language is set as a dependency, but doesn't exist
continue;
}
source.setInheritedLanguage(master);
}
}
public void register(String name, Language language) {
languages.put(name, language);
}
public Language getLanguage(String id) {
return languages.get(id);
}
}
something like this
this is out of my head, might be missing indentation
private void loadLocales() throws IOException, InvalidConfigurationException {
List<String> inJar = findLocaleResources();
for (String s : inJar) {
this.saveResource(s, true);
}
File langFolder = new File(plugin.getDataFolder(), "lang");
for (File localeFile : langFolder.listFiles()) {
if (localeFile.isDirectory())
continue;
if (!localeFile.getName().endsWith(".yml"))
continue;
FileConfiguration localeConfig = new YamlConfiguration();
localeConfig.load(localeFile);
//load it here
}
}
this is what i have
ye but what's wrong with my solution besides I not using ConcurrentHashMap?
Does your system allow for per player language messages?
oh right, that a thing
public class Language {
private final Map<MessageKey, List<String>> cachedMessages = new ConcurrentHashMap<>();
@Nullable
private final Language inheritedLanguage;
public Language(FileConfiguration configuration) {
load(configuration);
}
private void load(FileConfiguration configuration) {
// if it's a string, we just make an immutable list of size 1
// This allows support of multi-line messages
...
}
public void setInheritedLanguage(Language master) {
if(master.getInheritedLanguage() == this) {
// circular dependency? odd
throw new IllegalStateException("Circular language dependency");
}
this.inheritedLanguage = master;
}
public List<String> getMessage(MessageKey key) {
if(key == null) {
return Collections.emptyList();
}
List<String> messages = cachedMessages.get(key);
if(messages == null) {
if(inheritedLanguage == null) {
return Collections.emptyList();
}
return inheritedLanguage.getMessage(key);
}
return messages;
}
}
type deal
Now,
public class PlayerLanguageTracker {
private final LanguageRegistry registry;
private final Map<UUID, String> selectedLanguages = new ConcurrentHashMap<>();
public PlayerLanguageTracker(LanguageRegistry registry) {
this.registry = registry;
}
public void setLanguage(Player player, String language) {
setLanguage(player.getUniqueId(), language);
}
public void setLanguage(UUID playerId, String language) {
selectedLanguages.put(playerId, language);
}
public Language getLanguage(UUID playerId) {
String selectedLanguage = selectedLanguages.get(playerId);
if(selectedLanguage == null) {
return null;
}
return registry.getLanguage(selectedLanguage);
}
...
public void sendMessage(Player player, MessageKey key) {
if(key == null) {
throw new IllegalArgumentException(key);
}
Language language = getLanguage(player);
if(language == null) {
// critical error, player has no language?
return;
}
List<String> messages = language.getMessages(key);
for(String message : messages) {
...
}
}
}
type deal
add track(), untrack() methods to this registry
you know the deal
2 registries, 1 data class
You'd just call PlayerLanguageTracker#sendMessage all the time
sendMessage(player, NO_PERMISSION)
type deal
idfk
wrote all of this out of my head
Can someone please tell me what's wrong about this scheduler? For some reason it's only repeating 1 time instead of 5:
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
int number = 5;
@Override
public void run() {
if(number <= 0) {
Bukkit.getScheduler().cancelTask(taskID);
} else {
p.sendMessage("" + number);
number--;
}
}
}, 0, 5);```
let me see the messge it sends you
How would I be able to change the message that appears when the player changes an item in their hot bar?
My goal would be to change that to a custom multi line string, or remove it and only use the action bar
Example:
Well, you can listen for the PlayerItemHeldEvent and use that to display your string. However, you can't send multiline messages on the actionbar.
darn, also the item name is displayed on a separate line than the action bar
Yep, you would need packets to send messages there.
darn okay :/ Looks like I gotta make a mod then
would anyone know how someone generates this https://gist.github.com/nikes/aff59b758a807858da131a1881525b14
from the wiki.vg protocol page
@maiden thicket it's on the wiki.vg protocol page as well
let me find it
@maiden thicket https://wiki.vg/Data_Generators
here
but i don't believe that gives the dimensions registry does it?
ohh
it does
:v
how does wynncraft achieve being able to remove the old dialogue and put new dialogue there? do they just remember what was in your chat, completely clear the chat by sending so many empty messages, and then print what was in your chat with the new dialogue included? https://medal.tv/games/minecraft/clips/O1RiUWjT0I7uE/d13374xM99vd?invite=cr-MSx5NU0sNDY4MDQyMDAs
wynncraft is in fucking sane tbh
depending on your version there are packets to delete chat
yes
you can notice it flickering once or twice
they have great data structure by the looks of it
codebase needs to be hella organized
not technically advanced, just the basics really well
Has someone made an api for this or will I have to go make one tomorrow?
bukkit conversation api is pretty sexy for that, but not as custom as wynncraft's
this is extremely contrived but, well, it might get you somewhat started
public final class TestConversationsPlugin extends JavaPlugin implements Listener {
private ConversationFactory factory;
private final Map<UUID, Conversation> convos = new HashMap<>();
@Override
public void onEnable() {
factory = new ConversationFactory(this)
.withLocalEcho(true) // sender can see own messages in the convo
.withModality(true) // suppresses other chat for duration of convo
.withTimeout(30) // will cancel the convo if no activity for 30 secs
.withFirstPrompt(new FirstPrompt()); // convo starts with FirstPrompt (below)
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
final Conversation convo = factory.buildConversation(player);
convos.put(player.getUniqueId(), convo);
convo.begin();
}
@EventHandler
public void onShift(PlayerMoveEvent event) {
final Player player = event.getPlayer();
if (player.isConversing() && player.isSneaking()) {
final Conversation convo = convos.get(player.getUniqueId());
if (convo != null) {
convo.outputNextPrompt();
}
}
}
}
Then just need some prompts
public final class FirstPrompt extends MessagePrompt {
@Override
protected Prompt getNextPrompt(ConversationContext context) {
return new SecondPrompt();
}
@Override
public String getPromptText(ConversationContext context) {
return "Hey! Welcome to the conversation...\nPress shift to go to the next prompt...";
}
}
public final class SecondPrompt extends FixedSetPrompt {
@Override
protected Prompt acceptValidatedInput(ConversationContext context, String input) {
return Prompt.END_OF_CONVERSATION;
}
@Override
protected boolean isInputValid(ConversationContext context, String input) {
return input.toLowerCase(Locale.ROOT).matches("a|b|c");
}
@Override
public String getPromptText(ConversationContext context) {
return "Choose A, B, or C.";
}
}
more: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/conversations/package-summary.html
declaration: package: org.bukkit.conversations
^
Ok
well, you can send plugin message to spgiot server
then with a plugin on spigot server you can try looping through files in plugins folder, adding names to the list
and then send the result back to bungeecord with another plugin message
Yes, but I want to know if the server has spigot version of my plugin
To know if i should work with this server
well, you can register an incoming channel
and each time some spigot server send info from your spigot plugin, connect it to network or smth
i don't rly like plugin messaging cuz of it's limitations
requires player on a server
yes
this is the problem
always has been 😉
never tried that
Thanks
might help you
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class Commands implements Listener {
@EventHandler(ignoreCancelled = true)
public void onCmd(PlayerCommandPreprocessEvent e) {
if (e.getMessage().equalsIgnoreCase("gmc")) {
Bukkit.dispatchCommand(e.getPlayer(), "gm creative");
}
if (e.getMessage().equalsIgnoreCase("gms")) {
Bukkit.dispatchCommand(e.getPlayer(), "gm survival");
}
if (e.getMessage().equalsIgnoreCase("gma")) {
Bukkit.dispatchCommand(e.getPlayer(), "gm adventure");
}
}
}
why isnt this working?
Are you getting any errors? Did you register the event in the onEnable event?
An that's not really how you make commands either
yes i registered it
im not getting any errors
when im typing /gmc
it says /help
you can sorta kinda make commands that way i guess but...erm. wat.jpg
the message in the PlayerCommandPreprocessEvent would be prepended with a /
so you need to check /gmc, /gms, /gma etc...
atm you would literally type the message gmc as if it were a normal chat message and that's probably going to trigger it
For private plugins, use redis for messaging
why redis over sql for messaging you may ask? 1. redis is a lot faster, already has a message broker included + does not need to write your data persistently on your drive, so you will even save server resources and your drive
what you trying to do?
I want the Scheduler to count from 5 to 1
Hello I'm trying to unregister custom command (BukkitCommand) using my unregisterCommands method... But doesn't work..
How can i do that ? https://pastebin.com/yCfaDd8C
.unregister return true but i can still see and use command ig
ah, can i ask why your making a runnable in a scheduler
one moment ill type something up
Thanks!!
How would you make scheduler without runnable?
int number = 5;
Bukkit.getScheduler().runTaskTimer(Main.getPlugin()/* use di pls */, task -> {
if (number == 0) {
task.cancel(); /* might be something else idk, dont have ide open */
} else {
p.sendMessage(String.valueOf(number));
number--;
}
}, 0, 5);
lambda
Thanks I'll try it
the formatting might be a bit off because i didnt want to open an ide
It gives me an error at "number" inside of the Scheduler:
"Variable used in lambda expression should be final or effectively final"
ah, forgot about that. Easiest way to fix it i can think of atm is just making number static
anyone feel free to correct me
also not working
static isn't allowed there
Any reason you don't just use a bukkit runnable?
new BukkitRunnable() {
int number = 5;
@Override
public void run() {
if(number <= 0) {
cancel();
} else {
System.out.println("" + number);
number--;
}
}
}.runTaskTimer(this, 0, 5);
That was what I was about to try XD Thanks!
Trying to create a system that announces when everyone in a list of players earns a specific advancement, but I'm not sure what the best approach would be.
works perfectly, thanks
how to I get the position of the block 5 blocks away from the player in his viewing direction?
what they are looking at or just 5 straight ahead of them
just 5 straight ahead
i cant think of the code for it rn but the best option you have is #getBlockAt their location + 5 or - 5 from the X or Z they are facing
?paste
hey! sometimes if this gets exectued, i get kicked with the reason on the img
public void sendChat(Component message) {
Bukkit.getOnlinePlayers().forEach(player -> player.sendMessage(message));
}
what do i have to change?
lol thats a that huge difference?
This is spigot. you won't get help for PaperAPI here.
?whereami
Did that mistake too a long, long time ago
happened about here
Idk I think it was my first plugin and I didn't even know the difference between spigot and paper XD
lol
Anyone knows which event is called when a player successfully trades with a villager? so far on google search threads only found when a player opens the menu or clicks on a item to trade. not the trade itself.
just checked the jds and it appears there isnt one
i was checking the events list as well and couldn't find anything about trading or villagers on player events
theres trade select and some villager ones but none for a trade being completed
well, i can store the inventory when a player clicks on villager and when they close the Merchant inventory check if there was any change on the inventory
but people can drop items to each other in between those
one sec let me get my choco out
those last 2
Spigot/Bukkit would probably love a pr for that
arent those the ones?
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
they are villager so idk
i would guess the first one is for when a villager gets a new trade
the last one is probably for when they restock
3rd is when a villager upgrades and gets a new trade
so i need help with something
i want to make something that if you type a message like "hello world" its get changed byt another thing
what im trying to do is
oh, and 4th is just when the villager replenish his trades
yeah
spawn invisible armor stand with a custom player head
none for when the trade is successfull
SkullMeta
Yes
ItemStack helmet = new ItemStack(Material.PLAYER_HEAD);
SkullMeta skullMeta = (SkullMeta) helmet.getItemMeta();
skullMeta.setOwningPlayer(player);
helmet.setItemMeta(skullMeta);
armorstand.setHelmet(helmet);
And what‘s your question?
make a listener for an AsyncPlayerChatEvent
okay
and check if the message is "hello world"
So there's really no event when a trade is done? 🥹
sadly not
if it is the change the message to whatever you want
?stash one sec
ok thx
Isnt it just InventoryClickEvent ?
okay so what you could do, is listen to inv click and drag and check the slot it came from
that would return when they select a trade
check the slot num
Yeah
@EventHandler
public void onMessageSend(AsyncPlayerChatEvent event) {
if(event.getMessage().equals("hello world") {
event.setMessage("your text here")
}
}
couldnt tell you what number it is just make a quick listener for the click event, and set the item to something with the name of its slot number
so if they click on the trading item(the slot on the far right) basically?
yeah
how to know if it was successfull tho? 🤔
check if the item isnt null
let me check again how trades work
ah ok, its null if it doesnt trade?
How can it be unsuccessful o0
if the item is null nothing happened
Yes
yea
playing mc for so many years and forget something so trivial 😔
you could also check if the players statistic VillagerTrades increases
ty for the idea guys, will try
i want to know what they trade also
that would make all of the trades the same
oh well yeah then nvm
i will do like epic and alex said
Error within error (??!!!! SOMETHING WENT SUPER WRONG!): Internal exception was thrown!
what the hell
is this
how exactly can I do that?
?jd-s check the jd for stuff relating to where the player is facing
its slot 2 and if its AIR then its not a trade
i did check for null too
that should work how you want then
@EventHandler
public void onTradingVillager(InventoryClickEvent event) {
if (event.getClickedInventory() == null) return;
if (event.getClickedInventory().getType() != InventoryType.MERCHANT) return;
if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) return;
event.getWhoClicked().sendMessage("Clicked slot: " + event.getSlot());
event.getWhoClicked().sendMessage("Clicked item: " + event.getCurrentItem().getType().toString());
}```
yeah, now its good
make sure you listen to the inv drag event too
just need to add a check for slot if its 2
drag?
i know what it is but why
how do i change setOwningPlayer
as in?
why listen to the drag as well?
i would guess the even is called when they click somewhere then drag those items over there inv
i havent looked at source so it might now
it happens when u click on the item of the trade
if u check for the slot 2
then u can drag it or with shift insta send to inv
OfflinePlayer player = Bukkit.getOfflinePlayer(UUID);
Saw someone try to use kotlin on the forums yesterday, we are invading :strong_arm:
Time for some bleach
kotlin just looks funny
It's great
Though most people just use it as java
the the problem im having right now is that the event doesnt know if the player is buying 2x or more of an item. it only returns as 1 amount.
is there documentation on the BungeeCord plugin.yml (bungee.yml)
and can i define libraries to load on start like bukkit with the libraries: block?
instead of our nice
@EventHandler
public void onMove(PlayerMoveEvent event) {
event.setCancelled(true);
}
you have some fucking weird shit like this
@EventHandler
fun onMove(PlayerMoveEvent: event) {
event.setCancelled(true);
}
``` or some bs like that
@EventHandler
fun PlayerMoveEvent.onMove() {
this.setCancelled(true);
}
you what
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Wtf it seems like kotlins gets worse every year lmao
that has been there since inception lol
Much better https://puu.sh/Jvb0z/d5ab60e9db.png
i cant like being able to do method() would be cool
where is your question
@rotund ravine
code?
@EventHandler
public void onTradingVillager(InventoryClickEvent event) {
if (event.getClickedInventory() == null) return;
if (event.getClickedInventory().getType() != InventoryType.MERCHANT) return;
if (event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR) return;
if (event.getSlot() != 2) return;
event.getWhoClicked().sendMessage("§7§oTrade successfull.");
ItemStack i = event.getCurrentItem();
event.getWhoClicked().sendMessage("" + i.getType().toString() + " (" + i.getAmount() + ")");
}```
if the villager only trades X and X for Y(1) just check the count for amoung
that's one emerald
villgaer only trades 1 at the time but we can trade more
check the count
is there a way to know how many the person gets?
check how many emeralds they get
if they always get one the amount is the size of the stack
They will always get one unless they click two times, or shift click
declaration: package: org.bukkit.event.inventory, enum: ClickType
so check if its shift click and do the math myself?
Most likely
well
the question i have is
how do i know what trade the villager is doing?
is there any code for that?
declaration: package: org.bukkit.inventory, interface: MerchantInventory
Get the inventory clicked, check if it's a merchantinventory type and get the selected recipe
could also save something related from https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/TradeSelectEvent.html
declaration: package: org.bukkit.event.inventory, class: TradeSelectEvent
Well that is already what the above can do.
what if the trade is the 1st thing that pops up and they never click on any trade at all
u will never know if they traded more that way
is that possible?
i will check for merchantinventory on shift clicks
yes
ah yeah, just adding the items in
u can just put the items inside and trade for first thing
yeah thats probably better
I mean, you can take a snapshot of the player inventory before and after and compare the difference lol.
specially if u want to tell potatoes or smth at first
oh no
i will just check if its shift clicks and the trade
oh no guys
it seems like if i check whats the price for a thing, it returns 0 because the inventory click event "happens after the trade" and the trade doesnt exist anymore since Shift click trades all of it....
🥹
time to cancel shift click
Hi, firstly how should I paste code here? 😄
?paste
thanks
Hi again ^^!
When I teleport player to random and unloaded chunk location , server getting so many errors and player is kicked automaticlly.
What is the errors?
How can I stop a fireworkrocket from exploding because of a player in it's way?
I don't sure what part should I send it
All of it
just all of it in a paste
Hey, I'm kinda confused by how the tab completions work, why it doesn't eliminate the "aglerr" and "booster" suggestion? This is how I do the tab completions: https://paste.md-5.net/ecuyuluyep.coffeescript
because you are not sorting your completions based on the args
Because it's your job to filter inside the tab completion function
StringUtil.copyPartialMatches
I don't understand, how can I filter it? Any examples?
i myself would put a repeat scheduler every 1 second to check if its loaded and if it is, teleport them.
line 6 you literally add the players name
declaration: package: org.bukkit.util, class: StringUtil
never tried tho.
return this?
let me try it
yes
Alright, let me try it, thanks.
just make sure u cancel it when they teleport 😂
return StringUtil.copyPartialMatches(args[num], list that you would return without this, new ArrayList<>())
Having utils for everything nowadays, lol
utils is basically what .Net is
It's working perfectly, thank you so much guys!
how do i constantly add velocity to the armor stand
Only thing that sucks is that you probably didn't understand why nor did you learn anything. But hey, happy to hear that it works.
std-libs in general, in every language, xD.
i can use a loop to check if the armor stand exists if it exists add "amount of velocity" per tick but how do i add velocity to the facing direction
I kinda understand it, I wasn't know that I actually need to sort the List by myself.
Not quite sure what you mean by the facing direction. Do you want the balloon to behave like a real balloon? xD
What's the basic usage of scoreboard management?
Didn't mean it in any bad way. It's just that most people go ahead and call any utility without actually thinking about why that solves their problem. I myself (haven't been coding plugins in a while tho) used to create my own wrapper around the standard tab completer function to also get the current argument index, which is is basically determined by how many args there already are. By using streams I can also limit the max. number of responses in a centralized manner and do not have to filter out list items I don't need anyways.
This was my wrapper.
This is what I have so far
That's a question one would need to write a whole book about to answer properly.
depends what u want to do
Basically
I'm making a "Defend the Nexus" type of game
I want to make a scoreboard which shows all 4 Nexus' HP
I have a screenshot wait
Like this
that
All players view the same data, right?
Yup
i would recommend using teams and updating the teams when hp changes of a nexus
Then one scoreboard, created at init time, would be enough, which you send to all players.
well, im pretty sure u can find it online if u want examples of code
have u searched at all?
static Plugin plugin;
ScoreboardManager manager = Bukkit.getScoreboardManager();
final Scoreboard board = manager.getNewScoreboard();
final Objective objective = board.registerNewObjective("test", "dummy");
@EventHandler
public void PlayerJoin(PlayerJoinEvent e) {
final Player p = e.getPlayer();
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable() {
public void run() {
ScoreboardManager manager = Bukkit.getScoreboardManager();
final Scoreboard board = manager.getNewScoreboard();
final Objective objective = board.registerNewObjective("test", "dummy");
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName(ChatColor.RED + "YourScoreboardTitle");
Score score = objective.getScore("Score10");
score.setScore(10);
Score score1 = objective.getScore("Score9");
score1.setScore(9);
Score score2 = objective.getScore("Score8");
score2.setScore(8);
Score score3 = objective.getScore("§6Colors");
score3.setScore(7);
p.setScoreboard(board);
}
},0, 20 * 10);
}
}
I was about to give you code but better if you learn how to search it.
search for "with teams"
it seems like worked. Thanks!
I don't think I need that
you do need 😂
It's just a universal scoreboard which shows everyones' Nexus HP
to update the nexus HP
ah aight
well, u gonna update the score
then their "order" will keep changing
cause higher number goes higher on the lines
aight then
yep
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Here, you use the score to display nexus HP
already on it
are u coding on the latest versions?
1.19.2
alright then u should be fine
cheers
Shouldn't something dead simple like this do the trick? https://paste.md-5.net/jutuyeneyi.java
nope
i used baloon just as a name
Wouldn't know what to use teams for
i want to make the armor stand go towards its facing direction
setting the scoreboard all the time means flickering
at a constant rate
I thought setting it initially and then just updating scores would update the board?
hm
I always wrote my own API on top of packets, I hate the scoreboard API.
getLocation().getDirection().multiply(your_speed) ?
yeah
ah aight
Don't let md hear that.
everyone uses teams at this point
i didnt use teams for so long and its so good, not just the scoreboard but also for player "tags" above their head.
I'm sorry, but it just is that way. It has been initially implemented poorly and never got fixed up due to all of the backwards compatibility pressure.
@md_5 :trollface:
is it poorly efficient for big servers?
Oh, right... You want the constant movement, well then you'll need to either create your own armor stand with packets in order to avoid the server attaching physics and thus drag to it (slowing it down) and rendering your own vector in a separate task or you need to compensate for drag forces.
i just find it annoying the way to update it to all of the players, specially if u doing a minigame that requires tons of updates.
but always did the job
It's way easier to have a mental model of what's actually going on and how to handle/update boards if you get full control. The client stores this board, so why can I not just update it by updating a score of the scoreboard? Telling someone "just use teams" is insanity. It just obscures the inner workings.
so this basically means i don't have enough knowledge to achive what im trying to achive
im quite new i didnt understand what you are saying
i said to use teams because updating the score would mean the order changes.
if he doesnt care for the order then sure just update the scores.
i just need to move this armorstand towards what its facing
Doesn't have anything to do with knowledge, it's just something you notice once and then have to think about every time you want to do stuff like this. I'm sure you can get this working. I'd personally go for the packet route.
Oh, I never noticed that it was about the order, well sorry then
@dry yacht
it was just because of that and i said i recommended using teams
Teleporting it will only work if you let the delta in distance get small enough, which then requires to compensate with how often you teleport, if you want to have natural movements. I'd rather use packets, as the client interpolates between move packets.
Lol
Yep, you're right, I missed that.
Impossible.
Because even the server sends packets, lol
Kotlin can extend existing APIs, right? Extend the inventory, haha
Yes yes, I get what you mean, it should've been there a long time ago.
Yeah, I ment extending without implementing and having to carry your own impl around
Is there even a packet to update a window's title by it's ID? Don't remember anymore
Well you just reopen a new window with the same id, right?
Is there a reason for the server to know what you're typing?
Not really so it does make sense
For vanilla
Not you
Yes, I do know about that, but you cannot change the title once the screen has been opened. You need to create a new screen.
Because mojang
I also hated that, because I wanted to write a book editor
1000iq, omg
So the window state persists when doing that?
That would legit be a gamechanger
Because so many people spam the whole state accross the nework to do inv-title animations
Yeah, I think I'm gonna try that now, just need to get into bukkit real quick. I need the latest windowID, i got some old reflection util of mine to read that somewhere on my disk here.
Is there any InventoryCloseEvent reason get method?
... it's only paper I think
I'm actually making an Util library...
The Util will be used to make Setup Inventories.
I want to get the reason, if it is "COMPLETED", event.setCancelled(false)
otherwise Inventory.reopen("this");
Is it a bad idea?
ProtocolRock?
to add the feature?
Yeah... I can do that
Do you have any alternative idea to do that thing?
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
stupid question
yknow PlayerRespawnEvent
what happens if i did event.setCancelled(true)
so the player would simply not just respawn?
That's not the respawn event though :kekw:
Would someone know how to exactly get total amount of kills from an entire team (like add up all the kills), and then divide it by the number of team members?
This is my current code:
int team_amount = team.getMembers().size() + 1 + team.getOfficers().size();
for (int team_kills : ProfileManager.getProfile(player).getStat(PlayerStat.KILLS) {
}```
¯_(ツ)_/¯
But idk how to exactly get all kills from every player in a team and then add it up on top of each other
ah right
Since you appear to have every players kill stat just add them together and divide by the amount of players?
He does?
total amount of kills from an entire team
and then divide it by the number of team members
If you don't want the average just skip the divide part
How do I get the every player kill stat in current team tho?
yes
You can use a map with the team as a key or specifically look for players in the same team in the loop
Depends on what you want to do
guys i have a problem.
I want to create my first plugin but , when i do java -jar BuildTools.jar --rev latest in terminal , it say this:
Well, it's quite simple.
Your desktop is in the onedrive folder
Don't run it in a onedrive folder.
^
ok thanks guys
wouldn't it be more lightweight to just add up the existing stats of players in a team instead of storing new variables?
Guys i have downloaded Git Bash but it say this
what i can do?
I mean? sorry I’m not very practical
Just let it run
It will download git and continue
oh ok
I really cannot seem to get that to work, :(
Getting this error for some reason
Just does nothing
Trying out the PacketPlayOutOpenWindow to update inventory titles. It definitely sends out the packet, and the window-id is matching, but no effect. https://paste.md-5.net/botuxikake.java
Just check out attachAnimation