Исправь ошибку в коде (BukkitAPI):

  • Майская распродажа!

    Впереди теплые праздники, цены таят на глазах! Поздравляем вас и дарим вам специальный купон.
    Мы предлагаем вам специальное предложение на подписку, действительное только по временному купону.
    Обнови свой сервер с лучшими сборками, плагинами и картами!

    Купон
    MAY20
  • Мы теперь в Discord

    Мы рады объявить, что теперь у нас есть сервер Discord. В честь этого мы проводим розыгрыш!
    Теперь вы можете легко связаться с нами и другими участниками сообщества,
    обмениваться идеями и получать обновления о нашей деятельности.

  • EXCLUSIVE ⚡

    Гость, покупая подписку, ты увеличишь свои доходы в разы!
    Мы делаем самые актуальные сборки, переводим лучшие приватные плагины, а так-же обновляем их и фиксим любые ошибки.
    Дешевле, чем студии и другие разработчики!

  • Приветствуем тебя Гость!⁣

    Недавно на форуме? Не знаешь как можно скачивать ресурсы?
    Для этого нужно лишь зарегистрировать на форуме, и получать доступ к профессиональным плагинам, оптимизированным настройкам.
    Здесь только самое лучшее.

  • Обновленный «Mc-market.ru»

    Теперь у вас есть возможность продавать свои товары на Minecraft маркете.
    Это отличная возможность для вас начать зарабатывать на своих навыках и труде.
    Начни продавать сейчас!

  • Интеграция ChatGPT

    Администраторы Minecraft могут столкнуться с различными проблемами, связанными с работой серверов и кодом.
    Однако, благодаря инновационным технологиям, искусственный интеллект может помочь решить эти проблемы.
    Реши свою любую проблему сейчас!

K0lbasa

Пользователь
19 Фев 2021
255
0
16
Исправь ошибку в коде (BukkitAPI):



if (is.hasItemMeta()) {
String dm = is.getItemMeta().getDisplayName();
String s = cm.getClan(p.getName());
List<String> list = cm.getPerms(s, role.get(p.getName()));
StringBuilder str = new StringBuilder();
p.sendMessage(list.toString());

if (dm.contains("Добавлять участников")) {
if (list.contains("users")) { list.remove("users");
} else { list.add("users"); }

} else if (dm.contains("Покупать улучшения")) {
if (list.contains("perks")) { list.remove("perks");
} else { list.add("perks"); }

} else if (dm.contains("Редактировать описание")) {
if (list.contains("lore")) { list.remove("lore");
} else { list.add("lore"); }

} else if (dm.contains("Кикать участников")) {
if (list.contains("kick")) {
list.remove("kick"); p.sendMessage("removedkick");
} else { list.add("kick"); p.sendMessage("addedkick"); }
}

p.sendMessage(list.toString()+" Last!");

for (String st : list) {
str.append(st);
} cm.setPerms(s, role.get(p.getName()), str.toString());
new PermsGUI().openGUI(p);
}
 

ChatGPT ?

Официальный
30 Мар 2023
630
5
1
There are multiple syntax errors in the code that need to be fixed:

1. Line 9: The if statement is not closed properly with a closing brace.
2. Line 13: The if statement is not closed properly with a closing brace.
3. Line 17: The if statement is not closed properly with a closing brace.
4. Line 23-26: The if-else statements are not closed properly with a closing brace after the else statements.

Here's the corrected code:

if (is.hasItemMeta()) {
String dm = is.getItemMeta().getDisplayName();
String s = cm.getClan(p.getName());
List<String> list = cm.getPerms(s, role.get(p.getName()));
StringBuilder str = new StringBuilder();
p.sendMessage(list.toString());

if (dm.contains("Добавлять участников")) {
if (list.contains("users")) {
list.remove("users");
} else {
list.add("users");
}
} else if (dm.contains("Покупать улучшения")) {
if (list.contains("perks")) {
list.remove("perks");
} else {
list.add("perks");
}
} else if (dm.contains("Редактировать описание")) {
if (list.contains("lore")) {
list.remove("lore");
} else {
list.add("lore");
}
} else if (dm.contains("Кикать участников")) {
if (list.contains("kick")) {
list.remove("kick");
p.sendMessage("removedkick");
} else {
list.add("kick");
p.sendMessage("addedkick");
}
}

p.sendMessage(list.toString() + " Last!");

for (String st : list) {
str.append(st);
}
cm.setPerms(s, role.get(p.getName()), str.toString());
new PermsGUI().openGUI(p);
}
 

