Skip to content

Commit

Permalink
version 2.2.1 running cookieclicker 2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasEi committed Aug 5, 2018
1 parent 2b630a8 commit a3083f2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 55 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

### v 2.2.1
- implement option for games to add commands to the gamebox commands
- cancel game invitations when the other player is in a disabled world
- make skull display names in top lists configurable
- fix ItemStackUtility throwing error on invalid materials, when a data value is given
- hide leftover debug messages
- fix high number names loaded from langauge file

### v 2.2.0
- compatibility with minecraft 1.13
Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>gamebox</artifactId>
<groupId>me.nikl</groupId>
<version>2.2.0</version>
<version>2.2.1</version>
</parent>
<artifactId>gamebox-core</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
import me.nikl.gamebox.utility.Permission;
import org.apache.commons.lang.Validate;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
* @author Niklas Eicker
*/
public abstract class GameAdminCommand extends GameBoxBaseCommand {
public class GameAdminCommand extends GameBoxBaseCommand {
private Module module;

public GameAdminCommand(GameBox gameBox, Module module) {
super(gameBox);
Validate.notNull(module, "The GameAdminCommand needs a valid module!");
this.module = module;
gameBox.getCommands().registerCommand(this);
}

@Override
Expand All @@ -30,10 +28,6 @@ public boolean preCommand(CommandSender sender) {
sender.sendMessage(gameBox.lang.PREFIX + gameBox.lang.CMD_NO_PERM);
return true;
}
if (sender instanceof Player) {
sender.sendMessage(gameBox.lang.PREFIX + " Only from the console!");
return true;
}
return false;
}
}
11 changes: 11 additions & 0 deletions core/src/main/java/me/nikl/gamebox/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ public void onEnable() throws GameLoadException {
init();
loadGameManager();
hook();
// load anything that needs the game manager
finish();
}

/**
* Load anything that depends on a fully initialized GameManger and a successful hook into GameBox
*
* example: Game commands that need a list of game types
*/
protected void finish() {
// to be Overridden
}

private void checkRequirements() throws GameLoadException {
Expand Down
42 changes: 0 additions & 42 deletions core/src/main/java/me/nikl/gamebox/inventory/shop/Category.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import me.nikl.gamebox.utility.StringUtility;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -50,21 +49,17 @@ public Category(GameBox plugin, ShopManager shopManager, GUIManager guiManager,
loadShopItems();
}


private void loadShopItems() {
ConfigurationSection pageSection = shop.getConfigurationSection("shop.categories." + key + ".items");
if (pageSection == null) return;

Map<Integer, Button> allItems = new HashMap<>();
ItemStack itemStack;
ItemMeta meta;
List<String> lore = new ArrayList<>();
int counter = 0, token = 0, money = 0, amount = 0;
for (String itemKey : pageSection.getKeys(false)) {

// if null no item will be given
itemStack = ItemStackUtility.getItemStack(pageSection.getString(itemKey + ".materialData"));

// load the prices of the item
if (pageSection.isSet(itemKey + ".tokens") && pageSection.isInt(itemKey + ".tokens")) {
token = pageSection.getInt(itemKey + ".tokens");
Expand All @@ -79,12 +74,10 @@ private void loadShopItems() {
} else {
money = pageSection.getInt(itemKey + ".money");
}

// get the amount of the item (default = 1). Check for MaxStackSize!
if (itemStack != null) {
if (pageSection.isSet(itemKey + ".count") && pageSection.isInt(itemKey + ".count")) {
amount = pageSection.getInt(itemKey + ".count");

if (amount > itemStack.getMaxStackSize()) {
itemStack.setAmount(itemStack.getMaxStackSize());
} else {
Expand All @@ -94,15 +87,12 @@ private void loadShopItems() {
if (pageSection.getBoolean(itemKey + ".glow", false)) {
itemStack = NmsFactory.getNmsUtility().addGlow(itemStack);
}

meta = itemStack.getItemMeta();
if (pageSection.isString(itemKey + ".displayName")) {
meta.setDisplayName(StringUtility.color(pageSection.getString(itemKey + ".displayName")));
}

if (pageSection.isList(itemKey + ".lore")) {
lore = new ArrayList<>(pageSection.getStringList(itemKey + ".lore"));

for (int i = 0; i < lore.size(); i++) {
lore.set(i, StringUtility.color(lore.get(i)));
}
Expand All @@ -117,37 +107,26 @@ private void loadShopItems() {
Bukkit.getConsoleSender().sendMessage(plugin.lang.PREFIX + ChatColor.RED + " Skipping...");
continue;
}


// load shop item
ShopItem shopItem = new ShopItem();

if (itemStack != null) {
shopItem.setItemStack(new ItemStack(itemStack));
}

if (pageSection.isList(itemKey + ".requirements" + ".permissions")) {
shopItem.setPermissions(pageSection.getStringList(itemKey + ".requirements" + ".permissions"));
}

if (pageSection.isList(itemKey + ".requirements" + ".noPermissions")) {
shopItem.setNoPermissions(pageSection.getStringList(itemKey + ".requirements" + ".noPermissions"));
}

if (pageSection.getBoolean(itemKey + ".manipulatesInventory", false)) {
shopItem.setManipulatesInventory(true);
}

if (pageSection.isList(itemKey + ".commands")) {
shopItem.setCommands(pageSection.getStringList(itemKey + ".commands"));
}


// load button
Button button = new Button(buttonItem);
button.setAction(ClickAction.BUY);


meta = button.getItemMeta();
lore.clear();
lore.add("");
Expand All @@ -159,30 +138,19 @@ private void loadShopItems() {
if (money != 0) {
lore.add(this.plugin.lang.SHOP_MONEY.replace("%money%", String.valueOf(money)));
}

if (meta.hasLore()) lore.addAll(meta.getLore());

meta.setLore(lore);
button.setItemMeta(meta);

button.setArgs(key, String.valueOf(counter), String.valueOf(token), String.valueOf(money));

allItems.put(counter, button);

shopItems.put(String.valueOf(counter), shopItem);

counter++;
}
GameBox.debug("All loaded items of page " + key + ":");
for (int number : allItems.keySet()) {
GameBox.debug(" " + allItems.get(number).toString());
}
counter++;
int pageNum = counter / itemsPerPage + (counter % itemsPerPage == 0 ? 0 : 1);
counter = 0;
Page page = null;
while (!allItems.isEmpty()) {
GameBox.debug(allItems.keySet().size() + " Items left to sort");
if ((counter) % itemsPerPage == 0) {
pages.put(counter / itemsPerPage, (page = new Page(plugin, guiManager, slots, counter / itemsPerPage, shopManager, new String[]{key, String.valueOf(counter / itemsPerPage)})));
if (counter / itemsPerPage == 0) {
Expand All @@ -206,42 +174,32 @@ private ItemStack getButtonItem(ItemStack itemStack, ConfigurationSection pageSe
if (presentItem == null && itemStack == null) {
return null;
}

if (presentItem == null) {
presentItem = new ItemStack(itemStack);
}

if (pageSection.getBoolean(path + ".glow", false)) {
presentItem = NmsFactory.getNmsUtility().addGlow(presentItem);
}

if (pageSection.isInt(path + ".count")) {
presentItem.setAmount(pageSection.getInt(path + ".count"));
}

ItemMeta meta = presentItem.getItemMeta();

if (pageSection.isString(path + ".displayName")) {
meta.setDisplayName(StringUtility.color(pageSection.getString(path + ".displayName")));
}

if (pageSection.isList(path + ".additionalLore")) {
List<String> lore = new ArrayList<>();
lore.add(" ");
lore.add(ChatColor.GOLD + "- - - - - - - - - - - - - - - - - - -");
lore.add(" ");

List<String> addLore = new ArrayList<>(pageSection.getStringList(path + ".additionalLore"));
for (int i = 0; i < addLore.size(); i++) {
addLore.set(i, StringUtility.color(addLore.get(i)));
}
lore.addAll(addLore);
meta.setLore(lore);
}

presentItem.setItemMeta(meta);


return presentItem;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: GameBox
author: Nikl
main: me.nikl.gamebox.GameBox
version: 2.2.0
version: 2.2.1
website: nikl.me
softdepend: [Vault, PlaceholderAPI, CalendarEvents]

Expand Down
6 changes: 3 additions & 3 deletions distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>gamebox</artifactId>
<groupId>me.nikl</groupId>
<version>2.2.0</version>
<version>2.2.1</version>
</parent>
<artifactId>gamebox-distribution</artifactId>

Expand Down Expand Up @@ -68,14 +68,14 @@
<dependency>
<groupId>me.nikl</groupId>
<artifactId>gamebox-core</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<!-- games -->
<dependency>
<groupId>me.nikl</groupId>
<artifactId>cookieclicker</artifactId>
<version>2.2.0</version>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>me.nikl</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>gamebox</artifactId>
<name>gamebox</name>
<packaging>pom</packaging>
<version>2.2.0</version>
<version>2.2.1</version>
<description>Collection of inventory games</description>
<url>https://gamebox.nikl.me</url>

Expand Down

0 comments on commit a3083f2

Please sign in to comment.