mirror of
https://github.com/darverdevs/BossBarAPI.git
synced 2024-12-21 23:04:11 -08:00
parent
548369fda3
commit
e2d756d51e
9
.idea/BossBarAPI.iml
Normal file
9
.idea/BossBarAPI.iml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
18
.idea/ClassicCore.iml
Normal file
18
.idea/ClassicCore.iml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.EaglerMaven:craftbukkit:1.5.2-R1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.EaglerMaven:Factions:2.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.EaglerMaven:MassiveCore:6.4.1" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
|
@ -6,11 +6,11 @@
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
<outputRelativeToContentRoot value="true" />
|
<outputRelativeToContentRoot value="true" />
|
||||||
<module name="ClassicCore" />
|
<module name="BossBarAPI" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel>
|
<bytecodeTargetLevel>
|
||||||
<module name="BossBarAPI" target="1.8" />
|
<module name="ClassicCore" target="1.8" />
|
||||||
<module name="untitled" target="1.5" />
|
<module name="untitled" target="1.5" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="DiscordProjectSettings">
|
<component name="DiscordProjectSettings">
|
||||||
<option name="show" value="PROJECT_FILES" />
|
<option name="show" value="ASK" />
|
||||||
<option name="description" value="" />
|
<option name="description" value="" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/ClassicCore.iml" filepath="$PROJECT_DIR$/.idea/ClassicCore.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
37
README.md
37
README.md
|
@ -1,2 +1,35 @@
|
||||||
# ClassicCore
|
# BossBarAPI
|
||||||
A plugin made for BnogoCarft's Classic Factions gamemode
|
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
|
||||||
|
|
82
pom.xml
82
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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>games.bnogocarft</groupId>
|
<groupId>tech.nully</groupId>
|
||||||
<artifactId>ClassicCore</artifactId>
|
<artifactId>BossBarAPI</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -22,23 +22,77 @@
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- PrimCore dependencies -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.EaglerMaven</groupId>
|
||||||
|
<artifactId>PacketWrapper</artifactId>
|
||||||
|
<version>1.5.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.EaglerMaven</groupId>
|
||||||
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
<version>3.6.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.EaglerMaven</groupId>
|
<groupId>com.github.EaglerMaven</groupId>
|
||||||
<artifactId>craftbukkit</artifactId>
|
<artifactId>craftbukkit</artifactId>
|
||||||
<version>1.5.2-R1.0</version>
|
<version>1.5.2-R1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.EaglerMaven</groupId>
|
|
||||||
<artifactId>Factions</artifactId>
|
|
||||||
<version>2.0.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.EaglerMaven</groupId>
|
|
||||||
<artifactId>MassiveCore</artifactId>
|
|
||||||
<version>6.4.1</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifestEntries>
|
||||||
|
<Built-By/>
|
||||||
|
</manifestEntries>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<generateUniqueDependencyReducedPom>false</generateUniqueDependencyReducedPom>
|
||||||
|
<filters>
|
||||||
|
<filter>
|
||||||
|
<artifact>*:*</artifact>
|
||||||
|
<excludes>
|
||||||
|
<exclude>META-INF/*.SF</exclude>
|
||||||
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
|
</excludes>
|
||||||
|
</filter>
|
||||||
|
</filters>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -1,79 +0,0 @@
|
||||||
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<String> 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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
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<Player> onChatCD = new ArrayList<>();
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
instance = this;
|
|
||||||
getServer().getPluginManager().registerEvents(new ChatListener(), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Overrides onDisable
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
72
src/main/java/tech/nully/BossBarAPI/BossBar.java
Normal file
72
src/main/java/tech/nully/BossBarAPI/BossBar.java
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
src/main/java/tech/nully/BossBarAPI/FakeWitherCommand.java
Normal file
38
src/main/java/tech/nully/BossBarAPI/FakeWitherCommand.java
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
32
src/main/java/tech/nully/BossBarAPI/Main.java
Normal file
32
src/main/java/tech/nully/BossBarAPI/Main.java
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
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() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
143
src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java
Normal file
143
src/main/java/tech/nully/BossBarAPI/SpawnFakeWither.java
Normal file
|
@ -0,0 +1,143 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java
Normal file
16
src/main/java/tech/nully/BossBarAPI/TeleportScheduler.java
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,12 @@
|
||||||
name: ClassicCore
|
name: BossBarAPI
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
main: games.bnogocarft.ClassicCore.Main
|
main: tech.nully.BossBarAPI.Main
|
||||||
prefix: [ClassicCore]
|
prefix: [BossBarAPI]
|
||||||
authors: [BongoCat]
|
authors: [BongoCat]
|
||||||
description: A plugin made for BnogoCarft's classic factions gamemode
|
description: An API for eaglercraft to be able to display bossbars
|
||||||
website: https://bnogocarft.games
|
depend: [ProtocolLib]
|
||||||
|
website: nully.tech
|
||||||
|
commands:
|
||||||
|
bossbar:
|
||||||
|
usage: /<command>
|
||||||
|
description: Displays a bossbar
|
|
@ -1,7 +1,12 @@
|
||||||
name: ClassicCore
|
name: BossBarAPI
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
main: games.bnogocarft.ClassicCore.Main
|
main: tech.nully.BossBarAPI.Main
|
||||||
prefix: [ClassicCore]
|
prefix: [BossBarAPI]
|
||||||
authors: [BongoCat]
|
authors: [BongoCat]
|
||||||
description: A plugin made for BnogoCarft's classic factions gamemode
|
description: An API for eaglercraft to be able to display bossbars
|
||||||
website: https://bnogocarft.games
|
depend: [ProtocolLib]
|
||||||
|
website: nully.tech
|
||||||
|
commands:
|
||||||
|
bossbar:
|
||||||
|
usage: /<command>
|
||||||
|
description: Displays a bossbar
|
|
@ -1,5 +1,5 @@
|
||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Thu Aug 11 20:32:55 PDT 2022
|
#Fri Jun 24 18:50:10 PDT 2022
|
||||||
|
groupId=tech.nully
|
||||||
|
artifactId=BossBarAPI
|
||||||
version=0.0.1
|
version=0.0.1
|
||||||
groupId=games.bnogocarft
|
|
||||||
artifactId=ClassicCore
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
games/bnogocarft/ClassicCore/Main.class
|
tech/nully/BossBarAPI/BossBar.class
|
||||||
games/bnogocarft/ClassicCore/ChatListener.class
|
tech/nully/BossBarAPI/Main.class
|
||||||
games/bnogocarft/ClassicCore/ChatListener$2.class
|
tech/nully/BossBarAPI/SpawnFakeWither.class
|
||||||
games/bnogocarft/ClassicCore/ChatListener$1.class
|
tech/nully/BossBarAPI/TeleportScheduler.class
|
||||||
|
tech/nully/BossBarAPI/FakeWitherCommand.class
|
||||||
|
tech/nully/BossBarAPI/SpawnFakeWither$FakeWither.class
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
/home/bongle/GitHub/ClassicCore/src/main/java/games/bnogocarft/ClassicCore/ChatListener.java
|
C:\Users\PC\Documents\BossBarAPI\src\main\java\tech\nully\BossBarAPI\SpawnFakeWither.java
|
||||||
/home/bongle/GitHub/ClassicCore/src/main/java/games/bnogocarft/ClassicCore/Main.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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user