Skip to content

Commit 29c2a2a

Browse files
committed
v1.2 Update
1 parent 1333296 commit 29c2a2a

18 files changed

+823
-365
lines changed

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
**What's this?** <br>
2-
A simple and easy to use plugin with which it is possible to configure cubes, which in turn can start a countdown after being filled with blocks (as well as other actions). The countdown as well as the actions can be fully customized and it even includes an API to customize the plugin perfectly for yourself (Java knowledge required)
2+
A simple and easy to use plugin with which it is possible to configure cubes, which in turn can start a countdown after
3+
being filled with blocks (as well as other actions). The countdown as well as the actions can be fully customized and it
4+
even includes an API to customize the plugin perfectly for yourself (Java knowledge required)
35

46
**Compatible Software:** TikFinity <br>
5-
**Compatible Plugins:** DelayedTNT
7+
**Compatible Plugins:** DelayedTNT, PlaceholderAPI
68

79
**Installation:** <br>
810
**1.** Download the newest version from Releases <br>
@@ -14,31 +16,49 @@ A simple and easy to use plugin with which it is possible to configure cubes, wh
1416
Setup is very easy! Once the plugin is installed, run the **/cc setup** command and follow the plugin's instructions
1517

1618
**Commands:**
17-
<br> /cubiccountdown **setup** - Starts the setup process in which 5 simple steps must be followed to add a cube (MAIN COMMAND)
19+
<br> /cubiccountdown **setup** - Starts the setup process in which 5 simple steps must be followed to add a cube (MAIN
20+
COMMAND)
21+
<br> /cubiccountdown **fill MAPNAME BLOCKTYPE1,BLOCKTYPE2,... AMOUNT1,AMOUNT2,...** - Fills the cube with an specific amount of specific blocks
22+
<br> /cubiccountdown **clear MAPNAME** - Clears the whole area inside the provided cube
1823
<br> /cubiccountdown **cancel MAPNAME** - Cancels a running countdown of a map
1924
<br> /cubiccountdown **delete MAPNAME** - Deletes an existing cube (which was created before with /cc setup)
2025
<br> /cubiccountdown **reload** - Reloads the Config and data files
26+
<br> /cubiccountdown **cubes** - Shows you all the cubes which you already created
2127
<br> /cubiccountdown **help** - Opens the help menu
28+
<br> /cubiccountdown **setEntry CONFIGKEY CONFIGVALUE** - With this command you are able to edit config entries easily without opening a file so it's easier for me to help people out on my discord. **Important:** Don't use this command if you don't know what you're doing
29+
30+
**PlaceholderAPI Support:**
31+
<br>You want to use the CubicCountdown statistics (like the wins, loses or games played) in another plugin (like a scoreboard plugin)? Now it is possible! If you're using a plugin which supports the PlaceholderAPI (the PlaceholderAPI plugin needs to be installed too), you're now able to use these placeholders in it:
32+
<br>
33+
<br>*Show the number of wins on a specific cube/map:* **%cc_win_counter_MAPNAME%**
34+
<br>*Show the number of loses on a specific cube/map:* **%cc_lose_counter_MAPNAME%**
35+
<br>*Show the number of games you played on a specific cube/map:* **%cc_games_played_MAPNAME%**
36+
<br>
37+
<br>**By the way:** If you're using version 1.2.0 or higher, you're also able to use placeholders from other plugins in the titles of the CubicCountdown plugin
2238

2339
**QAndA:**
2440
<br>**Q:** *Help! The plugin says that I do not have the permission to use the plugin commands!*
25-
<br>**A:** To solve this issue just open your server console and type the following command into the console: **op yourminecraftusername**
41+
<br>**A:** To solve this issue just open your server console and type the following command into the console: **op
42+
yourminecraftusername**
2643
<br>**Q:** *What is the first and second edge?*
2744
<br>**A:** This means the bottom corner and the diagonal top corner. The order doesn't matter
2845
<br>**Q:** *How can I change the title formatting, the sound effects,... of the plugin?*
29-
<br>**A:** This specific settings cannot be changed ingame. To change it, open your minecraft server folder, open the plugins and after that the CubicCountdown folder. If you open the config.yml you'll see many settings. Change it to your preferences, save the file, go back ingame and type **/cc reload** into the chat.
46+
<br>**A:** This specific settings cannot be changed ingame. To change it, open your minecraft server folder, open the
47+
plugins and after that the CubicCountdown folder. If you open the config.yml you'll see many settings. Change it to your
48+
preferences, save the file, go back ingame and type **/cc reload** into the chat.
3049

3150
**API:**
32-
<br> Currently there's no maven or gradle respository out yet. To get access to the api you need to add the JAR file from the releases tab to the build path of your project (in your IDEA). After that you're able to proceed:
51+
<br> Currently there's no maven or gradle repository out yet. To get access to the api you need to add the JAR file
52+
from the releases tab to the build path of your project (in your IDEA). After that you're able to proceed:
3353
<br> **COMING SOON**
3454

35-
**Tutorial:**
36-
<br>**COMING SOON**
55+
**Tutorials:**
56+
<br>English Tutorial by TikTokLive with Harry:
57+
<br>Spanish Tutorial:
3758

3859
**Support:** <br>
39-
You got any wishes or found any bug? Feel free to join my discord: https://discord.tikmc.de/
60+
You got any wishes or found any bug? Feel free to join my discord or open an issue on this github page: https://discord.tikmc.de/
4061

4162
**License:** <br>
4263
The source code as well as the JAR file may be used and modified for commercial as well as private
43-
purposes <br>
44-
64+
purposes <br>

src/main/java/de/timecoding/cc/CubicCountdown.java

Lines changed: 21 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,50 @@
99
import de.timecoding.cc.file.DataHandler;
1010
import de.timecoding.cc.listener.CubicListener;
1111
import de.timecoding.cc.util.CountdownModule;
12-
import de.timecoding.cc.util.type.Cube;
12+
import de.timecoding.cc.util.CubicAPI;
1313
import org.bukkit.Bukkit;
1414
import org.bukkit.command.PluginCommand;
1515
import org.bukkit.entity.Player;
1616
import org.bukkit.plugin.java.JavaPlugin;
1717

18-
import java.util.ArrayList;
1918
import java.util.HashMap;
2019
import java.util.List;
21-
import java.util.concurrent.atomic.AtomicBoolean;
22-
import java.util.concurrent.atomic.AtomicReference;
2320

