diff --git a/.idea/BossBarAPI.iml b/.idea/BossBarAPI.iml deleted file mode 100644 index d6ebd48..0000000 --- a/.idea/BossBarAPI.iml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index e36d8f8..1263d3e 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -6,10 +6,11 @@ - + + diff --git a/.idea/discord.xml b/.idea/discord.xml index 30bab2a..d8e9561 100644 --- a/.idea/discord.xml +++ b/.idea/discord.xml @@ -1,7 +1,7 @@ - \ No newline at end of file diff --git a/BossBarAPI.iml b/BossBarAPI.iml deleted file mode 100644 index 4ec1b0e..0000000 --- a/BossBarAPI.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - BUKKIT - - - - - \ No newline at end of file diff --git a/README.md b/README.md index d510c30..1869cb9 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,2 @@ -# BossBarAPI -Adds the ability to display BossBars to eaglercraft with an API -## How to use: -There is one default command that BossBarAPI comes with and that is /bossbar which creates a bossbar with the text "Countdown" and the bar slowly goes down - -Here is a guide to the API: -To create a BossBar do - -```BossBar bar = new BossBar(player)``` - -This will create a bossbar instance but wont spawn in the bossbar itself to the player - -To set the Bars health do - -```bar.setBarHealth(int)``` - -To set the bar's text do: - -```bar.setText(String)``` - -If these values are not set before the bossbar is displayed, they will default to 200 which is the bar's full health and "A Bossbar!" - -there are also getters for these 2 methods - -To display a bossbar, use - -```bar.display()``` - -To delete the bossbar, do - -```bar.delete``` - -There is also a `bar.getLocation` which returns the location of the Enderdragon but you will most likely never use this method - -ok thanx byeee +# ClassicCore +A plugin made for BnogoCarft's Classic Factions gamemode diff --git a/pom.xml b/pom.xml index c4de976..5b2a7a9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - tech.nully - BossBarAPI + games.bnogocarft + ClassicCore 0.0.1 @@ -22,77 +22,23 @@ - - - com.github.EaglerMaven - PacketWrapper - 1.5.2 - compile - - - com.github.EaglerMaven - ProtocolLib - 3.6.4 - provided - com.github.EaglerMaven craftbukkit 1.5.2-R1.0 provided + + com.github.EaglerMaven + Factions + 2.0.1 + provided + + + com.github.EaglerMaven + MassiveCore + 6.4.1 + provided + - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.0 - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - - - false - - - *:* - - META-INF/*.SF - META-INF/*.DSA - META-INF/*.RSA - - - - true - - - - - \ No newline at end of file diff --git a/src/main/java/games/bnogocarft/ClassicCore/ChatListener.java b/src/main/java/games/bnogocarft/ClassicCore/ChatListener.java new file mode 100644 index 0000000..5715426 --- /dev/null +++ b/src/main/java/games/bnogocarft/ClassicCore/ChatListener.java @@ -0,0 +1,79 @@ +package games.bnogocarft.ClassicCore; + +import com.massivecraft.factions.entity.UPlayer; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.AsyncPlayerChatEvent; + +import java.util.Arrays; +import java.util.List; + +public class ChatListener implements Listener { + @EventHandler + public void onPlayerChat(AsyncPlayerChatEvent e) { + if (Main.onChatCD.contains(e.getPlayer())) { + e.setCancelled(true); + e.getPlayer().sendMessage(ChatColor.RED + "ey man chill out 1 message every 1.5 seconds thanks"); + return; + } + List arrayMessage = Arrays.asList(e.getMessage().split(" ")); + for (String word : arrayMessage) { + if (word.contains("nigger") || + word.contains("faggot") || + word.contains("cum") || + word.contains("fag") || + word.contains("nazi") || + word.contains("nig") || + word.contains("beaner") || + word.contains("niggers") || + word.contains("faggots") || + word.contains("fags") || + word.contains("nigga") || + word.contains("niggas") || + word.contains("faggotass") || + word.contains("n1gger") || + word.contains("n1g") || + word.contains("n1gga") || + word.contains("beaners") + ) { + arrayMessage.set(arrayMessage.indexOf(word), word.replaceAll("[A-Za-z]", "#")); + } + } + e.setMessage(String.join(" ", arrayMessage)); + + Player player = e.getPlayer(); + if (player.hasPermission("bnogorpg.chat.admin")) { + e.setFormat("" + ChatColor.DARK_GRAY + '[' + ChatColor.DARK_RED + "Admin" + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_RED + player.getName() + ChatColor.DARK_GRAY + "» " + ChatColor.WHITE + e.getMessage()); + return; + } + + if (player.hasPermission("bnogorpg.chat.mod")) { + e.setFormat("" + ChatColor.DARK_GRAY + '[' + ChatColor.DARK_BLUE + "Mod" + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_BLUE + player.getName() + ChatColor.DARK_GRAY + "» " + ChatColor.WHITE + e.getMessage()); + return; + } + + if (player.hasPermission("bnogorpg.chat.helper")) { + e.setFormat("" + ChatColor.DARK_GRAY + '[' + ChatColor.BLUE + "Helper" + ChatColor.DARK_GRAY + ']' + ChatColor.GRAY + ' ' + UPlayer.get(player).getFaction().getName() + ' ' + ChatColor.GRAY + player.getName() + ChatColor.DARK_GRAY + "» " + ChatColor.GRAY + e.getMessage()); + Main.onChatCD.add(e.getPlayer()); + Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() { + @Override + public void run() { + Main.onChatCD.remove(e.getPlayer()); + } + }, 30L); + return; + } + + e.setFormat(ChatColor.GRAY + UPlayer.get(player).getFaction().getName() + ' ' + ChatColor.GRAY + player.getName() + ChatColor.DARK_GRAY + "» " + ChatColor.GRAY + e.getMessage()); + Main.onChatCD.add(e.getPlayer()); + Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() { + @Override + public void run() { + Main.onChatCD.remove(e.getPlayer()); + } + }, 30L); + } +} diff --git a/src/main/java/games/bnogocarft/ClassicCore/Main.java b/src/main/java/games/bnogocarft/ClassicCore/Main.java new file mode 100644 index 0000000..5deb888 --- /dev/null +++ b/src/main/java/games/bnogocarft/ClassicCore/Main.java @@ -0,0 +1,29 @@ +package games.bnogocarft.ClassicCore; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.List; + +public class Main extends JavaPlugin { + + private static Plugin instance; + + public static Plugin getInstance() { + return instance; + } + public static List onChatCD = new ArrayList<>(); + @Override + public void onEnable() { + instance = this; + getServer().getPluginManager().registerEvents(new ChatListener(), this); + } + + // Overrides onDisable + @Override + public void onDisable() { + + } +} diff --git a/src/main/java/tech/nully/BossBarAPI/BossBar.java b/src/main/java/tech/nully/BossBarAPI/BossBar.java deleted file mode 100644 index e0b96eb..0000000 --- a/src/main/java/tech/nully/BossBarAPI/BossBar.java +++ /dev/null @@ -1,72 +0,0 @@ -package tech.nully.BossBarAPI; - -import com.comphenix.protocol.ProtocolLibrary; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -public class BossBar { - private int bossHealth = 200; - private String text = "A BossBar!"; - - private SpawnFakeWither.FakeWither dragon; - - private Player p; - - public BossBar(Player p) { - this.p = p; - } - - public int getHealth() { - return bossHealth; - } - - private TeleportScheduler t; - - public void setHealth(int bossHealth) { - this.bossHealth = bossHealth; - if (dragon != null) { - if (dragon.created) { - dragon.setHealth(bossHealth); - } - } - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - if (dragon != null) { - if (dragon.created) { - dragon.setCustomName(text); - } - } - } - - public void display() { - if (dragon != null) { - if (dragon.created) { - dragon.destroy(); - } - } - dragon = new SpawnFakeWither.FakeWither(p, ProtocolLibrary.getProtocolManager()); - dragon.setCustomName(text); - dragon.create(); - - t = new TeleportScheduler(this); - Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), t, 100); - } - - public void delete() { - if (dragon != null) { - if (dragon.created) { - if (t != null) { - t.cancel(); - } - dragon.destroy(); - } - } - } -} diff --git a/src/main/java/tech/nully/BossBarAPI/FakeWitherCommand.java b/src/main/java/tech/nully/BossBarAPI/FakeWitherCommand.java deleted file mode 100644 index 127227b..0000000 --- a/src/main/java/tech/nully/BossBarAPI/FakeWitherCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package tech.nully.BossBarAPI; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitTask; - -import static tech.nully.BossBarAPI.SpawnFakeWither.TICKS_PER_SECOND; - -public class FakeWitherCommand implements CommandExecutor { - - private BukkitTask task; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (sender instanceof Player) { - Player player = (Player) sender; - BossBar bar = new BossBar(player); - bar.setText("Countdown"); - bar.display(); - - - // Count down - task = Bukkit.getServer().getScheduler().runTaskTimer(Main.getInstance(), () -> { - // Count down - bar.setHealth(bar.getHealth() - 1); - - if (bar.getHealth() <= 0) { - bar.delete(); - task.cancel(); - } - }, TICKS_PER_SECOND / 4, TICKS_PER_SECOND / 4); - } - return true; - } -} diff --git a/src/main/java/tech/nully/BossBarAPI/Main.java b/src/main/java/tech/nully/BossBarAPI/Main.java deleted file mode 100644 index 4241a2f..0000000 --- a/src/main/java/tech/nully/BossBarAPI/Main.java +++ /dev/null @@ -1,32 +0,0 @@ -package tech.nully.BossBarAPI; - -import com.comphenix.packetwrapper.Packet3ENamedSoundEffect; -import com.comphenix.protocol.PacketType; -import com.comphenix.protocol.ProtocolLibrary; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import net.minecraft.server.v1_5_R3.Packet62NamedSoundEffect; -import org.bukkit.plugin.Plugin; -import org.bukkit.plugin.java.JavaPlugin; - -public class Main extends JavaPlugin { - - private static Plugin instance; - - public static Plugin getInstance() { - return instance; - } - @Override - public void onEnable() { - instance = this; - System.out.println("BossBar is on"); - getCommand("bossbar").setExecutor(new FakeWitherCommand()); - } - - // Overrides onDisable - @Override - public void onDisable() { - - } -} diff --git a/src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java b/src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java deleted file mode 100644 index 3b69bea..0000000 --- a/src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java +++ /dev/null @@ -1,143 +0,0 @@ -package tech.nully.BossBarAPI; - -import com.comphenix.packetwrapper.Packet18SpawnMob; -import com.comphenix.packetwrapper.Packet1DDestroyEntity; -import com.comphenix.packetwrapper.Packet28EntityMetadata; -import com.comphenix.protocol.ProtocolManager; -import com.comphenix.protocol.injector.PlayerLoggedOutException; -import com.comphenix.protocol.wrappers.WrappedDataWatcher; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import java.lang.reflect.InvocationTargetException; -import java.util.logging.Level; - -public class SpawnFakeWither extends JavaPlugin { - public static final int TICKS_PER_SECOND = 20; - - // You could also use a full-fledged API like RemoteEntities - public static class FakeWither { - public static final byte INVISIBLE = 0x20; - // Next entity ID - public static int NEXT_ID = 6000; - - public static final int METADATA_WITHER_HEALTH = 16; // 1.5.2 -> Change to 16 - - // Metadata indices - public static final int METADATA_FLAGS = 0; - public static final int METADATA_NAME = 5; // 1.5.2 -> Change to 5 - public static final int METADATA_SHOW_NAME = 6; // 1.5.2 -> Change to 6 - - // Unique ID - public int id = NEXT_ID++; - // Default health - public int health = 200; - public String customName; - public boolean created; - - public Location location; - public ProtocolManager manager; - public Player p; - - public FakeWither(Player p, ProtocolManager manager) { - this.location = new Location(p.getWorld(), p.getLocation().getX(), p.getLocation().getY() - 45, p.getLocation().getZ()); - this.manager = manager; - this.p = p; - } - - public int getHealth() { - return health; - } - - public void setHealth(int health) { - // Update the health of the entity - if (created) { - WrappedDataWatcher watcher = new WrappedDataWatcher(); - - watcher.setObject(METADATA_WITHER_HEALTH, (int) health); // 1.5.2 -> Change to (int) - sendMetadata(watcher); - } - this.health = health; - } - - public void setCustomName(String name) { - if (created) { - WrappedDataWatcher watcher = new WrappedDataWatcher(); - - if (name != null) { - watcher.setObject(METADATA_NAME, name); - watcher.setObject(METADATA_SHOW_NAME, (byte) 1); - } else { - // Hide custom name - watcher.setObject(METADATA_SHOW_NAME, (byte) 0); - } - - // Only players nearby when this is sent will see this name - sendMetadata(watcher); - } - this.customName = name; - } - - public void sendMetadata(WrappedDataWatcher watcher) { - Packet28EntityMetadata update = new Packet28EntityMetadata(); - - update.setEntityId(id); - update.setEntityMetadata(watcher.getWatchableObjects()); - try { - manager.sendServerPacket(p, update.getHandle()); - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "Cannot send " + update.getHandle() + " to " + p, e); - } - } - - public int getId() { - return id; - } - - public void create() { - Packet18SpawnMob spawnMob = new Packet18SpawnMob(); - WrappedDataWatcher watcher = new WrappedDataWatcher(); - - watcher.setObject(METADATA_FLAGS, INVISIBLE); - watcher.setObject(METADATA_WITHER_HEALTH, (int) health); // 1.5.2 -> Change to (int) - - - if (customName != null) { - watcher.setObject(METADATA_NAME, customName); - watcher.setObject(METADATA_SHOW_NAME, (byte) 1); - } - - spawnMob.setEntityID(id); - spawnMob.setType(EntityType.ENDER_DRAGON); - spawnMob.setX(location.getX()); - spawnMob.setY(location.getY()); - spawnMob.setZ(location.getZ()); - spawnMob.setMetadata(watcher); - - try { - manager.sendServerPacket(p, spawnMob.getHandle()); - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "Cannot send " + spawnMob.getHandle() + " to " + p, e); - } catch (PlayerLoggedOutException ignored) {} - created = true; - } - - public void destroy() { - if (!created) - throw new IllegalStateException("Cannot kill a killed entity."); - - Packet1DDestroyEntity destroyMe = new Packet1DDestroyEntity(); - destroyMe.setEntities(new int[]{id}); - - try { - manager.sendServerPacket(p, destroyMe.getHandle()); - } catch (InvocationTargetException e) { - Bukkit.getLogger().log(Level.WARNING, "Cannot send " + destroyMe.getHandle() + " to " + p, e); - } catch (PlayerLoggedOutException ignored) {} - created = false; - } - } -} \ No newline at end of file diff --git a/src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java b/src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java deleted file mode 100644 index dcc7b60..0000000 --- a/src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java +++ /dev/null @@ -1,16 +0,0 @@ -package tech.nully.BossBarAPI; - -import org.bukkit.scheduler.BukkitRunnable; - -public class TeleportScheduler extends BukkitRunnable { - private BossBar b; - - public TeleportScheduler(BossBar b) { - this.b = b; - } - - @Override - public void run() { - b.display(); - } -} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3412f00..636d691 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,12 +1,7 @@ -name: BossBarAPI +name: ClassicCore version: 0.0.1 -main: tech.nully.BossBarAPI.Main -prefix: [BossBarAPI] +main: games.bnogocarft.ClassicCore.Main +prefix: [ClassicCore] authors: [BongoCat] -description: An API for eaglercraft to be able to display bossbars -depend: [ProtocolLib] -website: nully.tech -commands: - bossbar: - usage: / - description: Displays a bossbar \ No newline at end of file +description: A plugin made for BnogoCarft's classic factions gamemode +website: https://bnogocarft.games \ No newline at end of file diff --git a/target/BossBarAPI-0.0.1.jar b/target/BossBarAPI-0.0.1.jar deleted file mode 100644 index 8a0abbb..0000000 Binary files a/target/BossBarAPI-0.0.1.jar and /dev/null differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index 3412f00..636d691 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -1,12 +1,7 @@ -name: BossBarAPI +name: ClassicCore version: 0.0.1 -main: tech.nully.BossBarAPI.Main -prefix: [BossBarAPI] +main: games.bnogocarft.ClassicCore.Main +prefix: [ClassicCore] authors: [BongoCat] -description: An API for eaglercraft to be able to display bossbars -depend: [ProtocolLib] -website: nully.tech -commands: - bossbar: - usage: / - description: Displays a bossbar \ No newline at end of file +description: A plugin made for BnogoCarft's classic factions gamemode +website: https://bnogocarft.games \ No newline at end of file diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties index 20902d1..df62145 100644 --- a/target/maven-archiver/pom.properties +++ b/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Fri Jun 24 18:50:10 PDT 2022 -groupId=tech.nully -artifactId=BossBarAPI +#Thu Aug 11 20:32:55 PDT 2022 version=0.0.1 +groupId=games.bnogocarft +artifactId=ClassicCore diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 62fb876..c1704b7 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,6 +1,4 @@ -tech/nully/BossBarAPI/BossBar.class -tech/nully/BossBarAPI/Main.class -tech/nully/BossBarAPI/SpawnFakeWither.class -tech/nully/BossBarAPI/TeleportScheduler.class -tech/nully/BossBarAPI/FakeWitherCommand.class -tech/nully/BossBarAPI/SpawnFakeWither$FakeWither.class +games/bnogocarft/ClassicCore/Main.class +games/bnogocarft/ClassicCore/ChatListener.class +games/bnogocarft/ClassicCore/ChatListener$2.class +games/bnogocarft/ClassicCore/ChatListener$1.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index b142acd..83cbf9d 100644 --- a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,4 +1,2 @@ -C:\Users\PC\Documents\BossBarAPI\src\main\java\tech\nully\BossBarAPI\SpawnFakeWither.java -C:\Users\PC\Documents\BossBarAPI\src\main\java\tech\nully\BossBarAPI\Main.java -C:\Users\PC\Documents\BossBarAPI\src\main\java\tech\nully\BossBarAPI\BossBar.java -C:\Users\PC\Documents\BossBarAPI\src\main\java\tech\nully\BossBarAPI\FakeWitherCommand.java +/home/bongle/GitHub/ClassicCore/src/main/java/games/bnogocarft/ClassicCore/ChatListener.java +/home/bongle/GitHub/ClassicCore/src/main/java/games/bnogocarft/ClassicCore/Main.java diff --git a/target/original-BossBarAPI-0.0.1.jar b/target/original-BossBarAPI-0.0.1.jar deleted file mode 100644 index 0304054..0000000 Binary files a/target/original-BossBarAPI-0.0.1.jar and /dev/null differ