K0lbasa

Пользователь
19 Фев 2021
255
0
16
There are multiple syntax errors in the code that need to be fixed:

1. Line 9: The if statement is not closed properly with a closing brace.
2. Line 13: The if statement is not closed properly with a closing brace.
3. Line 17: The if statement is not closed properly with a closing brace.
4. Line 23-26: The if-else statements are not closed properly with a closing brace after the else statements.

Here's the corrected code:

if (is.hasItemMeta()) {
String dm = is.getItemMeta().getDisplayName();
String s = cm.getClan(p.getName());
List<String> list = cm.getPerms(s, role.get(p.getName()));
StringBuilder str = new StringBuilder();
p.sendMessage(list.toString());

if (dm.contains("Добавлять участников")) {
if (list.contains("users")) {
list.remove("users");
} else {
list.add("users");
}
} else if (dm.contains("Покупать улучшения")) {
if (list.contains("perks")) {
list.remove("perks");
} else {
list.add("perks");
}
} else if (dm.contains("Редактировать описание")) {
if (list.contains("lore")) {
list.remove("lore");
} else {
list.add("lore");
}
} else if (dm.contains("Кикать участников")) {
if (list.contains("kick")) {
list.remove("kick");
p.sendMessage("removedkick");
} else {
list.add("kick");
p.sendMessage("addedkick");
}
}

p.sendMessage(list.toString() + " Last!");

for (String st : list) {
str.append(st);
}
cm.setPerms(s, role.get(p.getName()), str.toString());
new PermsGUI().openGUI(p);
}
не работает, строка не убирается из списка.
 

ChatGPT ?

Официальный
30 Мар 2023
630
5
1
не работает, строка не убирается из списка.
There may be an issue with the logic inside the code. Without seeing the rest of the code and understanding the context, it's hard to give a definitive answer. However, here are a few things you can try to debug the issue:

1. Print out the value of `dm` and make sure it contains the expected string value.
2. Print out the value of `list` before and after running the `list.remove()` function. Make sure the value is actually being removed from the list.
3. Check if any other functions in the code are modifying the value of `list`. This could be causing the issue.

Once you have identified the issue, you can make the necessary changes to the code.
 

K0lbasa

Пользователь
19 Фев 2021
255
0
16
There may be an issue with the logic inside the code. Without seeing the rest of the code and understanding the context, it's hard to give a definitive answer. However, here are a few things you can try to debug the issue:

1. Print out the value of `dm` and make sure it contains the expected string value.
2. Print out the value of `list` before and after running the `list.remove()` function. Make sure the value is actually being removed from the list.
3. Check if any other functions in the code are modifying the value of `list`. This could be causing the issue.

Once you have identified the issue, you can make the necessary changes to the code.
Скорее всего ошибка из-за этого метода:


public void setPerms(String clan, String role, String perms) {
for(String s : getRoles(clan)) {
if(s.contains(role)) {
String[] str = s.split("\\s");
cfg.set(clan+".Roles", str[0]+" "+perms);
SClans.getInstance().saveConfig();
}
}
}
 

ChatGPT ?

Официальный
30 Мар 2023
630
5
1
Скорее всего ошибка из-за этого метода:


public void setPerms(String clan, String role, String perms) {
for(String s : getRoles(clan)) {
if(s.contains(role)) {
String[] str = s.split("\\s");
cfg.set(clan+".Roles", str[0]+" "+perms);
SClans.getInstance().saveConfig();
}
}
}
It seems like the issue could be within the `setPerms` method. One thing you can try is to loop through the roles of the clan and update the permissions of the specific role using the `split` method to separate the role name from its associated permissions. Here's a modified version of the `setPerms` method that may help:

```
public void setPerms(String clan, String role, String perms) {
List<String> roles = getRoles(clan);
for (int i = 0; i < roles.size(); i++) {
String line = roles.get(i); // get the current line in the list
String[] splitLine = line.split("\\s+"); // split the line by any number of whitespaces
if (splitLine[0].equals(role)) { // if the first part of the line matches the role we are updating
roles.set(i, splitLine[0] + " " + perms); // update the line with the new permissions
break; // exit the loop once the correct role has been updated
}
}
cfg.set(clan + ".Roles", roles); // update the config with the new list of roles
SClans.getInstance().saveConfig(); // save the config
}
```

This method loops through the `roles` list to find the specified role, updates the permissions of that role, and then updates the `cfg` config with the updated list of roles.
 

K0lbasa

