Skip to content

Commit

Permalink
Merge branch 'release/1.x' of https://github.com/Nookure/MAStaff into…
Browse files Browse the repository at this point in the history
… release/1.x
  • Loading branch information
Angelillo15 committed Mar 28, 2024
2 parents cae4211 + 81e121e commit 463a498
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,37 @@ public class VanishPartial {
@Comment("Message sent to the player when the vanish is toggled on.")
private String vanishEnabled = "{prefix} <gray>Vanish has been toggled <green>on</green>.";

@Setting
@Comment("""
Message to broadcast to online players when a staff member enable vanish.
Change it to "" to disable the broadcast.
""")
private String vanishEnabledBroadcast = "<yellow>{player} has left the game.";

@Setting
@Comment("Message sent to the player when the vanish is toggled off.")
private String vanishDisabled = "{prefix} <gray>Vanish has been toggled <red>off</red>.";

@Setting
@Comment("""
Message to broadcast to online players when a staff member disable vanish.
Change it to "" to disable the broadcast.
""")
private String vanishDisabledBroadcast = "<yellow>{player} has joined the game.";

public String vanishEnabled() {
return vanishEnabled;
}

public String vanishDisabled() {
return vanishDisabled;
}

public String vanishEnabledBroadcast() {
return vanishEnabledBroadcast;
}

public String vanishDisabledBroadcast() {
return vanishDisabledBroadcast;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public void publish(@NotNull PlayerWrapper sender, @NotNull Event event) {
objectOutputStream.writeObject(event);
objectOutputStream.flush();


publish(sender, byteArrayOutputStream.toByteArray());
} catch (IOException e) {
logger.severe("Error while serializing event");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.nookure.staff.api.extension.StaffPlayerExtension;
import com.nookure.staff.api.extension.StaffPlayerExtensionManager;
import com.nookure.staff.api.item.StaffItem;
import com.nookure.staff.api.manager.PlayerWrapperManager;
import com.nookure.staff.api.manager.StaffItemsManager;
import com.nookure.staff.api.messaging.EventMessenger;
import com.nookure.staff.api.model.StaffDataModel;
Expand Down Expand Up @@ -60,6 +61,8 @@ public class StaffPaperPlayerWrapper extends PaperPlayerWrapper implements Staff
private StaffPlayerExtensionManager extensionManager;
@Inject
private Injector injector;
@Inject
private PlayerWrapperManager<Player> playerWrapperManager;
private final Map<Class<? extends StaffPlayerExtension>, StaffPlayerExtension> extensionMap = new HashMap<>();
private final Map<Integer, StaffItem> items = new HashMap<>();
private StaffDataModel staffDataModel;
Expand Down Expand Up @@ -97,7 +100,14 @@ public void enableVanish(boolean silent) {

logger.debug("Enabling vanish for %s", player.getName());

if (!silent) sendMiniMessage(messages.get().vanish.vanishEnabled());
if (!silent) {
sendMiniMessage(messages.get().vanish.vanishEnabled());

playerWrapperManager.stream()
.forEach(p ->
p.sendMiniMessage(messages.get().vanish.vanishEnabledBroadcast(), "{player}", player.getName())
);
}

Bukkit.getOnlinePlayers().stream()
.filter(p -> !p.hasPermission(Permissions.STAFF_VANISH_SEE))
Expand All @@ -110,7 +120,14 @@ public void disableVanish(boolean silent) {

logger.debug("Disabling vanish for %s", player.getName());

if (!silent) sendMiniMessage(messages.get().vanish.vanishDisabled());
if (!silent) {
sendMiniMessage(messages.get().vanish.vanishDisabled());

playerWrapperManager.stream()
.forEach(p ->
p.sendMiniMessage(messages.get().vanish.vanishDisabledBroadcast(), "{player}", player.getName())
);
}

Bukkit.getOnlinePlayers()
.forEach(p -> p.showPlayer(javaPlugin, player));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.nookure.staff.paper.listener.staff;

import com.google.inject.Inject;
import com.nookure.staff.api.Logger;
import com.nookure.staff.api.Permissions;
import com.nookure.staff.api.StaffPlayerWrapper;
import com.nookure.staff.api.config.ConfigurationContainer;
Expand All @@ -12,6 +13,7 @@
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;

import java.util.Optional;
Expand All @@ -26,7 +28,10 @@ public class OnPlayerInStaffChatTalk implements Listener {
@Inject
private ServerUtils serverUtils;

@EventHandler
@EventHandler(
priority = EventPriority.HIGH,
ignoreCancelled = true
)
private void onPlayerInStaffChatTalk(AsyncChatEvent event) {
Optional<StaffPlayerWrapper> optionalStaffPlayerWrapper = playerWrapperManager.getStaffPlayer(event.getPlayer().getUniqueId());

Expand Down

0 comments on commit 463a498

Please sign in to comment.