Skip to content

Commit 9d72fd3

Browse files
committed
Bingo v1
1 parent d26151d commit 9d72fd3

File tree

10 files changed

+35
-12
lines changed

10 files changed

+35
-12
lines changed
439 Bytes
Binary file not shown.
Binary file not shown.
268 Bytes
Binary file not shown.
2.75 KB
Binary file not shown.
213 Bytes
Binary file not shown.

src/fr/azrotho/bingo/Main.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,43 @@
44
import fr.azrotho.bingo.commands.DebugCommand;
55
import fr.azrotho.bingo.events.OnJoin;
66
import fr.azrotho.bingo.events.PlayerInventory;
7+
import fr.azrotho.bingo.utils.Checker;
78
import fr.azrotho.bingo.utils.Timer;
89
import org.bukkit.Material;
910
import org.bukkit.inventory.ItemStack;
1011
import org.bukkit.plugin.java.JavaPlugin;
1112

12-
import java.util.ArrayList;
13-
import java.util.Arrays;
14-
import java.util.List;
13+
import java.util.*;
1514

1615
public class Main extends JavaPlugin {
1716
public static ArrayList<ItemStack> materialsIniatial;
1817
public static int timer = 0;
1918
public static Boolean isStarted = false;
19+
private static HashMap<UUID,Integer> score;
2020

2121

2222

2323
@Override
2424
public void onEnable() {
25+
score = new HashMap<>();
2526
System.out.println("Bingo plugin enabled");
2627
getCommand("debug").setExecutor(new DebugCommand());
2728
getCommand("bingo").setExecutor(new BingoCommand());
2829
getServer().getPluginManager().registerEvents(new PlayerInventory(), this);
2930
getServer().getPluginManager().registerEvents(new OnJoin(), this);
3031
Timer timer = new Timer();
3132
timer.runTaskTimer(this, 0, 20);
32-
33+
Checker checker = new Checker();
34+
checker.runTaskTimer(this, 0, 10);
3335
}
3436

3537
@Override
3638
public void onDisable() {
3739
System.out.println("Bingo plugin disabled");
3840
}
41+
42+
public static HashMap<UUID, Integer> getScore() {
43+
return score;
44+
}
3945
}
46+

src/fr/azrotho/bingo/commands/BingoCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public class BingoCommand implements CommandExecutor {
1414
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
1515
if(Main.isStarted){
1616
Player p = (Player) commandSender;
17-
Inventory inv = Bukkit.createInventory(null, 45, "§c§lItems à trouver");
17+
Inventory inv = Bukkit.createInventory(null, 54, "§c§lItems à trouver");
1818
p.openInventory(inv);
19-
for(int i = 0; i < 45; i++){
19+
for(int i = 0; i < 54; i++){
2020
inv.setItem(i, Main.materialsIniatial.get(i));
2121
}
2222

src/fr/azrotho/bingo/commands/DebugCommand.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ public boolean onCommand(CommandSender commandSender, Command command, String s,
3232

3333
p.setHealth(20);
3434
p.setFoodLevel(20);
35+
Main.getScore().put(p.getUniqueId(), 0);
3536
}
3637
int current = 0;
3738
Material[] materials = Material.values();
3839
List<Material> materialList = Arrays.asList(materials);
3940
Collections.shuffle(materialList);
40-
// Todo: Take 25 items random from the list of materials
41+
4142
ArrayList<ItemStack> itms = new ArrayList<ItemStack>();
42-
for (int i = 0; i < 45; i++) {
43+
for (int i = 0; i < 54; i++) {
4344
if(current == 1000){
4445
break;
4546
}

src/fr/azrotho/bingo/utils/Checker.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package fr.azrotho.bingo.utils;
22

3+
import fr.azrotho.bingo.Main;
34
import org.bukkit.Bukkit;
45
import org.bukkit.Material;
56
import org.bukkit.entity.Player;
@@ -13,11 +14,22 @@ public void run() {
1314
for(ItemStack m : fr.azrotho.bingo.Main.materialsIniatial){
1415
if(p.getInventory().contains(m)){
1516
p.getInventory().remove(m);
17+
Main.materialsIniatial.remove(m);
18+
Main.materialsIniatial.add(new ItemStack(Material.BARRIER));
1619
p.sendMessage("§c§lBINGO! §fVous avez trouvé un item !");
17-
Bukkit.broadcastMessage("§c§lBINGO! §f" + p.getName() + " a trouvé un item !");
20+
Main.getScore().put(p.getUniqueId(), Main.getScore().get(p.getUniqueId()) + 1);
21+
Bukkit.broadcastMessage("§c§lBINGO! §f" + p.getName() + " a trouvé un item ! §7(" + Main.getScore().get(p.getUniqueId()) + "/10)");
22+
}
23+
}
24+
if(Main.getScore().get(p.getUniqueId()).equals(10)){
25+
Bukkit.broadcastMessage("§c§lBINGO! §f" + p.getName() + " a gagné !");
26+
Main.isStarted = false;
27+
for(Player p2 : Bukkit.getOnlinePlayers()){
28+
p2.setGameMode(org.bukkit.GameMode.SPECTATOR);
29+
p2.sendMessage("fVotre score: " + Main.getScore().get(p2.getUniqueId()));
30+
Main.getScore().put(p2.getUniqueId(), 0);
1831
}
1932
}
2033
}
21-
2234
}
2335
}

src/fr/azrotho/bingo/utils/Timer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
public class Timer extends BukkitRunnable {
1010
@Override
1111
public void run() {
12-
// Do Scoreboard
12+
if(Main.isStarted){
13+
Main.timer++;
14+
}
1315
for (Player p : Bukkit.getOnlinePlayers()) {
1416
ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
1517
Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
@@ -18,8 +20,9 @@ public void run() {
1820
objective.setDisplayName("§6§lBlockShuffle");
1921
Score score = objective.getScore("§f");
2022
score.setScore(1);
21-
final Score Timeri = objective.getScore("§f" + ((Main.timer - (1200 * (Main.timer / 1200))) / 60 + " §cmin§f " + Main.timer % 60));
23+
final Score Timeri = objective.getScore( Main.timer / 3600 + "§ch§f " + ((Main.timer - (1200 * (Main.timer / 1200))) / 60 + "§cmin§f " + Main.timer % 60 + "§cs"));
2224
Timeri.setScore(0);
25+
p.setScoreboard(scoreboard);
2326
}
2427
}
2528
}

0 commit comments

Comments
 (0)