Пользователь
19 Фев 2021
255
0
16
It seems like the issue could be within the `setPerms` method. One thing you can try is to loop through the roles of the clan and update the permissions of the specific role using the `split` method to separate the role name from its associated permissions. Here's a modified version of the `setPerms` method that may help:

```
public void setPerms(String clan, String role, String perms) {
List<String> roles = getRoles(clan);
for (int i = 0; i < roles.size(); i++) {
String line = roles.get(i); // get the current line in the list
String[] splitLine = line.split("\\s+"); // split the line by any number of whitespaces
if (splitLine[0].equals(role)) { // if the first part of the line matches the role we are updating
roles.set(i, splitLine[0] + " " + perms); // update the line with the new permissions
break; // exit the loop once the correct role has been updated
}
}
cfg.set(clan + ".Roles", roles); // update the config with the new list of roles
SClans.getInstance().saveConfig(); // save the config
}
```

This method loops through the `roles` list to find the specified role, updates the permissions of that role, and then updates the `cfg` config with the updated list of roles.
Появилась другая проблема:

if (is.hasItemMeta()) {
String dm = is.getItemMeta().getDisplayName();
String s = cm.getClan(p.getName());
List<String> list = cm.getPerms(s, role.get(p.getName()));
StringBuilder str = new StringBuilder();

if (dm.contains("Добавлять участников")) {
if (list.contains("users")) {
list.remove("users");
} else {
list.add("users");
}
} else if (dm.contains("Покупать улучшения")) {
if (list.contains("perks")) {
list.remove("perks");
} else {
list.add("perks");
}
} else if (dm.contains("Редактировать описание")) {
if (list.contains("lore")) {
list.remove("lore");
} else {
list.add("lore");
}
} else if (dm.contains("Кикать участников")) {
if (list.contains("kick")) {
list.remove("kick");
} else {
list.add("kick");
}
}

p.sendMessage(list.toString());

for (String st : list) {
if((list.indexOf(st)+1) == list.size()) {
str.append(st);
} else {
str.append(st).append("-");
}
}
cm.setPerms(s, role.get(p.getName()), str.toString());
new PermsGUI().openGUI(p);
}
 

ChatGPT ?

Официальный
30 Мар 2023
630
5
1
Появилась другая проблема:

if (is.hasItemMeta()) {
String dm = is.getItemMeta().getDisplayName();
String s = cm.getClan(p.getName());
List<String> list = cm.getPerms(s, role.get(p.getName()));
StringBuilder str = new StringBuilder();

if (dm.contains("Добавлять участников")) {
if (list.contains("users")) {
list.remove("users");
} else {
list.add("users");
}
} else if (dm.contains("Покупать улучшения")) {
if (list.contains("perks")) {
list.remove("perks");
} else {
list.add("perks");
}
} else if (dm.contains("Редактировать описание")) {
if (list.contains("lore")) {
list.remove("lore");
} else {
list.add("lore");
}
} else if (dm.contains("Кикать участников")) {
if (list.contains("kick")) {
list.remove("kick");
} else {
list.add("kick");
}
}

p.sendMessage(list.toString());

for (String st : list) {
if((list.indexOf(st)+1) == list.size()) {
str.append(st);
} else {
str.append(st).append("-");
}
}
cm.setPerms(s, role.get(p.getName()), str.toString());
new PermsGUI().openGUI(p);
}
It seems that the issue could be caused by the `cm.setPerms` method. One possible solution could be to clear the permissions list in the `cm` object before setting the updated permissions for the specified role. Here's an updated version of the `setPerms` method for your reference:

```
public void setPerms(String clan, String role, String perms) {
List<String> roles = getRoles(clan);
for (int i = 0; i < roles.size(); i++) {
String line = roles.get(i);
String[] splitLine = line.split("\\s+");
if (splitLine[0].equals(role)) {
roles.set(i, splitLine[0] + " " + perms);
break;
}
}
cfg.set(clan + ".Roles", roles);
SClans.getInstance().saveConfig();
cm.clearPerms(clan, role); // clear the permissions for the specified role
for (String permission : perms.split("-")) { // add the updated permissions to the role
cm.addPerm(clan, role, permission.trim());
}
}
```

This updated method clears the permissions for the specified role using the `cm.clearPerms` method before adding the updated permissions to the role using the `cm.addPerm` method.
 

Помочь проекту! 💕

Собрано
"40,197.60" ₽
Цель
"50,000.00" ₽

Новые сообщения

Последние ресурсы