Skip to content

Commit

Permalink
Added Bedwars
Browse files Browse the repository at this point in the history
  • Loading branch information
Devlrxxh committed Apr 4, 2024
1 parent 1124e0f commit 157cd9d
Show file tree
Hide file tree
Showing 27 changed files with 468 additions and 212 deletions.
18 changes: 7 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,20 @@
<artifactId>mongodb-driver-sync</artifactId>
<version>4.11.1</version>
</dependency>

<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>6.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/WorldEdit.jar</systemPath>
</dependency>
<dependency>
<groupId>org.github.paperspigot</groupId>
<artifactId>paperspigot-api</artifactId>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/PaperSpigot-1.8.8-R0.1-SNAPSHOT.jar</systemPath>
</dependency>

<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId>
<version>6.0.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/WorldEdit.jar</systemPath>
</dependency>
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
Expand All @@ -62,13 +60,11 @@
<version>3.0.2</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>co.aikar</groupId>
<artifactId>acf-paper</artifactId>
<version>0.5.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/me/lrxh/practice/Locale.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ public enum Locale {
MATCH_NO_LONGER_SPECTATING("MATCH.NO_LONGER_SPECTATING"),
MATCH_PLAYING_ARENA("MATCH.PLAYING_ARENA"),
MATCH_START("MATCH.START"),
MATCH_BED_BROKEN("MATCH.BED_BROKEN"),
MATCH_START_TIMER("MATCH.START_TIMER"),
MATCH_RESPAWN_TIMER("MATCH.RESPAWN_TIMER"),
MATCH_RESPAWNED("MATCH.RESPAWNED"),
MATCH_STARTED("MATCH.STARTED"),
MATCH_WARNING("MATCH.WARNING"),
MATCH_END_DETAILS("MATCH.END_DETAILS"),
Expand All @@ -58,6 +61,7 @@ public enum Locale {
MATCH_CLICK_TO_VIEW_HOVER("MATCH.CLICK_TO_VIEW_HOVER"),
MATCH_ELO_CHANGES("MATCH.ELO_CHANGES"),
MATCH_PLAYER_KILLED("MATCH.PLAYER_KILLED"),
MATCH_PLAYER_FINAL_KILL("MATCH.PLAYER_FINAL_KILL"),
MATCH_PLAYER_DIED("MATCH.PLAYER_DIED"),
REMATCH_SENT_REQUEST("REMATCH.SENT_REQUEST"),
REMATCH_RECEIVED_REQUEST("REMATCH.RECEIVED_REQUEST"),
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/me/lrxh/practice/Practice.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ public void onEnable() {
new LeaderboardThread().start();
new Metrics(this, 20915);


Arrays.asList(
new KitEditorListener(),
new PartyListener(),
Expand All @@ -152,6 +151,11 @@ public void onEnable() {
world.setDifficulty(Difficulty.HARD);
clearEntities(world);
});

for (World world : getInstance().getServer().getWorlds()) {
world.setGameRuleValue("doDaylightCycle", "false");
}

Plugin placeholderAPI = getServer().getPluginManager().getPlugin("PlaceholderAPI");
if (placeholderAPI != null && placeholderAPI.isEnabled()) {
new Placeholder().register();
Expand Down
21 changes: 5 additions & 16 deletions src/main/java/me/lrxh/practice/arena/Arena.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public class Arena extends Cuboid {
protected Location spawnA;
protected Location spawnB;
protected boolean active;
protected Location bedA;
protected Location bedB;
private List<String> kits = new ArrayList<>();
private Map<Chunk, ChunkSnapshot> chunkSnapshots = new HashMap<>();

Expand Down Expand Up @@ -70,13 +68,6 @@ public static void init() {
arena.setSpawnB(LocationUtil.deserialize(configuration.getString(path + ".spawnB")));
}

if (configuration.contains(path + ".bedA")) {
arena.setBedA(LocationUtil.deserialize(configuration.getString(path + ".bedA")));
}

if (configuration.contains(path + ".bedB")) {
arena.setBedB(LocationUtil.deserialize(configuration.getString(path + ".bedB")));
}

String displayName = configuration.getString(path + ".displayName");
arena.setDisplayName(displayName);
Expand All @@ -98,13 +89,6 @@ public static void init() {

duplicate.setSpawnA(spawn1);
duplicate.setSpawnB(spawn2);
if (configuration.contains(path + ".bedA")) {
arena.setBedA(LocationUtil.deserialize(configuration.getString(path + ".bedA")));
}

if (configuration.contains(path + ".bedB")) {
arena.setBedB(LocationUtil.deserialize(configuration.getString(path + ".bedB")));
}
duplicate.setKits(arena.getKits());

((StandaloneArena) arena).getDuplicates().add(duplicate);
Expand Down Expand Up @@ -207,6 +191,11 @@ public int getMaxBuildHeight() {
return highest + 5;
}

public int getDeathZone() {
int lowest = (int) (Math.min(spawnA.getY(), spawnB.getY()));
return lowest - 8;
}

public Location getSpawnA() {
if (spawnA == null) {
return null;
Expand Down
27 changes: 2 additions & 25 deletions src/main/java/me/lrxh/practice/arena/command/ArenaCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import me.lrxh.practice.util.CC;
import me.lrxh.practice.util.ChatComponentBuilder;
import me.lrxh.practice.util.ChatHelper;
import me.lrxh.practice.util.PlayerUtil;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.StringEscapeUtils;
Expand Down Expand Up @@ -122,8 +121,8 @@ public void setDisplayName(Player player, String arenaName, String value) {
}
Arena arena = Arena.getByName(arenaName);
arena.setDisplayName(value);

player.sendMessage(CC.GREEN + "Successfully set " + arena.getDisplayName() + " display name!");
arena.save();
player.sendMessage(CC.GREEN + "Successfully set " + arena.getName() + " display name!");
}


Expand Down Expand Up @@ -377,28 +376,6 @@ public void setspawn(Player player, String arenaName, SpawnType pos) {
player.sendMessage(CC.GREEN + "Updated spawn point " + pos + " for arena " + arena.getName());
}

@Subcommand("setBedSpawn")
@CommandCompletion("@arenas")
@Syntax("<arena> <pos>")
public void setBedSpawn(Player player, String arenaName, SpawnType pos) {
if (checkArena(arenaName)) {
player.sendMessage(CC.translate("&4ERROR - &cArena doesn't exists!"));
return;
}
if (!(PlayerUtil.getTargetBlock(player, 6).getType().equals(Material.BED_BLOCK) || PlayerUtil.getTargetBlock(player, 6).getType().equals(Material.BED))) {
player.sendMessage(CC.translate("&4ERROR - &cYou aren't looking at a bed!"));
return;
}
Arena arena = Arena.getByName(arenaName);
if (pos.equals(SpawnType.A)) {
arena.setBedA(PlayerUtil.getTargetBlock(player, 6).getLocation());
} else {
arena.setBedB(PlayerUtil.getTargetBlock(player, 6).getLocation());
}

arena.save();
player.sendMessage(CC.GREEN + "Updated bed " + pos + " for arena " + arena.getDisplayName());
}

private boolean checkArena(String arena) {
return !Arena.getArenas().contains(Arena.getByName(arena));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public void save() {
configuration.set(path + ".spawnA", LocationUtil.serialize(spawnA));
configuration.set(path + ".displayName", displayName);
configuration.set(path + ".spawnB", LocationUtil.serialize(spawnB));
configuration.set(path + ".bedA", LocationUtil.serialize(bedA));
configuration.set(path + ".bedB", LocationUtil.serialize(bedB));
configuration.set(path + ".cuboid.location1", LocationUtil.serialize(getLowerCorner()));
configuration.set(path + ".cuboid.location2", LocationUtil.serialize(getUpperCorner()));
configuration.set(path + ".kits", getKits());
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/me/lrxh/practice/kit/KitLoadout.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ public KitLoadout(String customName) {
this.contents = new ItemStack[36];
}

public KitLoadout(ItemStack[] armor, ItemStack[] contents) {
this.armor = armor;
this.contents = contents;
}

}
34 changes: 17 additions & 17 deletions src/main/java/me/lrxh/practice/kit/command/KitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void help3(Player player) {
player.sendMessage(CC.translate("&7* &c/kit hpregen &7<kit> - &fSet HPRegen rule"));
player.sendMessage(CC.translate("&7* &c/kit hitdelay &7<kit> <value> - &fSet hit delay"));
player.sendMessage(CC.translate("&7* &c/kit boxing &7<kit> - &fAdd Boxing rule"));
// player.sendMessage(CC.translate("&7* &c/kit bedwars &7<kit> - &fAdd Bedwars rule"));
player.sendMessage(CC.translate("&7* &c/kit bedwars &7<kit> - &fAdd Bedwars rule"));
player.sendMessage(CC.translate("&7&m-----------------------------------------"));
}

Expand Down Expand Up @@ -255,22 +255,22 @@ public void build(Player player, String kitName) {
player.sendMessage(CC.GREEN + "You updated the kit's build status to " + (kit.getGameRules().isBuild() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
}

// @Subcommand("bedwars")
// @CommandCompletion("@kits")
// @Syntax("<kit>")
// public void bedwars(Player player, String kitName) {
// if (!Kit.getKits().contains(Kit.getByName(kitName))) {
// player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
// return;
// }
// Kit kit = Kit.getByName(kitName);
// if (kit == null) return;
//
// kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
// kit.save();
//
// player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
// }
@Subcommand("bedwars")
@CommandCompletion("@kits")
@Syntax("<kit>")
public void bedwars(Player player, String kitName) {
if (!Kit.getKits().contains(Kit.getByName(kitName))) {
player.sendMessage(CC.translate("&4ERROR - &cKit doesn't exists!"));
return;
}
Kit kit = Kit.getByName(kitName);
if (kit == null) return;

kit.getGameRules().setBedwars(!kit.getGameRules().isBedwars());
kit.save();

player.sendMessage(CC.GREEN + "You updated the kit's bedwars status to " + (kit.getGameRules().isBedwars() ? "Enabled" : ChatColor.RED + "Disabled" + "."));
}

@Subcommand("spleef")
@CommandCompletion("@kits")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
import me.lrxh.practice.queue.Queue;
import me.lrxh.practice.util.CC;
import me.lrxh.practice.util.ItemBuilder;
import me.lrxh.practice.util.PlayerUtil;
import me.lrxh.practice.util.TimeUtil;
import me.lrxh.practice.util.menu.Button;
import me.lrxh.practice.util.menu.Menu;
import me.lrxh.practice.util.menu.filters.Filters;
import org.bukkit.Material;
import org.bukkit.SkullType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -63,11 +61,6 @@ public Map<Integer, Button> getButtons(Player player) {
private class GlobalStatsButton extends Button {
public ItemStack getButtonItem(Player player) {

ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta skullMeta = (SkullMeta) head.getItemMeta();
skullMeta.setOwner(player.getName());
head.setItemMeta(skullMeta);

List<String> lore = new ArrayList<>();
Profile profile = Profile.getByUuid(player.getUniqueId());

Expand All @@ -80,7 +73,7 @@ public ItemStack getButtonItem(Player player) {
}


return new ItemBuilder(head)
return new ItemBuilder(PlayerUtil.getPlayerHead(player.getUniqueId()))
.name(Practice.getInstance().getMenusConfig().getString("LEADERBOARD.GLOBAL-STATS.GLOBAL-STATS-NAME"))
.lore(lore)
.clearEnchantments()
Expand Down
Loading

0 comments on commit 157cd9d

Please sign in to comment.