0.6.0 RP, Glyphs, ClientSide builds

This commit is contained in:
unurled 2023-06-06 17:25:19 +02:00
parent c80a684d8e
commit e92772a714
Signed by: unurled
GPG key ID: FDBC9CBE1F82423F
47 changed files with 1120 additions and 239 deletions

View file

@ -22,6 +22,7 @@
- [ ] guilds - [ ] guilds
- [ ] quests (hard coded) and db/json - [ ] quests (hard coded) and db/json
- [ ] filter chat - [ ] filter chat
- [ ] resource pack (host, upload, compress)
## tests ## tests

12
docs/examples/Glyphs.md Normal file
View 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:"
```

View file

@ -2,6 +2,9 @@
see all the exemples in this folder : 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) - [Effects.md](/Elixium/raxen/src/branch/plugin/docs/examples/Effects.md)
- [Items.md](/Elixium/raxen/src/branch/plugin/docs/examples/Items.md) - [Items.md](/Elixium/raxen/src/branch/plugin/docs/examples/Items.md)
- [Mobs.md](/Elixium/raxen/src/branch/plugin/docs/examples/Mobs.md) - [Mobs.md](/Elixium/raxen/src/branch/plugin/docs/examples/Mobs.md)

View file

@ -20,7 +20,7 @@ public final class Raxen extends JavaPlugin {
"<aqua>Rx</aqua><light_purple>></light_purple> "; "<aqua>Rx</aqua><light_purple>></light_purple> ";
@Getter @Getter
private static String version = "0.5.8"; private static String version = "0.6.0";
private boolean loading = true; private boolean loading = true;
private final PluginManager pm = getServer().getPluginManager(); private final PluginManager pm = getServer().getPluginManager();

View file

@ -1,6 +1,12 @@
package me.unurled.raxen.commands; 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 java.util.List;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
@ -35,9 +41,9 @@ public class RaxenCommand implements TabExecutor {
msgPlayer( msgPlayer(
player, player,
coloredString(Raxen.getPrefix()) + coloredString(Raxen.getPrefix()) +
colorTextComp( colorTextComp(
"<red>You can't execute this command. Insufficient permission." "<red>You can't execute this command. Insufficient permission."
) )
); );
} }
switch (args.length) { switch (args.length) {
@ -49,17 +55,17 @@ public class RaxenCommand implements TabExecutor {
sender.sendMessage( sender.sendMessage(
stringToComp( stringToComp(
Raxen.getPrefix() + Raxen.getPrefix() +
colorTextComp( colorTextComp(
"<gold>Printing About Raxen's MongoDB connection..." "<gold>Printing About Raxen's MongoDB connection..."
) )
) )
); );
msgPlayer( msgPlayer(
player, player,
coloredString(Raxen.getPrefix()) + coloredString(Raxen.getPrefix()) +
colorTextComp( colorTextComp(
"<gold>---------------------------------------------" "<gold>---------------------------------------------"
) )
); );
msgPlayer( msgPlayer(
player, player,
@ -131,9 +137,9 @@ public class RaxenCommand implements TabExecutor {
msgSender( msgSender(
sender, sender,
Raxen.getPrefix() + Raxen.getPrefix() +
"<gold>Printing About Raxen's MongoDB connection...", "<gold>Printing About Raxen's MongoDB connection...",
"<gold>---------------------------------------------" + "<gold>---------------------------------------------" +
"<red>MONGO DB" "<red>MONGO DB"
); );
sender.sendMessage( sender.sendMessage(
stringToComp( stringToComp(
@ -174,7 +180,7 @@ public class RaxenCommand implements TabExecutor {
msgSender( msgSender(
sender, sender,
Raxen.getPrefix() + Raxen.getPrefix() +
"<gold>Printing About Raxen...", "<gold>Printing About Raxen...",
"<gold>---------------------------------------------", "<gold>---------------------------------------------",
"<dark_aqua> Raxen ", "<dark_aqua> Raxen ",
"<dark_aqua> - Version: " + Raxen.getVersion(), "<dark_aqua> - Version: " + Raxen.getVersion(),

View 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;
}
}

View file

@ -1,7 +1,10 @@
package me.unurled.raxen.commands.admin; package me.unurled.raxen.commands.admin;
import static me.unurled.raxen.utils.Items.customModelData; 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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -21,6 +24,7 @@ public class CustomModelDataCommand implements TabExecutor {
/** /**
* change custom model data of an item * change custom model data of an item
*
* @param sender Source of the command * @param sender Source of the command
* @param command Command which was executed * @param command Command which was executed
* @param label Alias of the command which was used * @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 * @param sender Source of the command. For players tab-completing a command inside of a
* command inside of a command block, this will be the player, not * command block, this will be the player, not the command block.
* the command block.
* @param command Command which was executed * @param command Command which was executed
* @param label Alias of the command which was used * @param label Alias of the command which was used
* @param args The arguments passed to the command, including final * @param args The arguments passed to the command, including final partial argument to be
* partial argument to be completed * completed
* @return * @return
*/ */
@Override @Override

View file

@ -1,7 +1,8 @@
package me.unurled.raxen.commands.admin; package me.unurled.raxen.commands.admin;
import static me.unurled.raxen.utils.Items.itemTo64; 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 java.util.List;
import org.bukkit.command.Command; 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 * @param sender Source of the command. For players tab-completing a command inside of a
* command inside of a command block, this will be the player, not * command block, this will be the player, not the command block.
* the command block.
* @param command Command which was executed * @param command Command which was executed
* @param label Alias of the command which was used * @param label Alias of the command which was used
* @param args The arguments passed to the command, including final * @param args The arguments passed to the command, including final partial argument to be
* partial argument to be completed * completed
* @return * @return
*/ */
@Override @Override

View file

@ -1,7 +1,11 @@
package me.unurled.raxen.commands.admin; package me.unurled.raxen.commands.admin;
import static me.unurled.raxen.components.entity.player.PlayerUtils.updateSkills; 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 de.tr7zw.nbtapi.NBTItem;
import java.util.ArrayList; import java.util.ArrayList;
@ -124,11 +128,11 @@ public class NbtCommand implements TabExecutor {
player, player,
colorTextComp( colorTextComp(
Raxen.getPrefix() + Raxen.getPrefix() +
"<white>You successfully added the nbt " + "<white>You successfully added the nbt " +
/*attributes(args[0])*/args[0] + /*attributes(args[0])*/args[0] +
"<white>with " + "<white>with " +
args[1] + args[1] +
"<white>." "<white>."
) )
); );
updateSkills(main, player); updateSkills(main, player);

View file

@ -1,13 +1,17 @@
package me.unurled.raxen.commands.admin; 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.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.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.components.entity.other.EntityNamespacedKey; import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -54,8 +58,9 @@ public class SpawnEntity implements TabExecutor {
); );
log( log(
colorTextComp( 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>" +
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
) )
); );
return false; return false;
@ -69,7 +74,7 @@ public class SpawnEntity implements TabExecutor {
Double.parseDouble(args[4]) Double.parseDouble(args[4])
); );
Entity e = loc.getWorld().spawnEntity(loc, types, false); Entity e = loc.getWorld().spawnEntity(loc, types, false);
setNameSpacedKeys( /* setNameSpacedKeys(
e, e,
getStringFromArg(args), getStringFromArg(args),
Integer.parseInt(args[6]), Integer.parseInt(args[6]),
@ -81,7 +86,7 @@ public class SpawnEntity implements TabExecutor {
0, 0,
Integer.parseInt(args[10]), Integer.parseInt(args[10]),
0 0
); ); */
e.customName(colorTextComp(getStringFromArg(args))); e.customName(colorTextComp(getStringFromArg(args)));
e.setCustomNameVisible(true); e.setCustomNameVisible(true);
if (e instanceof LivingEntity livingEntity) { if (e instanceof LivingEntity livingEntity) {
@ -107,9 +112,10 @@ public class SpawnEntity implements TabExecutor {
throw new RuntimeException(e); throw new RuntimeException(e);
} catch (IOException e) { } catch (IOException e) {
error( 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() + +
")" sender.getName() +
")"
); );
throw new RuntimeException(e); throw new RuntimeException(e);
} }
@ -133,8 +139,9 @@ public class SpawnEntity implements TabExecutor {
); );
log( log(
colorTextComp( 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>" +
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
) )
); );
return false; return false;
@ -148,7 +155,7 @@ public class SpawnEntity implements TabExecutor {
Double.parseDouble(args[4]) Double.parseDouble(args[4])
); );
Entity e = loc.getWorld().spawnEntity(loc, types, false); Entity e = loc.getWorld().spawnEntity(loc, types, false);
setNameSpacedKeys( /* setNameSpacedKeys(
e, e,
getStringFromArg(args), getStringFromArg(args),
Integer.parseInt(args[6]), Integer.parseInt(args[6]),
@ -160,7 +167,7 @@ public class SpawnEntity implements TabExecutor {
0, 0,
Integer.parseInt(args[10]), Integer.parseInt(args[10]),
0 0
); ); */
e.customName(colorTextComp(getStringFromArg(args))); e.customName(colorTextComp(getStringFromArg(args)));
e.setCustomNameVisible(true); e.setCustomNameVisible(true);
if (e instanceof LivingEntity livingEntity) { if (e instanceof LivingEntity livingEntity) {
@ -187,8 +194,8 @@ public class SpawnEntity implements TabExecutor {
} catch (IOException e) { } catch (IOException e) {
error( 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() + sender.getName() +
")" ")"
); );
throw new RuntimeException(e); throw new RuntimeException(e);
} }

View file

@ -1,6 +1,8 @@
package me.unurled.raxen.commands.player; 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 java.util.List;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -12,15 +12,15 @@ import org.jetbrains.annotations.NotNull;
public class EntityUtils { public class EntityUtils {
private static Raxen main; private Raxen main;
private static EntityNamespacedKey namespacedKey; private EntityNamespacedKey namespacedKey;
public EntityUtils(Raxen main) { public EntityUtils(Raxen main) {
this.main = main; this.main = main;
namespacedKey = new EntityNamespacedKey(main); namespacedKey = new EntityNamespacedKey(main);
} }
public static void setNameSpacedKeys( public void setNameSpacedKeys(
org.bukkit.entity.@NotNull Entity e, org.bukkit.entity.@NotNull Entity e,
String name, String name,
Integer level, Integer level,
@ -62,7 +62,7 @@ public class EntityUtils {
data.set(namespacedKey.level, PersistentDataType.INTEGER, level); data.set(namespacedKey.level, PersistentDataType.INTEGER, level);
} }
public static void updateSkills(@NotNull LivingEntity livingEntity) { public void updateSkills(@NotNull LivingEntity livingEntity) {
PlayerManager pm = PlayerManager pm =
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager() ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
.getPlayerManager(); .getPlayerManager();
@ -85,7 +85,7 @@ public class EntityUtils {
livingEntity.getAttribute( livingEntity.getAttribute(
org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED
) != ) !=
null null
) { ) {
livingEntity livingEntity
.getAttribute( .getAttribute(
@ -99,7 +99,7 @@ public class EntityUtils {
livingEntity.getAttribute( livingEntity.getAttribute(
org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED
) != ) !=
null null
) { ) {
livingEntity livingEntity
.getAttribute( .getAttribute(

View file

@ -176,14 +176,14 @@ public class MobData {
dead = true; dead = true;
EntityManager manager = main.getManager().getEntityManager(); EntityManager manager = main.getManager().getEntityManager();
if (entity == null) { if (entity == null) {
manager.spawnedMob.remove(entity.getUniqueId()); manager.getSpawnedMob().remove(entity.getUniqueId());
manager.spawnedMobsOnlyMain.remove(entity.getUniqueId()); manager.getSpawnedMobsOnlyMain().remove(entity.getUniqueId());
entity.remove(); entity.remove();
} }
entity = null; entity = null;
if (mount != null) { if (mount != null) {
manager.spawnedMob.remove(mount.getUniqueId()); manager.getSpawnedMob().remove(mount.getUniqueId());
manager.spawnedMobsOnlyMain.remove(mount.getUniqueId()); manager.getSpawnedMobsOnlyMain().remove(mount.getUniqueId());
mount.remove(); mount.remove();
} }
mount = null; mount = null;

View file

@ -1,5 +1,7 @@
package me.unurled.raxen.components.entity.other; package me.unurled.raxen.components.entity.other;
import static me.unurled.raxen.utils.Utils.colorString;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -52,6 +54,10 @@ public abstract class RaxenEntity {
public HashMap<UUID, Long> lastAttackedByTimes; public HashMap<UUID, Long> lastAttackedByTimes;
public java.util.HashMap<UUID, Long> damageDealt; public java.util.HashMap<UUID, Long> damageDealt;
@Getter
@Setter
Boolean isHostile;
public RaxenEntity( public RaxenEntity(
Raxen main, Raxen main,
String name, String name,
@ -66,6 +72,7 @@ public abstract class RaxenEntity {
this.level = level; this.level = level;
this.health = health; this.health = health;
this.strength = strength; this.strength = strength;
isHostile = true;
} }
/*public Entity createEntity( /*public Entity createEntity(
@ -242,4 +249,28 @@ public abstract class RaxenEntity {
} }
return true; 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)
);
}
}
} }

View file

@ -66,7 +66,7 @@ public abstract class Entity implements org.bukkit.entity.Entity {
} }
public void register(Raxen main) { public void register(Raxen main) {
main.getManager().getEntityManager().entities.put(name, this); // main.getManager().getEntityManager().entities.put(name, this);
} }
public String getName() { public String getName() {

View file

@ -1,10 +1,11 @@
package me.unurled.raxen.components.entity.player; 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.Raxen;
import me.unurled.raxen.manager.entity.PlayerManager; import me.unurled.raxen.manager.entity.PlayerManager;
import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -81,14 +82,14 @@ public class PlayerUtils {
player.sendActionBar( player.sendActionBar(
colorComp( colorComp(
"<red>" + "<red>" +
pm.getHealth().get(player) + pm.getHealth().get(player) +
"/" + "/" +
pm.getMaxHealth().get(player) + pm.getMaxHealth().get(player) +
"❤</red> <aqua>" + "❤</red> <aqua>" +
pm.getMana().get(player) + pm.getMana().get(player) +
"/" + "/" +
pm.getMaxMana().get(player) + pm.getMaxMana().get(player) +
"</aqua>" "</aqua>"
) )
); );
} }

View file

@ -1,12 +1,18 @@
package me.unurled.raxen.components.entity.player; 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.Raxen;
import me.unurled.raxen.utils.libs.Vault; import me.unurled.raxen.utils.libs.Vault;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; 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 { public class Scoreboard {
@ -62,7 +68,8 @@ public class Scoreboard {
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR); player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
debug(main, String.valueOf(player.getScoreboard().getEntries())); debug(main, String.valueOf(player.getScoreboard().getEntries()));
for (String str : player.getScoreboard().getEntries()) { for (String str : player.getScoreboard().getEntries()) {
if (str.contains(player.getName())) {} if (str.contains(player.getName())) {
}
} }
player.getScoreboard().resetScores("Coins"); player.getScoreboard().resetScores("Coins");
assert objective != null; assert objective != null;

View file

@ -0,0 +1,5 @@
package me.unurled.raxen.components.glyph;
public class Glyph {
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -33,6 +33,7 @@ public class ItemBuilder {
private Component displayName; private Component displayName;
private int amount; private int amount;
private int customModelData; private int customModelData;
private String customModelDataPath;
private boolean hasCustomModelData; private boolean hasCustomModelData;
private Color color; private Color color;
private @NotNull PotionData potionData; private @NotNull PotionData potionData;
@ -113,4 +114,9 @@ public class ItemBuilder {
public void color(Color color) { public void color(Color color) {
this.color = color; this.color = color;
} }
public void modelData(String path, int data) {
this.customModelData = data;
this.customModelDataPath = path;
}
} }

View file

@ -16,6 +16,8 @@ public class ItemParser {
if (section.isConfigurationSection("Pack")) { if (section.isConfigurationSection("Pack")) {
ConfigurationSection packSection = section.getConfigurationSection("Pack"); ConfigurationSection packSection = section.getConfigurationSection("Pack");
// TODO: Parse pack section // 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")) { if (section.contains("color")) {
item.color(Utils.color(section.getString("color", "FFFFFF"))); 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; return item;
} }
} }

View file

@ -2,6 +2,7 @@ package me.unurled.raxen.components.resourcepack;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.manager.server.ResourcePackManager; import me.unurled.raxen.manager.server.ResourcePackManager;
import me.unurled.raxen.utils.Utils;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -24,12 +25,24 @@ public class ResourcePack {
public void run() { public void run() {
if (resourcePackManager.isUseRP()) { if (resourcePackManager.isUseRP()) {
player.setResourcePack( player.setResourcePack(
config.getString("ressource_pack_url"), resourcePackManager.getUrl(),
config.getString("resource_pack_sha1") resourcePackManager.getSha1(),
true
); );
} }
} }
} }.runTaskLater(main, 10L);
.runTaskLater(main, 2L); 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, 600L);
} }
} }

View file

@ -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();
}

View file

@ -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;
}
}

View file

@ -5,8 +5,6 @@ import static me.unurled.raxen.utils.Utils.log;
import static me.unurled.raxen.utils.Utils.msgPlayer; import static me.unurled.raxen.utils.Utils.msgPlayer;
import lombok.Getter; 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.Raxen;
import me.unurled.raxen.components.entity.player.RaxenPlayer; import me.unurled.raxen.components.entity.player.RaxenPlayer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -59,10 +57,7 @@ public class Tutorial {
player.teleport( player.teleport(
new Location(world, 15.82, 74.00, 117.21, 899.21F, 0.90f)); new Location(world, 15.82, 74.00, 117.21, 899.21F, 0.90f));
msgPlayer(player, colorTextComp("<green>Welcome to the tutorial!")); msgPlayer(player, colorTextComp("<green>Welcome to the tutorial!"));
HolographicDisplaysAPI api = main.getManager().getLibsManager().getHolographicDisplay() // Hologram holo = api.createHologram(new Location(world, 15.5, 76.00, 112.5, 179.21f, 0.90f));
.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!");
} }
public void stopTutorial() { public void stopTutorial() {

View file

@ -3,12 +3,7 @@ package me.unurled.raxen.config;
import static me.unurled.raxen.utils.Utils.debug; import static me.unurled.raxen.utils.Utils.debug;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException; 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 lombok.Getter;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
@ -50,22 +45,5 @@ public class Config {
if (!Raxen.getVersion().equals(config.getString("version"))) { if (!Raxen.getVersion().equals(config.getString("version"))) {
main.saveResource("config.yml", true); 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);
}
;
} }
} }

View 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;
}
}

View file

@ -6,7 +6,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import me.unurled.raxen.Raxen; 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.ItemBuilder;
import me.unurled.raxen.components.items.ItemParser; import me.unurled.raxen.components.items.ItemParser;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -19,14 +18,14 @@ public class ItemConfig {
public ItemConfig(Raxen main) { public ItemConfig(Raxen main) {
this.main = main; this.main = main;
validatesConfig();
} }
public boolean validatesConfig() { public void validatesConfig() {
itemsFolder = new File(main.getDataFolder(), "items"); itemsFolder = new File(main.getDataFolder(), "items");
if (!itemsFolder.exists()) { if (!itemsFolder.exists()) {
itemsFolder.mkdirs(); itemsFolder.mkdirs();
} }
return true;
} }
public Map<File, Map<String, ItemBuilder>> parseItemConfigs() { public Map<File, Map<String, ItemBuilder>> parseItemConfigs() {
@ -61,11 +60,15 @@ public class ItemConfig {
return map; return map;
} }
public Map<File, Map<String, EffectBuilder>> parseEffectConfig() { /*public Map<File, Map<String, EffectBuilder>> parseEffectConfig() {
// TODO: efffects // TODO: efffects
} }*/
private File[] getItemsFiles() { private File[] getItemsFiles() {
if (!itemsFolder.exists()) {
itemsFolder.mkdirs();
return new File[0];
}
File[] itemConfigs = Arrays.stream(itemsFolder.listFiles()).filter(File::isFile) File[] itemConfigs = Arrays.stream(itemsFolder.listFiles()).filter(File::isFile)
.toArray(File[]::new); .toArray(File[]::new);
Arrays.sort(itemConfigs); Arrays.sort(itemConfigs);

View file

@ -62,7 +62,7 @@ public class DamageEntity implements Listener {
} else { } else {
// attack between player and mob // attack between player and mob
RaxenPlayer rx = pm.getRaxenPlayer((Player) attacker); RaxenPlayer rx = pm.getRaxenPlayer((Player) attacker);
MobData re = main.getManager().getEntityManager().spawnedMob.get( MobData re = main.getManager().getEntityManager().getSpawnedMob().get(
defender.getUniqueId()); defender.getUniqueId());
if (rx != null) { if (rx != null) {
rx.attackMob(re); rx.attackMob(re);
@ -94,7 +94,7 @@ public class DamageEntity implements Listener {
rx.attackPlayer(rx2, rpgDamage, projectile); rx.attackPlayer(rx2, rpgDamage, projectile);
} }
} else { } else {
MobData mb = main.getManager().getEntityManager().spawnedMob.get( MobData mb = main.getManager().getEntityManager().getSpawnedMob().get(
defender.getUniqueId()); defender.getUniqueId());
if (rx != null && mb != null) { if (rx != null && mb != null) {
if (rpgKnockback >= 0) { if (rpgKnockback >= 0) {
@ -107,7 +107,7 @@ public class DamageEntity implements Listener {
} }
} else { } else {
if (defender instanceof Player) { if (defender instanceof Player) {
MobData a = main.getManager().getEntityManager().spawnedMob.get( MobData a = main.getManager().getEntityManager().getSpawnedMob().get(
attacker.getUniqueId()); attacker.getUniqueId());
RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer( RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer(
(Player) defender); (Player) defender);
@ -122,7 +122,7 @@ public class DamageEntity implements Listener {
attacker.remove(); attacker.remove();
} else { } else {
if (defender instanceof Player) { if (defender instanceof Player) {
MobData a = main.getManager().getEntityManager().spawnedMob.get( MobData a = main.getManager().getEntityManager().getSpawnedMob().get(
attacker.getUniqueId()); attacker.getUniqueId());
RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer( RaxenPlayer d = main.getManager().getPlayerManager().getRaxenPlayer(
(Player) defender); (Player) defender);

View file

@ -5,6 +5,7 @@ import static me.unurled.raxen.utils.Utils.debug;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.components.entity.other.EntityNamespacedKey; import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
import me.unurled.raxen.components.entity.other.EntityUtils; import me.unurled.raxen.components.entity.other.EntityUtils;
import org.bukkit.entity.Display;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -26,19 +27,24 @@ public class SpawnEvent implements Listener {
} }
/** /**
* when a new entity spawns * when a new entity spawns adds all persistent data container
* adds all persistent data container *
* @param e * @param e
*/ */
@EventHandler @EventHandler
public void Spawn(EntitySpawnEvent e) { public void Spawn(EntitySpawnEvent e) {
e.getEntity().getWorld().spawn(e.getLocation(), Display.class);
if (e.getEntity() instanceof Player) { if (e.getEntity() instanceof Player) {
//player stuff dont want to talk about it; already doing it in player join event //player stuff dont want to talk about it; already doing it in player join event
debug(main, "Player: " + ((Player) e.getEntity()).getName()); debug(main, "Player: " + ((Player) e.getEntity()).getName());
} else if ( } else if (
e.getEntity().getType() != EntityType.DROPPED_ITEM && e.getEntity().getType() != EntityType.DROPPED_ITEM &&
e.getEntity().getType() != EntityType.FALLING_BLOCK && 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()); debug(main, e.getEntity().getName());
if ( if (
@ -61,7 +67,10 @@ public class SpawnEvent implements Listener {
0 0
); );
} }
main.getManager().getEntityManager().registerEntity(e.getEntity());
entityUtils.updateSkills((LivingEntity) e.getEntity()); entityUtils.updateSkills((LivingEntity) e.getEntity());
// add nametag
} }
} }
} }

View file

@ -1,8 +1,5 @@
package me.unurled.raxen.listener.player; 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 de.tr7zw.nbtapi.NBT;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -21,7 +18,8 @@ public class InteractEvent implements Listener {
if (i != null && i.getType() != Material.AIR) { if (i != null && i.getType() != Material.AIR) {
String id = NBT.get(i, nbt -> nbt.getString("ID")); String id = NBT.get(i, nbt -> nbt.getString("ID"));
if (id != null && !id.isEmpty()) { if (id != null && !id.isEmpty()) {
if (id.equals("PHONE")) {} if (id.equals("PHONE")) {
}
} }
} }
} }

View file

@ -2,7 +2,6 @@ package me.unurled.raxen.listener.player;
import java.io.IOException; import java.io.IOException;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.components.entity.player.PlayerUtils;
import me.unurled.raxen.config.PlayerConfig; import me.unurled.raxen.config.PlayerConfig;
import me.unurled.raxen.manager.entity.PlayerManager; import me.unurled.raxen.manager.entity.PlayerManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,6 +21,7 @@ public class LeaveEvent implements Listener {
/** /**
* when player leaves, saves everything * when player leaves, saves everything
*
* @param e * @param e
* @throws IOException * @throws IOException
*/ */

View file

@ -9,8 +9,10 @@ import me.unurled.raxen.manager.entity.PartyManager;
import me.unurled.raxen.manager.entity.PlayerManager; import me.unurled.raxen.manager.entity.PlayerManager;
import me.unurled.raxen.manager.entity.SpellManager; import me.unurled.raxen.manager.entity.SpellManager;
import me.unurled.raxen.manager.entity.StorageManager; 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.CommandManager;
import me.unurled.raxen.manager.server.DungeonsManager; 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.LibsManager;
import me.unurled.raxen.manager.server.ListenerManager; import me.unurled.raxen.manager.server.ListenerManager;
import me.unurled.raxen.manager.server.ResourcePackManager; import me.unurled.raxen.manager.server.ResourcePackManager;
@ -69,6 +71,12 @@ public class Manager {
@Getter @Getter
private SpellManager spellManager; private SpellManager spellManager;
@Getter
private GlyphManager glyphManager;
@Getter
private BuildManager buildManager;
/** /**
* Create an instance of all managers. * Create an instance of all managers.
* *
@ -92,5 +100,7 @@ public class Manager {
tutorialManager = new TutorialManager(); tutorialManager = new TutorialManager();
partyManager = new PartyManager(main); partyManager = new PartyManager(main);
spellManager = new SpellManager(main); spellManager = new SpellManager(main);
glyphManager = new GlyphManager(main);
buildManager = new BuildManager(main);
} }
} }

View file

@ -2,6 +2,8 @@ package me.unurled.raxen.manager.entity;
import static me.unurled.raxen.utils.Utils.debug; 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.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; 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.MobData;
import me.unurled.raxen.components.entity.other.MobType; import me.unurled.raxen.components.entity.other.MobType;
import me.unurled.raxen.components.entity.other.RaxenEntity; import me.unurled.raxen.components.entity.other.RaxenEntity;
import me.unurled.raxen.utils.Tags;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
public class EntityManager { public class EntityManager {
@ -41,57 +46,67 @@ public class EntityManager {
@Getter @Getter
@Setter @Setter
public List<EntityType> list = new ArrayList<>(); private List<EntityType> list = new ArrayList<>();
public HashMap<String, MobType> mobTypes;
public HashMap<UUID, MobData> spawnedMob;
public HashMap<UUID, MobData> spawnedMobsOnlyMain;
@Getter @Getter
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute = private HashMap<String, MobType> mobTypes;
new HashMap<>(); @Getter
private final HashMap<UUID, MobData> spawnedMob;
@Getter
private HashMap<UUID, MobData> spawnedMobsOnlyMain;
public HashMap<String, me.unurled.raxen.components.entity.other.RaxenEntity> entities = @Getter
new HashMap<>(); 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 final HashMap<UUID, Entity> livingEntities = new HashMap<>();
private Health health; private HashMap<UUID, BukkitTask> nameTags;
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;
public EntityManager(Raxen main) { public EntityManager(Raxen main) {
this.main = main; this.main = main;
entities = new HashMap<>();
attribute = new HashMap<>();
mobTypes = new HashMap<>(); mobTypes = new HashMap<>();
spawnedMob = new HashMap<>(); spawnedMob = new HashMap<>();
spawnedMobsOnlyMain = new HashMap<>(); spawnedMobsOnlyMain = new HashMap<>();
nameTags = new HashMap<>();
reload(); reload();
registerAttributes(); registerAttributes();
} }
public static void reload() { public void reload() {
Collection<MobData> collection = new ArrayList<>(); Collection<MobData> collection = new ArrayList<>();
collection.addAll(spawnedMob.values()); collection.addAll(spawnedMob.values());
for (MobData mobData : collection) { for (MobData mobData : collection) {
mobData.entity.die(false); // mobData.entity.die(false);
} }
} }
public void registerLivingEntities(World world) { 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 * used to register entities using fileconfigs but rapidly abandoned
* *
@ -109,7 +124,7 @@ public class EntityManager {
} }
public RaxenEntity getEntity(Entity entity) { public RaxenEntity getEntity(Entity entity) {
entities.get(entity.getUniqueId()); return entities.get(entity.getUniqueId());
} }
/** /**
@ -118,50 +133,50 @@ public class EntityManager {
public void registerAttributes() { public void registerAttributes() {
EntityNamespacedKey key = new EntityNamespacedKey(main); EntityNamespacedKey key = new EntityNamespacedKey(main);
this.defense = new Defense(key.defense, "DEFENSE"); // Attributes
Defense defense = new Defense(key.defense, "DEFENSE");
attribute.put("DEFENSE", defense); attribute.put("DEFENSE", defense);
this.health = new Health(key.health, "HEALTH"); Health health = new Health(key.health, "HEALTH");
attribute.put("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); 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); 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); 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); 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); 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); attribute.put("ITEM_STRENGTH", itemStrength);
this.luck = new Luck(key.luck, "LUCK"); Luck luck = new Luck(key.luck, "LUCK");
attribute.put("LUCK", luck); attribute.put("LUCK", luck);
this.mana = new Mana(key.mana, "MANA"); Mana mana = new Mana(key.mana, "MANA");
attribute.put("MANA", mana); attribute.put("MANA", mana);
this.maxMana = MaxMana maxMana = new MaxManaBuilder()
new MaxManaBuilder() .setNamespacekey(key.maxMana)
.setNamespacekey(key.maxMana) .setName("MAX_MANA")
.setName("MAX_MANA") .createMaxMana();
.createMaxMana();
attribute.put("MAX_MANA", maxMana); 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); attribute.put("MAX_HEALTH", maxHealth);
this.speed = new Speed(key.speed, "SPEED"); Speed speed = new Speed(key.speed, "SPEED");
attribute.put("SPEED", speed); attribute.put("SPEED", speed);
this.strength = new Strength(key.strength, "STRENGTH"); Strength strength = new Strength(key.strength, "STRENGTH");
attribute.put("STRENGTH", strength); attribute.put("STRENGTH", strength);
} }

View file

@ -3,6 +3,7 @@ package me.unurled.raxen.manager.server;
import lombok.Getter; import lombok.Getter;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.commands.RaxenCommand; 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.CustomModelDataCommand;
import me.unurled.raxen.commands.admin.EntitiyCommand; import me.unurled.raxen.commands.admin.EntitiyCommand;
import me.unurled.raxen.commands.admin.ItemListCommand; import me.unurled.raxen.commands.admin.ItemListCommand;
@ -39,6 +40,7 @@ public class CommandManager {
private ItemTo64Command itemTo64Command; private ItemTo64Command itemTo64Command;
private TutorialManagerCommand tutorialManagerCommand; private TutorialManagerCommand tutorialManagerCommand;
private PartyCommand partyCommand; private PartyCommand partyCommand;
private BuildCommand buildCommand;
public CommandManager(Raxen main) { public CommandManager(Raxen main) {
this.main = main; this.main = main;
@ -54,6 +56,7 @@ public class CommandManager {
this.itemTo64Command = new ItemTo64Command(); this.itemTo64Command = new ItemTo64Command();
this.tutorialManagerCommand = new TutorialManagerCommand(main); this.tutorialManagerCommand = new TutorialManagerCommand(main);
this.partyCommand = new PartyCommand(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").setExecutor(partyCommand);
main.getCommand("party").setTabCompleter(partyCommand); main.getCommand("party").setTabCompleter(partyCommand);
main.getCommand("build").setExecutor(buildCommand);
main.getCommand("build").setTabCompleter(buildCommand);
} }
} }

View file

@ -3,8 +3,6 @@ package me.unurled.raxen.manager.server;
import lombok.Getter; import lombok.Getter;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.utils.libs.CitizensApi; 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.MongoDB;
import me.unurled.raxen.utils.libs.Mysql; import me.unurled.raxen.utils.libs.Mysql;
import me.unurled.raxen.utils.libs.PlaceHolderAPI; import me.unurled.raxen.utils.libs.PlaceHolderAPI;
@ -15,9 +13,6 @@ public class LibsManager {
@Getter @Getter
private final ProtocolManager protocolManager; private final ProtocolManager protocolManager;
@Getter
private final LuckPerm luckPerm;
@Getter @Getter
private final Vault vault; private final Vault vault;
@ -33,17 +28,12 @@ public class LibsManager {
@Getter @Getter
private CitizensApi citizens; private CitizensApi citizens;
@Getter
private HolographicDisplay holographicDisplay;
public LibsManager(Raxen main) { public LibsManager(Raxen main) {
this.luckPerm = new LuckPerm(main);
this.luckPerm.register();
this.vault = new Vault(main); this.vault = new Vault(main);
this.protocolManager = new ProtocolManager(main); this.protocolManager = new ProtocolManager(main);
this.mongoDB = new MongoDB(); this.mongoDB = new MongoDB();
this.placeHolderAPI = new PlaceHolderAPI(main); this.placeHolderAPI = new PlaceHolderAPI(main);
this.citizens = new CitizensApi(main); this.citizens = new CitizensApi(main);
this.holographicDisplay = new HolographicDisplay(main);
} }
} }

View file

@ -1,11 +1,15 @@
package me.unurled.raxen.manager.server; package me.unurled.raxen.manager.server;
import com.comphenix.protocol.PacketType; import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.PacketType.Play.Server;
import com.comphenix.protocol.events.ListenerPriority; import com.comphenix.protocol.events.ListenerPriority;
import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.wrappers.BlockPosition;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.components.clientbuild.Builds;
import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class ProtocolManager { 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);
}
});
} }
} }

View file

@ -1,12 +1,22 @@
package me.unurled.raxen.manager.server; package me.unurled.raxen.manager.server;
import static me.unurled.raxen.utils.Utils.debug; 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.Objects;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import lombok.Getter; import lombok.Getter;
import me.unurled.raxen.Raxen; import me.unurled.raxen.Raxen;
import me.unurled.raxen.components.resourcepack.ResourcePack; 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; import org.bukkit.configuration.file.FileConfiguration;
public class ResourcePackManager { public class ResourcePackManager {
@ -18,6 +28,13 @@ public class ResourcePackManager {
private FileConfiguration config; private FileConfiguration config;
private UUID uuid;
@Getter
private String url;
@Getter
private String sha1;
private File resourcePackFile;
@Getter @Getter
private boolean useRP; private boolean useRP;
@ -25,40 +42,161 @@ public class ResourcePackManager {
this.main = main; this.main = main;
this.resourcePack = new ResourcePack(main, this); this.resourcePack = new ResourcePack(main, this);
this.config = main.getConfig(); this.config = main.getConfig();
this.useRP = this.config.getBoolean("useResourcePack"); this.useRP = this.config.getBoolean("useResourcePack", false);
enable(); 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() { private void enable() {
if (useRP) { if (useRP) {
if ( if (config.getString("resource_pack_url") == null ||
config.getString("resource_pack_url") == null || Objects.equals(config.getString("resource_pack_url"), "")) {
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!"
);
debug(main, "Resource pack not enabled."); debug(main, "Resource pack not enabled.");
useRP = false; useRP = false;
} else { } else {
debug(main, "Ressource Pack enabled."); 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 { } else {
debug(main, "Resource pack not enabled."); 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);
}
} }

View file

@ -1,6 +1,10 @@
package me.unurled.raxen.manager.server; 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.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -20,8 +24,7 @@ public class WorldManager {
MVWorldManager worldManager; MVWorldManager worldManager;
/** /**
* String : name * String : name MultiverseWorld : a world that need to be registered
* MultiverseWorld : a world that need to be registered
*/ */
private Map<String, MultiverseWorld> loadedWorlds = new HashMap<>(); private Map<String, MultiverseWorld> loadedWorlds = new HashMap<>();
@ -40,6 +43,7 @@ public class WorldManager {
/** /**
* remove a world * remove a world
*
* @param name * @param name
*/ */
public void removeWorld(String name) { public void removeWorld(String name) {
@ -65,8 +69,8 @@ public class WorldManager {
pluginFolder.mkdirs(); pluginFolder.mkdirs();
error( error(
"Please put in the folder " + "Please put in the folder " +
pluginFolder.getAbsolutePath() + pluginFolder.getAbsolutePath() +
" all the needed worlds :" " all the needed worlds :"
); );
for (String s : worlds) { for (String s : worlds) {
error(" - " + s + ","); error(" - " + s + ",");
@ -94,6 +98,7 @@ public class WorldManager {
/** /**
* load world from the name of it * load world from the name of it
*
* @param name * @param name
*/ */
public void loadWorld(String name) { public void loadWorld(String name) {
@ -101,10 +106,10 @@ public class WorldManager {
if (!world.exists() || !world.isDirectory()) { if (!world.exists() || !world.isDirectory()) {
error( error(
"Loading world " + "Loading world " +
name + name +
". Folder " + ". Folder " +
world.getAbsolutePath() + world.getAbsolutePath() +
" don't exists." " don't exists."
); );
return; return;
} }
@ -116,10 +121,10 @@ public class WorldManager {
), ),
colorTextComp( colorTextComp(
"<blue>From " + "<blue>From " +
world.getAbsolutePath() + world.getAbsolutePath() +
" to " + " to " +
newWorld.getAbsolutePath() + newWorld.getAbsolutePath() +
".</blue>" ".</blue>"
) )
); );
copyDirectory(world.getAbsolutePath(), newWorld.getAbsolutePath()); copyDirectory(world.getAbsolutePath(), newWorld.getAbsolutePath());

View 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;
}
}

View file

@ -1,35 +1,128 @@
package me.unurled.raxen.utils; 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 java.util.Objects;
import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI; import java.util.UUID;
import me.filoghost.holographicdisplays.api.hologram.Hologram;
import me.unurled.raxen.Raxen; 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.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class Tags { public class Tags {
public static final double STEP = 0.5;
public static void makeFloatingText(String name, Location loc, double xzOffset, double yMin, public static void makeFloatingText(String name, Location loc, double xzOffset, double yMin,
double yMax, double durationSec) { double yMax, double durationSec) {
loc.add(-xzOffset / 2 + (java.lang.Math.random() * (xzOffset)), loc.add(-xzOffset / 2 + (java.lang.Math.random() * (xzOffset)),
(java.lang.Math.random() * (yMax - yMin)) + yMin, -xzOffset / 2 + ( (java.lang.Math.random() * (yMax - yMin)) + yMin, -xzOffset / 2 + (
java.lang.Math.random() * (xzOffset))); java.lang.Math.random() * (xzOffset)));
HolographicDisplaysAPI api = HolographicDisplaysAPI.get((Raxen) Objects.requireNonNull( DHAPI.createHologram(name, loc, List.of(name));
Bukkit.getPluginManager()
.getPlugin("Raxen")));
Hologram hologram = api.createHologram(loc);
hologram.getLines().appendText(coloredString(name));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
hologram.delete(); DHAPI.removeHologram(name);
} }
}.runTaskLater(((Raxen) Objects.requireNonNull( }.runTaskLater(((Raxen) Objects.requireNonNull(
Bukkit.getPluginManager() Bukkit.getPluginManager()
.getPlugin("Raxen"))).getPlugin(), (long) (durationSec * 20)); .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;
}
} }

View 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");
}
}

View file

@ -1,15 +1,15 @@
version: "${version}" version: "${version}"
motd: "YAY, Super server!" motd: "YAY, Super server!"
motd-reload: "Server reloading!" motd-reload: "Server reloading!"
storage: "MONGODB" # switch between "MONGODB", "MYSQL"(not implemented), "YML"(currently making it) storage: "MONGODB" # switch between "MONGODB", "MYSQL"(not implemented), "YML"(currently making it)
# if MYSQL or MongoDB # if MYSQL or MongoDB
username: "no_usr" # if mysql if you are on mongodb, add username in the url 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 password: "no_pass" # if mysql if you are on mongodb, add password in the url
url: "mongodb://localhost:27017" url: "mongodb://localhost:27017"
useResourcePack: false 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_url: "https://pack.unurled.me" # do not change if you want it to work with the intended server
resource_pack_sha1: "sha1hallo" # sha1 hash resource_pack_uuid: "00000000-0000-0000-0000-000000000000" # do not change it will auto update with the plugin
debug: false debug: false

View file

@ -3,8 +3,8 @@ version: '${version}'
main: me.unurled.raxen.Raxen main: me.unurled.raxen.Raxen
author: unurled author: unurled
api-version: 1.19 api-version: 1.19
depend: [ ProtocolLib, PlaceholderAPI, 'Multiverse-Core', Citizens, HolographicDisplays ] depend: [ ProtocolLib, PlaceholderAPI, 'Multiverse-Core', Citizens ]
softdepend: [ LuckPerms, Essentials ] softdepend: [ Essentials ]
commands: commands:
reloadplugin: reloadplugin:
@ -46,6 +46,8 @@ commands:
description: tutorial command description: tutorial command
party: party:
description: party command description: party command
build:
description: build command
permissions: permissions:
raxen.reload.cmd: raxen.reload.cmd:
@ -75,4 +77,6 @@ permissions:
raxen.tutorial.cmd: raxen.tutorial.cmd:
description: tutorial command permission description: tutorial command permission
raxen.party.cmd: raxen.party.cmd:
description: party command permission description: party command permission
raxen.build.cmd:
description: build command permission