fix
This commit is contained in:
parent
c3af2d9311
commit
b761af24ce
4 changed files with 29 additions and 24 deletions
|
@ -17,10 +17,10 @@ public class CommandManager {
|
||||||
new HologramCommand();
|
new HologramCommand();
|
||||||
new CraftCommand();
|
new CraftCommand();
|
||||||
new EnchantingCommand();
|
new EnchantingCommand();
|
||||||
|
new WeaponCommand();
|
||||||
new BetaCommand(main);
|
new BetaCommand(main);
|
||||||
new RankCommand(main);
|
new RankCommand(main);
|
||||||
new UtilCommand(main);
|
new UtilCommand(main);
|
||||||
new WeaponCommand(main);
|
|
||||||
new MinerCommand(main);
|
new MinerCommand(main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,9 @@ public class WeaponCommand extends Command {
|
||||||
public void onCommand(CommandSender sender, String[] args) {
|
public void onCommand(CommandSender sender, String[] args) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
StringBuilder s = new StringBuilder();
|
StringBuilder s = new StringBuilder();
|
||||||
|
if (args.length == 0) {
|
||||||
|
player.sendMessage(ChatColor.RED + "This item doesn't exist");
|
||||||
|
} else {
|
||||||
List<String> b = Arrays.asList(args);
|
List<String> b = Arrays.asList(args);
|
||||||
for (String a : args) {
|
for (String a : args) {
|
||||||
if (a.equals(b.get(b.size() - 1))) {
|
if (a.equals(b.get(b.size() - 1))) {
|
||||||
|
@ -31,9 +34,6 @@ public class WeaponCommand extends Command {
|
||||||
s.append(" ");
|
s.append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s.isEmpty()) {
|
|
||||||
player.sendMessage(ChatColor.RED + "This item doesn't exist");
|
|
||||||
} else {
|
|
||||||
ItemStack item = CustomItemManager.getItem(s.toString());
|
ItemStack item = CustomItemManager.getItem(s.toString());
|
||||||
if (item.hasItemMeta()) {
|
if (item.hasItemMeta()) {
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.mongodb.client.model.Filters;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
private MongoClient client;
|
private MongoClient client;
|
||||||
private static MongoCollection<Document> users;
|
private static MongoCollection<Document> users;
|
||||||
|
@ -37,16 +39,19 @@ public class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public static void getUser(String username) {
|
public static HashMap<String, Object> getUser(String username) {
|
||||||
try (MongoCursor<Document> cursor = users.find(Filters.eq("Username", username)).cursor()) {
|
try (MongoCursor<Document> cursor = users.find(Filters.eq("Username", username)).cursor()) {
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
Document doc = (Document) cursor.next();
|
Document doc = cursor.next();
|
||||||
for(String a : doc.keySet()) {
|
for (String a : doc.keySet()) {
|
||||||
if(!a.equals("_id")) {
|
if (!a.equals("_id")) {
|
||||||
// System.out.println(a + ": " + doc.get(a));
|
HashMap<String, Object> details = new HashMap<>();
|
||||||
|
details.put(a, doc.get(a));
|
||||||
|
return details;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,11 +108,11 @@ public class CustomItemEvents implements Listener {
|
||||||
ItemStack weapon = player.getInventory().getItemInMainHand();
|
ItemStack weapon = player.getInventory().getItemInMainHand();
|
||||||
ItemMeta weaponMeta = weapon.getItemMeta();
|
ItemMeta weaponMeta = weapon.getItemMeta();
|
||||||
PersistentDataContainer container = weaponMeta.getPersistentDataContainer();
|
PersistentDataContainer container = weaponMeta.getPersistentDataContainer();
|
||||||
System.out.println(name);
|
|
||||||
if(container != null) {
|
if(container != null) {
|
||||||
int ammo = container.get(CustomItemManager.keys.get("Snow Gun" + "." + "ammo"), PersistentDataType.INTEGER);
|
NamespacedKey ammocount = CustomItemManager.keys.get("Snow Gun.ammo");
|
||||||
container.set(CustomItemManager.keys.get("Snow Gun" + "." + "ammo"), PersistentDataType.INTEGER, ammo - 1);
|
int ammo = container.get(ammocount, PersistentDataType.INTEGER);
|
||||||
int maxload = container.get(CustomItemManager.keys.get("Snow Gun" + "." + "maxload"), PersistentDataType.INTEGER);
|
container.set(ammocount, PersistentDataType.INTEGER, ammo - 1);
|
||||||
|
int maxload = container.get(CustomItemManager.keys.get("Snow Gun.maxload"), PersistentDataType.INTEGER);
|
||||||
weapon.setItemMeta(weaponMeta);
|
weapon.setItemMeta(weaponMeta);
|
||||||
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6AK-47 ( " + (ammo - 1) + "/ " + maxload + " )")));
|
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', "&6AK-47 ( " + (ammo - 1) + "/ " + maxload + " )")));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue