Skip to content

Commit

Permalink
bump version to 16.5.30
Browse files Browse the repository at this point in the history
  • Loading branch information
PMFRTT committed Apr 1, 2021
1 parent b24532b commit e8ea32d
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 44 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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>Bingo</groupId>
<artifactId>Bingo</artifactId>
<version>16.5.30-dev</version>
<version>16.5.30</version>
<packaging>jar</packaging>

<name>Bingo</name>
Expand Down
29 changes: 18 additions & 11 deletions src/main/java/bingo/BingoPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import bingo.commandExecutor.TopCommandExecutor;
import bingo.eventhandler.BingoEventhandler;
import bingo.eventhandler.CheckInventory;
import bingo.teleporter.Teleporter;
import core.core.CoreMain;
import core.Utils;
import core.timer.Timer;
Expand All @@ -20,19 +21,21 @@

public final class BingoPlugin extends JavaPlugin {

private final BingoEventhandler bingoEventhandler = new BingoEventhandler(this);
private static BingoSettings bingoSettings;
private int difficulty = 0;
private static int difficulty = 0;
private static Timer timer;

public static int items = 0;
public static SideList sideList;
private static Timer timer;
public static boolean scatter;
public static boolean tpEnabled = false;

@Override
public void onEnable() {

CoreMain.setPlugin(this);
timer = new Timer(this, TimerType.INCREASING, "Das Bingo läuft seit: &b", "&cDas Bingo ist pausiert", false);
BingoEventhandler bingoEventhandler = new BingoEventhandler(this);
bingoEventhandler.initialize();
bingoSettings = new BingoSettings(this);
BingoCommandExecutor bingoCommandExecutor = new BingoCommandExecutor(this);
Expand Down Expand Up @@ -72,17 +75,15 @@ public void startBingo() {
SettingCycle items = (SettingCycle) bingoSettings.getSettingbyName("Items");
SettingSwitch keepInventory = (SettingSwitch) bingoSettings.getSettingbyName("Keep Inventory");
SettingSwitch singlePlayer = (SettingSwitch) bingoSettings.getSettingbyName("Singleplayer");
SettingSwitch advancements = (SettingSwitch) bingoSettings.getSettingbyName("Announce Advancements");
SettingSwitch scatter = (SettingSwitch) bingoSettings.getSettingbyName("Scatter Players");
SettingCycle singlePlayerStartTime = (SettingCycle) bingoSettings.singlePlayerSubSettings.getSettingbyName("Start-Zeit");
SettingCycle scatterPlayerSize = (SettingCycle) bingoSettings.scatterPlayerSubSettings.getSettingbyName("Scatter-Größe");
SettingCycle teleportTime = (SettingCycle) bingoSettings.teleporterSubSettings.getSettingbyName("Countdown-Zeit");
SettingCycle teleportRange = (SettingCycle) bingoSettings.teleporterSubSettings.getSettingbyName("Teleporter-Radius");
SettingSwitch enabletp = (SettingSwitch) bingoSettings.getSettingbyName("Teleporter");
this.difficulty = difficulty.getValue();
this.scatter = scatter.getSettingValue();
if (advancements.getSettingValue()) {
Utils.changeGamerule(GameRule.ANNOUNCE_ADVANCEMENTS, true);
} else {
Utils.changeGamerule(GameRule.ANNOUNCE_ADVANCEMENTS, false);
}
tpEnabled = enabletp.getSettingValue();
BingoPlugin.scatter = scatter.getSettingValue();
boolean singleplayer = singlePlayer.getSettingValue();
if (keepInventory.getSettingValue()) {
Utils.changeGamerule(GameRule.KEEP_INVENTORY, true);
Expand All @@ -92,10 +93,16 @@ public void startBingo() {
timer.setSeconds(singlePlayerStartTime.getValue());
timer.setSingle(true);
}
this.items = items.getValue();
BingoPlugin.items = items.getValue();
int teleporterRadius = teleportRange.getValue();
int teleporterTime = teleportTime.getValue();
BingoList.populatePlayerBingoList(difficulty.getValue(), items.getValue());
bingo.Utils.preparePlayers(scatterPlayerSize.getValue());
sideList.init();
if (enabletp.getSettingValue()) {
Teleporter teleporter = new Teleporter(this, true, teleporterTime, teleporterRadius);
teleporter.init();
}
timer.resume();
}

Expand Down
64 changes: 54 additions & 10 deletions src/main/java/bingo/BingoSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ private void addSettings() {
add(Utils.colorize("&7ihre Items &cverlieren &7oder &abehalten"));
}}, Material.ENDER_EYE, false);

this.addSetting("Announce Advancements", new ArrayList<String>() {{
/*this.addSetting("Announce Advancements", new ArrayList<String>() {{
add(Utils.colorize("&7Legt fest, ob Gegenspieler im"));
add(Utils.colorize("&7Chat erfahren, dass ein"));
add(Utils.colorize("&6Advancement erreicht &7wurde"));
}}, Material.NOTE_BLOCK, false);
}}, Material.NOTE_BLOCK, false);*/

this.addSetting("Scatter Players", new ArrayList<String>() {{
add(Utils.colorize("&7Legt fest, ob Spieler"));
Expand All @@ -80,7 +80,7 @@ private void addSettings() {

scatterPlayerSubSettings.addSetting("Scatter-Größe", new ArrayList<String>() {{
add(Utils.colorize("&7Hier kannst du einstellen,"));
add(Utils.colorize("&7wie &6groß der Radius&7 des "));
add(Utils.colorize("&7wie groß der &6Radius&7 des "));
add(Utils.colorize("&7Scatterns sein soll"));
}}, Material.CARTOGRAPHY_TABLE, new ArrayList<Integer>() {{
add(100);
Expand Down Expand Up @@ -112,13 +112,6 @@ private void addSettings() {
add(Utils.colorize("&8Shift + Rechtsclick -> Einstellungen"));
}}, Material.TOTEM_OF_UNDYING, false, singlePlayerSubSettings);

this.addSetting("Teleporter", new ArrayList<String>() {{
add(Utils.colorize("&7Ermöglicht dem Spieler sich"));
add(Utils.colorize("&7entweder einmalig oder mit einem"));
add(Utils.colorize("&7Countdown zu &ateleportieren!"));
add(Utils.colorize("&8Shift + Rechtsclick -> Einstellungen"));
}}, Material.ENDERMAN_SPAWN_EGG, false, teleporterSubSettings);

singlePlayerSubSettings.addSetting("Start-Zeit", new ArrayList<String>() {{
add(core.Utils.colorize("&7Hier kannst du einstellen, mit wie"));
add(core.Utils.colorize("&7viel &6Zeit &7du in dem"));
Expand Down Expand Up @@ -147,6 +140,57 @@ private void addSettings() {
add(Utils.colorize("&a10 Minuten"));
}});

this.addSetting("Teleporter", new ArrayList<String>() {{
add(Utils.colorize("&7Ermöglicht dem Spieler sich"));
add(Utils.colorize("&7entweder einmalig oder mit einem"));
add(Utils.colorize("&7Countdown zu &ateleportieren!"));
add(Utils.colorize("&8Shift + Rechtsclick -> Einstellungen"));
}}, Material.ENDERMAN_SPAWN_EGG, false, teleporterSubSettings);

teleporterSubSettings.addSetting("Countdown", new ArrayList<String>(){{
add(Utils.colorize("&7Wenn diese Einstellung aktiv ist,"));
add(Utils.colorize("&7kann der Teleporter &6wiederholt nach"));
add(Utils.colorize("&6einer bestimmten Zeit &7genutzt werden!"));
}}, Material.CLOCK, true);

teleporterSubSettings.addSetting("Countdown-Zeit", new ArrayList<String>(){{
add(Utils.colorize("&7Hier legst du fest, &6wie lange&7 ein"));
add(Utils.colorize("&7Spieler &6warten &7muss, bis er sich"));
add(Utils.colorize("&7wieder teleportieren kann!"));
}}, Material.NAUTILUS_SHELL, new ArrayList<Integer>(){{
add(120);
add(300);
add(600);
}}, new ArrayList<String>(){{
add(Utils.colorize("&b2 Minuten"));
add(Utils.colorize("&b5 Minuten"));
add(Utils.colorize("&b10 Minuten"));
}});

teleporterSubSettings.addSetting("Teleporter-Radius", new ArrayList<String>() {{
add(Utils.colorize("&7Hier kannst du einstellen,"));
add(Utils.colorize("&7wie groß der &6Radius&7 des "));
add(Utils.colorize("&7Telportierens sein soll"));
}}, Material.CARTOGRAPHY_TABLE, new ArrayList<Integer>() {{
add(100);
add(250);
add(500);
add(750);
add(1000);
add(1500);
add(2000);
}}, new ArrayList<String>() {{
add(Utils.colorize("&b100 &fBlöcke"));
add(Utils.colorize("&b250 &fBlöcke"));
add(Utils.colorize("&b500 &fBlöcke"));
add(Utils.colorize("&b750 &fBlöcke"));
add(Utils.colorize("&b1000 &fBlöcke"));
add(Utils.colorize("&b1500 &fBlöcke"));
add(Utils.colorize("&b2000 &fBlöcke"));
}});



//this.addSetting();
}
}
31 changes: 15 additions & 16 deletions src/main/java/bingo/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,29 @@

public class Utils {

private static void scatterPlayers(int scatterSize) {
public static void scatterPlayer(Player player, int scatterSize) {
Random random = new Random();
World world = Bukkit.getWorld("world");
for (Player player : Bukkit.getOnlinePlayers()) {
Location location = player.getLocation();
do {
double x = (random.nextFloat() - 0.5f) * scatterSize;
double z = (random.nextFloat() - 0.5f) * scatterSize;
location.setX(x);
location.setZ(z);
assert world != null;
location.setY(world.getHighestBlockYAt((int) x, (int) z));
} while (location.getBlock().isLiquid());
location.add(0, 2, 0);
player.setBedSpawnLocation(location, true);
player.teleport(location);
}
Location location = player.getLocation();
do {
double x = (random.nextFloat() - 0.5f) * scatterSize;
double z = (random.nextFloat() - 0.5f) * scatterSize;
location.setX(x);
location.setZ(z);
assert world != null;
location.setY(world.getHighestBlockYAt((int) x, (int) z));
} while (location.getBlock().isLiquid());
location.add(0, 2, 0);
player.setBedSpawnLocation(location, true);
player.teleport(location);
}

public static void preparePlayers(int scatterSize) {
clearPlayers();
CheckInventory.createLock();
if (BingoPlugin.scatter) {
scatterPlayers(scatterSize);
for(Player player : Bukkit.getOnlinePlayers())
scatterPlayer(player, scatterSize);
}
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/bingo/commandExecutor/BingoCommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import bingo.BingoInventory;
import bingo.BingoList;
import bingo.BingoPlugin;
import bingo.teleporter.Teleporter;
import bingo.teleporter.TeleporterTimer;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -54,7 +56,17 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}
}
} else if (command.getLabel().equalsIgnoreCase("rtp")) {

assert player != null;
if (BingoPlugin.tpEnabled) {
if (Teleporter.canTP(player)) {
Teleporter.teleport(player);
player.sendMessage(Utils.getPrefix("Teleporter") + Utils.colorize("Du wurdest &ateleportiert&f!"));
} else {
player.sendMessage(Utils.getPrefix("Teleporter") + Utils.colorize("Du musst noch &b" + Utils.formatTimerTimeText(Teleporter.getTimer(player).getSeconds()) + "&f warten!"));
}
} else {
player.sendMessage(Utils.getPrefix("Teleporter") + Utils.colorize("Das Teleport-Feature ist &cdeaktiviert&f!"));
}
return false;
}

Expand Down
59 changes: 59 additions & 0 deletions src/main/java/bingo/teleporter/Teleporter.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,63 @@
package bingo.teleporter;

import bingo.BingoPlugin;
import core.Utils;
import core.timer.TimerType;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.HashMap;

public class Teleporter {

private static boolean enabled;
private static int time;
private static int radius;
private static BingoPlugin bingoPlugin;


private static HashMap<String, TeleporterTimer> playerCountdown = new HashMap<String, TeleporterTimer>();

public Teleporter(BingoPlugin bingoPlugin, boolean enabled, int time, int radius) {
Teleporter.enabled = enabled;
Teleporter.time = time;
Teleporter.radius = radius;
Teleporter.bingoPlugin = bingoPlugin;
}

public void init() {
if (enabled) {
for (Player player : Bukkit.getOnlinePlayers()) {
TeleporterTimer teleporterTimer = new TeleporterTimer(bingoPlugin, TimerType.DECREASING, "", "", true, Utils.colorize("Du kannst dich wieder &bteleportieren&f!"), player);
teleporterTimer.setSeconds(time);
teleporterTimer.resume();
playerCountdown.put(player.getDisplayName(), teleporterTimer);
}
}
}

public void enable() {
enabled = true;
}

public void disable() {
enabled = false;
}

public static boolean canTP(Player player){
return playerCountdown.get(player.getDisplayName()).getTicks() == 0;
}

public static void teleport(Player player){
TeleporterTimer teleporterTimer = playerCountdown.get(player.getDisplayName());
teleporterTimer.setSeconds(time);
teleporterTimer.resume();
Utils.sendDebugMessage("&cPlayer has been teleported");
playerCountdown.put(player.getDisplayName(), teleporterTimer);
bingo.Utils.scatterPlayer(player, radius);
}

public static TeleporterTimer getTimer(Player player){
return playerCountdown.get(player.getDisplayName());
}
}
5 changes: 3 additions & 2 deletions src/main/java/bingo/teleporter/TeleporterTimer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import core.timer.Timer;
import core.timer.TimerType;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

public class TeleporterTimer extends Timer {
public TeleporterTimer(Plugin plugin, TimerType timerType, String runningString, String pausedString, boolean hidden) {
super(plugin, timerType, runningString, pausedString, hidden);
public TeleporterTimer(Plugin plugin, TimerType timerType, String runningString, String pausedString, boolean hidden, String timerReady, Player player) {
super(plugin, timerType, runningString, pausedString, hidden, timerReady, player);
}
}

0 comments on commit e8ea32d

Please sign in to comment.