mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2026-01-06 15:42:00 +00:00
new event
This commit is contained in:
@@ -22,6 +22,9 @@ import dev.dejvokep.boostedyaml.block.implementation.Section;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentLike;
|
||||
import net.kyori.adventure.text.TranslatableComponent;
|
||||
import net.momirealms.customnameplates.common.event.Cancellable;
|
||||
import net.momirealms.customnameplates.common.event.CommandFeedbackEvent;
|
||||
import net.momirealms.customnameplates.common.event.NameplatesEvent;
|
||||
import net.momirealms.customnameplates.common.locale.CustomNameplatesCaptionFormatter;
|
||||
import net.momirealms.customnameplates.common.locale.CustomNameplatesCaptionProvider;
|
||||
import net.momirealms.customnameplates.common.locale.TranslationManager;
|
||||
@@ -72,6 +75,11 @@ public abstract class AbstractCommandManager<C> implements CustomNameplatesComma
|
||||
@Override
|
||||
public TriConsumer<C, String, Component> defaultFeedbackConsumer() {
|
||||
return ((sender, node, component) -> {
|
||||
NameplatesEvent event = plugin.getEventManager().dispatch(CommandFeedbackEvent.class, sender, node, component);
|
||||
if (event instanceof Cancellable cancellable) {
|
||||
if (cancellable.cancelled())
|
||||
return;
|
||||
}
|
||||
wrapSender(sender).sendMessage(
|
||||
component, true
|
||||
);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) <2024> <XiaoMoMi>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.momirealms.customnameplates.common.event;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public interface CommandFeedbackEvent<C> extends NameplatesEvent, Cancellable {
|
||||
|
||||
@Param(0)
|
||||
C sender();
|
||||
|
||||
@Param(1)
|
||||
String key();
|
||||
|
||||
@Param(2)
|
||||
Component message();
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
package net.momirealms.customnameplates.common.plugin;
|
||||
|
||||
import net.momirealms.customnameplates.common.dependency.DependencyManager;
|
||||
import net.momirealms.customnameplates.common.event.EventManager;
|
||||
import net.momirealms.customnameplates.common.locale.TranslationManager;
|
||||
import net.momirealms.customnameplates.common.plugin.classpath.ClassPathAppender;
|
||||
import net.momirealms.customnameplates.common.plugin.config.ConfigLoader;
|
||||
@@ -80,6 +81,10 @@ public interface NameplatesPlugin {
|
||||
return getDataDirectory();
|
||||
}
|
||||
|
||||
default File getDataFolder() {
|
||||
return getDataDirectory().toFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the dependency manager.
|
||||
*
|
||||
@@ -145,9 +150,17 @@ public interface NameplatesPlugin {
|
||||
*/
|
||||
void debug(Supplier<String> supplier);
|
||||
|
||||
/**
|
||||
* Check if the plugin is the latest
|
||||
*
|
||||
* @return is latest or not
|
||||
*/
|
||||
boolean isUpToDate();
|
||||
|
||||
default File getDataFolder() {
|
||||
return getDataDirectory().toFile();
|
||||
}
|
||||
/**
|
||||
* Gets the event manager
|
||||
*
|
||||
* @return the event manager
|
||||
*/
|
||||
EventManager getEventManager();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user