0.6.0 RP, Glyphs, ClientSide builds
This commit is contained in:
parent
c80a684d8e
commit
e92772a714
47 changed files with 1120 additions and 239 deletions
|
@ -22,6 +22,7 @@
|
|||
- [ ] guilds
|
||||
- [ ] quests (hard coded) and db/json
|
||||
- [ ] filter chat
|
||||
- [ ] resource pack (host, upload, compress)
|
||||
|
||||
## tests
|
||||
|
||||
|
|
12
docs/examples/Glyphs.md
Normal file
12
docs/examples/Glyphs.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Glyphs
|
||||
|
||||
this is an example of a simple glyph
|
||||
|
||||
```yaml
|
||||
testGlyph:
|
||||
Pack:
|
||||
model: raxen/testGlyph
|
||||
texture: raxen/testGlyph
|
||||
char: "\uE000"
|
||||
placeholder: ":test:"
|
||||
```
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
see all the exemples in this folder :
|
||||
|
||||
to create any of the following, create a new file in the folder type of your choice (e.g. `
|
||||
plugins/Raxen/items/exampleItem.yml`)
|
||||
|
||||
- [Effects.md](/Elixium/raxen/src/branch/plugin/docs/examples/Effects.md)
|
||||
- [Items.md](/Elixium/raxen/src/branch/plugin/docs/examples/Items.md)
|
||||
- [Mobs.md](/Elixium/raxen/src/branch/plugin/docs/examples/Mobs.md)
|
|
@ -20,7 +20,7 @@ public final class Raxen extends JavaPlugin {
|
|||
"<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
|
||||
@Getter
|
||||
private static String version = "0.5.8";
|
||||
private static String version = "0.6.0";
|
||||
|
||||
private boolean loading = true;
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package me.unurled.raxen.commands;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.coloredString;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
import static me.unurled.raxen.utils.Utils.msgSender;
|
||||
import static me.unurled.raxen.utils.Utils.stringToComp;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
|
|
108
src/main/java/me/unurled/raxen/commands/admin/BuildCommand.java
Normal file
108
src/main/java/me/unurled/raxen/commands/admin/BuildCommand.java
Normal file
|
@ -0,0 +1,108 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BuildCommand implements TabExecutor {
|
||||
|
||||
private Raxen raxen;
|
||||
|
||||
List<String> complete = new ArrayList<>();
|
||||
|
||||
public BuildCommand(Raxen raxen) {
|
||||
this.raxen = raxen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command,
|
||||
@NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
Utils.errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (args.length == 0) {
|
||||
p.sendMessage(Utils.colorComp(
|
||||
"<reset><yellow>/build [discard|edit|hide|list|on|remove|save|show|tp]"));
|
||||
return true;
|
||||
}
|
||||
if (args.length == 1) {
|
||||
switch (args[0]) {
|
||||
case "discard":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Discarded build!"));
|
||||
return true;
|
||||
case "edit":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Editing build!"));
|
||||
return true;
|
||||
case "hide":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Hiding build!"));
|
||||
return true;
|
||||
case "list":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Listing builds!"));
|
||||
return true;
|
||||
case "on":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Build mode enabled!"));
|
||||
return true;
|
||||
case "remove":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Removed build!"));
|
||||
return true;
|
||||
case "save":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Saved build!"));
|
||||
return true;
|
||||
case "show":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Showing build!"));
|
||||
return true;
|
||||
case "tp":
|
||||
p.sendMessage(Utils.colorComp("<reset><yellow>Teleporting to build!"));
|
||||
return true;
|
||||
default:
|
||||
p.sendMessage(Utils.colorComp(
|
||||
"<reset><yellow>/build [discard|edit|hide|list|on|remove|save|show|tp]"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender,
|
||||
@NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (complete.isEmpty()) {
|
||||
complete.add("discard");
|
||||
complete.add("edit");
|
||||
complete.add("hide");
|
||||
complete.add("list");
|
||||
complete.add("on");
|
||||
complete.add("remove");
|
||||
complete.add("save");
|
||||
complete.add("show");
|
||||
complete.add("tp");
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (String s : complete) {
|
||||
if (s.toLowerCase().startsWith(args[0].toLowerCase())) {
|
||||
result.add(s);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else if (args.length == 2) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.getName().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
result.add(p.getName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.customModelData;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
import static me.unurled.raxen.utils.Utils.errorConsoleSender;
|
||||
import static me.unurled.raxen.utils.Utils.isInt;
|
||||
import static me.unurled.raxen.utils.Utils.noPerms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -21,6 +24,7 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
|
||||
/**
|
||||
* change custom model data of an item
|
||||
*
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
|
@ -92,13 +96,12 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param sender Source of the command. For players tab-completing a command inside of a
|
||||
* command block, this will be the player, not the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @param args The arguments passed to the command, including final partial argument to be
|
||||
* completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.itemTo64;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.errorConsoleSender;
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -37,13 +38,12 @@ public class ItemTo64Command implements TabExecutor {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param sender Source of the command. For players tab-completing a command inside of a
|
||||
* command block, this will be the player, not the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @param args The arguments passed to the command, including final partial argument to be
|
||||
* completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.components.entity.player.PlayerUtils.updateSkills;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorString;
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.util.ArrayList;
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.components.entity.other.EntityUtils.setNameSpacedKeys;
|
||||
import static me.unurled.raxen.utils.Items.itemFrom64;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
import static me.unurled.raxen.utils.Utils.getStringFromArg;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
import static me.unurled.raxen.utils.Utils.noPerms;
|
||||
import static me.unurled.raxen.utils.Utils.setNullInArgs;
|
||||
import static me.unurled.raxen.utils.Utils.validateArgs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -54,7 +58,8 @@ public class SpawnEntity implements TabExecutor {
|
|||
);
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength "
|
||||
+
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
|
||||
)
|
||||
);
|
||||
|
@ -69,7 +74,7 @@ public class SpawnEntity implements TabExecutor {
|
|||
Double.parseDouble(args[4])
|
||||
);
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(
|
||||
/* setNameSpacedKeys(
|
||||
e,
|
||||
getStringFromArg(args),
|
||||
Integer.parseInt(args[6]),
|
||||
|
@ -81,7 +86,7 @@ public class SpawnEntity implements TabExecutor {
|
|||
0,
|
||||
Integer.parseInt(args[10]),
|
||||
0
|
||||
);
|
||||
); */
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
|
@ -107,7 +112,8 @@ public class SpawnEntity implements TabExecutor {
|
|||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by " +
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by "
|
||||
+
|
||||
sender.getName() +
|
||||
")"
|
||||
);
|
||||
|
@ -133,7 +139,8 @@ public class SpawnEntity implements TabExecutor {
|
|||
);
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength "
|
||||
+
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
|
||||
)
|
||||
);
|
||||
|
@ -148,7 +155,7 @@ public class SpawnEntity implements TabExecutor {
|
|||
Double.parseDouble(args[4])
|
||||
);
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(
|
||||
/* setNameSpacedKeys(
|
||||
e,
|
||||
getStringFromArg(args),
|
||||
Integer.parseInt(args[6]),
|
||||
|
@ -160,7 +167,7 @@ public class SpawnEntity implements TabExecutor {
|
|||
0,
|
||||
Integer.parseInt(args[10]),
|
||||
0
|
||||
);
|
||||
); */
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package me.unurled.raxen.commands.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorString;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package me.unurled.raxen.components.clientbuild;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class Builds {
|
||||
|
||||
private Instant start;
|
||||
private Instant end;
|
||||
private Location startLocation;
|
||||
private UUID owner;
|
||||
|
||||
private ArrayList<Block> blocks = new ArrayList<>();
|
||||
|
||||
public Builds(Location startLocation, UUID owner) {
|
||||
start = Instant.now();
|
||||
this.startLocation = startLocation;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public Instant getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setEnd(Instant end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public Location getStartLocation() {
|
||||
return startLocation;
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public ArrayList<Block> getBlocks() {
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public void setBlocks(ArrayList<Block> blocks) {
|
||||
this.blocks = blocks;
|
||||
}
|
||||
|
||||
public void addBlock(Block block) {
|
||||
blocks.add(block);
|
||||
}
|
||||
|
||||
public void removeBlock(Block block) {
|
||||
blocks.remove(block);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package me.unurled.raxen.components.clientbuild;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerList {
|
||||
|
||||
private final ArrayList<Player> players = new ArrayList<>();
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
players.add(player);
|
||||
}
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
public ArrayList<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,15 +12,15 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
public class EntityUtils {
|
||||
|
||||
private static Raxen main;
|
||||
private static EntityNamespacedKey namespacedKey;
|
||||
private Raxen main;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
|
||||
public EntityUtils(Raxen main) {
|
||||
this.main = main;
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
public static void setNameSpacedKeys(
|
||||
public void setNameSpacedKeys(
|
||||
org.bukkit.entity.@NotNull Entity e,
|
||||
String name,
|
||||
Integer level,
|
||||
|
@ -62,7 +62,7 @@ public class EntityUtils {
|
|||
data.set(namespacedKey.level, PersistentDataType.INTEGER, level);
|
||||
}
|
||||
|
||||
public static void updateSkills(@NotNull LivingEntity livingEntity) {
|
||||
public void updateSkills(@NotNull LivingEntity livingEntity) {
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
|
|
|
@ -176,14 +176,14 @@ public class MobData {
|
|||
dead = true;
|
||||
EntityManager manager = main.getManager().getEntityManager();
|
||||
if (entity == null) {
|
||||
manager.spawnedMob.remove(entity.getUniqueId());
|
||||
manager.spawnedMobsOnlyMain.remove(entity.getUniqueId());
|
||||
manager.getSpawnedMob().remove(entity.getUniqueId());
|
||||
manager.getSpawnedMobsOnlyMain().remove(entity.getUniqueId());
|
||||
entity.remove();
|
||||
}
|
||||
entity = null;
|
||||
if (mount != null) {
|
||||
manager.spawnedMob.remove(mount.getUniqueId());
|
||||
manager.spawnedMobsOnlyMain.remove(mount.getUniqueId());
|
||||
manager.getSpawnedMob().remove(mount.getUniqueId());
|
||||
manager.getSpawnedMobsOnlyMain().remove(mount.getUniqueId());
|
||||
mount.remove();
|
||||
}
|
||||
mount = null;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.components.entity.other;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
@ -52,6 +54,10 @@ public abstract class RaxenEntity {
|
|||
public HashMap<UUID, Long> lastAttackedByTimes;
|
||||
public java.util.HashMap<UUID, Long> damageDealt;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
Boolean isHostile;
|
||||
|
||||
public RaxenEntity(
|
||||
Raxen main,
|
||||
String name,
|
||||
|
@ -66,6 +72,7 @@ public abstract class RaxenEntity {
|
|||
this.level = level;
|
||||
this.health = health;
|
||||
this.strength = strength;
|
||||
isHostile = true;
|
||||
}
|
||||
|
||||
/*public Entity createEntity(
|
||||
|
@ -242,4 +249,28 @@ public abstract class RaxenEntity {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
if (isHostile) {
|
||||
return colorString(
|
||||
getLevel() +
|
||||
"<white>⚔️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
getMaxHealth(entity)
|
||||
);
|
||||
} else {
|
||||
return colorString(
|
||||
getLevel() +
|
||||
"<white>❤️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
getMaxHealth(entity)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ public abstract class Entity implements org.bukkit.entity.Entity {
|
|||
}
|
||||
|
||||
public void register(Raxen main) {
|
||||
main.getManager().getEntityManager().entities.put(name, this);
|
||||
// main.getManager().getEntityManager().entities.put(name, this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package me.unurled.raxen.components.entity.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package me.unurled.raxen.components.entity.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.textCompToString;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.libs.Vault;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.*;
|
||||
import org.bukkit.scoreboard.Criteria;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Score;
|
||||
import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
public class Scoreboard {
|
||||
|
||||
|
@ -62,7 +68,8 @@ public class Scoreboard {
|
|||
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
debug(main, String.valueOf(player.getScoreboard().getEntries()));
|
||||
for (String str : player.getScoreboard().getEntries()) {
|
||||
if (str.contains(player.getName())) {}
|
||||
if (str.contains(player.getName())) {
|
||||
}
|
||||
}
|
||||
player.getScoreboard().resetScores("Coins");
|
||||
assert objective != null;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package me.unurled.raxen.components.glyph;
|
||||
|
||||
public class Glyph {
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package me.unurled.raxen.components.glyph;
|
||||
|
||||
public class GlyphBuilder {
|
||||
|
||||
String chars;
|
||||
String model;
|
||||
String texture;
|
||||
String placeholder;
|
||||
|
||||
public GlyphBuilder(String chars) {
|
||||
this.chars = chars;
|
||||
}
|
||||
|
||||
public void model(String s) {
|
||||
model = s;
|
||||
}
|
||||
|
||||
public void texture(String s) {
|
||||
texture = s;
|
||||
}
|
||||
|
||||
public void placeholder(String s) {
|
||||
placeholder = s;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package me.unurled.raxen.components.glyph;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class GlyphParser {
|
||||
|
||||
private final ConfigurationSection section;
|
||||
|
||||
public GlyphParser(ConfigurationSection section) {
|
||||
this.section = section;
|
||||
if (section.isConfigurationSection("Pack")) {
|
||||
ConfigurationSection packSection = section.getConfigurationSection("Pack");
|
||||
applyConfig(buildGlyph());
|
||||
}
|
||||
}
|
||||
|
||||
public GlyphBuilder buildGlyph() {
|
||||
return buildGlyph(section.contains("char") ? section.getString("char") : null);
|
||||
}
|
||||
|
||||
public GlyphBuilder buildGlyph(String car) {
|
||||
GlyphBuilder glyph = null;
|
||||
if (car != null) {
|
||||
glyph = new GlyphBuilder(car);
|
||||
}
|
||||
return glyph;
|
||||
}
|
||||
|
||||
private GlyphBuilder applyConfig(GlyphBuilder glyph) {
|
||||
if (section.contains("Pack")) {
|
||||
ConfigurationSection s = section.getConfigurationSection("Pack");
|
||||
if (s.contains("model")) {
|
||||
glyph.model(s.getString("model"));
|
||||
}
|
||||
if (s.contains("texture")) {
|
||||
glyph.texture(s.getString("texture"));
|
||||
}
|
||||
if (s.contains("placeholder")) {
|
||||
glyph.placeholder(s.getString("placeholder"));
|
||||
}
|
||||
}
|
||||
return glyph;
|
||||
}
|
||||
}
|
|
@ -33,6 +33,7 @@ public class ItemBuilder {
|
|||
private Component displayName;
|
||||
private int amount;
|
||||
private int customModelData;
|
||||
private String customModelDataPath;
|
||||
private boolean hasCustomModelData;
|
||||
private Color color;
|
||||
private @NotNull PotionData potionData;
|
||||
|
@ -113,4 +114,9 @@ public class ItemBuilder {
|
|||
public void color(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public void modelData(String path, int data) {
|
||||
this.customModelData = data;
|
||||
this.customModelDataPath = path;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ public class ItemParser {
|
|||
if (section.isConfigurationSection("Pack")) {
|
||||
ConfigurationSection packSection = section.getConfigurationSection("Pack");
|
||||
// TODO: Parse pack section
|
||||
// item.modelData(section.getString("Pack.model", null), section.getInt("Pack.custom_model_data", 0));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,6 +43,10 @@ public class ItemParser {
|
|||
if (section.contains("color")) {
|
||||
item.color(Utils.color(section.getString("color", "FFFFFF")));
|
||||
}
|
||||
|
||||
if (section.contains("Pack")) {
|
||||
item.modelData(section.getString("Pack.model", null), section.getInt("Pack.custom_model_data", 0));
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package me.unurled.raxen.components.resourcepack;
|
|||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.server.ResourcePackManager;
|
||||
import me.unurled.raxen.utils.Utils;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -24,12 +25,24 @@ public class ResourcePack {
|
|||
public void run() {
|
||||
if (resourcePackManager.isUseRP()) {
|
||||
player.setResourcePack(
|
||||
config.getString("ressource_pack_url"),
|
||||
config.getString("resource_pack_sha1")
|
||||
resourcePackManager.getUrl(),
|
||||
resourcePackManager.getSha1(),
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(main, 10L);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (resourcePackManager.isUseRP()) {
|
||||
if (!player.hasResourcePack()) {
|
||||
player.kick(Utils.colorComp(
|
||||
"<red>Raxen<gray>| <red>Please enable your resource pack!"));
|
||||
}
|
||||
.runTaskLater(main, 2L);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(main, 600L);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package me.unurled.raxen.components.resourcepack.hosting;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Hosting {
|
||||
|
||||
boolean upload(File resoucepack);
|
||||
|
||||
UUID getUUID();
|
||||
|
||||
String getPackURL();
|
||||
|
||||
String getMinecraftPackURL();
|
||||
|
||||
byte[] getSHA1();
|
||||
|
||||
String getOriginalSHA1();
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package me.unurled.raxen.components.resourcepack.hosting;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.UUID;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
public class PackHoster implements Hosting {
|
||||
|
||||
private final String serverAddress;
|
||||
private String packURL;
|
||||
private String minecraftPackURL;
|
||||
private String sha1;
|
||||
private UUID uuid;
|
||||
|
||||
public PackHoster(String serverAddress) {
|
||||
this.serverAddress = "https://" + serverAddress + "/";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upload(File resoucepack) {
|
||||
try {
|
||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||
|
||||
HttpPost httpPost = new HttpPost(serverAddress + "upload/" + uuid.toString());
|
||||
|
||||
HttpEntity entity = MultipartEntityBuilder.create()
|
||||
.addBinaryBody("file", resoucepack, ContentType.DEFAULT_BINARY,
|
||||
resoucepack.getName())
|
||||
.build();
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
// Execute the request
|
||||
HttpResponse response = null;
|
||||
response = httpClient.execute(httpPost);
|
||||
String responseString = EntityUtils.toString(response.getEntity());
|
||||
JsonObject json;
|
||||
try {
|
||||
json = JsonParser.parseString(responseString).getAsJsonObject();
|
||||
} catch (JsonSyntaxException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (json.has("url") && json.has("sha1")) {
|
||||
packURL = json.get("url").getAsString();
|
||||
minecraftPackURL = packURL.replace("https://", "http://");
|
||||
sha1 = json.get("sha1").getAsString();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Get the response code
|
||||
int responseCode = response.getStatusLine().getStatusCode();
|
||||
System.out.println("Response Code: " + responseCode);
|
||||
|
||||
// Read the response body
|
||||
String responseBody = null;
|
||||
|
||||
responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
System.out.println("Response Body: " + responseBody);
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUUID(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPackURL() {
|
||||
return packURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMinecraftPackURL() {
|
||||
return minecraftPackURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getSHA1() {
|
||||
int len = sha1.length();
|
||||
byte[] data = new byte[len / 2];
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
data[i / 2] = (byte) ((Character.digit(sha1.charAt(i), 16) << 4)
|
||||
+ Character.digit(sha1.charAt(i + 1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalSHA1() {
|
||||
return sha1;
|
||||
}
|
||||
}
|
|
@ -5,8 +5,6 @@ import static me.unurled.raxen.utils.Utils.log;
|
|||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.RaxenPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -59,10 +57,7 @@ public class Tutorial {
|
|||
player.teleport(
|
||||
new Location(world, 15.82, 74.00, 117.21, 899.21F, 0.90f));
|
||||
msgPlayer(player, colorTextComp("<green>Welcome to the tutorial!"));
|
||||
HolographicDisplaysAPI api = main.getManager().getLibsManager().getHolographicDisplay()
|
||||
.getApi();
|
||||
Hologram holo = api.createHologram(new Location(world, 15.5, 76.00, 112.5, 179.21f, 0.90f));
|
||||
holo.getLines().appendText("Welcome to the tutorial!");
|
||||
// Hologram holo = api.createHologram(new Location(world, 15.5, 76.00, 112.5, 179.21f, 0.90f));
|
||||
}
|
||||
|
||||
public void stopTutorial() {
|
||||
|
|
|
@ -3,12 +3,7 @@ package me.unurled.raxen.config;
|
|||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
|
@ -50,22 +45,5 @@ public class Config {
|
|||
if (!Raxen.getVersion().equals(config.getString("version"))) {
|
||||
main.saveResource("config.yml", true);
|
||||
}
|
||||
if (new File(main.getDataFolder().toString() + "/schematics/").mkdir()) {
|
||||
String url = "https://pb.unurled.me/file/otter-panda-cobra/template_tuto.schem";
|
||||
ReadableByteChannel readableByteChannel = null;
|
||||
try {
|
||||
readableByteChannel = Channels.newChannel(new URL(url).openStream());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(
|
||||
main.getDataFolder() + "schematics/template_tuto.schem");
|
||||
FileChannel fileChannel = fileOutputStream.getChannel();
|
||||
fileOutputStream.getChannel()
|
||||
.transferFrom(readableByteChannel, 0, Long.MAX_VALUE);
|
||||
} catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// main.saveResource("schematics/template_tuto.schem", false);
|
||||
}
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
74
src/main/java/me/unurled/raxen/config/GlyphConfig.java
Normal file
74
src/main/java/me/unurled/raxen/config/GlyphConfig.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
package me.unurled.raxen.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.glyph.GlyphBuilder;
|
||||
import me.unurled.raxen.components.glyph.GlyphParser;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class GlyphConfig {
|
||||
|
||||
private Raxen main;
|
||||
private File glyphFolder;
|
||||
|
||||
public GlyphConfig(Raxen main) {
|
||||
this.main = main;
|
||||
validatesConfig();
|
||||
}
|
||||
|
||||
public void validatesConfig() {
|
||||
glyphFolder = new File(main.getDataFolder(), "items");
|
||||
if (!glyphFolder.exists()) {
|
||||
glyphFolder.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
public Map<File, Map<String, GlyphBuilder>> parseGlyphConfigs() {
|
||||
Map<File, Map<String, GlyphBuilder>> parseMap = new LinkedHashMap<>();
|
||||
List<File> config = Arrays.stream(getGlyphFiles())
|
||||
.filter(file -> file.getName().endsWith(".yml"))
|
||||
.toList();
|
||||
for (File file : config) {
|
||||
parseMap.put(file, parseGlyphConfig(YamlConfiguration.loadConfiguration(file), file));
|
||||
}
|
||||
return parseMap;
|
||||
}
|
||||
|
||||
public Map<String, GlyphBuilder> parseGlyphConfig(YamlConfiguration config, File file) {
|
||||
Map<String, GlyphParser> parseMap = new LinkedHashMap<>();
|
||||
for (String glyphSelection : config.getKeys(false)) {
|
||||
if (!config.isConfigurationSection(glyphSelection)) {
|
||||
continue;
|
||||
}
|
||||
ConfigurationSection glyphSection = config.getConfigurationSection(glyphSelection);
|
||||
parseMap.put(glyphSelection, new GlyphParser(glyphSection));
|
||||
}
|
||||
boolean configUpdated = false;
|
||||
Map<String, GlyphBuilder> map = new LinkedHashMap<>();
|
||||
for (Map.Entry<String, GlyphParser> entry : parseMap.entrySet()) {
|
||||
GlyphParser parser = entry.getValue();
|
||||
try {
|
||||
map.put(entry.getKey(), parser.buildGlyph());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private File[] getGlyphFiles() {
|
||||
if (!glyphFolder.exists()) {
|
||||
glyphFolder.mkdirs();
|
||||
return new File[0];
|
||||
}
|
||||
File[] itemConfigs = Arrays.stream(glyphFolder.listFiles()).filter(File::isFile)
|
||||
.toArray(File[]::new);
|
||||
Arrays.sort(itemConfigs);
|
||||
return itemConfigs;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.effect.EffectBuilder;
|
||||
import me.unurled.raxen.components.items.ItemBuilder;
|
||||
import me.unurled.raxen.components.items.ItemParser;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -19,14 +18,14 @@ public class ItemConfig {
|
|||
|
||||
public ItemConfig(Raxen main) {
|
||||
this.main = main;
|
||||
validatesConfig();
|
||||
}
|
||||
|
||||
public boolean validatesConfig() {
|
||||
public void validatesConfig() {
|
||||
itemsFolder = new File(main.getDataFolder(), "items");
|
||||
if (!itemsFolder.exists()) {
|
||||
itemsFolder.mkdirs();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Map<File, Map<String, ItemBuilder>> parseItemConfigs() {
|
||||
|
@ -61,11 +60,15 @@ public class ItemConfig {
|
|||
return map;
|
||||
}
|
||||
|
||||
public Map<File, Map<String, EffectBuilder>> parseEffectConfig() {
|
||||
/*public Map<File, Map<String, EffectBuilder>> parseEffectConfig() {
|
||||
// TODO: efffects
|
||||
}
|
||||
}*/
|
||||
|
||||
private File[] getItemsFiles() {
|
||||
if (!itemsFolder.exists()) {
|
||||
itemsFolder.mkdirs();
|
||||
return new File[0];
|
||||
}
|
||||
File[] itemConfigs = Arrays.stream(itemsFolder.listFiles()).filter(File::isFile)
|
||||
.toArray(File[]::new);
|
||||
Arrays.sort(itemConfigs);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class DamageEntity implements Listener {
|
|||
} else {
|
||||
// attack between player and mob
|
||||
RaxenPlayer rx = pm.getRaxenPlayer((Player) attacker);
|
||||
MobData re = main.getManager().getEntityManager().spawnedMob.get(
|
||||
MobData re = main.getManager().getEntityManager().getSpawnedMob().get(
|
||||
defender.getUniqueId());
|
||||
if (rx != null) {
|
||||
rx.attackMob(re);
|
||||
|
@ -94,7 +94,7 @@ public class DamageEntity implements Listener {
|
|||
rx.attackPlayer(rx2, rpgDamage, projectile);
|
||||
}
|
||||
} else {
|
||||
MobData mb = main.getManager().getEntityManager().spawnedMob.get(
|
||||
MobData mb = main.getManager().getEntityManager().getSpawnedMob().get(
|
||||
defender.getUniqueId());
|
||||
if (rx != null && mb != null) {
|
||||
if (rpgKnockback >= 0) {
|
||||
|
@ -107,7 +107,7 @@ public class DamageEntity implements Listener {
|
|||
}
|
||||
} else {
|
||||
if (defender instanceof Player) {
|
||||
MobData a = main.getManager().getEntityManager().spawnedMob.get(
|
||||
MobData a = main.getManager().getEntityManager().getSpawnedMob().get(
|
||||
attacker.getUniqueId());
|
||||
RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer(
|
||||
(Player) defender);
|
||||
|
@ -122,7 +122,7 @@ public class DamageEntity implements Listener {
|
|||
attacker.remove();
|
||||
} else {
|
||||
if (defender instanceof Player) {
|
||||
MobData a = main.getManager().getEntityManager().spawnedMob.get(
|
||||
MobData a = main.getManager().getEntityManager().getSpawnedMob().get(
|
||||
attacker.getUniqueId());
|
||||
RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer(
|
||||
(Player) defender);
|
||||
|
|
|
@ -5,6 +5,7 @@ import static me.unurled.raxen.utils.Utils.debug;
|
|||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import me.unurled.raxen.components.entity.other.EntityUtils;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -26,19 +27,24 @@ public class SpawnEvent implements Listener {
|
|||
}
|
||||
|
||||
/**
|
||||
* when a new entity spawns
|
||||
* adds all persistent data container
|
||||
* when a new entity spawns adds all persistent data container
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void Spawn(EntitySpawnEvent e) {
|
||||
e.getEntity().getWorld().spawn(e.getLocation(), Display.class);
|
||||
if (e.getEntity() instanceof Player) {
|
||||
//player stuff dont want to talk about it; already doing it in player join event
|
||||
debug(main, "Player: " + ((Player) e.getEntity()).getName());
|
||||
} else if (
|
||||
e.getEntity().getType() != EntityType.DROPPED_ITEM &&
|
||||
e.getEntity().getType() != EntityType.FALLING_BLOCK &&
|
||||
e.getEntity().getType() != EntityType.ARROW
|
||||
e.getEntity().getType() != EntityType.ARROW &&
|
||||
e.getEntity().getType() != EntityType.ITEM_DISPLAY &&
|
||||
e.getEntity().getType() != EntityType.BLOCK_DISPLAY &&
|
||||
e.getEntity().getType() != EntityType.TEXT_DISPLAY &&
|
||||
!(e.getEntity() instanceof Display)
|
||||
) {
|
||||
debug(main, e.getEntity().getName());
|
||||
if (
|
||||
|
@ -61,7 +67,10 @@ public class SpawnEvent implements Listener {
|
|||
0
|
||||
);
|
||||
}
|
||||
main.getManager().getEntityManager().registerEntity(e.getEntity());
|
||||
entityUtils.updateSkills((LivingEntity) e.getEntity());
|
||||
|
||||
// add nametag
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
import de.tr7zw.nbtapi.NBT;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -21,7 +18,8 @@ public class InteractEvent implements Listener {
|
|||
if (i != null && i.getType() != Material.AIR) {
|
||||
String id = NBT.get(i, nbt -> nbt.getString("ID"));
|
||||
if (id != null && !id.isEmpty()) {
|
||||
if (id.equals("PHONE")) {}
|
||||
if (id.equals("PHONE")) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package me.unurled.raxen.listener.player;
|
|||
|
||||
import java.io.IOException;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.PlayerUtils;
|
||||
import me.unurled.raxen.config.PlayerConfig;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -22,6 +21,7 @@ public class LeaveEvent implements Listener {
|
|||
|
||||
/**
|
||||
* when player leaves, saves everything
|
||||
*
|
||||
* @param e
|
||||
* @throws IOException
|
||||
*/
|
||||
|
|
|
@ -9,8 +9,10 @@ import me.unurled.raxen.manager.entity.PartyManager;
|
|||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import me.unurled.raxen.manager.entity.SpellManager;
|
||||
import me.unurled.raxen.manager.entity.StorageManager;
|
||||
import me.unurled.raxen.manager.server.BuildManager;
|
||||
import me.unurled.raxen.manager.server.CommandManager;
|
||||
import me.unurled.raxen.manager.server.DungeonsManager;
|
||||
import me.unurled.raxen.manager.server.GlyphManager;
|
||||
import me.unurled.raxen.manager.server.LibsManager;
|
||||
import me.unurled.raxen.manager.server.ListenerManager;
|
||||
import me.unurled.raxen.manager.server.ResourcePackManager;
|
||||
|
@ -69,6 +71,12 @@ public class Manager {
|
|||
@Getter
|
||||
private SpellManager spellManager;
|
||||
|
||||
@Getter
|
||||
private GlyphManager glyphManager;
|
||||
|
||||
@Getter
|
||||
private BuildManager buildManager;
|
||||
|
||||
/**
|
||||
* Create an instance of all managers.
|
||||
*
|
||||
|
@ -92,5 +100,7 @@ public class Manager {
|
|||
tutorialManager = new TutorialManager();
|
||||
partyManager = new PartyManager(main);
|
||||
spellManager = new SpellManager(main);
|
||||
glyphManager = new GlyphManager(main);
|
||||
buildManager = new BuildManager(main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@ package me.unurled.raxen.manager.entity;
|
|||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import eu.decentsoftware.holograms.api.DHAPI;
|
||||
import eu.decentsoftware.holograms.api.holograms.Hologram;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
@ -29,11 +31,14 @@ import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
|||
import me.unurled.raxen.components.entity.other.MobData;
|
||||
import me.unurled.raxen.components.entity.other.MobType;
|
||||
import me.unurled.raxen.components.entity.other.RaxenEntity;
|
||||
import me.unurled.raxen.utils.Tags;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class EntityManager {
|
||||
|
||||
|
@ -41,57 +46,67 @@ public class EntityManager {
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public List<EntityType> list = new ArrayList<>();
|
||||
|
||||
public HashMap<String, MobType> mobTypes;
|
||||
public HashMap<UUID, MobData> spawnedMob;
|
||||
public HashMap<UUID, MobData> spawnedMobsOnlyMain;
|
||||
private List<EntityType> list = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute =
|
||||
new HashMap<>();
|
||||
private HashMap<String, MobType> mobTypes;
|
||||
@Getter
|
||||
private final HashMap<UUID, MobData> spawnedMob;
|
||||
@Getter
|
||||
private HashMap<UUID, MobData> spawnedMobsOnlyMain;
|
||||
|
||||
public HashMap<String, me.unurled.raxen.components.entity.other.RaxenEntity> entities =
|
||||
new HashMap<>();
|
||||
@Getter
|
||||
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute;
|
||||
|
||||
public HashMap<UUID, Entity> livingEntities = new HashMap<>();
|
||||
private final HashMap<String, me.unurled.raxen.components.entity.other.RaxenEntity> entities;
|
||||
|
||||
// Attributes
|
||||
private Defense defense;
|
||||
private Health health;
|
||||
private ItemDefense itemDefense;
|
||||
private ItemHealth itemHealth;
|
||||
private ItemLuck itemLuck;
|
||||
private ItemMana itemMana;
|
||||
private ItemSpeed itemSpeed;
|
||||
private ItemStrength itemStrength;
|
||||
private Luck luck;
|
||||
private Mana mana;
|
||||
private MaxHealth maxHealth;
|
||||
private MaxMana maxMana;
|
||||
private Speed speed;
|
||||
private Strength strength;
|
||||
|
||||
private final HashMap<UUID, Entity> livingEntities = new HashMap<>();
|
||||
private HashMap<UUID, BukkitTask> nameTags;
|
||||
|
||||
public EntityManager(Raxen main) {
|
||||
this.main = main;
|
||||
entities = new HashMap<>();
|
||||
attribute = new HashMap<>();
|
||||
mobTypes = new HashMap<>();
|
||||
spawnedMob = new HashMap<>();
|
||||
spawnedMobsOnlyMain = new HashMap<>();
|
||||
nameTags = new HashMap<>();
|
||||
reload();
|
||||
registerAttributes();
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
public void reload() {
|
||||
Collection<MobData> collection = new ArrayList<>();
|
||||
collection.addAll(spawnedMob.values());
|
||||
for (MobData mobData : collection) {
|
||||
mobData.entity.die(false);
|
||||
// mobData.entity.die(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerLivingEntities(World world) {
|
||||
}
|
||||
|
||||
public void registerEntity(Entity entity) {
|
||||
/* RaxenEntity raxenEntity = new RaxenEntity();
|
||||
raxenEntity.register(entity);
|
||||
entities.put(entity.getUniqueId(), raxenEntity); */
|
||||
}
|
||||
|
||||
public void setNameTag(Entity entity) {
|
||||
Hologram holo = Tags.createNameTag(main, entity);
|
||||
if (holo == null) {
|
||||
return;
|
||||
}
|
||||
BukkitTask run = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DHAPI.moveHologram(holo, entity.getLocation());
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
nameTags.put(entity.getUniqueId(), run);
|
||||
}
|
||||
|
||||
/**
|
||||
* used to register entities using fileconfigs but rapidly abandoned
|
||||
*
|
||||
|
@ -109,7 +124,7 @@ public class EntityManager {
|
|||
}
|
||||
|
||||
public RaxenEntity getEntity(Entity entity) {
|
||||
entities.get(entity.getUniqueId());
|
||||
return entities.get(entity.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,50 +133,50 @@ public class EntityManager {
|
|||
public void registerAttributes() {
|
||||
EntityNamespacedKey key = new EntityNamespacedKey(main);
|
||||
|
||||
this.defense = new Defense(key.defense, "DEFENSE");
|
||||
// Attributes
|
||||
Defense defense = new Defense(key.defense, "DEFENSE");
|
||||
attribute.put("DEFENSE", defense);
|
||||
|
||||
this.health = new Health(key.health, "HEALTH");
|
||||
Health health = new Health(key.health, "HEALTH");
|
||||
attribute.put("HEALTH", health);
|
||||
|
||||
this.itemDefense = new ItemDefense(key.itemDefense, "ITEM_DEFENSE");
|
||||
ItemDefense itemDefense = new ItemDefense(key.itemDefense, "ITEM_DEFENSE");
|
||||
attribute.put("ITEM_DEFENSE", itemDefense);
|
||||
|
||||
this.itemHealth = new ItemHealth(key.itemHealth, "ITEM_HEALTH");
|
||||
ItemHealth itemHealth = new ItemHealth(key.itemHealth, "ITEM_HEALTH");
|
||||
attribute.put("ITEM_HEALTH", itemHealth);
|
||||
|
||||
this.itemLuck = new ItemLuck(key.itemLuck, "ITEM_LUCK");
|
||||
ItemLuck itemLuck = new ItemLuck(key.itemLuck, "ITEM_LUCK");
|
||||
attribute.put("ITEM_LUCK", itemLuck);
|
||||
|
||||
this.itemMana = new ItemMana(key.itemMana, "ITEM_MANA");
|
||||
ItemMana itemMana = new ItemMana(key.itemMana, "ITEM_MANA");
|
||||
attribute.put("ITEM_MANA", itemMana);
|
||||
|
||||
this.itemSpeed = new ItemSpeed(key.itemSpeed, "ITEM_SPEED");
|
||||
ItemSpeed itemSpeed = new ItemSpeed(key.itemSpeed, "ITEM_SPEED");
|
||||
attribute.put("ITEM_SPEED", itemSpeed);
|
||||
|
||||
this.itemStrength = new ItemStrength(key.itemStrength, "ITEM_STRENGTH");
|
||||
ItemStrength itemStrength = new ItemStrength(key.itemStrength, "ITEM_STRENGTH");
|
||||
attribute.put("ITEM_STRENGTH", itemStrength);
|
||||
|
||||
this.luck = new Luck(key.luck, "LUCK");
|
||||
Luck luck = new Luck(key.luck, "LUCK");
|
||||
attribute.put("LUCK", luck);
|
||||
|
||||
this.mana = new Mana(key.mana, "MANA");
|
||||
Mana mana = new Mana(key.mana, "MANA");
|
||||
attribute.put("MANA", mana);
|
||||
|
||||
this.maxMana =
|
||||
new MaxManaBuilder()
|
||||
MaxMana maxMana = new MaxManaBuilder()
|
||||
.setNamespacekey(key.maxMana)
|
||||
.setName("MAX_MANA")
|
||||
.createMaxMana();
|
||||
attribute.put("MAX_MANA", maxMana);
|
||||
|
||||
this.maxHealth = new MaxHealth(key.maxHealth, "MAX_HEALTH");
|
||||
MaxHealth maxHealth = new MaxHealth(key.maxHealth, "MAX_HEALTH");
|
||||
attribute.put("MAX_HEALTH", maxHealth);
|
||||
|
||||
this.speed = new Speed(key.speed, "SPEED");
|
||||
Speed speed = new Speed(key.speed, "SPEED");
|
||||
attribute.put("SPEED", speed);
|
||||
|
||||
this.strength = new Strength(key.strength, "STRENGTH");
|
||||
Strength strength = new Strength(key.strength, "STRENGTH");
|
||||
attribute.put("STRENGTH", strength);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.unurled.raxen.manager.server;
|
|||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.commands.RaxenCommand;
|
||||
import me.unurled.raxen.commands.admin.BuildCommand;
|
||||
import me.unurled.raxen.commands.admin.CustomModelDataCommand;
|
||||
import me.unurled.raxen.commands.admin.EntitiyCommand;
|
||||
import me.unurled.raxen.commands.admin.ItemListCommand;
|
||||
|
@ -39,6 +40,7 @@ public class CommandManager {
|
|||
private ItemTo64Command itemTo64Command;
|
||||
private TutorialManagerCommand tutorialManagerCommand;
|
||||
private PartyCommand partyCommand;
|
||||
private BuildCommand buildCommand;
|
||||
|
||||
public CommandManager(Raxen main) {
|
||||
this.main = main;
|
||||
|
@ -54,6 +56,7 @@ public class CommandManager {
|
|||
this.itemTo64Command = new ItemTo64Command();
|
||||
this.tutorialManagerCommand = new TutorialManagerCommand(main);
|
||||
this.partyCommand = new PartyCommand(main);
|
||||
this.buildCommand = new BuildCommand(main);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,5 +106,8 @@ public class CommandManager {
|
|||
|
||||
main.getCommand("party").setExecutor(partyCommand);
|
||||
main.getCommand("party").setTabCompleter(partyCommand);
|
||||
|
||||
main.getCommand("build").setExecutor(buildCommand);
|
||||
main.getCommand("build").setTabCompleter(buildCommand);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ package me.unurled.raxen.manager.server;
|
|||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.libs.CitizensApi;
|
||||
import me.unurled.raxen.utils.libs.HolographicDisplay;
|
||||
import me.unurled.raxen.utils.libs.LuckPerm;
|
||||
import me.unurled.raxen.utils.libs.MongoDB;
|
||||
import me.unurled.raxen.utils.libs.Mysql;
|
||||
import me.unurled.raxen.utils.libs.PlaceHolderAPI;
|
||||
|
@ -15,9 +13,6 @@ public class LibsManager {
|
|||
@Getter
|
||||
private final ProtocolManager protocolManager;
|
||||
|
||||
@Getter
|
||||
private final LuckPerm luckPerm;
|
||||
|
||||
@Getter
|
||||
private final Vault vault;
|
||||
|
||||
|
@ -33,17 +28,12 @@ public class LibsManager {
|
|||
@Getter
|
||||
private CitizensApi citizens;
|
||||
|
||||
@Getter
|
||||
private HolographicDisplay holographicDisplay;
|
||||
|
||||
public LibsManager(Raxen main) {
|
||||
this.luckPerm = new LuckPerm(main);
|
||||
this.luckPerm.register();
|
||||
this.vault = new Vault(main);
|
||||
this.protocolManager = new ProtocolManager(main);
|
||||
this.mongoDB = new MongoDB();
|
||||
this.placeHolderAPI = new PlaceHolderAPI(main);
|
||||
this.citizens = new CitizensApi(main);
|
||||
this.holographicDisplay = new HolographicDisplay(main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.PacketType.Play.Server;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.clientbuild.Builds;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ProtocolManager {
|
||||
|
@ -33,5 +37,23 @@ public class ProtocolManager {
|
|||
}
|
||||
}
|
||||
);
|
||||
manager.addPacketListener(
|
||||
new PacketAdapter(main, ListenerPriority.NORMAL, Server.BLOCK_CHANGE) {
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
BlockPosition pos = packet.getBlockPositionModifier().read(0);
|
||||
Location loc;
|
||||
if (main.getManager().getBuildManager().isABuild(
|
||||
loc = new Location(event.getPlayer().getWorld(), pos.getX(), pos.getY(),
|
||||
pos.getZ()))) {
|
||||
Builds build = main.getManager().getBuildManager().getBuildsByLocation(loc);
|
||||
if (!main.getManager().getBuildManager().isInPlayerList(build, event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
super.onPacketSending(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.resourcepack.ResourcePack;
|
||||
import me.unurled.raxen.components.resourcepack.hosting.Hosting;
|
||||
import me.unurled.raxen.components.resourcepack.hosting.PackHoster;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
public class ResourcePackManager {
|
||||
|
@ -18,6 +28,13 @@ public class ResourcePackManager {
|
|||
|
||||
private FileConfiguration config;
|
||||
|
||||
private UUID uuid;
|
||||
@Getter
|
||||
private String url;
|
||||
@Getter
|
||||
private String sha1;
|
||||
private File resourcePackFile;
|
||||
|
||||
@Getter
|
||||
private boolean useRP;
|
||||
|
||||
|
@ -25,40 +42,161 @@ public class ResourcePackManager {
|
|||
this.main = main;
|
||||
this.resourcePack = new ResourcePack(main, this);
|
||||
this.config = main.getConfig();
|
||||
this.useRP = this.config.getBoolean("useResourcePack");
|
||||
this.useRP = this.config.getBoolean("useResourcePack", false);
|
||||
prepareFolder();
|
||||
resourcePackFile = packageRp();
|
||||
if (resourcePackFile != null) {
|
||||
enable();
|
||||
} else {
|
||||
useRP = false;
|
||||
}
|
||||
if (useRP) {
|
||||
upload();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to enable the ressourcepack
|
||||
* Create all folders for the resource pack
|
||||
*/
|
||||
private void prepareFolder() {
|
||||
// Create main folder3
|
||||
File rp = new File(main.getDataFolder(), "resoucepack");
|
||||
rp.mkdirs();
|
||||
|
||||
File minecraft = new File(rp, "minecraft");
|
||||
minecraft.mkdirs();
|
||||
|
||||
// Create mcmeta file
|
||||
String content = """
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 12,
|
||||
"description": "§bRaxen - By §6unurled"
|
||||
}
|
||||
}""";
|
||||
try {
|
||||
File file = new File(minecraft, "pack.mcmeta");
|
||||
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
|
||||
bufferedWriter.write(content);
|
||||
|
||||
bufferedWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Create texture folder
|
||||
File texture = new File(minecraft, "textures");
|
||||
texture.mkdirs();
|
||||
new File(texture, "item").mkdirs();
|
||||
new File(texture, "block").mkdirs();
|
||||
|
||||
// Create model folder
|
||||
File model = new File(minecraft, "models");
|
||||
model.mkdirs();
|
||||
new File(model, "item").mkdirs();
|
||||
new File(model, "block").mkdirs();
|
||||
|
||||
// Create font folder
|
||||
File font = new File(minecraft, "font");
|
||||
font.mkdirs();
|
||||
|
||||
// Create sound folder
|
||||
File sound = new File(minecraft, "sounds");
|
||||
sound.mkdirs();
|
||||
}
|
||||
|
||||
private File packageRp() {
|
||||
String zipFilePath = main.getDataFolder() + "/resourcepack.zip";
|
||||
String folderPath = main.getDataFolder() + "/resourcepack";
|
||||
try {
|
||||
zipFolder(folderPath, zipFilePath);
|
||||
return new File(zipFilePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to enable the ressource pack
|
||||
*/
|
||||
private void enable() {
|
||||
if (useRP) {
|
||||
if (
|
||||
config.getString("resource_pack_url") == null ||
|
||||
Objects.equals(config.getString("rssource_pack_url"), "") ||
|
||||
config.getString("resource_pack_sha1") == null ||
|
||||
Objects.equals(config.getString("resource_pack_sha1"), "") ||
|
||||
Objects.equals(
|
||||
config.getString("resource_pack_url"),
|
||||
"https://mc-packs.net/"
|
||||
) ||
|
||||
Objects.equals(
|
||||
config.getString("resource_pack_sha1"),
|
||||
"sha1hallo"
|
||||
)
|
||||
) {
|
||||
error(
|
||||
main,
|
||||
"You must specify an resource_pack_url and resource_pack_sha1!"
|
||||
);
|
||||
if (config.getString("resource_pack_url") == null ||
|
||||
Objects.equals(config.getString("resource_pack_url"), "")) {
|
||||
debug(main, "Resource pack not enabled.");
|
||||
useRP = false;
|
||||
} else {
|
||||
debug(main, "Ressource Pack enabled.");
|
||||
if (config.contains("resource_pack_uuid") &&
|
||||
config.getString("resource_pack_uuid") != null &&
|
||||
!Objects.equals(config.getString("resource_pack_uuid"),
|
||||
"00000000-0000-0000-0000-000000000000")) {
|
||||
uuid = UUID.fromString(config.getString("resource_pack_uuid"));
|
||||
} else {
|
||||
uuid = UUID.randomUUID();
|
||||
config.set("resource_pack_uuid", uuid.toString());
|
||||
main.saveConfig();
|
||||
}
|
||||
url = config.getString("resource_pack_url") + "/download/" + uuid.toString();
|
||||
}
|
||||
} else {
|
||||
debug(main, "Resource pack not enabled.");
|
||||
}
|
||||
}
|
||||
|
||||
private static void zipFolder(String folderPath, String zipFilePath) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(zipFilePath);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
File folder = new File(folderPath);
|
||||
zipFiles(folder, folder.getName(), zos);
|
||||
|
||||
zos.close();
|
||||
fos.close();
|
||||
}
|
||||
|
||||
private static void zipFiles(File folder, String parentFolder, ZipOutputStream zos)
|
||||
throws IOException {
|
||||
byte[] buffer = new byte[1024];
|
||||
if (folder.listFiles() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : folder.listFiles()) {
|
||||
if (file.isDirectory()) {
|
||||
zipFiles(file, parentFolder + "/" + file.getName(), zos);
|
||||
continue;
|
||||
}
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
|
||||
zos.putNextEntry(new ZipEntry(parentFolder + "/" + file.getName()));
|
||||
|
||||
int length;
|
||||
while ((length = fis.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
zos.closeEntry();
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void upload() {
|
||||
resourcePackFile = packageRp();
|
||||
if (resourcePackFile != null) {
|
||||
Hosting host = createHosting();
|
||||
host.upload(resourcePackFile);
|
||||
sha1 = host.getOriginalSHA1();
|
||||
}
|
||||
}
|
||||
|
||||
private Hosting createHosting() {
|
||||
return new PackHoster(url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.copyDirectory;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
import static me.unurled.raxen.utils.Utils.removeDirectory;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
|
@ -20,8 +24,7 @@ public class WorldManager {
|
|||
MVWorldManager worldManager;
|
||||
|
||||
/**
|
||||
* String : name
|
||||
* MultiverseWorld : a world that need to be registered
|
||||
* String : name MultiverseWorld : a world that need to be registered
|
||||
*/
|
||||
private Map<String, MultiverseWorld> loadedWorlds = new HashMap<>();
|
||||
|
||||
|
@ -40,6 +43,7 @@ public class WorldManager {
|
|||
|
||||
/**
|
||||
* remove a world
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void removeWorld(String name) {
|
||||
|
@ -94,6 +98,7 @@ public class WorldManager {
|
|||
|
||||
/**
|
||||
* load world from the name of it
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public void loadWorld(String name) {
|
||||
|
|
37
src/main/java/me/unurled/raxen/utils/ComponentSpilt.java
Normal file
37
src/main/java/me/unurled/raxen/utils/ComponentSpilt.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package me.unurled.raxen.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.Style;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
final class ComponentSplit {
|
||||
|
||||
private ComponentSplit() {
|
||||
}
|
||||
|
||||
static @NotNull List<Component> split(final @NotNull Component self,
|
||||
final @NotNull Component separator) {
|
||||
if (self.children().size() == 0) {
|
||||
return Collections.singletonList(self);
|
||||
}
|
||||
|
||||
final List<Component> result = new ArrayList<>();
|
||||
final Component root = self.children(Collections.emptyList());
|
||||
TextComponent.Builder build = Component.text();
|
||||
build.append(root.style(Style.empty()));
|
||||
for (final Component child : self.children()) {
|
||||
if (child.equals(separator)) {
|
||||
result.add(build.build().applyFallbackStyle(root.style()));
|
||||
build = Component.text();
|
||||
} else {
|
||||
build.append(child);
|
||||
}
|
||||
}
|
||||
result.add(build.build().applyFallbackStyle(root.style()));
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,35 +1,128 @@
|
|||
package me.unurled.raxen.utils;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.coloredString;
|
||||
|
||||
import eu.decentsoftware.holograms.api.DHAPI;
|
||||
import eu.decentsoftware.holograms.api.holograms.Hologram;
|
||||
import eu.decentsoftware.holograms.api.holograms.HologramLine;
|
||||
import eu.decentsoftware.holograms.api.holograms.HologramPage;
|
||||
import eu.decentsoftware.holograms.api.utils.Common;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||
import me.filoghost.holographicdisplays.api.hologram.Hologram;
|
||||
import java.util.UUID;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.RaxenEntity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class Tags {
|
||||
|
||||
public static final double STEP = 0.5;
|
||||
|
||||
public static void makeFloatingText(String name, Location loc, double xzOffset, double yMin,
|
||||
double yMax, double durationSec) {
|
||||
loc.add(-xzOffset / 2 + (java.lang.Math.random() * (xzOffset)),
|
||||
(java.lang.Math.random() * (yMax - yMin)) + yMin, -xzOffset / 2 + (
|
||||
java.lang.Math.random() * (xzOffset)));
|
||||
HolographicDisplaysAPI api = HolographicDisplaysAPI.get((Raxen) Objects.requireNonNull(
|
||||
Bukkit.getPluginManager()
|
||||
.getPlugin("Raxen")));
|
||||
Hologram hologram = api.createHologram(loc);
|
||||
hologram.getLines().appendText(coloredString(name));
|
||||
DHAPI.createHologram(name, loc, List.of(name));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hologram.delete();
|
||||
DHAPI.removeHologram(name);
|
||||
}
|
||||
}.runTaskLater(((Raxen) Objects.requireNonNull(
|
||||
Bukkit.getPluginManager()
|
||||
.getPlugin("Raxen"))).getPlugin(), (long) (durationSec * 20));
|
||||
}
|
||||
|
||||
public static void makeFloatingTextStylishWhenHit(Location damager, Location victim,
|
||||
String name, String... text) {
|
||||
ArrayList<Location> loc = getParabolicCurve(victim, damager);
|
||||
Hologram holo = DHAPI.createHologram(name, victim, Arrays.stream(text).toList());
|
||||
for (Location location : loc) {
|
||||
DHAPI.moveHologram(holo, location);
|
||||
if (loc.indexOf(location) == loc.size() - 1) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
DHAPI.removeHologram(name);
|
||||
}
|
||||
}.runTaskLater(((Raxen) Objects.requireNonNull(
|
||||
Bukkit.getPluginManager()
|
||||
.getPlugin("Raxen"))).getPlugin(), 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ArrayList<Location> getParabolicCurve(Location start, Location end) {
|
||||
ArrayList<Location> results = new ArrayList<>();
|
||||
|
||||
Vector line = end.clone().subtract(start).toVector();
|
||||
line.setY(start.getY());
|
||||
double length = line.length();
|
||||
line.normalize();
|
||||
|
||||
for (double x = 0; x < length; x += STEP) {
|
||||
double a = -1.0 / x;
|
||||
double y = a * java.lang.Math.pow(x, 2) + x;
|
||||
Location point = start.clone();
|
||||
point.add(line.multiply(x)).setY(point.getY() + y);
|
||||
results.add(point);
|
||||
line.multiply(1 / x);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public static Hologram createNameTag(Raxen main, Entity entity) {
|
||||
RaxenEntity e = main.getManager().getEntityManager().getEntity(entity);
|
||||
|
||||
// TODO: implement this...
|
||||
|
||||
if (e != null) {
|
||||
TextComponent txt = Utils.colorTextComp(e.getFullName());
|
||||
return createHologram(e.getName() + UUID.randomUUID(), entity.getLocation(),
|
||||
false, txt);
|
||||
} else {
|
||||
// register entity...
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Hologram createHologram(String name, Location location, boolean saveToFile,
|
||||
TextComponent lines) throws IllegalArgumentException {
|
||||
Validate.notNull(name);
|
||||
Validate.notNull(location);
|
||||
|
||||
if (!name.matches(Common.NAME_REGEX)) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Hologram name can only contain alphanumeric characters, underscores and dashes! (%s)",
|
||||
name));
|
||||
}
|
||||
|
||||
if (Hologram.getCachedHologramNames().contains(name)) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Hologram with that name already exists! (%s)", name));
|
||||
}
|
||||
|
||||
Hologram hologram = new Hologram(name, location, saveToFile);
|
||||
HologramPage page = hologram.getPage(0);
|
||||
if (lines != null) {
|
||||
for (Component line : ComponentSplit.split(lines, Component.newline())) {
|
||||
HologramLine hologramLine = new HologramLine(page, page.getNextLineLocation(),
|
||||
Utils.textCompToString(line));
|
||||
page.addLine(hologramLine);
|
||||
}
|
||||
}
|
||||
hologram.showAll();
|
||||
hologram.save();
|
||||
return hologram;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
12
src/main/java/me/unurled/raxen/utils/libs/Redis.java
Normal file
12
src/main/java/me/unurled/raxen/utils/libs/Redis.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
package me.unurled.raxen.utils.libs;
|
||||
|
||||
import redis.clients.jedis.JedisPooled;
|
||||
|
||||
public class Redis {
|
||||
|
||||
JedisPooled jedis;
|
||||
|
||||
public Redis() {
|
||||
jedis = new JedisPooled("localhost");
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
version: "${version}"
|
||||
motd: "YAY, Super server!"
|
||||
motd-reload: "Server reloading!"
|
||||
version: "${version}"
|
||||
motd: "YAY, Super server!"
|
||||
motd-reload: "Server reloading!"
|
||||
|
||||
storage: "MONGODB" # switch between "MONGODB", "MYSQL"(not implemented), "YML"(currently making it)
|
||||
# if MYSQL or MongoDB
|
||||
username: "no_usr" # if mysql if you are on mongodb, add username in the url
|
||||
password: "no_pass" # if mysql if you are on mongodb, add password in the url
|
||||
url: "mongodb://localhost:27017"
|
||||
storage: "MONGODB" # switch between "MONGODB", "MYSQL"(not implemented), "YML"(currently making it)
|
||||
# if MYSQL or MongoDB
|
||||
username: "no_usr" # if mysql if you are on mongodb, add username in the url
|
||||
password: "no_pass" # if mysql if you are on mongodb, add password in the url
|
||||
url: "mongodb://localhost:27017"
|
||||
|
||||
useResourcePack: false
|
||||
resource_pack_url: "https://mc-packs.net/" # recommend to use https://mc-packs.net/ => free resource pack hoster (will eventually develop one myself but not atm)
|
||||
resource_pack_sha1: "sha1hallo" # sha1 hash
|
||||
useResourcePack: false
|
||||
resource_pack_url: "https://pack.unurled.me" # do not change if you want it to work with the intended server
|
||||
resource_pack_uuid: "00000000-0000-0000-0000-000000000000" # do not change it will auto update with the plugin
|
||||
|
||||
debug: false
|
||||
debug: false
|
|
@ -3,8 +3,8 @@ version: '${version}'
|
|||
main: me.unurled.raxen.Raxen
|
||||
author: unurled
|
||||
api-version: 1.19
|
||||
depend: [ ProtocolLib, PlaceholderAPI, 'Multiverse-Core', Citizens, HolographicDisplays ]
|
||||
softdepend: [ LuckPerms, Essentials ]
|
||||
depend: [ ProtocolLib, PlaceholderAPI, 'Multiverse-Core', Citizens ]
|
||||
softdepend: [ Essentials ]
|
||||
|
||||
commands:
|
||||
reloadplugin:
|
||||
|
@ -46,6 +46,8 @@ commands:
|
|||
description: tutorial command
|
||||
party:
|
||||
description: party command
|
||||
build:
|
||||
description: build command
|
||||
|
||||
permissions:
|
||||
raxen.reload.cmd:
|
||||
|
@ -76,3 +78,5 @@ permissions:
|
|||
description: tutorial command permission
|
||||
raxen.party.cmd:
|
||||
description: party command permission
|
||||
raxen.build.cmd:
|
||||
description: build command permission
|
Loading…
Reference in a new issue