-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
229 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
group = "fr.euphyllia.skyllia"; | ||
version = "1.1"; | ||
|
||
dependencies { | ||
compileOnly("io.papermc.paper:paper-api:1.21.3-R0.1-SNAPSHOT") | ||
compileOnly(project(":api")) | ||
compileOnly(project(":plugin")) | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_21 | ||
targetCompatibility = JavaVersion.VERSION_21 | ||
} | ||
|
||
tasks { | ||
compileJava { | ||
options.encoding = "UTF-8" | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
addons/SkylliaChat/src/main/java/fr/euphyllia/skylliachat/ChatListeners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package fr.euphyllia.skylliachat; | ||
|
||
import fr.euphyllia.skyllia.api.SkylliaAPI; | ||
import fr.euphyllia.skyllia.api.skyblock.Island; | ||
import fr.euphyllia.skyllia.api.skyblock.Players; | ||
import fr.euphyllia.skyllia.configuration.LanguageToml; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
|
||
public class ChatListeners implements Listener { | ||
|
||
private final Main plugin; | ||
|
||
public ChatListeners(Main plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerChat(final AsyncPlayerChatEvent event) { | ||
Player player = event.getPlayer(); | ||
|
||
if (Main.getPlugin(Main.class).getIslandChatEnabled().getOrDefault(player, false)) { | ||
event.setCancelled(true); | ||
|
||
Bukkit.getAsyncScheduler().runNow(Main.getPlugin(Main.class), scheduledTask -> { | ||
Island island = SkylliaAPI.getCacheIslandByPlayerId(player.getUniqueId()); | ||
if (island == null) { | ||
LanguageToml.sendMessage(player, LanguageToml.messagePlayerHasNotIsland); | ||
return; | ||
} | ||
|
||
String message = event.getMessage(); | ||
String format = this.plugin.getConfig().getString("chat.format", "<red>[Messaging Island] %player_name%: <gray>%message%") | ||
.replace("%player_name%", player.getName()) | ||
.replace("%message%", message); | ||
for (Players islandMember : island.getMembersCached()) { | ||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(islandMember.getMojangId()); | ||
if (offlinePlayer.isOnline() && offlinePlayer.getPlayer() != null) { | ||
LanguageToml.sendMessage(offlinePlayer.getPlayer(), format); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
addons/SkylliaChat/src/main/java/fr/euphyllia/skylliachat/Main.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package fr.euphyllia.skylliachat; | ||
|
||
import fr.euphyllia.skyllia.api.SkylliaAPI; | ||
import fr.euphyllia.skyllia.api.commands.SubCommandRegistry; | ||
import fr.euphyllia.skylliachat.commands.IslandChatCommand; | ||
import fr.euphyllia.skylliachat.commands.IslandChatReloadCommand; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public final class Main extends JavaPlugin { | ||
|
||
private final ConcurrentHashMap<Player, Boolean> islandChatEnabled = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public void onEnable() { | ||
saveDefaultConfig(); | ||
// Plugin startup logic | ||
SkylliaAPI.registerCommands(new IslandChatCommand(this), "chat"); | ||
SkylliaAPI.registerAdminCommands(new IslandChatReloadCommand(this), "chat_reload"); | ||
|
||
getServer().getPluginManager().registerEvents(new ChatListeners(this), this); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
} | ||
|
||
public ConcurrentHashMap<Player, Boolean> getIslandChatEnabled() { | ||
return islandChatEnabled; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
addons/SkylliaChat/src/main/java/fr/euphyllia/skylliachat/commands/IslandChatCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package fr.euphyllia.skylliachat.commands; | ||
|
||
import fr.euphyllia.skyllia.api.commands.SubCommandInterface; | ||
import fr.euphyllia.skyllia.configuration.LanguageToml; | ||
import fr.euphyllia.skylliachat.Main; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.Plugin; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class IslandChatCommand implements SubCommandInterface { | ||
|
||
private final Main plugin; | ||
|
||
public IslandChatCommand(Main main) { | ||
plugin = main; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender, @NotNull String[] args) { | ||
if (!(sender instanceof Player player)) { | ||
LanguageToml.sendMessage(sender, LanguageToml.messageCommandPlayerOnly); | ||
return true; | ||
} | ||
if (!sender.hasPermission("skylliachat.use")) { | ||
LanguageToml.sendMessage(sender, "<red>You are not a permission to execute this commands."); | ||
return true; | ||
} | ||
|
||
// Toggle island chat mode | ||
boolean isEnabled = this.plugin.getIslandChatEnabled().getOrDefault(player, false); | ||
this.plugin.getIslandChatEnabled().put(player, !isEnabled); | ||
|
||
String msg; | ||
if (isEnabled) { | ||
msg = this.plugin.getConfig().getString("message.chat.disabled", "<red>Island messaging Disabled."); | ||
} else { | ||
msg = this.plugin.getConfig().getString("message.chat.enabled", "<green>Island Messaging Enabled."); | ||
} | ||
LanguageToml.sendMessage(sender, msg); | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull List<String> onTabComplete(@NotNull Plugin plugin, @NotNull CommandSender sender, @NotNull String[] args) { | ||
return Collections.emptyList(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
.../SkylliaChat/src/main/java/fr/euphyllia/skylliachat/commands/IslandChatReloadCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package fr.euphyllia.skylliachat.commands; | ||
|
||
import fr.euphyllia.skyllia.api.commands.SubCommandInterface; | ||
import fr.euphyllia.skyllia.configuration.LanguageToml; | ||
import fr.euphyllia.skylliachat.Main; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.plugin.Plugin; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class IslandChatReloadCommand implements SubCommandInterface { | ||
|
||
private final Main plugin; | ||
|
||
public IslandChatReloadCommand(Main plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(@NotNull Plugin plugin, @NotNull CommandSender sender, @NotNull String[] args) { | ||
if (!sender.hasPermission("skylliachat.reload")) { | ||
LanguageToml.sendMessage(sender, "<red>You are not a permission to execute this commands."); | ||
return true; | ||
} | ||
|
||
// Recharge la configuration | ||
this.plugin.reloadConfig(); | ||
|
||
String msg = this.plugin.getConfig().getString("message.config.reloaded", "<green>Configuration successfully reloaded!"); | ||
LanguageToml.sendMessage(sender, msg); | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull List<String> onTabComplete(@NotNull Plugin plugin, @NotNull CommandSender sender, @NotNull String[] args) { | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
chat: | ||
format: "<red>[Messaging Island] %player_name%: <gray>%message%" | ||
|
||
message: | ||
config: | ||
reloaded: "<green>Configuration successfully reloaded!" | ||
chat: | ||
enabled: "<green>Island Messaging Enabled." | ||
disabled: "<red>Island messaging Disabled." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: SkylliaChat | ||
version: '1.1' | ||
main: fr.euphyllia.skylliachat.Main | ||
api-version: '1.20' | ||
folia-supported: true | ||
|
||
dependencies: | ||
server: | ||
Skyllia: | ||
load: OMIT | ||
required: true | ||
join-classpath: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters