Skip to content

Commit

Permalink
Version 1.3.4a (integrated reload system and code optimization)
Browse files Browse the repository at this point in the history
  • Loading branch information
Draww committed Feb 9, 2018
1 parent 85f4d9e commit a732e79
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 71 deletions.
181 changes: 118 additions & 63 deletions .idea/workspace.xml

Large diffs are not rendered by default.

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>com.drawwdev</groupId>
<artifactId>Raffle</artifactId>
<version>1.3.4</version>
<version>1.3.4a</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/drawwdev/raffle/CustomRaffle.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class CustomRaffle extends Raffle {
private String name;

public CustomRaffle(String id) {
super(Main.getInstance().getConfigs().get("custom").getConfig().getInt("CustomRaffles" + id + ".time"), null, null, Main.getInstance().getConfigs().get("custom").getConfig().getString("CustomRaffles" + id + ".datatype", ""), RaffleType.CUSTOM);
super(Main.getInstance().getConfigs().get("custom").getConfig().getInt("CustomRaffles." + id + ".time"), null, null, Main.getInstance().getConfigs().get("custom").getConfig().getString("CustomRaffles." + id + ".datatype", ""), RaffleType.CUSTOM);
config = Main.getInstance().getConfigs().get("custom");
actions = config.getConfig().getStringList("CustomRaffles" + id + ".actions");
predicate = config.getConfig().getStringList("CustomRaffles" + id + ".predicate");
name = config.getConfig().getString("CustomRaffles" + id + ".name");
actions = config.getConfig().getStringList("CustomRaffles." + id + ".actions");
predicate = config.getConfig().getStringList("CustomRaffles." + id + ".predicate");
name = config.getConfig().getString("CustomRaffles." + id + ".name");
setConsumer((player, raffleData, fromPlayer) -> Main.getInstance().getScriptSystem().executeActions(player, getActions(), raffleData));
setPredicate((player, raffleData) -> {
Boolean r = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/drawwdev/raffle/RaffleBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RaffleBuilder {

public RaffleBuilder(RaffleStorage raffle, String raffleName){
this.raffle = raffle;
this.raffleName = raffleName.toUpperCase();
this.raffleName = raffleName;
this.raffleType = RaffleType.NORMAL;
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/drawwdev/raffle/RaffleCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,17 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
player.sendMessage(cc("&f- &b" + r + "&7(" + raffle.getDatatype() + ") " + state));
}
}
} else if (args[0].equalsIgnoreCase("reload")){
plugin.reloadConfig();
Main.getInstance().getConfigs().get("custom").load();
getRaffleManager().reload();
player.sendMessage(cc(plugin.getConfig().getString("prefix") + " &7All systems reloaded and restored!"));
} else if (args[0].equalsIgnoreCase("help")) {
player.sendMessage(cc("&6o0=======&c[&eRaffle Help&c]&6========0o"));
player.sendMessage(cc("&b/" + label + " start <type> <data> &f- &e" + "Starting a raffle"));
player.sendMessage(cc("&b/" + label + " stop &f- &e" + "Stop the raffle"));
player.sendMessage(cc("&b/" + label + " types &f- &e" + "RaffleStorage types"));
player.sendMessage(cc("&b/" + label + " reload &f- &e" + "Reloads the all systems"));
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/drawwdev/raffle/RaffleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void loadCustomRaffle(){
if (raffleStorage.getAllKey().stream().noneMatch(p -> p.equals(custom))){
CustomRaffle customRaffle = new CustomRaffle(custom);
try {
raffleStorage.newBuilder(customRaffle.getName())
raffleStorage.newBuilder(customRaffle.getName().toUpperCase())
.setType(RaffleType.CUSTOM)
.setTime(customRaffle.getTime())
.setDatatype(customRaffle.getDatatype())
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/drawwdev/raffle/RaffleManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public RaffleManager(Main plugin) {
reset();
}

public void reload(){
reset();
raffleStorage = new RaffleLoader(plugin, new RaffleStorage(plugin)).load();
}

public void start(Player player, String raffleName, RaffleData raffleData, String... nonGroup) throws RaffleException {
if (getStatus()) throw new RaffleException(" &7There's a raffle going on!");
if (getRaffleStorage().getConsumer(raffleName) == null)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Raffle
main: com.drawwdev.raffle.Main
version: 1.3.4
version: 1.3.4a
author: drawwdev
commands:
raffle:
Expand Down

0 comments on commit a732e79

Please sign in to comment.