first commit

This commit is contained in:
Spencer
2021-06-16 23:04:34 -04:00
commit 4507b43477
9 changed files with 178 additions and 0 deletions

11
.classpath Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/home/spencer/Downloads/spigot-1.15.2.jar">
<attributes>
<attribute name="javadoc_location" value="https://hub.spigotmc.org/javadocs/spigot/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
**/bin/
.metadata/
.settings/

17
.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PinCount</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

0
README.md Normal file
View File

5
config.yml Normal file
View File

@@ -0,0 +1,5 @@
# Enter the exchange value of the following
# Currently not being used
gb-value = 81
gi-value = 9
gn-value = 1

7
plugin.yml Normal file
View File

@@ -0,0 +1,7 @@
name: PinCount
main: dev.pinfosec.pincount.Main
version: 1.0
api-version: 1.15
commands:
pc:
pa:

View File

@@ -0,0 +1,20 @@
package dev.pinfosec.pincount;
import org.bukkit.plugin.java.JavaPlugin;
import dev.pinfosec.pincount.commands.PCount;
import dev.pinfosec.pincount.commands.PAmount;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
//this.saveDefaultConfig();
new PCount(this);
new PAmount(this);
}
@Override
public void onDisable() {
}
}

View File

@@ -0,0 +1,49 @@
package dev.pinfosec.pincount.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import dev.pinfosec.pincount.Main;
import net.md_5.bungee.api.ChatColor;
public class PAmount implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public PAmount(Main plugin) {
this.plugin = plugin;
plugin.getCommand("pa").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can run this command");
return true;
}
if (args.length < 1 || args.length > 1) {
sender.sendMessage("Usage: /pa {amount}");
return true;
}
int sum = Integer.valueOf(args[0]);
int gbcount = (sum / 81);
sum = (sum - (gbcount * 81));
int gicount = (sum / 9);
sum = (sum - (gicount * 9));
int gncount = sum;
sender.sendMessage(ChatColor.DARK_GRAY + "==" + ChatColor.RESET + ChatColor.DARK_AQUA + "Gold Amount" + ChatColor.RESET + ChatColor.DARK_GRAY + "==");
sender.sendMessage(ChatColor.GOLD + "GN: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gncount));
sender.sendMessage(ChatColor.GOLD + "GI: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gicount));
sender.sendMessage(ChatColor.GOLD + "GB: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gbcount));
return true;
}
}

View File

@@ -0,0 +1,66 @@
package dev.pinfosec.pincount.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import dev.pinfosec.pincount.Main;
import net.md_5.bungee.api.ChatColor;
public class PCount implements CommandExecutor {
@SuppressWarnings("unused")
private Main plugin;
public PCount(Main plugin) {
this.plugin = plugin;
plugin.getCommand("pc").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can execute this command");
return true;
}
Player p = (Player) sender;
int gncount = 0, gicount = 0, gbcount = 0;
for (ItemStack item : p.getInventory().getContents()) {
try {
if (item != null) {
if (item.getType() == Material.GOLD_NUGGET) {
gncount = gncount + item.getAmount();
}
if (item.getType() == Material.GOLD_INGOT) {
gicount = gicount + item.getAmount();
}
if (item.getType() == Material.GOLD_BLOCK) {
gbcount = gbcount + item.getAmount();
}
}
}
catch(Exception e) {
sender.sendMessage(String.valueOf(e));
}
}
int sum = (gncount) + (gicount * 9) + (gbcount * 81);
sender.sendMessage(ChatColor.DARK_GRAY + "==" + ChatColor.RESET + ChatColor.DARK_AQUA + "Gold Balance" + ChatColor.RESET + ChatColor.DARK_GRAY + "==");
sender.sendMessage(ChatColor.GOLD + "GN: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gncount));
sender.sendMessage(ChatColor.GOLD + "GI: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gicount));
sender.sendMessage(ChatColor.GOLD + "GB: " + ChatColor.RESET + ChatColor.DARK_GRAY + String.valueOf(gbcount));
sender.sendMessage(ChatColor.AQUA + "Total: " + ChatColor.RESET + ChatColor.DARK_GRAY + "G" + String.valueOf(sum));
return true;
}
}