Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
ed37993134 | |||
a80fb99bdc | |||
3943c3d239 | |||
c1c736a034 | |||
04dcf23145 | |||
c882fe6031 | |||
45c2770873 | |||
a054eb096e | |||
6c41124db4 | |||
a0909717fd | |||
41f21bc539 | |||
f4583bc2ec | |||
68844e611a | |||
b6b80874c8 | |||
3fd16f2957 | |||
83019e160d | |||
dbc76b7cca |
11 changed files with 210 additions and 7 deletions
4
pom.xml
4
pom.xml
|
@ -54,7 +54,7 @@
|
|||
<artifactId>run-paper-maven-plugin</artifactId>
|
||||
<version>1.1.1</version>
|
||||
<configuration>
|
||||
<minecraftVersion>1.21.7</minecraftVersion>
|
||||
<minecraftVersion>1.21.8</minecraftVersion>
|
||||
<acceptEula>true</acceptEula>
|
||||
<serverDirectory>run</serverDirectory>
|
||||
<jvmFlags>
|
||||
|
@ -88,7 +88,7 @@
|
|||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.7-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# No, thank you, Microsoft
|
||||
This is the gay version!
|
||||
|
||||
This plugin was created with the scope of being an incredibly simple way to remove the ability for Mojang to snoop through you messages by reimplementing the PlayerChatEvent to be a server broadcast, however, I have added some interesting features.
|
||||
|
||||
When making this plugin, I took the liberty to make it so you can customise how the messages look using [MiniMessage](https://docs.advntr.dev/minimessage/index.html). Keep in mind that players can also format the message content with MiniMessage.
|
||||
|
||||
It is very lightweight, having a little under 50 lines of code, however this might change when I will get to implementing PlaceholderAPI support.
|
||||
|
||||
Licensed under WTFPL.
|
||||
|
||||
Download from the [releases tab](https://git.fzorb.xyz/fzorb/noThankYouMicrosoft/releases).
|
||||
Licensed under WTFPL.
|
|
@ -1,21 +1,71 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft;
|
||||
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import xyz.fzorb.noThankYouMicrosoft.flagFrontend.menuEvents;
|
||||
import xyz.fzorb.noThankYouMicrosoft.flagFrontend.prideCommand;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class NoThankYouMicrosoft extends JavaPlugin {
|
||||
|
||||
private static JavaPlugin instance;
|
||||
private static File databaseFile;
|
||||
private static YamlConfiguration databaseFileConfig;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
this.saveDefaultConfig();
|
||||
createDatabaseConfig();
|
||||
this.getServer().getPluginManager().registerEvents(new messageListener(), this);
|
||||
this.getServer().getPluginManager().registerEvents(new menuEvents(), this);
|
||||
this.getCommand("pride").setExecutor(new prideCommand());
|
||||
}
|
||||
|
||||
private void createDatabaseConfig() {
|
||||
databaseFile = new File(getDataFolder(), "database.yml");
|
||||
if (!databaseFile.exists()) {
|
||||
databaseFile.getParentFile().mkdirs();
|
||||
saveResource("database.yml", false);
|
||||
}
|
||||
|
||||
databaseFileConfig = new YamlConfiguration();
|
||||
try {
|
||||
databaseFileConfig.load(databaseFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reReadDatabase(JavaPlugin instance) {
|
||||
File databaseFile = new File(instance.getDataFolder(), "database.yml");
|
||||
databaseFileConfig = new YamlConfiguration();
|
||||
try {
|
||||
databaseFileConfig.load(databaseFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveDatabase(JavaPlugin instance) {
|
||||
File databaseFile = new File(instance.getDataFolder(), "database.yml");
|
||||
try {
|
||||
databaseFileConfig.save(databaseFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static JavaPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
public static FileConfiguration getDatabase() {
|
||||
return databaseFileConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft.flagFrontend;
|
||||
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import xyz.fzorb.noThankYouMicrosoft.flagManager;
|
||||
|
||||
public class menuEvents implements Listener {
|
||||
@EventHandler
|
||||
public static void onPlayerInteractWithChestGUI(InventoryClickEvent event) {
|
||||
if (event.getInventory().equals(prideMenu.prideMenus.get(event.getWhoClicked().getUniqueId()))) {
|
||||
event.setCancelled(true);
|
||||
event.getInventory().close();
|
||||
prideMenu.prideMenus.remove(event.getWhoClicked().getUniqueId());
|
||||
ItemStack item = event.getCurrentItem();
|
||||
String pride = PlainTextComponentSerializer.plainText().serialize(item.getItemMeta().displayName());
|
||||
flagManager.setUserPride(event.getWhoClicked().getUniqueId(), pride);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft.flagFrontend;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.fzorb.noThankYouMicrosoft.flagManager;
|
||||
|
||||
public class prideCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) { return true; }
|
||||
prideMenu.prideMenus.put(((Player) sender).getUniqueId(), prideMenu.generatePrideMenu());
|
||||
((Player) sender).openInventory(prideMenu.prideMenus.get(((Player) sender).getUniqueId()));
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft.flagFrontend;
|
||||
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import xyz.fzorb.noThankYouMicrosoft.NoThankYouMicrosoft;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class prideMenu {
|
||||
|
||||
public static final Map<UUID, Inventory> prideMenus = new HashMap<>();
|
||||
|
||||
public static Integer calculateRows(Integer number) {
|
||||
if (number <= 9) { return 9; }
|
||||
else if (number <= 18) { return 18; }
|
||||
else if (number <= 27) { return 27; }
|
||||
else if (number <= 36) { return 36; }
|
||||
else if (number <= 45) { return 45; }
|
||||
else if (number <= 54) { return 54; }
|
||||
return 0; // this can NEVER be the case, can it? who am I kidding, I DOUBT there will ever be more than 54 flags!
|
||||
}
|
||||
|
||||
public static ItemStack generatePrideItem(String pride) {
|
||||
ItemStack is = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.displayName(MiniMessage.miniMessage().deserialize("<pride:" + pride + ">" + pride + "</pride>"));
|
||||
is.setItemMeta(im);
|
||||
return is;
|
||||
}
|
||||
|
||||
public static ItemStack generateNoPrideItem() {
|
||||
ItemStack is = new ItemStack(Material.BARRIER, 1);
|
||||
ItemMeta im = is.getItemMeta();
|
||||
im.displayName(MiniMessage.miniMessage().deserialize("<red>none</red>"));
|
||||
is.setItemMeta(im);
|
||||
return is;
|
||||
}
|
||||
|
||||
public static Inventory generatePrideMenu() {
|
||||
List<String> prides = NoThankYouMicrosoft.getInstance().getConfig().getStringList("prides");
|
||||
Inventory inventory = Bukkit.createInventory(null, calculateRows(prides.toArray().length + 1), MiniMessage.miniMessage().deserialize("<pride>Choose your flag</pride>"));
|
||||
for (String pride : prides) {
|
||||
inventory.addItem(generatePrideItem(pride));
|
||||
}
|
||||
inventory.addItem(generateNoPrideItem());
|
||||
return inventory;
|
||||
}
|
||||
}
|
21
src/main/java/xyz/fzorb/noThankYouMicrosoft/flagManager.java
Normal file
21
src/main/java/xyz/fzorb/noThankYouMicrosoft/flagManager.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package xyz.fzorb.noThankYouMicrosoft;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class flagManager {
|
||||
public static String getUserPride(UUID uuid) {
|
||||
NoThankYouMicrosoft.reReadDatabase(NoThankYouMicrosoft.getInstance());
|
||||
String pride = NoThankYouMicrosoft.getDatabase().getString("players.%s.flag".formatted(uuid.toString()));
|
||||
if (pride == null) {
|
||||
return "none";
|
||||
} else {
|
||||
return pride;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setUserPride(UUID uuid, String pride) {
|
||||
NoThankYouMicrosoft.reReadDatabase(NoThankYouMicrosoft.getInstance());
|
||||
NoThankYouMicrosoft.getDatabase().set("players.%s.flag".formatted(uuid.toString()), pride);
|
||||
NoThankYouMicrosoft.saveDatabase(NoThankYouMicrosoft.getInstance());
|
||||
}
|
||||
}
|
|
@ -14,6 +14,19 @@ public class messageListener implements Listener {
|
|||
String message = MiniMessage.miniMessage().serialize(event.message());
|
||||
event.setCancelled(true);
|
||||
String format = NoThankYouMicrosoft.getInstance().getConfig().getString("format");
|
||||
Bukkit.getServer().broadcast(MiniMessage.miniMessage().deserialize(format.replace("{{username}}", player.getDisplayName()).replace("{{message}}", message)));
|
||||
String finalMessage = format
|
||||
.replace("{{username}}", player.getDisplayName())
|
||||
.replace("{{message}}", message);
|
||||
if (!flagManager.getUserPride(player.getUniqueId()).equals("none")) {
|
||||
finalMessage = finalMessage
|
||||
.replace("{{pride_start}}", "<pride:" + flagManager.getUserPride(player.getUniqueId()) + ">")
|
||||
.replace("{{pride_end}}", "</pride>");
|
||||
} else {
|
||||
finalMessage = finalMessage
|
||||
.replace("{{pride_start}}", "")
|
||||
.replace("{{pride_end}}", "");
|
||||
}
|
||||
Bukkit.getServer().broadcast(MiniMessage.miniMessage().deserialize(finalMessage));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,21 @@
|
|||
format: "<{{username}}> {{message}}" #you can use MiniMessage!
|
||||
format: "<{{pride_start}}{{username}}{{pride_end}}> {{message}}" #you can use MiniMessage!
|
||||
|
||||
prides:
|
||||
- pride
|
||||
- progress
|
||||
- trans
|
||||
- bi
|
||||
- pan
|
||||
- nb
|
||||
- lesbian
|
||||
- ace
|
||||
- agender
|
||||
- demisexual
|
||||
- genderqueer
|
||||
- genderfluid
|
||||
- intersex
|
||||
- aro
|
||||
- queer
|
||||
- gay
|
||||
- bigender
|
||||
- demigender
|
3
src/main/resources/database.yml
Normal file
3
src/main/resources/database.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
players:
|
||||
uuid:
|
||||
flag: pride
|
|
@ -6,3 +6,7 @@ prefix: nTYM
|
|||
authors: [ fzorb ]
|
||||
description: Rewrites your Minecraft messages to make them unreportable
|
||||
website: https://git.fzorb.xyz/fzorb/noThankYouMicrosoft
|
||||
commands:
|
||||
pride:
|
||||
description: Open pride selection menu
|
||||
usage: /pride
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue