Merge branch 'development' into 'master'

2.0.3

See merge request Songoda/songodaupdater!6
This commit is contained in:
Jacob Scott 2019-09-03 20:40:15 +00:00
commit 5aa06c72e8
5 changed files with 39 additions and 19 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "SongodaCore"
path: "/builds/$CI_PROJECT_PATH"
version: "2.0.2"
version: "2.0.3"
build:
stage: build

View File

@ -129,16 +129,19 @@
<groupId>com.songoda</groupId>
<artifactId>UltimateStacker</artifactId>
<version>1.9.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.bgsoftware</groupId>
<artifactId>WildStacker</artifactId>
<version>2-9-0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>uk.antiperson</groupId>
<artifactId>stackmob</artifactId>
<version>4-0-2</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -1158,6 +1158,19 @@ public enum LegacyMaterials {
return name == null ? null : lookupMap.get(name.toUpperCase());
}
/**
* Lookup a Legacy Material by its modern id name. <br />
* This also can grab materials by their legacy, but only if there is no
* modern material by that name.
*
* @param name item to lookup
* @param def default item if this is not a valid material
* @return LegacyMaterial or null if none found
*/
public static LegacyMaterials getMaterial(String name, LegacyMaterials def) {
return name == null ? def : lookupMap.getOrDefault(name.toUpperCase(), def);
}
/**
* Lookup a Legacy Material by bukkit material.
*
@ -1299,7 +1312,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isBlock() {
return material == null && material.isBlock();
return material != null && material.isBlock();
}
/**
@ -1308,7 +1321,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isEdible() {
return material == null && material.isEdible();
return material != null && material.isEdible();
}
/**
@ -1317,7 +1330,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isSolid() {
return material == null && material.isSolid();
return material != null && material.isSolid();
}
/**
@ -1326,7 +1339,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isTransparent() {
return material == null && material.isTransparent();
return material != null && material.isTransparent();
}
/**
@ -1335,7 +1348,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isFlammable() {
return material == null && material.isFlammable();
return material != null && material.isFlammable();
}
/**
@ -1344,7 +1357,7 @@ public enum LegacyMaterials {
* @return
*/
public boolean isBurnable() {
return material == null && material.isBurnable();
return material != null && material.isBurnable();
}
/**
@ -1544,14 +1557,14 @@ public enum LegacyMaterials {
* @return
*/
public boolean isOccluding() {
return material == null && material.isOccluding();
return material != null && material.isOccluding();
}
/**
* @return True if this material is affected by gravity.
*/
public boolean hasGravity() {
return material == null && material.hasGravity();
return material != null && material.hasGravity();
}
/**

View File

@ -243,7 +243,7 @@ public class Gui {
public Gui setItem(int cell, ItemStack item) {
cellItems.put(cell, item);
if (open && cell >= 0 && cell < inventory.getSize()) {
if (inventory != null && cell >= 0 && cell < inventory.getSize()) {
inventory.setItem(cell, item);
}
return this;
@ -252,7 +252,7 @@ public class Gui {
public Gui setItem(int row, int col, ItemStack item) {
final int cell = col + row * 9;
cellItems.put(cell, item);
if (open && cell >= 0 && cell < inventory.getSize()) {
if (inventory != null && cell >= 0 && cell < inventory.getSize()) {
inventory.setItem(cell, item);
}
return this;

View File

@ -4,6 +4,7 @@ import com.songoda.core.compatibility.LegacyMaterials;
import static com.songoda.core.gui.Gui.trimTitle;
import com.songoda.core.gui.events.GuiClickEvent;
import com.songoda.core.gui.methods.Clickable;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -169,13 +170,12 @@ public class SimplePagedGui extends Gui {
pages = (int) Math.ceil(maxRows / rowsPerPage);
// create a new inventory if needed
final int cells = rows * 9;
boolean isNew = false;
if (cells != inventory.getSize()) {
this.setRows(maxRows + (useHeader ? 2 : 1));
inventory = Bukkit.getServer().createInventory(inventory.getHolder(), cells,
List<Player> toUpdate = null;
if (Math.min(54, (maxRows + (useHeader ? 1 : 0)) * 9) != inventory.getSize()) {
toUpdate = getPlayers();
this.setRows(maxRows + (useHeader ? 1 : 0));
inventory = Bukkit.getServer().createInventory(inventory.getHolder(), rows * 9,
title == null ? "" : trimTitle(ChatColor.translateAlternateColorCodes('&', title)));
isNew = true;
}
// populate header
@ -185,17 +185,21 @@ public class SimplePagedGui extends Gui {
inventory.setItem(i, item != null ? item : (headerBackItem != null ? headerBackItem : blankItem));
}
}
// last row is dedicated to pagation
final int cells = rows * 9;
for (int i = cells - 9; i < cells; ++i) {
inventory.setItem(i, footerBackItem != null ? footerBackItem : blankItem);
}
// fill out the rest of the page
showPage();
if(isNew) {
// did we need to change the display window size?
if(toUpdate != null) {
// whoopsie!
exit();
getPlayers().forEach(player -> ((GuiHolder) inventory.getHolder()).manager.showGUI(player, this));
toUpdate.forEach(player -> ((GuiHolder) inventory.getHolder()).manager.showGUI(player, this));
}
}