Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ dependencies {
implementation(libs.javaapiforkml) {
exclude(group = "com.sun.xml.bind", module = "jaxb-xjc") // Else Remapping will yell of duplicated classes
}
implementation(libs.googlecode.json.simple)
implementation(libs.bstats.bukkit)
implementation(libs.buildtheearth.projection) {
exclude(group = "com.google.guava", module = "guava")
Expand Down Expand Up @@ -116,6 +115,12 @@ tasks.shadowJar {
// Prevents the plugin itself from being relocated by autorelocate
// This is needed because net.buildtheearth.projection shares the same package namespace
relocate("net.buildtheearth.buildteamtools", "net.buildtheearth.buildteamtools")

// Let KotlinModuleMetadataTransformer merge okhttp/okio/stdlib .kotlin_module files
// (default EXCLUDE drops duplicates before the transformer sees them).
filesMatching("META-INF/*.kotlin_module") {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}

tasks.assemble {
Expand Down
3 changes: 0 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ dazzleconf = "2.0.0-M3"
fawe-bom = "1.56"
# https://central.sonatype.com/artifact/com.google.code.gson/gson
googlecode-gson = "2.15.0"
# https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple
googlecode-json-simple = "1.1.1"
# https://github.com/urbancamo/javaapiforkml
javaapiforkml = "3.1.2"
# https://mvnrepository.com/artifact/org.json/json
Expand Down Expand Up @@ -75,7 +73,6 @@ dazzleconf = { module = "space.arim.dazzleconf:dazzleconf-yaml", version.ref = "
com-alpsbte-alpslib-alpslib-libpsterra = { module = "com.alpsbte.alpslib:alpslib-libpsterra", version.ref = "alpslib-libpsterra" }
fawe-bom = { module = "com.intellectualsites.bom:bom-newest", version.ref = "fawe-bom" }
googlecode-gson = { module = "com.google.code.gson:gson", version.ref = "googlecode-gson" }
googlecode-json-simple = { module = "com.googlecode.json-simple:json-simple", version.ref = "googlecode-json-simple" }
javaapiforkml = { module = "uk.m0nom:javaapiforkml", version.ref = "javaapiforkml" }
json = { module = "org.json:json", version.ref = "json" }
okhttp-jvm = { module = "com.squareup.okhttp3:okhttp-jvm", version.ref = "okhttp-jvm" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public static Locale locale(@Nullable Audience audience) {
return audience.get(Identity.LOCALE).orElse(Translations.DEFAULT_LOCALE);
}

public static Locale locale(Player player) {
public static Locale locale(@Nullable Player player) {
if (player == null) {
return Translations.DEFAULT_LOCALE;
}
return player.locale();
}

Expand All @@ -78,24 +81,24 @@ public static Component render(@Nullable Audience audience, Component component)
return render(component, locale(audience));
}

public static Component render(Player player, Component component) {
public static Component render(@Nullable Player player, Component component) {
return render(component, locale(player));
}

public static Component render(Player player, String key, ComponentLike... args) {
public static Component render(@Nullable Player player, String key, ComponentLike... args) {
return render(player, component(key, args));
}

/** Legacy section string for APIs that still require {@link String} item names/lore. */
public static String legacy(Player player, Component component) {
public static String legacy(@Nullable Player player, Component component) {
return LEGACY.serialize(render(player, component));
}

public static String legacy(Player player, String key, ComponentLike... args) {
public static String legacy(@Nullable Player player, String key, ComponentLike... args) {
return legacy(player, component(key, args));
}

public static String plain(Player player, String key, ComponentLike... args) {
public static String plain(@Nullable Player player, String key, ComponentLike... args) {
return PLAIN.serialize(render(player, key, args));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private static void updateCacheCommand(@NonNull CommandSender sender) {
private static void displayCache(CommandSender sender) {
if (StatsModule.getInstance().isEnabled()) {
MessageBoxes.send(sender, plainTitle(sender, MessageKeys.Common.CACHE_TITLE), () ->
sender.sendMessage(StatsModule.getInstance().getCurrentCache().toJSONString()));
sender.sendMessage(StatsModule.getInstance().getCurrentCache().toString()));
} else {
sender.sendMessage(Messages.component(MessageKeys.Common.CACHE_STATS_DISABLED));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.Arrays;

public class ExceptionListener implements Listener {

public static boolean limiter = false;
Expand All @@ -14,8 +12,6 @@ public class ExceptionListener implements Listener {
public void onException(ServerExceptionEvent e) {
if (limiter) return;

String string = Arrays.toString(e.getException().getStackTrace());

//TODO implement Build Team Exception Handling

limiter = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,7 @@ public void fieldScript_v_1_0() {
for (int i = 0; i < schematicAmount; i++)
availableDirections[i] = Short.parseShort(schematics[i].getName().replace(".schematic", ""));

// Calculate which direction should be used
short directionToUse = availableDirections[0]; // Assume the first element is the closest initially
short minDifference = Short.MAX_VALUE; // Initial difference

for (short current : availableDirections) {
short difference1 = (short) Math.abs(yaw - current);
if (difference1 < minDifference) {
minDifference = difference1;
directionToUse = current;
}

short difference2 = (short) Math.abs(yaw - (current + 180));
if (difference2 < minDifference) {
minDifference = difference2;
directionToUse = current;
}
}
short directionToUse = closestDirection(availableDirections, yaw);

setGmask("<0");
String path =
Expand Down Expand Up @@ -320,4 +304,29 @@ public void fieldScript_v_1_0() {
finish(blocks, points);
*/
}

/**
* Picks the schematic line direction closest to the player's yaw
* (also considering the opposite 180° orientation).
*/
private static short closestDirection(short[] availableDirections, float yaw) {
short directionToUse = availableDirections[0];
short minDifference = Short.MAX_VALUE;

for (short current : availableDirections) {
short difference1 = (short) Math.abs(yaw - current);
if (difference1 < minDifference) {
minDifference = difference1;
directionToUse = current;
}

short difference2 = (short) Math.abs(yaw - (current + 180));
if (difference2 < minDifference) {
minDifference = difference2;
directionToUse = current;
}
}

return directionToUse;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void buildscript_v_1_2() {

// Set pos1 and pos2
List<Vector> outlinePoints = new ArrayList<>(selectionPoints);
outlinePoints.get(0).setY(highestBlock);
outlinePoints.getFirst().setY(highestBlock);
for (Vector point : outlinePoints)
point.setY(minY);
createSelection(outlinePoints);
Expand Down Expand Up @@ -175,7 +175,7 @@ public void buildscript_v_1_2() {

// Set pos1 and pos2
outlinePoints = new ArrayList<>(selectionPoints);
outlinePoints.get(0).setY(maxY);
outlinePoints.getFirst().setY(maxY);
for (Vector point : outlinePoints)
point.setY(minY);
createSelection(outlinePoints);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ public BlockModification(Block block, Material newType) {
this.newType = newType;
}

public Block block;
public Material previousType;
public Material newType;
public final Block block;
public final Material previousType;
public final Material newType;
}

//------------------------------------

public ChangeTransaction(Player p) {
this.player = p;
changes = new ArrayList<>();
blockPositions = new HashSet<BlockLocation>();
blockPositions = new HashSet<>();
}


Expand All @@ -49,7 +49,7 @@ public ChangeTransaction(Player p) {
*
* @param location the location to change
* @param newType the new material / block type for the location
* @return boolean: indicate if the change was accepted or not (i.e. wether this already had a change for the location or not)
* @return boolean: indicate if the change was accepted or not (i.e. whether this already had a change for the location or not)
*/
public boolean addBlockChange(Location location, Material newType) {
return addBlockChange(new BlockLocation(location.getBlockX(), location.getBlockY(), location.getBlockZ()), location.getWorld(), newType);
Expand All @@ -63,7 +63,7 @@ public boolean addBlockChange(Location location, Material newType) {
* @param world the world for the change
* @param location the location to change
* @param newType the new material / block type for the location
* @return boolean: indicate if the change was accepted or not (i.e. wether this already had a change for the location or not)
* @return boolean: indicate if the change was accepted or not (i.e. whether this already had a change for the location or not)
*/
public boolean addBlockChange(BlockLocation location, World world, Material newType) {
//check if we already have a change for this location.
Expand Down Expand Up @@ -97,9 +97,9 @@ public int size() {
return changes.size();
}

public Player player;
List<BlockModification> changes;
Set<BlockLocation> blockPositions; //check to prevent duplicates
public final Player player;
final List<BlockModification> changes;
final Set<BlockLocation> blockPositions; //check to prevent duplicates


}
Loading
Loading