generated from Matt-MX/KtPaperPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/mattmx/nametags/TestPlaceholderExpansion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.mattmx.nametags; | ||
|
||
import me.clip.placeholderapi.expansion.PlaceholderExpansion; | ||
import me.clip.placeholderapi.expansion.Relational; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.text.DecimalFormat; | ||
|
||
public class TestPlaceholderExpansion extends PlaceholderExpansion implements Relational { | ||
@Override | ||
public @NotNull String getIdentifier() { | ||
return "dev"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getAuthor() { | ||
return "MattMX"; | ||
} | ||
|
||
@Override | ||
public @NotNull String getVersion() { | ||
return "1.0.0"; | ||
} | ||
|
||
private static final DecimalFormat decimalFormat = new DecimalFormat("#,###.0"); | ||
|
||
@Override | ||
public String onPlaceholderRequest(Player one, Player two, String identifier) { | ||
if (one == two) { | ||
return "0.0"; | ||
} | ||
|
||
double blocks = one.getLocation().distance(two.getLocation()); | ||
// double blocks = one.getLocation().distance(one.getLocation().getWorld().getSpawnLocation()); | ||
|
||
if (blocks > 1000) { | ||
double km = blocks / 1000; | ||
return decimalFormat.format(km) + "k"; | ||
} else { | ||
return decimalFormat.format(blocks); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters