Skip to content

Commit

Permalink
Fixed couple bugs and updated configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Mar 30, 2024
1 parent b7ab21e commit 083df2d
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public enum Locale {
QUEUE_JOIN_UNRANKED("QUEUE.JOIN_UNRANKED"),
QUEUE_LEAVE_UNRANKED("QUEUE.LEAVE_UNRANKED"),
QUEUE_JOIN_RANKED("QUEUE.JOIN_RANKED"),
RANKED_ERROR("RANKED.ERROR-MESSAGE"),
RANKED_ERROR("QUEUE.RANKED-ERROR-MESSAGE"),
LEADERBOARD_REFRESH("LEADERBOARD.MESSAGE"),
PING_YOUR("PING.YOUR"),
PING_OTHERS("PING.OTHERS"),
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/lrxh/practice/Practice.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class Practice extends JavaPlugin {
private boolean placeholder = false;
//private SpigotHandler spigotHandler;
private Hotbar hotbar;

public static Practice getInstance() {
if (practice == null) {
practice = new Practice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {
Profile.getProfiles().put(player.getUniqueId(), profile);

PlayerUtil.teleportToSpawn(player);
player.setPlayerTime(profile.getOptions().time().getTime(), false);

for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
VisibilityLogic.handle(player, otherPlayer);
Expand All @@ -145,7 +146,6 @@ public void onPlayerJoinEvent(PlayerJoinEvent event) {
player.setFlying(true);
player.updateInventory();
}
player.setPlayerTime(profile.getOptions().time().getTime(), false);
new BukkitRunnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ public SelectQueueButton(boolean ranked) {

@Override
public ItemStack getButtonItem(Player player) {
ArrayList<String> lore = new ArrayList<>();

lore.add(CC.translate("&7Click to queue a random kit"));
return new ItemBuilder(Material.REDSTONE_COMPARATOR).name("&aRandom Queue").lore(lore).clearEnchantments().clearFlags().clearFlags().build();
return new ItemBuilder(Material.REDSTONE_COMPARATOR).name("&aRandom Queue").clearEnchantments().clearFlags().clearFlags().build();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/setting/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public enum Settings {
KILL_EFFECTS("Kill Effects", Material.DIAMOND_AXE, "Select Kill Effect."),
THEME("Select Theme", Material.BOOK, "Select Color Theme."),
PING_RANGE("Ping Range", Material.STICK, "Change Ping Range."),
TIME_CHANGE("Change Time", Material.LEVER, "Change Ping Range."),
TIME_CHANGE("Change Time", Material.WATCH, "Change Ping Range."),
MENU_SOUNDS("Menu Sounds", Material.REDSTONE_COMPARATOR, "Toggle Menu Sounds.");

private final String name;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lrxh/practice/setting/SettingsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public int getSize() {

@Override
public Filters getFilter() {
return Filters.FILL;
return Filters.valueOf(Practice.getInstance().getMenusConfig().getString("SETTINGS.FILTER"));
}

public boolean resetCursor() {
Expand Down
50 changes: 35 additions & 15 deletions src/main/java/me/lrxh/practice/util/PlayerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
import com.comphenix.protocol.events.PacketContainer;
import me.lrxh.practice.Practice;
import me.lrxh.practice.profile.SpawnTeleportEvent;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_8_R3.PacketPlayOutNamedEntitySpawn;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand All @@ -17,9 +21,13 @@
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.BlockIterator;

import java.lang.reflect.Field;
import java.util.UUID;

public class PlayerUtil {
private static Field STATUS_PACKET_ID_FIELD;
private static Field STATUS_PACKET_STATUS_FIELD;
private static Field SPAWN_PACKET_ID_FIELD;

public static void setLastAttacker(Player victim, Player attacker) {
victim.setMetadata("lastAttacker", new FixedMetadataValue(Practice.getInstance(), attacker.getUniqueId()));
Expand Down Expand Up @@ -101,30 +109,42 @@ public static void teleportToSpawn(Player player) {
}

public static void animateDeath(Player player) {

try {
final int radius = Bukkit.getServer().getViewDistance() * 16;
if (STATUS_PACKET_ID_FIELD == null) {
STATUS_PACKET_ID_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("a");
STATUS_PACKET_ID_FIELD.setAccessible(true);
}

PacketContainer namedEntitySpawnPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
namedEntitySpawnPacket.getIntegers().write(0, player.getEntityId()).write(1, -1);
if (STATUS_PACKET_STATUS_FIELD == null) {
STATUS_PACKET_STATUS_FIELD = PacketPlayOutEntityStatus.class.getDeclaredField("b");
STATUS_PACKET_STATUS_FIELD.setAccessible(true);
}

if (SPAWN_PACKET_ID_FIELD == null) {
SPAWN_PACKET_ID_FIELD = PacketPlayOutNamedEntitySpawn.class.getDeclaredField("a");
SPAWN_PACKET_ID_FIELD.setAccessible(true);
}

PacketContainer entityStatusPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_STATUS);
entityStatusPacket.getIntegers().write(0, player.getEntityId()).write(1, (int) (byte) 3);
SPAWN_PACKET_ID_FIELD.set(new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle()), -1);
STATUS_PACKET_ID_FIELD.set(new PacketPlayOutEntityStatus(), -1);
STATUS_PACKET_STATUS_FIELD.set(new PacketPlayOutEntityStatus(), (byte) 3);

final int radius = MinecraftServer.getServer().getPlayerList().d();

for (Entity entity : player.getNearbyEntities(radius, radius, radius)) {
if (!(entity instanceof Player)) {
continue;
}
Player watcher = (Player) entity;

Player watcher = (Player) entity;
if (!watcher.getUniqueId().equals(player.getUniqueId())) {
break;
}

if (!watcher.getUniqueId().equals(player.getUniqueId())) {
continue;
((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(new PacketPlayOutNamedEntitySpawn(((CraftPlayer) player).getHandle()));
((CraftPlayer) watcher).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityStatus());
}

ProtocolLibrary.getProtocolManager().sendServerPacket(watcher, namedEntitySpawnPacket);
ProtocolLibrary.getProtocolManager().sendServerPacket(watcher, entityStatusPacket);
}
} catch (Exception ignored) {
} catch(Exception ignored){
}
}
}
}
38 changes: 17 additions & 21 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
MONGO:
URI: mongodb+srv://lrxh:[email protected]/?retryWrites=true&w=majority
DATABASE: practice
URI:
DATABASE:
RANKED:
REQUIRED-WINS: 3
ERROR-MESSAGE: '&cYou cannot join ranked queues with less than 10 unranked 1v1 wins.
You need {0} more wins!'
DEFAULT-THEME-COLOR: AQUA
LEADERBOARD:
ENABLE-MESSAGE: true
Expand All @@ -16,88 +14,86 @@ HOTBAR_ITEMS:
MATERIAL: IRON_SWORD
DURABILITY: 0
NAME: '&bUnranked Queue &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 0
QUEUE_JOIN_RANKED:
MATERIAL: DIAMOND_SWORD
DURABILITY: 0
NAME: '&bRanked Queue &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 1
LEADERBOARDS:
MATERIAL: EMERALD
DURABILITY: 0
NAME: '&bLeaderboards &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 6
PARTY_CREATE:
MATERIAL: NAME_TAG
DURABILITY: 0
NAME: '&bCreate a Party &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 4
PROFILE_SETTINGS:
MATERIAL: PAPER
DURABILITY: 0
NAME: '&bProfile Menu &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 8
KIT_EDITOR:
MATERIAL: BOOK
DURABILITY: 0
NAME: '&bKit Editor &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 8
QUEUEING:
QUEUE_LEAVE:
MATERIAL: INK_SACK
DURABILITY: 1
NAME: '&cLeave Queue &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 8
PARTY:
PARTY_INFORMATION:
MATERIAL: NETHER_STAR
DURABILITY: 0
NAME: '&bParty Information &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 0
PARTY_EVENTS:
MATERIAL: DIAMOND_SWORD
DURABILITY: 0
NAME: '&bParty Events &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 1
OTHER_PARTIES:
MATERIAL: CHEST
DURABILITY: 0
NAME: '&bOther Parties &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 2
KIT_EDITOR:
MATERIAL: BOOK
DURABILITY: 0
NAME: '&bKit Editor &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 7
PARTY_DISBAND:
MATERIAL: INK_SACK
DURABILITY: 1
NAME: '&cDisaband Party &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 8
PARTY_LEAVE:
MATERIAL: INK_SACK
DURABILITY: 1
NAME: '&cLeave Party &7(Right Click)'
LORE: [ ]
LORE: []
SLOT: 8
SPECTATING:
SPECTATE_STOP:
MATERIAL: INK_SACK
DURABILITY: 1
NAME: '&cLeave Match &7(Right click)'
LORE: [ ]
SLOT: 8
ESSENTIAL:
SPAWN_LOCATION: world:0.5:52.0:0.5:0.68951416:-3.124416
LORE: []
SLOT: 8
23 changes: 21 additions & 2 deletions src/main/resources/kits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,37 @@ kits:
knockback-profile: sumo
Boxing:
enabled: true
description: '&7First to reach 100 hits wins'
description: '&7First to 100 hits wins'
icon:
material: DIAMOND_CHESTPLATE
durability: 0
loadout:
armor: t@0:d@-1:a@0;t@0:d@-1:a@0;t@0:d@-1:a@0;t@0:d@-1:a@0;
contents: t@276;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;t@0;
contents: t@276:e@16@5;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;null;
game-rules:
allow-build: false
spleef: false
sumo: false
health-regeneration: false
hit-delay: 20
boxing: true
bedwars: false
knockback-profile: boxing
BuildUHC:
enabled: true
description: '&7Ultra Hardcore'
icon:
material: LAVA_BUCKET
durability: 0
loadout:
armor: t@313:e@4@2:e@34@3;t@312:e@0@1:e@34@3;t@311:e@0@1:e@34@3;t@310:e@4@2:e@34@3;
contents: t@276:e@16@1:e@34@3;t@346:e@34@3;t@261:e@48@2:e@34@3;t@322:a@6;t@322:a@3:dn@ยง6Golden Head;t@327;t@326;t@4:a@64;t@278;t@262:a@64;null;null;null;null;null;null;t@5:a@64;null;null;null;null;null;null;null;null;t@5:a@64;null;null;null;null;null;null;t@327;t@326;t@4:a@64;t@279;
game-rules:
allow-build: true
spleef: false
sumo: false
health-regeneration: true
hit-delay: 20
boxing: false
bedwars: false
knockback-profile: builduhc
10 changes: 9 additions & 1 deletion src/main/resources/menus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,12 @@ LEADERBOARD:
LORE:
- " &7* &fWins: &b<wins>"
- " &7* &fLoses: &b<loses>"
- " &7* &fElo: &b<elo>"
- " &7* &fElo: &b<elo>"
SHOP-MENU:
TITLE: "&7Coin shop"
SIZE: 27
FILTER: FILL # THERE IS FILL AND BRODER
SHOP:
TITLE: "&7Coin shop"
SIZE: 27
FILTER: FILL # THERE IS FILL AND BRODER
5 changes: 3 additions & 2 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ OPTIONS:
SHOWPLAYERS_ENABLED: '&aShowen players!'
SHOWPLAYERS_DISABLED: '&cHidden all players!'
KILL_EFFECTS_SELECT: '&aYou have selected {0}!'
TIME_SELECT: '&aYou have selected {0}!'
THEME_SELECT: '&aYou have selected {0}!'
TIME_SELECT: '&aYou have selected {0}!'
MENU_SOUNDS_ENABLED: '&aEnabled Menu sounds!'
MENU_SOUNDS_DISABLED: '&cDisabled Menu sounds!'
PARTY:
Expand Down Expand Up @@ -75,9 +75,10 @@ DUEL:
QUEUE:
JOIN_UNRANKED: '&aYou are now queued for Unranked {0}.'
LEAVE_UNRANKED: '&cYou have been removed from queue.'
JOIN_RANKED: '&aYou are now queued for &aRanked {0}. &7&o[{1} ELO]'
JOIN_RANKED: '&aYou are now queued for &aRanked {0}. &7[{1} ELO]'
LEAVE_RANKED: '&cYou have been removed from queue.'
RANGE_INCREMENT: '&eSearching in ELO range &7[{1} -> {2}]&e...'
RANKED-ERROR-MESSAGE: '&cYou cannot join ranked queues with less than 10 unranked 1v1 wins. You need {0} more wins!'
MATCH:
START:
- ' '
Expand Down

0 comments on commit 083df2d

Please sign in to comment.