Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Drison64 authored Oct 26, 2019
1 parent dd73107 commit fea4975
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 41 deletions.
18 changes: 0 additions & 18 deletions me/Drison64/Lobby/ASclick.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,6 @@ public void clicked(Entity entity, Player player) {
if (entity.getType().equals(EntityType.ARMOR_STAND)) {
if (entity.getCustomName().equals(ChatColor.BLUE + "Daily Reward")) {
customConfig.reload();
/*
if (customConfig.get().isSet("dailyreward." + player.getName() + ".timestamp")) {
long now = Instant.now().getEpochSecond();
long finish = customConfig.get().getLong("dailyreward." + player.getName() + ".timestamp") + 86400;
player.openInventory(dailyReward.inv);
long seconds = (finish - now) % 60;
long hours = (finish - now) / 60;
long minutes = hours % 60;
hours = hours / 60;
if (!((finish - now) == 0)) {
dailyReward.inv.setItem(1, new ItemStack(mkitem.mkitem(1, Material.COAL, "Daily Reward", Arrays.asList("", "Next in " + hours + ":" + minutes + ":" + seconds))));
} else {
customConfig.get().set("dailyreward." + player.getName() + ".timestamp", null);
}
} else {
dailyReward.inv.setItem(1, new ItemStack(mkitem.mkitem(1, Material.DIAMOND, "Daily Reward", Arrays.asList("", "Click to get!"))));
}
*/
player.openInventory(dailyReward.inv);
} else if (entity.getCustomName().equals(ChatColor.BLUE + "Tic Tac Toe")) {
player.openInventory(Bukkit.createInventory(null, 27, "Tic tac toe menu"));
Expand Down
47 changes: 44 additions & 3 deletions me/Drison64/Lobby/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ public void run() {
customConfig.get().set(player.getUniqueId() + ".dr_timestamp", null);
customConfig.save();
}
} else {
if (!((finish - now) < 0)) {
player.getOpenInventory().getTopInventory().setItem(1, mkitem.mkitem(1, Material.COAL, "", Arrays.asList("", "Next in " + shours + ":" + sminutes + ":" + sseconds)));
player.updateInventory();
} else {
player.getOpenInventory().setItem(1, new ItemStack(mkitem.mkitem(1, Material.DIAMOND, "Daily Reward", Arrays.asList("", "Click to get!"))));
customConfig.get().set(player.getUniqueId() + ".dr_timestamp", null);
customConfig.save();
}
}
} else {
player.getOpenInventory().setItem(1, new ItemStack(mkitem.mkitem(1, Material.DIAMOND, "Daily Reward", Arrays.asList("", "Click to get!"))));
Expand Down Expand Up @@ -295,7 +304,25 @@ public void run() {
}
}
}
}, 0L, 2L);
}, 0L, 1L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
customConfig.reload();
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
objective.setDisplayName("Name");
Score score1 = objective.getScore("Coins: " + customConfig.get().get(player.getUniqueId() + ".coins"));
score1.setScore(9);
Score score = objective.getScore("");
score.setScore(10);
Score score2 = objective.getScore("");
score2.setScore(8);
player.setScoreboard(board);
}
}
}, 0L, 5L);
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -350,8 +377,6 @@ public void onJoin(PlayerJoinEvent e) {
customConfig.get().set(player.getUniqueId() + ".coins", 1000);
customConfig.save();
}
Score score1 = objective.getScore("Coins: " + customConfig.get().get(player.getUniqueId() + ".coins"));
score1.setScore(9);
player.setScoreboard(board);
player.setGameMode(GameMode.ADVENTURE);
Location spawn = new Location(Bukkit.getWorld("world"), 678.5, 127.5, -61.5, 180, 0);
Expand Down Expand Up @@ -425,4 +450,20 @@ public static Entity getAS(String type) {
return null;
}

public void updateScoreboard(Player player) {
Scoreboard sb = Bukkit.getScoreboardManager().getNewScoreboard();
Objective obj = sb.registerNewObjective("scoreboard", "dummy");
obj.setDisplaySlot(DisplaySlot.SIDEBAR);

customConfig.reload();
obj.setDisplayName("§6Server name");
obj.getScore("§6").setScore(5);
obj.getScore("§bHello " + player.getName()).setScore(4);
obj.getScore("§6").setScore(3);
obj.getScore("Coins: " + customConfig.get().getInt(player.getUniqueId() + ".coins")).setScore(2);
obj.getScore("§6").setScore(1);

player.setScoreboard(sb);
}

}
45 changes: 25 additions & 20 deletions me/Drison64/Lobby/dailyReward.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,32 @@ public void onInvClick(InventoryClickEvent e) {
e.setCancelled(true);
Player player = (Player) e.getWhoClicked();
if (e.getRawSlot() == 1) {
customConfig.get().set(player.getUniqueId() + ".dr_timestamp", Instant.now().getEpochSecond());
customConfig.save();
long now = Instant.now().getEpochSecond();
long finish = customConfig.get().getLong(player.getUniqueId() + ".dr_timestamp") + 10;
long seconds = (finish - now) % 60;
long hours = (finish - now) / 60;
long minutes = hours % 60;
hours = hours / 60;
String sseconds = String.valueOf(seconds);
String sminutes = String.valueOf(minutes);
String shours = String.valueOf(hours);
if (sseconds.length() == 1) {
sseconds = "0" + sseconds;
if (e.getView().getTopInventory().getItem(1).getType().equals(Material.DIAMOND)) {
customConfig.get().set(player.getUniqueId() + ".dr_timestamp", Instant.now().getEpochSecond());
customConfig.save();
long now = Instant.now().getEpochSecond();
long finish = customConfig.get().getLong(player.getUniqueId() + ".dr_timestamp") + 10;
long seconds = (finish - now) % 60;
long hours = (finish - now) / 60;
long minutes = hours % 60;
hours = hours / 60;
String sseconds = String.valueOf(seconds);
String sminutes = String.valueOf(minutes);
String shours = String.valueOf(hours);
if (sseconds.length() == 1) {
sseconds = "0" + sseconds;
}
if (sminutes.length() == 1) {
sminutes = "0" + sminutes;
}
if (shours.length() == 1) {
shours = "0" + shours;
}
player.getOpenInventory().getTopInventory().setItem(1, mkitem.mkitem(1, Material.COAL, "Daily Reward", Arrays.asList("", "Next in " + shours + ":" + sminutes + ":" + sseconds)));
customConfig.reload();
customConfig.get().set(player.getUniqueId() + ".coins", customConfig.get().getInt(player.getUniqueId() + ".coins") + 10);
customConfig.save();
}
if (sminutes.length() == 1) {
sminutes = "0" + sminutes;
}
if (shours.length() == 1) {
shours = "0" + shours;
}
player.getOpenInventory().getTopInventory().setItem(1, mkitem.mkitem(1, Material.COAL, "Daily Reward", Arrays.asList("", "Next in " + shours + ":" + sminutes + ":" + sseconds)));
}
}
}
Expand Down

0 comments on commit fea4975

Please sign in to comment.