Skip to content

Commit

Permalink
Merge pull request #35 from CivClassic/master
Browse files Browse the repository at this point in the history
Updating to 1.16.4
  • Loading branch information
ProgrammerDan authored Jan 4, 2021
2 parents 07ccdf5 + 7c9eb38 commit 5eb355f
Show file tree
Hide file tree
Showing 6 changed files with 745 additions and 79 deletions.
46 changes: 46 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@Library('civ_pipeline_lib')_

pipeline {
agent any
tools {
maven 'Maven 3.6.3'
jdk 'Java 8'
}
environment {
civ_dependent_plugins = ""
}
stages {
stage ('Build') {
steps {
civ_build_plugin()
}
}
stage ('Archive binaries') {
steps {
civ_archive_artifacts()
}
}
stage ('Archive javadoc') {
steps {
civ_archive_javadoc()
}
}
stage ('Aggregate reports') {
steps {
civ_aggregate_reports()
}
}
}

post {
always {
civ_post_always()
}
success {
civ_post_success()
}
failure {
civ_post_failure()
}
}
}
66 changes: 26 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.devotedmc</groupId>
<artifactId>hiddenore</artifactId>
<version>1.6.0</version>
<name>HiddenOre</name>
<parent>
<groupId>com.github.civclassic</groupId>
<artifactId>civclassic-parent</artifactId>
<version>1.0.0</version>
</parent>

<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<groupId>com.github.devotedmc</groupId>
<artifactId>hiddenore</artifactId>
<version>1.7.2</version>
<name>HiddenOre</name>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>civ-github-repo</id>
<url>https://raw.githubusercontent.com/CivClassic/artifacts/master/</url>
</repository>
</repositories>

<build>
<finalName>${project.name}-${project.version}</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
3 changes: 3 additions & 0 deletions src/main/java/com/github/devotedmc/hiddenore/BlockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public String getDropConfig(double dice, String biome, ItemStack tool, Player pl
Double.toString(tc == null ? 1.0 : tc.getDropChanceModifier()),
localChance, (tc == null ? null : tc.toString())});*/
}
if(localChance < 0){
continue;
}

if (dice >= cumChance && dice < cumChance + localChance) {
return dce.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public DropConfig(String dropName, List<DropItemConfig> drops, String command, b
this.transformIfAble = transformIfAble;
this.dropIfTransformFails = dropIfTransformFails;
this.maxDropsIfTransformFails = maxDropsIfTransformFails;
this.prefix = prefix;
this.limits = limits;
this.biomeLimits = new HashMap<String, DropLimitsConfig>();
this.veinNature = veinNature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ private void doBlockBreak(BlockBreakEvent event) {
if (Config.isListDrops()) {
alertUser.deleteCharAt(alertUser.length() - 1);
}

event.getPlayer().sendMessage(ChatColor.GOLD + alertUser.toString());
String alert = alertUser.toString();
if (alert.length() > 0) {
event.getPlayer().sendMessage(ChatColor.GOLD + alert);
}
}

plugin.getTracking().postTrackBreak(event.getBlock().getLocation(), true);
Expand Down Expand Up @@ -296,20 +298,19 @@ public void run() {

if (Config.isAlertUser()) {
if (blockConfig.hasCustomPrefix(dropName)) {
// Custom prefix items are immediately reported to a player
StringBuilder customAlerts = new StringBuilder(blockConfig.getPrefix(dropName));

for (ItemStack item : hoe.getDrops()) {
String name = item.hasItemMeta() && item.getItemMeta().hasDisplayName() ?
item.getItemMeta().getDisplayName() : Config.getPrettyName(item.getType().name());
customAlerts.append(" ").append(item.getAmount()).append(" ").append(name);
buildAlert(customAlerts, item, null, item.getAmount(), null);
}
player.sendMessage(ChatColor.GOLD + customAlerts.toString());
} else {
// otherwise, if list drops are enabled we aggregate and report items when done everything
if (Config.isListDrops()) {
for (ItemStack item : hoe.getDrops()) {
String name = item.hasItemMeta() && item.getItemMeta().hasDisplayName() ?
item.getItemMeta().getDisplayName() : Config.getPrettyName(item.getType().name());
alertBuffer.append(" ").append(item.getAmount()).append(" ").append(name).append(",");
buildAlert(alertBuffer, item, null, item.getAmount(), ",");

}
}
}
Expand Down Expand Up @@ -372,7 +373,8 @@ private void doActualGenerate(final List<ItemStack> items, final Location source
maxWalk --;
}

if (xform.getAmount() - cPlace < 1 && dropConfig.dropIfTransformFails) { // total failure.
int placed = xform.getAmount() - cPlace;
if (placed < 1 && dropConfig.dropIfTransformFails) { // total failure.
ItemStack toDrop = xform.clone();
toDrop.setAmount(Math.min(xform.getAmount(), dropConfig.maxDropsIfTransformFails));
final List<ItemStack> newDrops = new ArrayList<ItemStack>();
Expand All @@ -384,27 +386,41 @@ private void doActualGenerate(final List<ItemStack> items, final Location source

log("STAT: Player {0} at {1} broke {2} - replacing with {3} {4} as {6}",
player.getDisplayName(), player.getLocation(), blockName,
xform.getAmount()- cPlace, name, expressed);
placed, name, expressed);

// Anything to tell anyone about?
if (cPlace < xform.getAmount() && Config.isAlertUser()) {
if (placed > 0 && Config.isAlertUser()) {
if (blockConfig.hasCustomPrefix(dropName)) {
StringBuffer customAlerts = new StringBuffer(blockConfig.getPrefix(dropName));
// if this block has a custom prefix we alert immediately
StringBuilder customAlerts = new StringBuilder(blockConfig.getPrefix(dropName));

customAlerts.append(" ").append(xform.getAmount() - cPlace).append(" ").append(
name).append(" nearby"); // TODO: Replace with configured suffix
buildAlert(customAlerts, null, name, placed, " nearby");

player.sendMessage(ChatColor.GOLD + customAlerts.toString());
} else {
// otherwise, we aggregate our notices and send them after all drop / gen is done.
if (Config.isListDrops()) {
alertBuffer.append(" ").append(xform.getAmount() - cPlace).append(" ").append(
name).append(" nearby,"); // TODO: Replace with configured suffix
buildAlert(alertBuffer, null, name, placed, " nearby,");
}
}
}
}
}
}

private void buildAlert(StringBuilder alertBuilder, ItemStack item, String nameOverride, int amount, String postfix) {
String name = nameOverride;
if (name == null && item != null) {
name = item.hasItemMeta() && item.getItemMeta().hasDisplayName() ?
item.getItemMeta().getDisplayName() : Config.getPrettyName(item.getType().name());
}

alertBuilder.append(" ").append(amount).append(" ").append(name);
if (postfix != null) {
alertBuilder.append(postfix);
}
}

private static BlockFace[] visibleFaces = new BlockFace[] {
BlockFace.DOWN, BlockFace.UP, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH
};
Expand Down
Loading

0 comments on commit 5eb355f

Please sign in to comment.