2421
public class CubicCountdown extends JavaPlugin {
2522

2623
private ConfigHandler configHandler;
2724
private DataHandler dataHandler;
28-
private List<CountdownModule> countdownList = new ArrayList<>();
29-
private HashMap<Player, CubicSetup> setupList = new HashMap<>();
25+
private CubicAPI cubicAPI;
3026

3127
//FOR API USAGE ONLY
3228
private CubicCountdown plugin;
29+
private CubicListener cubicListener;
3330
private Metrics metrics = null;
3431

3532
public void onEnable() {
3633
this.plugin = this;
3734
this.configHandler = new ConfigHandler(this);
3835
this.dataHandler = new DataHandler(this);
39-
this.getServer().getPluginManager().registerEvents(new CubicListener(this), this);
36+
this.cubicListener = new CubicListener(this);
37+
this.getServer().getPluginManager().registerEvents(this.cubicListener, this);
38+
cubicAPI = new CubicAPI(this);
4039
PluginCommand pluginCommand = this.getCommand("cubiccountdown");
4140
pluginCommand.setExecutor(new CubicCommand(this));
4241
pluginCommand.setTabCompleter(new CubicCompleter(this));
4342
Bukkit.getConsoleSender().sendMessage("§cCubicCountdown §7(v" + this.getDescription().getVersion() + ") §aby §eTimeCode §awas enabled!");
4443
Bukkit.getConsoleSender().sendMessage("§cTHIS IS A BETA VERSION OF THE PLUGIN! PLEASE REPORT ALL ISSUES OR WISHES TO OUR DISCORD: https://discord.tikmc.de/");
45-
if(Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")){
44+
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
4645
Bukkit.getConsoleSender().sendMessage("§aSuccessfully registered the CubicCountdown §ePlaceholderAPI Expansion§a!");
4746
new CubicExpansion(this).register();
4847
}
49-
if(!configHandler.keyExists("bStats") || configHandler.getBoolean("bStats")){
48+
if (!configHandler.keyExists("bStats") || configHandler.getBoolean("bStats")) {
5049
this.metrics = new Metrics(this, 19676);
5150
}
52-
for(String key : plugin.getDataHandler().getConfig().getKeys(true)){
53-
if(key.endsWith("Wins") || key.endsWith("Loses")){
51+
cubicAPI.startActionbar();
52+
for (String key : plugin.getDataHandler().getConfig().getKeys(true)) {
53+
if (key.endsWith("Wins") || key.endsWith("Loses")) {
5454
plugin.getDataHandler().getConfig().set(key, null);
55-
Bukkit.getConsoleSender().sendMessage("§aSuccessfully deleted the §ewin and/or lose §acounter of the map §e"+key.split("\\.")[1]);
55+
Bukkit.getConsoleSender().sendMessage("§aSuccessfully deleted the §ewin and/or lose §acounter of the map §e" + key.split("\\.")[1]);
5656
plugin.getDataHandler().save();
5757
}
5858
}
@@ -62,15 +62,19 @@ public ConfigHandler getConfigHandler() {
6262
return configHandler;
6363
}
6464

65+
public CubicListener getCubicListener() {
66+
return cubicListener;
67+
}
68+
6569
public List<CountdownModule> getCountdownList() {
66-
return countdownList;
70+
return getCubicAPI().getCountdownList();
6771
}
6872

6973
public HashMap<Player, CubicSetup> getSetupList() {
70-
return setupList;
74+
return getCubicAPI().getSetupList();
7175
}
7276

73-
public CubicCountdown getPlugin() {
77+
public CubicCountdown getInstance() {
7478
return plugin;
7579
}
7680

@@ -82,89 +86,8 @@ public DataHandler getDataHandler() {
8286
return dataHandler;
8387
}
8488

85-
public List<Cube> getCubes() {
86-
List<String> cubeStringList = new ArrayList<>();
87-
for (String key : getDataHandler().getConfig().getValues(true).keySet()) {
88-
String[] keys = key.split("\\.");
89-
if (keys.length == 3 && !cubeStringList.contains(keys[1])) {
90-
cubeStringList.add(keys[1]);
91-
}
92-
}
93-
List<Cube> cubeList = new ArrayList<>();
94-
cubeStringList.forEach(string -> cubeList.add(new Cube(string, dataHandler.getLocation("Cube." + string + ".Pos1"), dataHandler.getLocation("Cube." + string + ".Pos2"), this)));
95-
return cubeList;
96-
}
97-
98-
public boolean viewingCountdown(Player player){
99-
AtomicBoolean viewing = new AtomicBoolean(false);
100-
getCountdownList().forEach(countdownModule -> {
101-
if(countdownModule.getCubicSettings().playerList().contains(player)){
102-
viewing.set(true);
103-
}
104-
});
105-
return viewing.get();
106-
}
107-
108-
public void removeCountdown(CountdownModule countdownModule){
109-
countdownList.forEach(countdownModule1 -> {
110-
if(countdownModule1.getCountdownId() == countdownModule.getCountdownId()){
111-
countdownList.remove(countdownModule1);
112-
}
113-
});
114-
}
115-
116-
public CountdownModule getCountdownModuleFromCube(Cube cube) {
117-
AtomicReference<CountdownModule> finalCountdownModule = new AtomicReference<>();
118-
countdownList.forEach(countdownModule -> {
119-
if (countdownModule.getCubicSettings().getCube().isSimilar(cube)) {
120-
finalCountdownModule.set(countdownModule);
121-
}
122-
});
123-
return finalCountdownModule.get();
124-
}
125-
126-
public Integer getWins(Cube cube){
127-
return getDataHandler().getInteger("Cube."+cube.getName()+".WinCounter");
128-
}
129-
130-
public Integer getWins(String cube){
131-
return getDataHandler().getInteger("Cube."+cube+".WinCounter");
132-
}
133-
134-
public void increaseWins(Cube cube){
135-
Integer integer = 1;
136-
if(getDataHandler().keyExists("Cube."+cube.getName()+".WinCounter")){
137-
integer = (getDataHandler().getInteger("Cube."+cube.getName()+".WinCounter")+1);
138-
}
139-
getDataHandler().getConfig().set("Cube."+cube.getName()+".WinCounter", integer);
140-
getDataHandler().save();
141-
}
142-
143-
public Integer getLoses(Cube cube){
144-
return getDataHandler().getInteger("Cube."+cube.getName()+".LoseCounter");
145-
}
146-
147-
public Integer getLoses(String cube){
148-
return getDataHandler().getInteger("Cube."+cube+".LoseCounter");
149-
}
150-
151-
public void increaseLoses(Cube cube){
152-
Integer integer = 1;
153-
if(getDataHandler().keyExists("Cube."+cube.getName()+".LoseCounter")){
154-
integer = (getDataHandler().getInteger("Cube."+cube.getName()+".LoseCounter")+1);
155-
}
156-
getDataHandler().getConfig().set("Cube."+cube.getName()+".LoseCounter", integer);
157-
getDataHandler().save();
158-
}
159-
160-
public boolean cubeNameExists(String name){
161-
AtomicBoolean exists = new AtomicBoolean(false);
162-
getCubes().forEach(cube -> {
163-
if(cube.getName().equalsIgnoreCase(name)){
164-
exists.set(true);
165-
}
166-
});
167-
return exists.get();
89+
public CubicAPI getCubicAPI() {
90+
return cubicAPI;
16891
}
16992

17093
}

src/main/java/de/timecoding/cc/api/CubicExpansion.java

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
import de.timecoding.cc.CubicCountdown;
44
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
55
import org.bukkit.OfflinePlayer;
6-
import org.bukkit.entity.Player;
76

87
public class CubicExpansion extends PlaceholderExpansion {
98

109
private CubicCountdown plugin;
1110

12-
public CubicExpansion(CubicCountdown plugin){
11+
public CubicExpansion(CubicCountdown plugin) {
1312
this.plugin = plugin;
1413
}
1514

1615
@Override
1716
public String getIdentifier() {
18-
return "CC_PAPI";
17+
return "cc";
1918
}
2019

2120
@Override
@@ -29,26 +28,33 @@ public String getVersion() {
2928
}
3029

3130
@Override
32-
public boolean persist(){
31+
public boolean persist() {
3332
return true;
3433
}
3534

3635
@Override
3736
public String onRequest(OfflinePlayer player, String params) {
38-
if(params.startsWith("%win_counter_") && params.endsWith("%")){
39-
String cubeName = params.substring(13, (params.length()-1));
40-
if(plugin.cubeNameExists(cubeName)){
41-
return plugin.getWins(cubeName).toString();
42-
}else{
37+
if (params.startsWith("win_counter_")) {
38+
String cubeName = params.substring(12);
39+
if (plugin.getCubicAPI().cubeNameExists(cubeName)) {
40+
return plugin.getCubicAPI().getWins(cubeName).toString();
41+
} else {
42+
return null;
43+
}
44+
} else if (params.startsWith("lose_counter_")) {
45+
String cubeName = params.substring(13);
46+
if (plugin.getCubicAPI().cubeNameExists(cubeName)) {
47+
return plugin.getCubicAPI().getLoses(cubeName).toString();
48+
} else {
49+
return null;
50+
}
51+
} else if (params.startsWith("games_played_")) {
52+
String cubeName = params.substring(13);
53+
if (plugin.getCubicAPI().cubeNameExists(cubeName)) {
54+
return plugin.getCubicAPI().getGamesPlayed(cubeName).toString();
55+
} else {
4356
return null;
4457
}
45-
}else if(params.startsWith("%lose_counter_") && params.endsWith("%")){
46-
String cubeName = params.substring(14, (params.length()-1));
47-
if(plugin.cubeNameExists(cubeName)){
48-
return plugin.getLoses(cubeName).toString();
49-
}else{
50-
return null;
51-
}
5258
}
5359
return null;
5460
}

0 commit comments

Comments
 (0)