├── .gitignore
├── LICENSE
├── README.md
├── pom.xml
└── src
└── main
├── java
└── me
│ └── hulipvp
│ └── chambers
│ ├── Chambers.java
│ ├── claim
│ ├── ClaimManager.java
│ ├── listener
│ │ ├── ClaimInteractListener.java
│ │ ├── ClaimMoveListener.java
│ │ └── ClaimProfileListener.java
│ └── structure
│ │ ├── Claim.java
│ │ ├── ClaimProfile.java
│ │ └── Pillar.java
│ ├── command
│ ├── ChambersCommand.java
│ └── commands
│ │ ├── BalanceCommand.java
│ │ ├── KothCommand.java
│ │ ├── PayCommand.java
│ │ ├── ToggleBoardCommand.java
│ │ └── VillagerCommand.java
│ ├── config
│ └── DataFile.java
│ ├── event
│ ├── ChambersEvent.java
│ └── movements
│ │ ├── PlayerEnterClaimEvent.java
│ │ └── PlayerLeaveClaimEvent.java
│ ├── game
│ ├── GameManager.java
│ ├── command
│ │ ├── GameCommand.java
│ │ └── general
│ │ │ ├── GameSetCountdownCommand.java
│ │ │ ├── GameSetKothNameCommand.java
│ │ │ ├── GameSetLobbyCommand.java
│ │ │ ├── GameSetMapNameCommand.java
│ │ │ ├── GameStartCommand.java
│ │ │ └── GameStopCommand.java
│ ├── listener
│ │ ├── GameDamageListener.java
│ │ ├── GameInteractListener.java
│ │ └── GameProtectionListener.java
│ └── structure
│ │ ├── Game.java
│ │ └── GameStatus.java
│ ├── koth
│ ├── KothManager.java
│ ├── listener
│ │ └── KothMoveListener.java
│ └── structure
│ │ └── Koth.java
│ ├── listener
│ ├── ListenerManager.java
│ └── listeners
│ │ ├── ChatListener.java
│ │ ├── EnderpearlListener.java
│ │ ├── PlayerDeathListener.java
│ │ ├── PlayerRespawnListener.java
│ │ ├── ProfileListener.java
│ │ └── ProfileStatusListener.java
│ ├── profile
│ ├── ProfileManager.java
│ └── structure
│ │ ├── ChatStatus.java
│ │ ├── Profile.java
│ │ └── ProfileStatus.java
│ ├── scoreboard
│ ├── PlayerScoreboard.java
│ ├── ScoreboardManager.java
│ ├── ScoreboardProvider.java
│ ├── ScoreboardWrapper.java
│ └── provider
│ │ ├── EndProvider.java
│ │ ├── IngameProvider.java
│ │ ├── LobbyProvider.java
│ │ └── ProviderResolver.java
│ ├── shop
│ ├── VillagerManager.java
│ └── structure
│ │ └── VillagerType.java
│ ├── task
│ ├── CountdownTask.java
│ ├── GameTask.java
│ ├── KothTask.java
│ └── RespawnTask.java
│ ├── team
│ ├── TeamManager.java
│ ├── command
│ │ ├── TeamCommand.java
│ │ ├── admin
│ │ │ ├── TeamBypassCommand.java
│ │ │ ├── TeamClaimCommand.java
│ │ │ ├── TeamForceJoinCommand.java
│ │ │ ├── TeamForceLeaveCommand.java
│ │ │ ├── TeamForcePlaceCommand.java
│ │ │ ├── TeamSetDtrCommand.java
│ │ │ ├── TeamSetHomeCommand.java
│ │ │ └── TeamSetVillagerCommand.java
│ │ └── normal
│ │ │ ├── TeamChatCommand.java
│ │ │ ├── TeamHelpCommand.java
│ │ │ ├── TeamLocationCommand.java
│ │ │ └── TeamShowCommand.java
│ ├── listener
│ │ ├── TeamBlockListener.java
│ │ ├── TeamDamageListener.java
│ │ ├── TeamDeathListener.java
│ │ └── TeamInteractListener.java
│ └── structure
│ │ ├── Team.java
│ │ └── TeamType.java
│ └── util
│ ├── Color.java
│ ├── ItemUtil.java
│ ├── LocationUtil.java
│ ├── MathUtil.java
│ └── commandapi
│ ├── BukkitCommand.java
│ ├── BukkitCompleter.java
│ ├── Command.java
│ ├── CommandArgs.java
│ ├── CommandFramework.java
│ └── Completer.java
└── resources
├── data.yml
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | ###########################################################
2 | # Big thanks to colinmcdonald22 for the .gitignore format #
3 | ###########################################################
4 |
5 | ###########
6 | # Eclipse #
7 | ###########
8 |
9 | .classpath
10 | .project
11 | .settings/
12 |
13 | ############
14 | # IntelliJ #
15 | ############
16 |
17 | .idea/
18 | *.iml
19 | *.iws
20 |
21 | #######
22 | # Mac #
23 | #######
24 |
25 | .DS_Store
26 |
27 |
28 | #########
29 | # Maven #
30 | #########
31 |
32 | log/
33 | target/
34 |
35 | ###################
36 | # Compiled source #
37 | ###################
38 |
39 | *.com
40 | *.class
41 | *.dll
42 | *.exe
43 | *.o
44 | *.so
45 |
46 | ############
47 | # Packages #
48 | ############
49 |
50 | *.7z
51 | *.dmg
52 | *.gz
53 | *.iso
54 | *.rar
55 | *.tar
56 | *.zip
57 |
58 | ######################
59 | # Logs and databases #
60 | ######################
61 |
62 | *.log
63 | *.sql
64 | *.sqlite
65 |
66 | ######################
67 | # OS generated files #
68 | ######################
69 |
70 | .DS_Store
71 | .DS_Store?
72 | ._*
73 | .Spotlight-V100
74 | .Trashes
75 | ehthumbs.db
76 | Thumbs.db
77 |
78 | bin/*.yml
79 |
80 | .classpath
81 |
82 | .project
83 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Zach Sills
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chambers
2 | This plugin is a replica of FrozenOrb's popular gamemode called Bunkers. I will only work on it when I have time to work on it, so please do not contact me to update it for a certain reason. It will be free and open-source, and because of that, it will all be hard-coded. If you wish to edit the messages, than clone the repository and then edit the messages yourself.
3 |
4 | ## FAQ
5 | Frequently asked questions on the topic of this project.
6 |
7 | ### May I use the source and build upon it to make my own version of the project?
8 | This project is under an MIT license, so you may as long as you keep a copy of the license
9 | in the project at all times.
10 |
11 | ### Can I contribute to this project?
12 | Of course you can, just make a Pull Request and I will look through it.
13 |
14 | ### Where can I report bugs, issues, and suggestions?
15 | You can contact me through any of the following platforms:
16 | ```
17 | MCM: HuliPvP
18 | Spigot: HuliPvP
19 | Discord: HuliPvP#1242
20 | E-Mail: support@projectbyte.org
21 | ```
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 |
5 | Chambers
6 | me.hulipvp.chambers
7 | 0.0.1-SNAPSHOT
8 |
9 |
10 | UTF-8
11 |
12 |
13 |
14 | src/main/java
15 |
16 |
17 | 3.6.1
18 | org.apache.maven.plugins
19 | maven-compiler-plugin
20 |
21 | 1.8
22 | 1.8
23 |
24 |
25 |
26 |
27 |
28 | src/main/resources
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
36 | spigotmc-repo
37 | https://hub.spigotmc.org/nexus/content/groups/public/
38 |
39 |
40 | sonatype
41 | https://oss.sonatype.org/content/groups/public/
42 |
43 |
44 |
45 |
46 |
47 | org.spigotmc
48 | spigot-api
49 | 1.8.8-R0.1-SNAPSHOT
50 |
51 |
52 | org.projectlombok
53 | lombok
54 | 1.16.16
55 | provided
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/Chambers.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers;
2 |
3 | import lombok.Getter;
4 | import me.hulipvp.chambers.claim.ClaimManager;
5 | import me.hulipvp.chambers.command.ChambersCommand;
6 | import me.hulipvp.chambers.command.commands.*;
7 | import me.hulipvp.chambers.config.DataFile;
8 | import me.hulipvp.chambers.game.GameManager;
9 | import me.hulipvp.chambers.game.command.GameCommand;
10 | import me.hulipvp.chambers.game.command.general.*;
11 | import me.hulipvp.chambers.koth.KothManager;
12 | import me.hulipvp.chambers.listener.ListenerManager;
13 | import me.hulipvp.chambers.profile.ProfileManager;
14 | import me.hulipvp.chambers.scoreboard.ScoreboardWrapper;
15 | import me.hulipvp.chambers.scoreboard.provider.ProviderResolver;
16 | import me.hulipvp.chambers.shop.VillagerManager;
17 | import me.hulipvp.chambers.team.TeamManager;
18 | import me.hulipvp.chambers.team.command.TeamCommand;
19 | import me.hulipvp.chambers.team.command.admin.*;
20 | import me.hulipvp.chambers.team.command.normal.TeamChatCommand;
21 | import me.hulipvp.chambers.team.command.normal.TeamHelpCommand;
22 | import me.hulipvp.chambers.team.command.normal.TeamLocationCommand;
23 | import me.hulipvp.chambers.team.command.normal.TeamShowCommand;
24 | import me.hulipvp.chambers.util.commandapi.CommandFramework;
25 | import org.bukkit.plugin.java.JavaPlugin;
26 |
27 | /**
28 | * Copyright (c) 2017 Zach Sills
29 | *
30 | * Permission is hereby granted, free of charge, to any person obtaining a copy
31 | * of this software and associated documentation files (the "Software"), to deal
32 | * in the Software without restriction, including without limitation the rights
33 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
34 | * copies of the Software, and to permit persons to whom the Software is
35 | * furnished to do so, subject to the following conditions:
36 | *
37 | * The above copyright notice and this permission notice shall be included in
38 | * all copies or substantial portions of the Software.
39 | *
40 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
45 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46 | * SOFTWARE.
47 | */
48 | @Getter
49 | public class Chambers extends JavaPlugin {
50 |
51 | /* SINGLE, like me, plugin instance */
52 | @Getter
53 | private static Chambers instance;
54 |
55 | /* Game Managers */
56 | private ClaimManager claimManager;
57 | private GameManager gameManager;
58 | private KothManager kothManager;
59 | private ProfileManager profileManager;
60 | private TeamManager teamManager;
61 | private ListenerManager listenerManager;
62 | private VillagerManager villagerManager;
63 |
64 | /* Scoreboard */
65 | private ScoreboardWrapper scoreboardWrapper;
66 |
67 | /* Commands & Listeners */
68 | private CommandFramework commandFramework;
69 |
70 | /* Data Files */
71 | private DataFile dataFile;
72 |
73 | public void onEnable() {
74 |
75 | instance = this;
76 |
77 | dataFile = new DataFile(this, "data");
78 |
79 | claimManager = new ClaimManager();
80 | gameManager = new GameManager();
81 | kothManager = new KothManager();
82 | profileManager = new ProfileManager();
83 | teamManager = new TeamManager();
84 | listenerManager = new ListenerManager();
85 | villagerManager = new VillagerManager();
86 |
87 | scoreboardWrapper = new ScoreboardWrapper(this, new ProviderResolver());
88 |
89 | commandFramework = new CommandFramework(this);
90 |
91 | registerAllCommands();
92 |
93 | }
94 |
95 | public void onDisable() {
96 | gameManager.clearAllMobs();
97 | }
98 |
99 | private void registerAllCommands() {
100 | new ChambersCommand();
101 | new BalanceCommand();
102 | new GameCommand();
103 | new GameStartCommand();
104 | new GameStopCommand();
105 | new GameSetCountdownCommand();
106 | new GameSetKothNameCommand();
107 | new GameSetLobbyCommand();
108 | new GameSetMapNameCommand();
109 | new KothCommand();
110 | new PayCommand();
111 | new ToggleBoardCommand();
112 | new VillagerCommand();
113 | new TeamCommand();
114 | new TeamBypassCommand();
115 | new TeamClaimCommand();
116 | new TeamForceJoinCommand();
117 | new TeamForceLeaveCommand();
118 | new TeamForcePlaceCommand();
119 | new TeamSetDtrCommand();
120 | new TeamSetHomeCommand();
121 | new TeamSetVillagerCommand();
122 | new TeamChatCommand();
123 | new TeamHelpCommand();
124 | new TeamLocationCommand();
125 | new TeamShowCommand();
126 | }
127 |
128 | }
129 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/ClaimManager.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim;
2 |
3 | import java.util.Arrays;
4 | import java.util.HashSet;
5 | import java.util.Set;
6 |
7 | import org.bukkit.Location;
8 | import org.bukkit.Material;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import me.hulipvp.chambers.Chambers;
12 | import me.hulipvp.chambers.claim.structure.Claim;
13 | import me.hulipvp.chambers.claim.structure.ClaimProfile;
14 | import me.hulipvp.chambers.profile.structure.Profile;
15 | import me.hulipvp.chambers.team.structure.Team;
16 | import me.hulipvp.chambers.team.structure.TeamType;
17 | import me.hulipvp.chambers.util.ItemUtil;
18 | import net.md_5.bungee.api.ChatColor;
19 |
20 | public class ClaimManager {
21 |
22 | private Set claims;
23 | private Set claimers;
24 |
25 | /**
26 | * Just initializes all of the private fields so they're not null, Nothing
27 | * surprising
28 | */
29 | public ClaimManager() {
30 |
31 | claims = new HashSet<>();
32 | claimers = new HashSet<>();
33 |
34 | }
35 |
36 | /**
37 | * Will return null if no Claim is found at that certain Location
38 | * provided
39 | *
40 | * @param location - the Location you wish to find a claim at
41 | * @return Claim - A claim that is found surrounding the provided location
42 | * @see {@link Claim#isInsideClaim(Location)}
43 | */
44 | public Claim getClaimAt(Location location) {
45 | return claims.stream().filter(claim -> claim.isInsideClaim(location)).findFirst().orElse(null);
46 | }
47 |
48 | /**
49 | * Attempts to find a claim with the same owner Faction as the provided
50 | * Faction
51 | * Will return null if no Claim with the same owner Faction is not
52 | * found
53 | *
54 | * @param owner - the Team you wish to see has a claim
55 | * @return Claim - A claim with the same owner Faction as the one provided
56 | * @see {@link Claim#getOwner()}
57 | */
58 | public Claim getClaimByTeam(Team owner) {
59 | return claims.stream().filter(claim -> claim.getOwner() == owner).findFirst().orElse(null);
60 | }
61 |
62 | /**
63 | * Return the Team at a certain Location
64 | * Will return the Team Wilderness if no claim is found at the provided Location
65 | *
66 | * @param location - the Location at which you wish to find the Claim of a Team at
67 | * @return Team - the Team that has a claim at that Location
68 | */
69 | public Team getTeamAt(Location location) {
70 | Claim claim = getClaimAt(location);
71 | return claim == null ? Chambers.getInstance().getTeamManager().getTeamByType(TeamType.WILDERNESS) : claim.getOwner();
72 | }
73 |
74 | /**
75 | * Adds a Claim to the Set of claims if the Claim is already
76 | * created
77 | *
78 | * @param claim
79 | * - the Claim you wish to store
80 | */
81 | public void addClaim(Claim claim) {
82 | claims.add(claim);
83 | }
84 |
85 | /**
86 | * Instantiates a new claim and then stores it to the Set
87 | *
88 | * @param cornerOne - the first corner Location of the claim
89 | * @param cornerTwo - the second corner Location of the claim
90 | * @param owner - the owner Faction of the claim
91 | */
92 | public void addClaim(Location cornerOne, Location cornerTwo, Team owner) {
93 | claims.add(new Claim(cornerOne, cornerTwo, owner));
94 | }
95 |
96 | /**
97 | * Simply removes a claim stores in the Set
98 | *
99 | * @param claim - the Claim you wish to remove
100 | */
101 | public void removeClaim(Claim claim) {
102 | claims.remove(claim);
103 | }
104 |
105 | /**
106 | * Get a ClaimProfile of a Profile to see whether has initiated a Claim sequence or not
107 | * Will return null if no ClaimProfile was found with the provided Profile
108 | *
109 | * @param profile - the Profile of the ClaimProfile you wish to find
110 | * @return ClaimProfile - a ClaimProfile with a matching Profile as the one provided
111 | */
112 | public ClaimProfile getClaimProfile(Profile profile) {
113 | return claimers.stream().filter(claimProfile -> claimProfile.getProfile() == profile).findFirst().orElse(null);
114 | }
115 |
116 | /**
117 | * Check to see whether a player is claiming or not
118 | *
119 | * @param profile - the Profile of the player that you wish to see has initiated a claim sequence
120 | * @return boolean - Returns true if the ClaimProfile is not null, however returns false if no ClaimProfile was found
121 | */
122 | public boolean isClaiming(Profile profile) {
123 | return getClaimProfile(profile) != null;
124 | }
125 |
126 | /**
127 | * Add a new ClaimProfile and then store it to manage it
128 | *
129 | * @param profile - the Profile you wish to store in the ClaimProfile
130 | */
131 | public void addClaimProfile(Profile profile) {
132 | claimers.add(new ClaimProfile(profile));
133 | }
134 |
135 | /**
136 | * Removes a ClaimProfile from the Set of ClaimProfiles... obviously
137 | *
138 | * @param profile - the Profile of the ClaimProfile you wish to remove
139 | */
140 | public void removeClaimProfile(Profile profile) {
141 | ClaimProfile claimProfile = getClaimProfile(profile);
142 | claimProfile.clearPillars();
143 | claimers.remove(claimProfile);
144 | }
145 |
146 | /**
147 | * Get the Claiming wand Item to be able to claim Team territories
148 | *
149 | * @return ItemStack - the Claiming Wand
150 | */
151 | public ItemStack getClaimingWand() {
152 | return new ItemUtil(Material.GOLD_HOE).name(ChatColor.GREEN + "Claiming Wand").lore(Arrays.asList(
153 | ChatColor.GREEN + "Right Click " + ChatColor.BLUE + "Block " + ChatColor.YELLOW + "to select Corner 1", " ",
154 | ChatColor.GREEN + "Left Click " + ChatColor.BLUE + "Block " + ChatColor.YELLOW + "to select Corner 2", " ",
155 | ChatColor.GREEN + "Shift + Left Click " + ChatColor.BLUE + "Air " + ChatColor.YELLOW + "to Cancel selection", " ",
156 | ChatColor.GREEN + "Shift + Right Click " + ChatColor.BLUE + "Air " + ChatColor.YELLOW + "to Claim selection"))
157 | .build();
158 | }
159 |
160 | }
161 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/listener/ClaimInteractListener.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.listener;
2 |
3 | import org.bukkit.ChatColor;
4 | import org.bukkit.Material;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.block.Action;
9 | import org.bukkit.event.player.PlayerInteractEvent;
10 |
11 | import me.hulipvp.chambers.Chambers;
12 | import me.hulipvp.chambers.claim.structure.Claim;
13 | import me.hulipvp.chambers.claim.structure.ClaimProfile;
14 | import me.hulipvp.chambers.claim.structure.Pillar;
15 | import me.hulipvp.chambers.profile.structure.Profile;
16 | import me.hulipvp.chambers.util.LocationUtil;
17 |
18 | public class ClaimInteractListener implements Listener {
19 |
20 | @EventHandler
21 | public void onInteract(PlayerInteractEvent event) {
22 | Player player = event.getPlayer();
23 | if (player.getItemInHand() == null || player.getItemInHand().getType() != Material.GOLD_HOE) {
24 | return;
25 | }
26 | Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(player.getUniqueId());
27 | if (!Chambers.getInstance().getClaimManager().isClaiming(profile)) {
28 | return;
29 | }
30 | if (profile.getTeam() == null || profile.getTeam().getType().getClaimMaterial() == null) {
31 | player.sendMessage(ChatColor.RED + "Please join a Team to claim for.");
32 | return;
33 | }
34 | ClaimProfile claimProfile = Chambers.getInstance().getClaimManager().getClaimProfile(profile);
35 | Action action = event.getAction();
36 | event.setCancelled(true);
37 | switch (action) {
38 | case RIGHT_CLICK_BLOCK: {
39 | if (claimProfile.getCornerOne() != null) {
40 | claimProfile.getPillarOne().remove();
41 | claimProfile.setPillarOne(null);
42 | }
43 | claimProfile.setCornerOne(event.getClickedBlock().getLocation());
44 | Pillar pillar = new Pillar(event.getPlayer(), event.getClickedBlock().getLocation(), profile.getTeam().getType().getClaimMaterial());
45 | claimProfile.setPillarOne(pillar);
46 | pillar.display();
47 | profile.sendMessage(ChatColor.GRAY + "Selected corner 1 for " + profile.getTeam().getFormattedName() + ChatColor.GRAY + ".");
48 | break;
49 | }
50 | case LEFT_CLICK_BLOCK: {
51 | if (claimProfile.getCornerTwo() != null) {
52 | claimProfile.getPillarTwo().remove();
53 | claimProfile.setPillarTwo(null);
54 | }
55 | claimProfile.setCornerTwo(event.getClickedBlock().getLocation());
56 | Pillar pillar = new Pillar(event.getPlayer(), event.getClickedBlock().getLocation(), profile.getTeam().getType().getClaimMaterial());
57 | claimProfile.setPillarTwo(pillar);
58 | pillar.display();
59 | profile.sendMessage(ChatColor.GRAY + "Selected corner 2 for " + profile.getTeam().getFormattedName() + ChatColor.GRAY + ".");
60 | break;
61 | }
62 | case LEFT_CLICK_AIR: {
63 | if (player.isSneaking()) {
64 | claimProfile.clearPillars();
65 | claimProfile.setCornerOne(null);
66 | claimProfile.setCornerTwo(null);
67 | player.sendMessage(ChatColor.GREEN + "Selection cleared.");
68 | }
69 | break;
70 | }
71 | case RIGHT_CLICK_AIR: {
72 | if (player.isSneaking()) {
73 | claimProfile.clearPillars();
74 | Claim claim = new Claim(claimProfile.getCornerOne(), claimProfile.getCornerTwo(), profile.getTeam());
75 | profile.getTeam().setClaim(claim);
76 | Chambers.getInstance().getClaimManager().addClaim(claim);
77 | Chambers.getInstance().getDataFile().getConfiguration().set("TEAMS." + profile.getTeam().getType().name() + ".CORNERONE", LocationUtil.serializeLocation(claimProfile.getCornerOne()));
78 | Chambers.getInstance().getDataFile().getConfiguration().set("TEAMS." + profile.getTeam().getType().name() + ".CORNERTWO", LocationUtil.serializeLocation(claimProfile.getCornerTwo()));
79 | Chambers.getInstance().getDataFile().save();
80 | Chambers.getInstance().getDataFile().load();
81 | Chambers.getInstance().getClaimManager().removeClaimProfile(profile);
82 | player.getInventory().removeItem(Chambers.getInstance().getClaimManager().getClaimingWand());
83 | player.sendMessage(ChatColor.GRAY + "Selection claimed for " + profile.getTeam().getFormattedName() + ChatColor.GRAY + ".");
84 | }
85 | break;
86 | }
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/listener/ClaimMoveListener.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.listener;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.Location;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerMoveEvent;
10 |
11 | import me.hulipvp.chambers.Chambers;
12 | import me.hulipvp.chambers.event.movements.PlayerEnterClaimEvent;
13 | import me.hulipvp.chambers.event.movements.PlayerLeaveClaimEvent;
14 | import me.hulipvp.chambers.game.structure.Game;
15 | import me.hulipvp.chambers.game.structure.GameStatus;
16 | import me.hulipvp.chambers.team.structure.Team;
17 | import me.hulipvp.chambers.team.structure.TeamType;
18 |
19 | public class ClaimMoveListener implements Listener {
20 |
21 | @EventHandler
22 | public void onMove(PlayerMoveEvent event) {
23 | Game game = Chambers.getInstance().getGameManager().getGame();
24 | if (game.getStatus() != GameStatus.INGAME) {
25 | return;
26 | }
27 | Location to = event.getTo();
28 | Location from = event.getFrom();
29 | if (to.getBlockX() != from.getBlockX() || to.getBlockZ() != from.getBlockZ()) {
30 | Player player = event.getPlayer();
31 | Team toTeam = Chambers.getInstance().getClaimManager().getTeamAt(to);
32 | Team fromTeam = Chambers.getInstance().getClaimManager().getTeamAt(from);
33 | if (toTeam != fromTeam) {
34 | Bukkit.getPluginManager().callEvent(new PlayerEnterClaimEvent(player, toTeam.getClaim()));
35 | Bukkit.getPluginManager().callEvent(new PlayerLeaveClaimEvent(player, fromTeam.getClaim()));
36 | if (toTeam.getType() == TeamType.KOTH_CAP || fromTeam.getType() == TeamType.KOTH_CAP) {
37 | return;
38 | }
39 | player.sendMessage(ChatColor.YELLOW + "Now leaving: " + fromTeam.getFormattedName());
40 | player.sendMessage(ChatColor.YELLOW + "Now entering: " + toTeam.getFormattedName());
41 | }
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/listener/ClaimProfileListener.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.listener;
2 |
3 | import org.bukkit.event.EventHandler;
4 | import org.bukkit.event.Listener;
5 | import org.bukkit.event.player.PlayerEvent;
6 | import org.bukkit.event.player.PlayerKickEvent;
7 | import org.bukkit.event.player.PlayerQuitEvent;
8 |
9 | import me.hulipvp.chambers.Chambers;
10 | import me.hulipvp.chambers.profile.structure.Profile;
11 |
12 | public class ClaimProfileListener implements Listener {
13 |
14 | public void removeClaimProfile(PlayerEvent event) {
15 | Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId());
16 | if (Chambers.getInstance().getClaimManager().isClaiming(profile)) {
17 | Chambers.getInstance().getClaimManager().removeClaimProfile(profile);
18 | }
19 | }
20 |
21 | @EventHandler
22 | public void onQuit(PlayerQuitEvent event) {
23 | removeClaimProfile(event);
24 | }
25 |
26 | @EventHandler
27 | public void onKick(PlayerKickEvent event) {
28 | removeClaimProfile(event);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/structure/Claim.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.structure;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.entity.Player;
5 |
6 | import lombok.AllArgsConstructor;
7 | import lombok.Getter;
8 | import lombok.Setter;
9 | import me.hulipvp.chambers.team.structure.Team;
10 |
11 | @AllArgsConstructor
12 | @Getter
13 | @Setter
14 | public class Claim {
15 |
16 | private Location cornerOne, cornerTwo;
17 |
18 | private Team owner;
19 |
20 | /**
21 | * Returns true if the provided Location is inside the claim.
22 | * However, it returns false if the provided Location is not inside
23 | * the claim
24 | *
25 | * @param location - the Location in which you wish to see is inside the claim
26 | * @return boolean - Whether or not the provided Location is inside the claim or not
27 | */
28 | public boolean isInsideClaim(Location location) {
29 | return (location.getBlockX() >= Math.min(cornerOne.getBlockX(), cornerTwo.getBlockX()))
30 | && (location.getBlockZ() >= Math.min(cornerOne.getBlockZ(), cornerTwo.getBlockZ()))
31 | && (location.getBlockX() <= Math.max(cornerOne.getBlockX(), cornerTwo.getBlockX()))
32 | && (location.getBlockZ() <= Math.max(cornerOne.getBlockZ(), cornerTwo.getBlockZ()));
33 | }
34 |
35 | /**
36 | * Returns true if the Player's location is inside the claim.
37 | * However, it returns false if the Player's location is not inside
38 | * the claim
39 | *
40 | * It's just a faster way instead of doing
41 | * {@link Claim#isInsideClaim(player.getLocation)}, cuz I'm just that lazy
42 | *
43 | * @param player - the Player in which you wish to see is inside the claim
44 | * @return boolean - Whether or not the player's location is inside the claim or not
45 | */
46 | public boolean isInsideClaim(Player player) {
47 | return isInsideClaim(player.getLocation());
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/structure/ClaimProfile.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.structure;
2 |
3 | import java.util.UUID;
4 |
5 | import org.bukkit.Location;
6 |
7 | import lombok.Getter;
8 | import lombok.Setter;
9 | import me.hulipvp.chambers.profile.structure.Profile;
10 |
11 | @Getter
12 | @Setter
13 | public class ClaimProfile {
14 |
15 | private UUID uuid;
16 | private Profile profile;
17 | private Location cornerOne, cornerTwo;
18 | private Pillar pillarOne, pillarTwo;
19 |
20 | /**
21 | * Constructs a new {@link ClaimProfile}
22 | *
23 | * @param profile - the Profile you wish to make a ClaimProfile for
24 | */
25 | public ClaimProfile(Profile profile) {
26 | this.uuid = profile.getId();
27 | this.profile = profile;
28 | this.cornerOne = null;
29 | this.cornerTwo = null;
30 | this.pillarOne = null;
31 | this.pillarTwo = null;
32 | }
33 |
34 | /**
35 | * Removes the pillar displays and then sets the pillars to null
36 | */
37 | public void clearPillars() {
38 | if (this.pillarOne != null) {
39 | this.pillarOne.remove();
40 | this.setPillarOne(null);
41 | }
42 | if (this.pillarTwo != null) {
43 | this.pillarTwo.remove();
44 | this.setPillarTwo(null);
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/claim/structure/Pillar.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.claim.structure;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.UUID;
6 |
7 | import org.bukkit.Location;
8 | import org.bukkit.Material;
9 | import org.bukkit.entity.Player;
10 |
11 | import lombok.Getter;
12 |
13 | @Getter
14 | public class Pillar {
15 |
16 | private UUID claimerId;
17 | private Player claimer;
18 | private Location location;
19 | private Material material;
20 |
21 | public Pillar(Player claimer, Location location, Material material) {
22 | this.claimerId = claimer.getUniqueId();
23 | this.claimer = claimer;
24 | this.location = location;
25 | this.material = material;
26 | }
27 |
28 | public void display() {
29 | List values = new ArrayList<>();
30 | for (int i = 0; i <= 256; i++) {
31 | Location location = new Location(this.getLocation().getWorld(), this.location.getBlockX(), i, this.location.getBlockZ());
32 | if (location.getBlock().getType() == Material.AIR && claimer != null) {
33 | if (values.contains(location.getBlockY())) {
34 | this.claimer.sendBlockChange(location, this.material, (byte) 0);
35 | this.claimer.sendBlockChange(location.add(0.0, 2.0, 0.0), Material.GLASS, (byte) 0);
36 | } else {
37 | this.claimer.sendBlockChange(location, Material.GLASS, (byte) 0);
38 | values.add(location.getBlockY() + 2);
39 | }
40 | }
41 | }
42 | }
43 |
44 | public void remove() {
45 | Location loc = null;
46 | for (int i = 0; i <= 256; i++) {
47 | loc = new Location(this.location.getWorld(), this.location.getBlockX(), i, this.location.getBlockZ());
48 | if (loc.getBlock().getType() == Material.AIR) {
49 | this.claimer.sendBlockChange(loc, Material.AIR, (byte) 0);
50 | }
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/ChambersCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command;
2 |
3 | import me.hulipvp.chambers.Chambers;
4 | import me.hulipvp.chambers.util.Color;
5 | import me.hulipvp.chambers.util.commandapi.Command;
6 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
7 |
8 | public class ChambersCommand {
9 |
10 | public Chambers plugin = Chambers.getInstance();
11 |
12 | public ChambersCommand() {
13 | plugin.getCommandFramework().registerCommands(this);
14 | plugin.getCommandFramework().registerHelp();
15 | }
16 |
17 | @Command(name = "chambers", description = "Get information about the plugin", aliases = { "bunkers" }, usage = "/")
18 | public void onCommand(CommandArgs commandArgs) {
19 | commandArgs.getSender().sendMessage(Color.color("&e" + plugin.getDescription().getName() + " " + plugin.getDescription().getVersion() + "&f by " + "&eHuliPvP"));
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/commands/BalanceCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command.commands;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.entity.Player;
6 |
7 | import me.hulipvp.chambers.profile.structure.Profile;
8 | import me.hulipvp.chambers.command.ChambersCommand;
9 | import me.hulipvp.chambers.util.commandapi.Command;
10 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
11 |
12 | public class BalanceCommand extends ChambersCommand {
13 |
14 | @Command(name = "balance", description = "See how much money a player has", aliases = { "bal", "checkbalance", "money", "checkmoney" }, usage = "/", playerOnly = true, requiresTeam = true)
15 | public void onCommand(CommandArgs commandArgs) {
16 | if (commandArgs.length() == 0) {
17 | Profile profile = plugin.getProfileManager().getProfileByUuid(commandArgs.getPlayer().getUniqueId());
18 | commandArgs.getPlayer().sendMessage(ChatColor.YELLOW + "Balance: " + ChatColor.GREEN + profile.getBalance());
19 | return;
20 | }
21 | Player target = Bukkit.getPlayer(commandArgs.getArgs(0));
22 | if (target == null) {
23 | commandArgs.getPlayer().sendMessage(ChatColor.RED + "That player is not online.");
24 | return;
25 | }
26 | Profile profile = plugin.getProfileManager().getProfileByUuid(target.getUniqueId());
27 | commandArgs.getPlayer().sendMessage(ChatColor.YELLOW + target.getName() + "'s Balance: " + ChatColor.GREEN + profile.getBalance());
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/commands/KothCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command.commands;
2 |
3 | import me.hulipvp.chambers.koth.structure.Koth;
4 | import me.hulipvp.chambers.command.ChambersCommand;
5 | import me.hulipvp.chambers.util.commandapi.Command;
6 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
7 | import net.md_5.bungee.api.ChatColor;
8 |
9 | public class KothCommand extends ChambersCommand {
10 |
11 | @Command(name = "koth", description = "See info about the Koth", aliases = { "checkkoth" }, usage = "/", playerOnly = true)
12 | public void onCommand(CommandArgs commandArgs) {
13 | Koth koth = plugin.getKothManager().getKoth();
14 | if (koth == null) {
15 | commandArgs.getPlayer().sendMessage(plugin.getKothManager().getKothFormat() + ChatColor.UNDERLINE + plugin.getGameManager().getGame().getKothName() + ChatColor.RESET.toString() + ChatColor.YELLOW + " is not running.");
16 | } else {
17 | commandArgs.getPlayer().sendMessage(plugin.getKothManager().getKothFormat() + ChatColor.UNDERLINE + plugin.getGameManager().getGame().getKothName() + ChatColor.RESET.toString() + ChatColor.YELLOW + " is able to be contested.");
18 | }
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/commands/PayCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command.commands;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.entity.Player;
6 |
7 | import me.hulipvp.chambers.profile.structure.Profile;
8 | import me.hulipvp.chambers.util.MathUtil;
9 | import me.hulipvp.chambers.command.ChambersCommand;
10 | import me.hulipvp.chambers.util.commandapi.Command;
11 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
12 |
13 | public class PayCommand extends ChambersCommand {
14 |
15 | @Command(name = "pay", description = "Send a player some money", aliases = { "sendmoney", "givemoney" }, usage = "/", playerOnly = true, requiresTeam = true)
16 | public void onCommand(CommandArgs commandArgs) {
17 | Profile profile = plugin.getProfileManager().getProfileByUuid(commandArgs.getPlayer().getUniqueId());
18 | if (commandArgs.length() != 2) {
19 | commandArgs.getPlayer().sendMessage(ChatColor.RED + "Usage: /" + commandArgs.getLabel() + " ");
20 | return;
21 | }
22 | Player target = Bukkit.getPlayer(commandArgs.getArgs(0));
23 | if (target == null) {
24 | commandArgs.getPlayer().sendMessage(ChatColor.RED + "That player is not online.");
25 | return;
26 | }
27 | Profile targetProfile = plugin.getProfileManager().getProfileByUuid(target.getUniqueId());
28 | if (targetProfile.getTeam() == null || profile.getTeam() != targetProfile.getTeam()) {
29 | profile.sendMessage(ChatColor.RED + "That player is not on your team!");
30 | return;
31 | }
32 | if (!MathUtil.isInt(commandArgs.getArgs(1))) {
33 | profile.sendMessage(ChatColor.RED + "Please enter a valid amount.");
34 | return;
35 | }
36 | int amount = Integer.valueOf(commandArgs.getArgs(1));
37 | if (profile.getBalance() < amount) {
38 | profile.sendMessage(ChatColor.RED + "You only have: $" + profile.getBalance());
39 | return;
40 | }
41 | profile.withdraw(amount);
42 | targetProfile.deposit(amount);
43 | profile.sendMessage(ChatColor.YELLOW + "You have sent " + ChatColor.RED + "$" + amount + ChatColor.YELLOW + " to " + ChatColor.GREEN + commandArgs.getArgs(1) + ChatColor.YELLOW + ".");
44 | targetProfile.sendMessage(ChatColor.YELLOW + "You have recieved " + ChatColor.GREEN + "$" + amount + ChatColor.YELLOW + " from " + ChatColor.GREEN + commandArgs.getSender().getName() + ChatColor.YELLOW + ".");
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/commands/ToggleBoardCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command.commands;
2 |
3 | import org.bukkit.ChatColor;
4 |
5 | import me.hulipvp.chambers.profile.structure.Profile;
6 | import me.hulipvp.chambers.command.ChambersCommand;
7 | import me.hulipvp.chambers.util.commandapi.Command;
8 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
9 |
10 | public class ToggleBoardCommand extends ChambersCommand {
11 |
12 | @Command(name = "toggleboard", description = "Toggle your scoreboard on and off", aliases = { "togglesb", "togglescoreboard", "hideboard", "showboard" }, usage = "/", playerOnly = true, requiresTeam = false)
13 | public void onCommand(CommandArgs commandArgs) {
14 | Profile profile = plugin.getProfileManager().getProfileByUuid(commandArgs.getPlayer().getUniqueId());
15 | profile.setHidingScoreboard(profile.isHidingScoreboard() ? false : true);
16 | profile.sendMessage(ChatColor.YELLOW + "Scoreboard has been " + (profile.isHidingScoreboard() ? ChatColor.RED + "disabled" : ChatColor.GREEN + "enabled") + ChatColor.YELLOW + ".");
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/command/commands/VillagerCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.command.commands;
2 |
3 | import me.hulipvp.chambers.command.ChambersCommand;
4 | import me.hulipvp.chambers.shop.structure.VillagerType;
5 | import me.hulipvp.chambers.util.commandapi.Command;
6 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
7 | import org.bukkit.ChatColor;
8 |
9 | import java.util.Arrays;
10 |
11 | public class VillagerCommand extends ChambersCommand {
12 |
13 | @Command(name = "villager", description = "Spawn in Shop Villagers", aliases = { "spawnvillager" }, usage = "/", playerOnly = true, requiresTeam = false, adminsOnly = true)
14 | public void onCommand(CommandArgs commandArgs) {
15 | if (commandArgs.length() != 1) {
16 | commandArgs.getPlayer().sendMessage(ChatColor.RED + "Usage: /" + commandArgs.getLabel() + " ");
17 | return;
18 | }
19 | String argument = commandArgs.getArgs(0);
20 | if (argument.equalsIgnoreCase("all")) {
21 | plugin.getVillagerManager().spawnAllVillagers();
22 | commandArgs.getPlayer().sendMessage(ChatColor.GREEN + "All Villagers have been spawned.");
23 | } else {
24 | VillagerType villagerType = VillagerType.getTypeFromString(commandArgs.getArgs(0));
25 | if (villagerType == null) {
26 | commandArgs.getPlayer().sendMessage(ChatColor.RED + "Invalid Villager type. Use one the following:");
27 | Arrays.stream(VillagerType.values()).forEach(type -> commandArgs.getPlayer().sendMessage(type.getFormattedName()));
28 | return;
29 | }
30 | plugin.getVillagerManager().spawnVillager(villagerType, commandArgs.getPlayer().getLocation());
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/config/DataFile.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.config;
2 |
3 | import me.hulipvp.chambers.util.Color;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.plugin.java.JavaPlugin;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.util.Arrays;
11 | import java.util.Collections;
12 | import java.util.List;
13 | import java.util.stream.Collectors;
14 |
15 | /**
16 | * I'm too lazy to ask alex for permission to use this class, so I typed
17 | * everything line by line so basically this class wasn't written by him. But
18 | * I'll still give that kid some credit. So here it goes - this class was
19 | * created by bizarrealex
20 | * (but I still typed it out line by line)
21 | *
22 | * @author bizarrealex
23 | */
24 | public class DataFile {
25 |
26 | private File file;
27 | private YamlConfiguration configuration;
28 |
29 | public DataFile(JavaPlugin plugin, String name) {
30 | file = new File(plugin.getDataFolder(), name + ".yml");
31 |
32 | if (!file.getParentFile().exists()) {
33 | file.getParentFile().mkdir();
34 | }
35 |
36 | plugin.saveResource(name + ".yml", false);
37 |
38 | configuration = YamlConfiguration.loadConfiguration(file);
39 | }
40 |
41 | /**
42 | * Loads the file
43 | * You can also use this method to reload the file
44 | */
45 | public void load() {
46 | configuration = YamlConfiguration.loadConfiguration(file);
47 | }
48 |
49 | /**
50 | * If you don't understand this, why are you even reading this
51 | */
52 | public void save() {
53 | try {
54 | configuration.save(file);
55 | } catch (IOException e) {
56 | e.printStackTrace();
57 | }
58 | }
59 |
60 | /**
61 | * Get the configuration so you can access it
62 | *
63 | * @return configuration - the YamlConfiguration object
64 | */
65 | public YamlConfiguration getConfiguration() {
66 | return configuration;
67 | }
68 |
69 | /**
70 | * Retrieve a double from the file
71 | * Will return as 0.0 if no double by the path name was found
72 | *
73 | * @param path - the path of the double you're looking for
74 | * @return double - the double which is found in the provided path
75 | */
76 | public double getDouble(String path) {
77 | if (configuration.contains(path)) {
78 | return configuration.getDouble(path);
79 | }
80 | return 0.0;
81 | }
82 |
83 | /**
84 | * Get an int from the file
85 | * Will returin as 0 is no int was found in the provided path
86 | *
87 | * @param path - the path of the integer value that you're looking for
88 | * @return int - the int which was found in the provided path
89 | */
90 | public int getInt(String path) {
91 | if (configuration.contains(path)) {
92 | return configuration.getInt(path);
93 | }
94 | return 0;
95 | }
96 |
97 | /**
98 | * Retrieve a boolean value from the file
99 | * Will return as a default value of false if there was nothing
100 | * found in the provided path
101 | *
102 | * @param path - the path of the boolean that you're looking for
103 | * @return boolean - the boolean which was found in the provided path
104 | */
105 | public boolean getBoolean(String path) {
106 | if (configuration.contains(path)) {
107 | return configuration.getBoolean(path);
108 | }
109 | return false;
110 | }
111 |
112 | /**
113 | * Retrieve a String from the file
114 | * Will return an empty String if there was no String found in the provided
115 | * path
116 | *
117 | * @param path - the path of the String you're looking for
118 | * @return String - the String which was found in the provided path
119 | */
120 | public String getString(String path) {
121 | if (configuration.contains(path)) {
122 | return ChatColor.translateAlternateColorCodes('&', configuration.getString(path));
123 | }
124 | return null;
125 | }
126 |
127 | /**
128 | * Retrieve a List of Strings from the file
129 | * Will return a list saying the path is invalid is no String List is found
130 | * in the provided path
131 | *
132 | * @param path - the path you wish to find a String list at
133 | * @return strings - a List of Strings which was found in the provided path
134 | */
135 | public List getStringList(String path) {
136 | if (configuration.contains(path)) {
137 | return configuration.getStringList(path).stream().map(Color::color).collect(Collectors.toList());
138 | }
139 | return Arrays.asList("Invalid path.");
140 | }
141 |
142 | /**
143 | * Simply reverses a String list
144 | * I'm not really sure why this is needed, but okay
145 | *
146 | * @param path - the path you wish to find a String list at
147 | * @return list - a List of Strings that are in reversed order from which it
148 | * was found
149 | */
150 | public List getReversedStringList(String path) {
151 | List list = getStringList(path);
152 | if (list != null) {
153 | Collections.reverse(list);
154 | return list;
155 | }
156 | return Arrays.asList("Invalid path.");
157 | }
158 |
159 | }
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/event/ChambersEvent.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.event;
2 |
3 | import org.bukkit.event.Event;
4 | import org.bukkit.event.HandlerList;
5 |
6 | /**
7 | * The main Event class to extend upon when creating a custom Event
8 | * called by Chambers
9 | */
10 | public class ChambersEvent extends Event {
11 |
12 | private static final HandlerList HANDLERS = new HandlerList();
13 |
14 | public HandlerList getHandlers() {
15 | return HANDLERS;
16 | }
17 |
18 | public static HandlerList getHandlerList() {
19 | return HANDLERS;
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/event/movements/PlayerEnterClaimEvent.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.event.movements;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | import lombok.AllArgsConstructor;
6 | import lombok.Getter;
7 | import me.hulipvp.chambers.claim.structure.Claim;
8 | import me.hulipvp.chambers.event.ChambersEvent;
9 |
10 | /**
11 | * The Event that is called when a Player enters a new Claim
12 | */
13 | @AllArgsConstructor
14 | @Getter
15 | public class PlayerEnterClaimEvent extends ChambersEvent {
16 |
17 | private Player player;
18 | private Claim claim;
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/event/movements/PlayerLeaveClaimEvent.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.event.movements;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | import lombok.AllArgsConstructor;
6 | import lombok.Getter;
7 | import me.hulipvp.chambers.claim.structure.Claim;
8 | import me.hulipvp.chambers.event.ChambersEvent;
9 |
10 | /**
11 | * The Event that is called when a Player leaves a Claim
12 | */
13 | @AllArgsConstructor
14 | @Getter
15 | public class PlayerLeaveClaimEvent extends ChambersEvent {
16 |
17 | private Player player;
18 | private Claim claim;
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/game/GameManager.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.game;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.GameMode;
6 | import org.bukkit.Material;
7 | import org.bukkit.entity.EntityType;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.inventory.ItemStack;
10 | import org.bukkit.scheduler.BukkitRunnable;
11 |
12 | import lombok.Getter;
13 | import me.hulipvp.chambers.Chambers;
14 | import me.hulipvp.chambers.game.structure.Game;
15 | import me.hulipvp.chambers.game.structure.GameStatus;
16 | import me.hulipvp.chambers.task.CountdownTask;
17 | import me.hulipvp.chambers.task.GameTask;
18 | import me.hulipvp.chambers.team.structure.Team;
19 |
20 | @Getter
21 | public class GameManager {
22 |
23 | private Game game;
24 |
25 | public GameManager() {
26 |
27 | game = new Game(GameStatus.LOBBY);
28 |
29 | }
30 |
31 | /**
32 | * Starts the Game
33 | */
34 | public void start() {
35 | game.setStatus(GameStatus.STARTING);
36 | Bukkit.getOnlinePlayers().stream().forEach(player -> player.getInventory().clear());
37 | new CountdownTask().runTaskTimerAsynchronously(Chambers.getInstance(), 0L, 20L);
38 | Bukkit.broadcastMessage(ChatColor.YELLOW + "The countdown is now starting");
39 | }
40 |
41 | /**
42 | * Stops the Game
43 | */
44 | public void stop(Team winner) {
45 | game.setWinner(winner);
46 | game.setStatus(GameStatus.OVER);
47 | game.setTotalTime(0);
48 | clearAllMobs();
49 | Bukkit.getOnlinePlayers().stream().forEach(player -> {
50 | Bukkit.getOnlinePlayers().stream().forEach(other -> {
51 | player.showPlayer(other);
52 | other.showPlayer(player);
53 | });
54 | player.setGameMode(GameMode.CREATIVE);
55 | player.getInventory().clear();
56 | player.updateInventory();
57 | player.getInventory().setArmorContents(null);
58 | player.setHealth(20.0);
59 | player.setFoodLevel(20);
60 | player.setFireTicks(0);
61 | player.setGameMode(GameMode.SURVIVAL);
62 | player.setExp(0.0F);
63 | player.setAllowFlight(true);
64 | player.setFlying(true);
65 | player.getActivePotionEffects().stream().forEach(effect -> player.removePotionEffect(effect.getType()));
66 | });
67 | Bukkit.getScheduler().scheduleSyncRepeatingTask(Chambers.getInstance(), new BukkitRunnable() {
68 | int time = 15;
69 | @Override
70 | public void run() {
71 | if (time == -2) {
72 | Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart");
73 | } else if (time == 0) {
74 | Bukkit.getOnlinePlayers().stream().forEach(player -> player.kickPlayer("Thanks for playing Chambers beta, join back soon!"));
75 | } else if (time % 2 == 0) {
76 | Bukkit.broadcastMessage(ChatColor.YELLOW + (winner == null ? "The game was forcefully stopped." : "The team " + winner.getFormattedName() + ChatColor.YELLOW + "has won the game!"));
77 | }
78 | time--;
79 | }
80 | }, 0, 20L);
81 | }
82 |
83 | /**
84 | * Attempts to start the Game
85 | */
86 | public void tryStart() {
87 | if (Bukkit.getOnlinePlayers().size() == 20) {
88 | start();
89 | }
90 | }
91 |
92 | /**
93 | * Finally starts the game after the countdown
94 | *
95 | * You have to load the chunk because the player could probably spawn in the
96 | * ground if the chunk is not loaded when the player is teleported
97 | */
98 | public void finallyStart() {
99 | game.setStatus(GameStatus.INGAME);
100 | Chambers.getInstance().getTeamManager().getAllPlayerTeams().stream().forEach(team -> {
101 | if (!team.getHome().getChunk().isLoaded()) {
102 | team.getHome().getChunk().load();
103 | }
104 | team.getOnlinePlayers().stream().forEach(player -> {
105 | giveStartingItems(player);
106 | player.setGameMode(GameMode.SURVIVAL);
107 | player.setAllowFlight(false);
108 | player.setFlying(false);
109 | player.teleport(team.getHome());
110 | });
111 | });
112 | new GameTask().runTaskTimerAsynchronously(Chambers.getInstance(), 0L, 20L);
113 | Bukkit.broadcastMessage(" ");
114 | Bukkit.broadcastMessage(ChatColor.YELLOW + "The game has now started! Good luck!");
115 | Bukkit.broadcastMessage(" ");
116 | }
117 |
118 | /**
119 | * Give a player their starting items
120 | *
121 | * @param player - the Player you wish to give the items to
122 | */
123 | public void giveStartingItems(Player player) {
124 | player.getInventory().clear();
125 | player.getInventory().setArmorContents(null);
126 | player.getInventory().addItem(new ItemStack(Material.IRON_PICKAXE, 1));
127 | player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 16));
128 | player.getInventory().addItem(new ItemStack(Material.IRON_AXE, 1));
129 | }
130 |
131 | /**
132 | * Remove all of the Mobs on the server
133 | */
134 | public void clearAllMobs() {
135 | Bukkit.getServer().getWorlds().forEach(world -> {
136 | world.getEntities().forEach(entity -> {
137 | if (!(entity instanceof Player)) {
138 | entity.remove();
139 | }
140 | if (entity.getType() == EntityType.VILLAGER) {
141 | entity.remove();
142 | }
143 | });
144 | });
145 | }
146 |
147 | }
148 |
--------------------------------------------------------------------------------
/src/main/java/me/hulipvp/chambers/game/command/GameCommand.java:
--------------------------------------------------------------------------------
1 | package me.hulipvp.chambers.game.command;
2 |
3 | import me.hulipvp.chambers.Chambers;
4 | import me.hulipvp.chambers.game.structure.Game;
5 | import me.hulipvp.chambers.util.Color;
6 | import me.hulipvp.chambers.util.commandapi.Command;
7 | import me.hulipvp.chambers.util.commandapi.CommandArgs;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.entity.Player;
10 |
11 | public class GameCommand {
12 |
13 | public Chambers plugin = Chambers.getInstance();
14 |
15 | public GameCommand() {
16 | plugin.getCommandFramework().registerCommands(this);
17 | plugin.getCommandFramework().registerHelp();
18 | }
19 |
20 | @Command(name = "game", description = "The main command to manage the Game", aliases = { "managegame" }, usage = "/", requiresTeam = false, adminsOnly = true)
21 | public void onCommand(CommandArgs commandArgs) {
22 | Player player = (Player) commandArgs.getSender();
23 | Game game = plugin.getGameManager().getGame();
24 | if (game == null) {
25 | commandArgs.getSender().sendMessage(ChatColor.RED+ "There is no game to manage. Please restart this server as an error had occured while enabling the plugin.");
26 | return;
27 | }
28 | showHelp(player);
29 | }
30 |
31 | public void showHelp(Player player) {
32 | player.sendMessage(Color.color("&6&m-------------------------------------------------------------"));
33 | player.sendMessage(Color.color("&d&lGame Help&7 - &fInformation on how to use faction command"));
34 | player.sendMessage(Color.color("&6&m-------------------------------------------------------------"));
35 | player.sendMessage(Color.color("&9General Commands:"));
36 | player.sendMessage(Color.color("&e/game start &7- Start the game"));
37 | player.sendMessage(Color.color("&e/game stop [Optional: ] &7- Stop the game"));
38 | player.sendMessage(Color.color("&e/game setcountdown