Skip to content

Commit

Permalink
Merge pull request #202 from nikosgram/master
Browse files Browse the repository at this point in the history
Minecraft v1.14
  • Loading branch information
nikosgram authored Jun 25, 2019
2 parents 3ef6a9e + 6f11953 commit b0fd2a6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [nikosgram]
custom: https://www.paypal.me/lordgram
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,4 @@ buildNumber.properties


# End of https://www.gitignore.io/api/java,maven,intellij,intellij+all,intellij+iml
.DS_Store
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theme: jekyll-theme-slate
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>minecraftwars</groupId>
<artifactId>Gringotts</artifactId>
<version>2.11.0-SNAPSHOT</version>
<version>2.11.1-SNAPSHOT</version>

<build>
<resources>
Expand Down Expand Up @@ -85,10 +85,9 @@

<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<classifier>shaded</classifier>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
45 changes: 24 additions & 21 deletions src/main/java/org/gestern/gringotts/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.WallSign;
import org.gestern.gringotts.currency.GringottsCurrency;

public class Util {

private Util() {}
private Util() {
}

/**
* Check whether a block is a sign or wall sign type.
Expand All @@ -29,7 +32,6 @@ public static boolean isSignBlock(Block block) {
* @return true if version is greater than greaterThanVersion, false otherwise
*/
public static boolean versionAtLeast(String version, String atLeast) {

int[] versionParts = versionParts(version);
int[] atLeastParts = versionParts(atLeast);

Expand All @@ -54,16 +56,17 @@ public static boolean versionAtLeast(String version, String atLeast) {
*/
public static int[] versionParts(String version) {
String[] strparts = version.split("\\.");
int[] parts = new int[strparts.length];
int[] parts = new int[strparts.length];

for (int i = 0; i < strparts.length; i++) {
// just cut off any non-number part
String number = strparts[i].replaceAll("(\\d+).*", "$1");
int part = 0;
int part = 0;

try {
part = Integer.parseInt(number);
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}

parts[i] = part;
}
Expand All @@ -78,8 +81,9 @@ public static int[] versionParts(String version) {
* @return formatted currency value
*/
public static String format(double value) {
GringottsCurrency cur = Configuration.CONF.getCurrency();
String formatString = "%." + cur.getDigits() + "f %s";
GringottsCurrency cur = Configuration.CONF.getCurrency();
String formatString = "%." + cur.getDigits() + "f %s";

return String.format(formatString, value, value == 1.0 ? cur.getName() : cur.getNamePlural());
}

Expand All @@ -91,23 +95,21 @@ public static String format(double value) {
*/
public static Block chestBlock(Sign sign) {
// is sign attached to a valid vault container?
Block signBlock = sign.getBlock();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) signBlock.getState().getData();
BlockFace attached = signData.getAttachedFace();
Block signBlock = sign.getBlock();
BlockData blockData = signBlock.getBlockData();

// allow either the block sign is attached to or the block below the sign as chest block. Prefer attached block.
Block blockAttached = signBlock.getRelative(attached);
Block blockBelow = signBlock.getRelative(BlockFace.DOWN);

if (validContainer(blockAttached.getType())) {
return blockAttached;
if (!(blockData instanceof WallSign)) {
return null;
}

if (validContainer(blockBelow.getType())) {
return blockBelow;
}
WallSign signData = (WallSign) blockData;
BlockFace attached = signData.getFacing().getOppositeFace();

// allow either the block sign is attached to or the block below the sign as chest block. Prefer attached block.
Block blockAttached = signBlock.getRelative(attached);
Block blockBelow = signBlock.getRelative(BlockFace.DOWN);

return null; // no valid container
return validContainer(blockAttached.getType()) ? blockAttached : validContainer(blockBelow.getType()) ? blockBelow : null;
}

/**
Expand All @@ -124,6 +126,7 @@ public static boolean validContainer(Material material) {
case FURNACE:
case HOPPER:
case DROPPER:
case BARREL:
return true;
default:
return false;
Expand All @@ -141,7 +144,7 @@ public static String translateColors(String s) {
}

public static String reformMaterialName(Material material) {
String name = material.name();
String name = material.name();
String[] words = name.split("_");

for (int i = 0; i < words.length; i++) {
Expand Down

0 comments on commit b0fd2a6

Please sign in to comment.