Skip to content

Commit

Permalink
Version 1.1.2: Blow Bow
Browse files Browse the repository at this point in the history
New Gamemode, other things.
  • Loading branch information
CKAY-9 committed Jul 26, 2024
1 parent 22e113c commit 392c753
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 180 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.ckay9</groupId>
<artifactId>duelcraft</artifactId>
<version>1.1.1</version>
<version>1.1.2</version>
<packaging>jar</packaging>

<name>duelcraft</name>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/dev/ckay9/duelcraft/Commands/DuelCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
case "spleef":
Match.createSpleefMatch(duels, player, selected_player);
break;
case "blowbow":
Match.createBlowBowMatch(duels, player, selected_player);
break;
case "accept":
if (active_match == null) {
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
if (!is_waiting) {
completers.add("spleef");
completers.add("classic");
completers.add("blowbow");
} else {
completers.add("delete");
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dev/ckay9/duelcraft/DuelCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import dev.ckay9.duelcraft.Listeners.PlayerJoin;
import dev.ckay9.duelcraft.Listeners.PlayerLeave;
import dev.ckay9.duelcraft.Listeners.PlayerMove;
import dev.ckay9.duelcraft.Listeners.ProjectileEvents;
import dev.ckay9.duelcraft.Tasks.MatchClearer;

public class DuelCraft extends JavaPlugin {
public ArrayList<Match> matches = new ArrayList<>();
public MatchClearer match_clearer;
public static String duels_version = "v1.1.1";
public static String duels_version = "v1.1.2";

@Override
public void onEnable() {
Expand All @@ -44,6 +45,7 @@ public void onEnable() {
manager.registerEvents(new PlayerDamage(this), this);
manager.registerEvents(new PlayerDeath(this), this);
manager.registerEvents(new BlockInteract(this), this);
manager.registerEvents(new ProjectileEvents(this), this);
manager.registerEvents(new PlayerMove(this), this);
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/dev/ckay9/duelcraft/Duels/DuelType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public enum DuelType {
CLASSIC,
SPLEEF
SPLEEF,
BLOWBOW
}
80 changes: 75 additions & 5 deletions src/main/java/dev/ckay9/duelcraft/Duels/DuelWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.generator.ChunkGenerator;
import org.joml.Math;

import dev.ckay9.duelcraft.DuelCraft;
import dev.ckay9.duelcraft.Storage;
Expand All @@ -32,8 +33,8 @@ public DuelWorld(DuelCraft duels) {
public World generateWorld(String name) {
WorldCreator world_creator = new WorldCreator("match_" + name);

world_creator.environment(World.Environment.NORMAL);
world_creator.type(WorldType.FLAT);
world_creator.generateStructures(false);

World new_world = world_creator.createWorld();
new_world.setDifficulty(Difficulty.PEACEFUL);
Expand Down Expand Up @@ -67,10 +68,10 @@ public void constructSpleefArena() {
for (int z = -100; z < 100; z++) {
if (floor == floor_count) {
Block block = this.getWorld().getBlockAt(
new Location(this.getWorld(),
center_location.getX() + x,
center_location.getY() - (1 + (floor * wall_height)),
center_location.getZ() + z));
new Location(this.getWorld(),
center_location.getX() + x,
center_location.getY() - (1 + (floor * wall_height)),
center_location.getZ() + z));
block.setType(Material.BEDROCK);
continue;
}
Expand Down Expand Up @@ -137,6 +138,61 @@ public void constructSpleefArena() {
}
}

public void constructBlowBowArena() {
Location center_location = this.getCenterLocation();
this.arena_radius = Storage.config.getInt("config.blowbow.platform_radius", 32);
this.wall_height = 40;
double deg_per_turn = 1;

for (int x = -arena_radius * 5; x < arena_radius * 5; x++) {
for (int z = -arena_radius * 5; z < arena_radius * 5; z++) {
Location point = new Location(
this.getWorld(),
center_location.getX() + x,
center_location.getY() - 10,
center_location.getZ() + z);
Block block = this.getWorld().getBlockAt(point);
block.setType(Material.LAVA);
}
}

for (int x = -arena_radius; x < arena_radius; x++) {
for (int z = -arena_radius; z < arena_radius; z++) {
Location point = new Location(
this.getWorld(),
center_location.getX() + x,
center_location.getY() - 1,
center_location.getZ() + z);
double distance = Math
.sqrt(((point.getX() - center_location.getX()) * (point.getX() - center_location.getX()))
+ ((point.getZ() - center_location.getZ()) * (point.getZ() - center_location.getZ())));
boolean inside_check = distance < arena_radius;
if (!inside_check) {
continue;
}

Block block = this.getWorld().getBlockAt(point);
block.setType(Material.WHITE_CONCRETE);
}
}

for (int deg = 0; deg < 360; deg += deg_per_turn) {
double rads = Math.toRadians(deg);
double x_distance = Math.cos(rads) * (arena_radius * 2);
double z_distance = Math.sin(rads) * (arena_radius * 2);

for (int y_add = 0; y_add < wall_height; y_add++) {
Location block_location = new Location(
this.getWorld(),
center_location.getX() + x_distance,
center_location.getY() + y_add,
center_location.getZ() + z_distance);
Block block = this.getWorld().getBlockAt(block_location);
block.setType(Material.OBSIDIAN);
}
}
}

public void constructClassicArena() {
Location center_location = this.getCenterLocation();

Expand Down Expand Up @@ -213,6 +269,20 @@ public void teleportPlayerToWorldSpawn(Player player) {
teleport_count++;
}

public static Match getMatchFromWorld(DuelCraft duel_craft, World world) {
for (int i = 0; i < duel_craft.matches.size(); i++) {
Match match = duel_craft.matches.get(i);
DuelWorld duel_world = match.getDuelWorld();
World a_world = duel_world.getWorld();

if (a_world == world) {
return match;
}
}

return null;
}

public long getWorldID() {
return this.world_id;
}
Expand Down
22 changes: 3 additions & 19 deletions src/main/java/dev/ckay9/duelcraft/Duels/GUI/ClickHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ private void handleDuelTypeSelect(InventoryClickEvent event) {
case 11: // Spleef
match.setDuelType(DuelType.SPLEEF);
break;
case 12: // Blow Bow
match.setDuelType(DuelType.BLOWBOW);
break;
default:
break;
}
Expand Down Expand Up @@ -248,26 +251,11 @@ private void handleAdmin(InventoryClickEvent event) {
clicker.sendMessage(Utils.formatText("&2&l[DUELS] Successfully reset stats!"));
clicker.playSound(clicker, Sound.BLOCK_NOTE_BLOCK_BELL, 1, 1);
break;
case 12: // Config slot
Views.openConfigMenu(clicker);
break;
default:
break;
}
}

private void handleConfig(InventoryClickEvent event) {
Player clicker = (Player)event.getWhoClicked();
if (event.getSlot() == ClickTypes.BACK_CLOSE_LARGE_MENU) {
Views.openNavigationMenu(clicker, this.duels);
return;
}

if (!clicker.isOp()) {
return;
}
}

private void handleAbout(InventoryClickEvent event) {
Player clicker = (Player)event.getWhoClicked();
if (event.getSlot() == ClickTypes.BACK_CLOSE_SMALL_MENU) {
Expand Down Expand Up @@ -302,10 +290,6 @@ public void onGUIClick(InventoryClickEvent event) {
handleAdmin(event);
return;
}
if (inv_title.contains("Config")) {
handleConfig(event);
return;
}
if (inv_title.contains("About")) {
handleAbout(event);
return;
Expand Down
68 changes: 2 additions & 66 deletions src/main/java/dev/ckay9/duelcraft/Duels/GUI/Views.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ public static void openDuelTypeSelect(Player player) {

ItemStack bow_button = new ItemStack(Material.BOW, 1);
ItemMeta bow_meta = bow_button.getItemMeta();
bow_meta.setDisplayName(Utils.formatText("&0&lCOMING SOON..."));
bow_meta.setDisplayName(Utils.formatText("&c&lBLOW BOW"));
List<String> bow_lore = new ArrayList<>();
bow_lore.add(Utils.formatText("&0What's next???"));
bow_lore.add(Utils.formatText("&cTry to knock your opponent off the platform with &lEXPLOSIVE BOWS"));
bow_meta.setLore(bow_lore);
bow_button.setItemMeta(bow_meta);
duel_inventory.setItem(running_total++, bow_button);
Expand Down Expand Up @@ -201,15 +201,6 @@ public static void openAdminMenu(Player player) {
reset_stats_button.setItemMeta(reset_stats_meta);
admin_inventory.setItem(running_total++, reset_stats_button);

ItemStack config_menu_button = new ItemStack(Material.BEACON, 1);
ItemMeta config_menu_meta = config_menu_button.getItemMeta();
config_menu_meta.setDisplayName(Utils.formatText("&b&lCONFIG"));
List<String> cm_lore = new ArrayList<>();
cm_lore.add(Utils.formatText("&bEdit your DuelCraft settings/config. Requires manual restart to update config."));
config_menu_meta.setLore(cm_lore);
config_menu_button.setItemMeta(config_menu_meta);
admin_inventory.setItem(running_total++, config_menu_button);

player.openInventory(admin_inventory);
}

Expand Down Expand Up @@ -239,59 +230,4 @@ public static void openAboutMenu(Player player) {

player.openInventory(about_inventory);
}

public static void openConfigMenu(Player player) {
player.closeInventory();
if (!player.isOp()) {
return;
}

Inventory config_inventory = Bukkit.createInventory(null, 54, Utils.formatText("&c&lDuelCraft " + DuelCraft.duels_version + ": Config"));
config_inventory.clear();
int running_total = 0;

config_inventory.setItem(ClickTypes.BACK_CLOSE_LARGE_MENU, GUIHelpers.generateBackButton());

ItemStack set_armor_button = new ItemStack(Material.NETHERITE_HELMET, 1);
ItemMeta armor_meta = set_armor_button.getItemMeta();
armor_meta.setDisplayName(Utils.formatText("&9&lSET ARMOR"));
List<String> sa_lore = new ArrayList<>();
sa_lore.add(Utils.formatText("Set the default armor given in duels."));
sa_lore.add(Utils.formatText("&c&lThis will reset the existing armor settings."));
armor_meta.setLore(sa_lore);
set_armor_button.setItemMeta(armor_meta);
config_inventory.setItem(running_total++, set_armor_button);

ItemStack set_hotbar_button = new ItemStack(Material.GOLDEN_SWORD, 1);
ItemMeta hotbar_meta = set_hotbar_button.getItemMeta();
hotbar_meta.setDisplayName(Utils.formatText("&e&lSET HOTBAR"));
List<String> sh_lore = new ArrayList<>();
sh_lore.add(Utils.formatText("Set the default hotbar given in duels."));
sh_lore.add(Utils.formatText("&c&lThis will reset the existing hotbar settings."));
hotbar_meta.setLore(sh_lore);
set_hotbar_button.setItemMeta(hotbar_meta);
config_inventory.setItem(running_total++, set_hotbar_button);

ItemStack set_off_hand_button = new ItemStack(Material.SHIELD, 1);
ItemMeta off_hand_meta = set_off_hand_button.getItemMeta();
off_hand_meta.setDisplayName(Utils.formatText("&a&lSET OFF-HAND"));
List<String> oh_lore = new ArrayList<>();
oh_lore.add(Utils.formatText("Set the default off-hand item given in duels."));
oh_lore.add(Utils.formatText("&c&lThis will reset the existing off-hand settings."));
off_hand_meta.setLore(oh_lore);
set_off_hand_button.setItemMeta(off_hand_meta);
config_inventory.setItem(running_total++, set_off_hand_button);

ItemStack set_radius_button = new ItemStack(Material.OAK_FENCE, 1);
ItemMeta radius_meta = set_radius_button.getItemMeta();
radius_meta.setDisplayName(Utils.formatText("&2&lSET ARENA RADIUS"));
List<String> sr_lore = new ArrayList<>();
sr_lore.add(Utils.formatText("Set the default arena radius for duels."));
sr_lore.add(Utils.formatText("&c&lThis will reset the existing arena radius setting."));
radius_meta.setLore(sr_lore);
set_radius_button.setItemMeta(radius_meta);
config_inventory.setItem(running_total++, set_radius_button);

player.openInventory(config_inventory);
}
}
Loading

0 comments on commit 392c753

Please sign in to comment.