Settings + Displayed Plugin Name is now configurable in config.yml
This commit is contained in:
parent
c8978e2625
commit
82a4920899
12 changed files with 240 additions and 28 deletions
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>de.lunarakai</groupId>
|
<groupId>de.lunarakai</groupId>
|
||||||
<artifactId>Minecleaner</artifactId>
|
<artifactId>Minecleaner</artifactId>
|
||||||
<version>1.0.4</version>
|
<version>1.1.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Minecleaner</name>
|
<name>Minecleaner</name>
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,16 @@ import de.lunarakai.minecleaner.game.BoardSize;
|
||||||
import de.lunarakai.minecleaner.game.Cell;
|
import de.lunarakai.minecleaner.game.Cell;
|
||||||
import de.lunarakai.minecleaner.game.Game;
|
import de.lunarakai.minecleaner.game.Game;
|
||||||
import de.lunarakai.minecleaner.utils.MinecleanerHeads;
|
import de.lunarakai.minecleaner.utils.MinecleanerHeads;
|
||||||
|
import de.lunarakai.minecleaner.utils.MinecleanerStringUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
@ -23,6 +27,7 @@ import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ItemDisplay;
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TextDisplay;
|
import org.bukkit.entity.TextDisplay;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Transformation;
|
import org.bukkit.util.Transformation;
|
||||||
import org.joml.Vector2i;
|
import org.joml.Vector2i;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
@ -41,6 +46,7 @@ public class MinecleanerArena {
|
||||||
private int flagsPlaced = 0;
|
private int flagsPlaced = 0;
|
||||||
private Player currentPlayer;
|
private Player currentPlayer;
|
||||||
private long currentGameStartTime;
|
private long currentGameStartTime;
|
||||||
|
private long ingameTime;
|
||||||
private Game currentMinecleanerGame;
|
private Game currentMinecleanerGame;
|
||||||
private final Location tempLoc = new Location(null, 0, 0, 0);
|
private final Location tempLoc = new Location(null, 0, 0, 0);
|
||||||
|
|
||||||
|
|
@ -219,6 +225,28 @@ public class MinecleanerArena {
|
||||||
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
|
currentMinecleanerGame = new Game(plugin, BoardSize.boardSizesWidth[widthIndex], BoardSize.boardSizesHeight[widthIndex], BoardSize.mineCounter[widthIndex]);
|
||||||
currentMinecleanerGame.start();
|
currentMinecleanerGame.start();
|
||||||
showTextDisplay();
|
showTextDisplay();
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
||||||
|
updateIngameInfoTexts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 20L, 20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(arenaStatus == ArenaStatus.PLAYING && currentPlayer != null) {
|
||||||
|
updateIngameInfoTexts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 1L, 1L);
|
||||||
|
}
|
||||||
|
|
||||||
removeStartHeads();
|
removeStartHeads();
|
||||||
flagsPlaced = 0;
|
flagsPlaced = 0;
|
||||||
hasMadeFirstClick = false;
|
hasMadeFirstClick = false;
|
||||||
|
|
@ -350,13 +378,31 @@ public class MinecleanerArena {
|
||||||
textdisplay.setDisplayHeight(3);
|
textdisplay.setDisplayHeight(3);
|
||||||
textdisplay.setDisplayWidth((float) BoardSize.boardSizesWidth[widthIndex] / 3);
|
textdisplay.setDisplayWidth((float) BoardSize.boardSizesWidth[widthIndex] / 3);
|
||||||
textdisplay.setPersistent(false);
|
textdisplay.setPersistent(false);
|
||||||
textdisplay.text(Component.text(ChatColor.GOLD + "Minesweeper"));
|
textdisplay.text(Component.text(ChatColor.GOLD + plugin.getDisplayedPluginName()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTextDisplay() {
|
private void updateIngameInfoTexts() {
|
||||||
|
String timer = "";
|
||||||
|
if(plugin.getManager().getSettingsValue("timer", currentPlayer) != 0) {
|
||||||
|
ingameTime += 1;
|
||||||
|
timer = ChatColor.GOLD + " Zeit: " + MinecleanerStringUtil.timeToString((ingameTime/20)*1000) + " ";
|
||||||
|
}
|
||||||
|
|
||||||
if (textDisplay != null) {
|
if (textDisplay != null) {
|
||||||
textDisplay.text(Component.text(ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --"));
|
String component = ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --";
|
||||||
|
//textDisplay.text(Component.text(ChatColor.GREEN + "-- Flaggen gesetzt: " + flagsPlaced + " --" + "\n" + ChatColor.RED + "-- Minen insgesamt: " + BoardSize.mineCounter[widthIndex] + " --"));
|
||||||
|
String newLine = "";
|
||||||
|
String filler = "";
|
||||||
|
if(!timer.equals("")) {
|
||||||
|
newLine = "\n" + ChatColor.GOLD + "-- ";
|
||||||
|
filler = " --";
|
||||||
|
}
|
||||||
|
textDisplay.text(Component.text(component + newLine + timer + filler));
|
||||||
|
}
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", currentPlayer) != 0) {
|
||||||
|
String componentActionBar = ChatColor.GREEN + "Flaggen gesetzt: " + flagsPlaced + ChatColor.RED + " Minen insgesamt: " + BoardSize.mineCounter[widthIndex];
|
||||||
|
currentPlayer.sendActionBar(Component.text(componentActionBar + " " + timer));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -394,12 +440,12 @@ public class MinecleanerArena {
|
||||||
}
|
}
|
||||||
if (cell.isFlagged() == true) {
|
if (cell.isFlagged() == true) {
|
||||||
flagsPlaced = flagsPlaced + 1;
|
flagsPlaced = flagsPlaced + 1;
|
||||||
updateTextDisplay();
|
updateIngameInfoTexts();
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_FLAG, true);
|
||||||
}
|
}
|
||||||
if (cell.isFlagged() == false) {
|
if (cell.isFlagged() == false) {
|
||||||
flagsPlaced = flagsPlaced - 1;
|
flagsPlaced = flagsPlaced - 1;
|
||||||
updateTextDisplay();
|
updateIngameInfoTexts();
|
||||||
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
setDiplayBlock(x, y, MinecleanerHeads.MINESWEEPER_TILE_UNKNOWN, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -423,7 +469,7 @@ public class MinecleanerArena {
|
||||||
if (currentMinecleanerGame.gameover) {
|
if (currentMinecleanerGame.gameover) {
|
||||||
plugin.getManager().handleGameover(player, this, !(cell.isRevealed() && cell.isExploded()));
|
plugin.getManager().handleGameover(player, this, !(cell.isRevealed() && cell.isExploded()));
|
||||||
} else {
|
} else {
|
||||||
updateTextDisplay();
|
updateIngameInfoTexts();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
ArrayList<Cell> floodedCells = currentMinecleanerGame.getfloodedCells();
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,39 @@ public class MinecleanerListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(e.getInventory().equals(plugin.getManager().getSettingsInventory())) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
int slot = e.getRawSlot();
|
||||||
|
switch (slot) {
|
||||||
|
case 12: {
|
||||||
|
if(plugin.getManager().getSettingsValue("additionaldisplay", player) == 0) {
|
||||||
|
plugin.getManager().updateSettingsValue("additionaldisplay", 1, player);
|
||||||
|
player.closeInventory();
|
||||||
|
player.openInventory(plugin.getManager().showSettingsInventory(player));
|
||||||
|
} else {
|
||||||
|
plugin.getManager().updateSettingsValue("additionaldisplay", 0, player);
|
||||||
|
player.closeInventory();
|
||||||
|
player.openInventory(plugin.getManager().showSettingsInventory(player));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 14: {
|
||||||
|
if(plugin.getManager().getSettingsValue("timer", player) == 0) {
|
||||||
|
plugin.getManager().updateSettingsValue("timer", 1, player);
|
||||||
|
player.closeInventory();
|
||||||
|
player.openInventory(plugin.getManager().showSettingsInventory(player));
|
||||||
|
} else {
|
||||||
|
plugin.getManager().updateSettingsValue("timer", 0, player);
|
||||||
|
player.closeInventory();
|
||||||
|
player.openInventory(plugin.getManager().showSettingsInventory(player));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.iani.cubesidestats.api.SettingKey;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -11,6 +13,7 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryType;
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
@ -41,6 +44,12 @@ public class MinecleanerManager {
|
||||||
private final HashMap<Integer, StatisticKey> statisticsTimeRecord;
|
private final HashMap<Integer, StatisticKey> statisticsTimeRecord;
|
||||||
private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed;
|
private final HashMap<Integer, StatisticKey> statisticsTotalGamesPlayed;
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
|
||||||
|
private Inventory settingsInventory;
|
||||||
|
private SettingKey minecleanerSettingTimerKey;
|
||||||
|
private SettingKey minecleanerAdditionalDisplaySettingKey;
|
||||||
|
|
||||||
public MinecleanerManager(MinecleanerPlugin plugin) {
|
public MinecleanerManager(MinecleanerPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
|
@ -50,12 +59,29 @@ public class MinecleanerManager {
|
||||||
this.sizes.put(2, "groß");
|
this.sizes.put(2, "groß");
|
||||||
this.sizes.put(3, "experte");
|
this.sizes.put(3, "experte");
|
||||||
|
|
||||||
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, "Minecleaner starten?");
|
this.confirmPlayingInventory = plugin.getServer().createInventory(null, InventoryType.HOPPER, plugin.getDisplayedPluginName() + " starten?");
|
||||||
this.confirmPlayingInventory.setItem(1,
|
this.confirmPlayingInventory.setItem(1,
|
||||||
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.GREEN_CONCRETE), ChatColor.GREEN + "Bestätigen")));
|
||||||
this.confirmPlayingInventory.setItem(3,
|
this.confirmPlayingInventory.setItem(3,
|
||||||
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen")));
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.RED_CONCRETE), ChatColor.RED + "Abbrechen")));
|
||||||
|
|
||||||
|
// Settings
|
||||||
|
|
||||||
|
|
||||||
|
minecleanerSettingTimerKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.timer");
|
||||||
|
minecleanerSettingTimerKey.setDefault(0);
|
||||||
|
minecleanerSettingTimerKey.setDisplayName("Timer");
|
||||||
|
|
||||||
|
minecleanerAdditionalDisplaySettingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings.additionaldisplay");
|
||||||
|
minecleanerAdditionalDisplaySettingKey.setDefault(0);
|
||||||
|
minecleanerAdditionalDisplaySettingKey.setDisplayName("Zusätzliche Anzeige in der Action Bar");
|
||||||
|
|
||||||
|
this.settingsInventory = plugin.getServer().createInventory(null, InventoryType.CHEST,
|
||||||
|
plugin.getDisplayedPluginName() + " Einstellungen");
|
||||||
|
|
||||||
|
|
||||||
|
// Statistics
|
||||||
|
|
||||||
statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal");
|
statisticsWonGamesTotal = plugin.getCubesideStatistics().getStatisticKey("minecleaner.wonGamestotal");
|
||||||
statisticsWonGamesTotal.setIsMonthlyStats(true);
|
statisticsWonGamesTotal.setIsMonthlyStats(true);
|
||||||
statisticsWonGamesTotal.setDisplayName("Runden gewonnen");
|
statisticsWonGamesTotal.setDisplayName("Runden gewonnen");
|
||||||
|
|
@ -86,10 +112,6 @@ public class MinecleanerManager {
|
||||||
statisticsTimeRecord.put(e.getKey(), s);
|
statisticsTimeRecord.put(e.getKey(), s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, String> getSizes() {
|
|
||||||
return sizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void joinArena(Player player, MinecleanerArena arena) {
|
public void joinArena(Player player, MinecleanerArena arena) {
|
||||||
if (!player.hasPermission(MinecleanerPlugin.PERMISSION_PLAY)) {
|
if (!player.hasPermission(MinecleanerPlugin.PERMISSION_PLAY)) {
|
||||||
|
|
@ -108,7 +130,7 @@ public class MinecleanerManager {
|
||||||
arena.removePlayer();
|
arena.removePlayer();
|
||||||
plugin.getArenaList().setArenaForPlayer(player, null);
|
plugin.getArenaList().setArenaForPlayer(player, null);
|
||||||
if(message) {
|
if(message) {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Das Minecleanerspiel wurde abgebrochen.");
|
player.sendMessage(ChatColor.YELLOW + "Das " + plugin.getDisplayedPluginName() + "spiel wurde abgebrochen.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,7 +139,7 @@ public class MinecleanerManager {
|
||||||
Preconditions.checkArgument(arena != null, "player is in no arena");
|
Preconditions.checkArgument(arena != null, "player is in no arena");
|
||||||
Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING, "not confirming playing status");
|
Preconditions.checkState(arena.getArenaStatus() == ArenaStatus.CONFIRM_PLAYING, "not confirming playing status");
|
||||||
arena.startNewGame();
|
arena.startNewGame();
|
||||||
player.sendMessage(ChatColor.YELLOW + "Du hast eine neue Runde Minecleaner gestartet.");
|
player.sendMessage(ChatColor.YELLOW + "Du hast eine neue Runde " + plugin.getDisplayedPluginName() + " gestartet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
|
public void handleGameover(Player player, MinecleanerArena arena, boolean isSuccessfullyCleared) {
|
||||||
|
|
@ -128,7 +150,7 @@ public class MinecleanerManager {
|
||||||
|
|
||||||
if(!isSuccessfullyCleared) {
|
if(!isSuccessfullyCleared) {
|
||||||
world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
world.playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.5f, 0.5f);
|
||||||
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das Minecleaner-Feld nicht erfolgreich lösen!");
|
player.sendMessage(ChatColor.YELLOW + "Game Over! Du konntest das " + plugin.getDisplayedPluginName() + "-Feld nicht erfolgreich lösen!");
|
||||||
arena.showMines();
|
arena.showMines();
|
||||||
|
|
||||||
if(sg != null) {
|
if(sg != null) {
|
||||||
|
|
@ -164,7 +186,7 @@ public class MinecleanerManager {
|
||||||
if(isUpdated != null && isUpdated) {
|
if(isUpdated != null && isUpdated) {
|
||||||
player.sendMessage(ChatColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) );
|
player.sendMessage(ChatColor.GOLD + "Herzlichen Glückwunsch! Du hast eine neue Bestzeit erreicht! " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) );
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das Minecleaner-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) + ChatColor.YELLOW + " erfolgreich lösen!");
|
player.sendMessage(ChatColor.YELLOW + "Glückwunsch, du konntest das " + plugin.getDisplayedPluginName() + "-Feld in " + ChatColor.RED + MinecleanerStringUtil.timeToString(millis) + ChatColor.YELLOW + " erfolgreich lösen!");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -209,9 +231,6 @@ public class MinecleanerManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getConfirmPlayingInventory() {
|
|
||||||
return confirmPlayingInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handleFieldClick(@NotNull Player player, int x, int y, boolean hasRightClicked) {
|
public void handleFieldClick(@NotNull Player player, int x, int y, boolean hasRightClicked) {
|
||||||
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
MinecleanerArena arena = plugin.getArenaList().getPlayerArena(player);
|
||||||
|
|
@ -325,6 +344,63 @@ public class MinecleanerManager {
|
||||||
for(StatisticKey statsKey : statisticsTotalGamesPlayed.values()) {
|
for(StatisticKey statsKey : statisticsTotalGamesPlayed.values()) {
|
||||||
statsPlayer.deleteScore(statsKey);
|
statsPlayer.deleteScore(statsKey);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory showSettingsInventory(Player player) {
|
||||||
|
int current = getSettingsValue("additionaldisplay", player);
|
||||||
|
|
||||||
|
if(current == 0) {
|
||||||
|
settingsInventory.setItem(12,
|
||||||
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.NAME_TAG), ChatColor.RED + "Zusätzliche Anzeige in der Action Bar")));
|
||||||
|
} else {
|
||||||
|
settingsInventory.setItem(12,
|
||||||
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.NAME_TAG), ChatColor.GREEN + "Zusätzliche Anzeige in der Action Bar")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
current = getSettingsValue("timer", player);
|
||||||
|
|
||||||
|
if(current == 0) {
|
||||||
|
settingsInventory.setItem(14,
|
||||||
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.CLOCK), ChatColor.RED + "Timer anzeigen")));
|
||||||
|
} else {
|
||||||
|
settingsInventory.setItem(14,
|
||||||
|
ItemStacks.lore(ItemStacks.rename(new ItemStack(Material.CLOCK), ChatColor.GREEN + "Timer anzeigen")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return settingsInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSettingsValue(String settingsKeyString, Player player) {
|
||||||
|
PlayerStatistics playerStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||||
|
SettingKey settingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings." + settingsKeyString);
|
||||||
|
|
||||||
|
return playerStatistics.getSettingValueOrDefault(settingKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSettingsValue(String settingsKeyString, int newValue, Player player) {
|
||||||
|
PlayerStatistics playerStatistics = plugin.getCubesideStatistics().getStatistics(player.getUniqueId());
|
||||||
|
SettingKey settingKey = plugin.getCubesideStatistics().getSettingKey("minecleaner.settings." + settingsKeyString);
|
||||||
|
playerStatistics.setSettingValue(settingKey, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<Integer, String> getSizes() {
|
||||||
|
return sizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getConfirmPlayingInventory() {
|
||||||
|
return confirmPlayingInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getSettingsInventory() {
|
||||||
|
return settingsInventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingKey getMinecleanerSettingTimerKey() {
|
||||||
|
return minecleanerSettingTimerKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SettingKey getMinecleanerAdditionalDisplaySettingKey() {
|
||||||
|
return minecleanerAdditionalDisplaySettingKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package de.lunarakai.minecleaner;
|
package de.lunarakai.minecleaner;
|
||||||
|
|
||||||
|
import de.lunarakai.minecleaner.commands.SettingsCommand;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import de.iani.cubesidestats.api.CubesideStatisticsAPI;
|
import de.iani.cubesidestats.api.CubesideStatisticsAPI;
|
||||||
import de.iani.cubesideutils.bukkit.commands.CommandRouter;
|
import de.iani.cubesideutils.bukkit.commands.CommandRouter;
|
||||||
|
|
@ -43,6 +44,7 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
minecleanerCommand.addCommandMapping(new StatsCommand(this), "stats");
|
minecleanerCommand.addCommandMapping(new StatsCommand(this), "stats");
|
||||||
minecleanerCommand.addCommandMapping(new DeletePlayerScoreCommand(this), "deleteplayerscores");
|
minecleanerCommand.addCommandMapping(new DeletePlayerScoreCommand(this), "deleteplayerscores");
|
||||||
minecleanerCommand.addCommandMapping(new InfoCommand(this), "info");
|
minecleanerCommand.addCommandMapping(new InfoCommand(this), "info");
|
||||||
|
minecleanerCommand.addCommandMapping(new SettingsCommand(this), "settings");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -67,4 +69,12 @@ public final class MinecleanerPlugin extends JavaPlugin {
|
||||||
public PlayerUUIDCache getPlayerUUIDCache() {
|
public PlayerUUIDCache getPlayerUUIDCache() {
|
||||||
return playerUUIDCache;
|
return playerUUIDCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDisplayedPluginName() {
|
||||||
|
return this.getConfig().getString("generalSettings.displayedPluginName");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSizeWinpoints(String size) {
|
||||||
|
return this.getConfig().getInt("winpoints.size." + size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,12 +94,12 @@ public class CreateCommand extends SubCommand {
|
||||||
@Nullable
|
@Nullable
|
||||||
RayTraceResult target = player.rayTraceBlocks(6);
|
RayTraceResult target = player.rayTraceBlocks(6);
|
||||||
if(target == null || target.getHitBlock() == null) {
|
if(target == null || target.getHitBlock() == null) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke den Block an, der im Zentrum des Minecleaner-Spielfelds sein soll.");
|
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke den Block an, der im Zentrum des " + plugin.getDisplayedPluginName() + "-Spielfelds sein soll.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
BlockFace face = target.getHitBlockFace();
|
BlockFace face = target.getHitBlockFace();
|
||||||
if(face != BlockFace.NORTH && face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.SOUTH) {
|
if(face != BlockFace.NORTH && face != BlockFace.WEST && face != BlockFace.EAST && face != BlockFace.SOUTH) {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke die Seite des Blockes an, wo das Minecleaner-Spielfeld erstellt werden soll.");
|
sender.sendMessage(ChatColor.DARK_RED + "Bitte gucke die Seite des Blockes an, wo das " + plugin.getDisplayedPluginName() + "-Spielfeld erstellt werden soll.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
location = target.getHitBlock().getLocation();
|
location = target.getHitBlock().getLocation();
|
||||||
|
|
|
||||||
|
|
@ -52,9 +52,9 @@ public class DeleteCommand extends SubCommand {
|
||||||
}
|
}
|
||||||
if(arena != null) {
|
if(arena != null) {
|
||||||
plugin.getArenaList().removeArena(arena);
|
plugin.getArenaList().removeArena(arena);
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Die Minecleaner-Arena " + arena.getName() + " wurde gelöscht.");
|
sender.sendMessage(ChatColor.YELLOW + "Die " + plugin.getDisplayedPluginName() + "-Arena " + arena.getName() + " wurde gelöscht.");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Hier befindet sich keine Minecleaner-Arena.");
|
sender.sendMessage(ChatColor.YELLOW + "Hier befindet sich keine " + plugin.getDisplayedPluginName() + "-Arena.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public class DeletePlayerScoreCommand extends SubCommand{
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Ein Spieler mit dem Namen '" + player + "' konnte nicht gefunden werden.");
|
sender.sendMessage(ChatColor.DARK_RED + "Ein Spieler mit dem Namen '" + player + "' konnte nicht gefunden werden.");
|
||||||
}
|
}
|
||||||
plugin.getManager().deleteScores(cachedPlayer.getUUID());
|
plugin.getManager().deleteScores(cachedPlayer.getUUID());
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Alle Minecleaner-Statistiken von Spieler '" + cachedPlayer.getName() + "' wurden gelöscht.");
|
sender.sendMessage(ChatColor.DARK_RED + "Alle " + plugin.getDisplayedPluginName() + "-Statistiken von Spieler '" + cachedPlayer.getName() + "' wurden gelöscht.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ public class ListCommand extends SubCommand{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
public boolean onCommand(CommandSender sender, Command arg1, String arg2, String commandString, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Angelegte Minecleaner-Arenen");
|
sender.sendMessage(ChatColor.YELLOW + "Angelegte "+ plugin.getDisplayedPluginName() + "-Arenen");
|
||||||
boolean any = false;
|
boolean any = false;
|
||||||
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
for(MinecleanerArena arena : plugin.getArenaList().getArenas()) {
|
||||||
Location location = arena.getLocation();
|
Location location = arena.getLocation();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package de.lunarakai.minecleaner.commands;
|
||||||
|
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.SubCommand;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.DisallowsCommandBlockException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.IllegalSyntaxException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.InternalCommandException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.NoPermissionException;
|
||||||
|
import de.iani.cubesideutils.bukkit.commands.exceptions.RequiresPlayerException;
|
||||||
|
import de.iani.cubesideutils.commands.ArgsParser;
|
||||||
|
import de.lunarakai.minecleaner.MinecleanerPlugin;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SettingsCommand extends SubCommand {
|
||||||
|
MinecleanerPlugin plugin;
|
||||||
|
|
||||||
|
public SettingsCommand(MinecleanerPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsage() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean requiresPlayer() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getRequiredPermission() {
|
||||||
|
return MinecleanerPlugin.PERMISSION_PLAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String s, String s1, ArgsParser args) throws DisallowsCommandBlockException, RequiresPlayerException, NoPermissionException, IllegalSyntaxException, InternalCommandException {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
player.openInventory(plugin.getManager().showSettingsInventory(player));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -52,7 +52,7 @@ public class StatsCommand extends SubCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(playerName == null) {
|
if(playerName == null) {
|
||||||
sender.sendMessage(ChatColor.AQUA + "Deine Minecleaner Statistik:");
|
sender.sendMessage(ChatColor.AQUA + "Deine " + plugin.getDisplayedPluginName() + " Statistik:");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.AQUA + "Minecleaner-Statistik von " + data.getPlayerName() + ":");
|
sender.sendMessage(ChatColor.AQUA + "Minecleaner-Statistik von " + data.getPlayerName() + ":");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
generalSettings:
|
||||||
|
displayedPluginName: Minecleaner
|
||||||
winpoints:
|
winpoints:
|
||||||
size:
|
size:
|
||||||
small: 1
|
small: 1
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue