Skip to content

Commit

Permalink
Версия 0.3.4
Browse files Browse the repository at this point in the history
- Добавлена возможность менять длительность оповещений о донатах на экране
- Добавлена возможность устанавливать количество сотрудников НКВД
- Фикс ошибки, из-за которой не считывалось из конфигурационного файла число хлеба, алмазов и радиуса взрыва BigBoomRadius
- Переименованы кастомные значения в конфигурационном файле в соответствии с общепринятым форматом
- Мелкие фиксы багов и очистка кода
  • Loading branch information
link1107 committed Feb 10, 2022
1 parent e28c8ad commit df8420d
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>IgorLink</groupId>
<artifactId>DonationExecutor</artifactId>
<version>0.3.3-SNAPSHOT</version>
<version>0.3.4-SNAPSHOT</version>
<packaging>jar</packaging>

<name>DonationExecutor</name>
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/igorlink/donationexecutor/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import static igorlink.service.Utils.*;
import static java.lang.Math.random;
import static java.lang.Math.round;
import static org.bukkit.Bukkit.getPlayer;
import static org.bukkit.Bukkit.getPlayerExact;

public class Executor {
Expand Down Expand Up @@ -105,7 +104,7 @@ public static void shitToInventory (Player player, String donationUsername) {
meta.setLore(List.of("§7Это говно ужасно вонюче и занимает много места"));
itemStack.setItemMeta(meta);

for (int i = 0; i < MainConfig.dirtAmount; i++) {
for (int i = 0; i < MainConfig.getDirtAmount(); i++) {
player.getInventory().addItem(itemStack);
}
}
Expand Down Expand Up @@ -187,7 +186,7 @@ public static void spawnCreeper (Player player, String donationUsername) {
public static void giveDiamonds (Player player, String donationUsername) {
//Give some diamonds to the player
announce(donationUsername, "насыпал тебе алмазов!", "насыпал алмазов", player, true);
ExecUtils.giveToPlayer(player, Material.DIAMOND, 4, donationUsername);
ExecUtils.giveToPlayer(player, Material.DIAMOND, MainConfig.getDiamondsAmount(), donationUsername);
}

public static void giveStackOfDiamonds (Player player, String donationUsername) {
Expand All @@ -197,7 +196,7 @@ public static void giveStackOfDiamonds (Player player, String donationUsername)

public static void giveBread (Player player, String donationUsername) {
announce(donationUsername, "дал тебе Советского Хлеба!", "дал Советского Хлеба", player, true);
ExecUtils.giveToPlayer(player, Material.BREAD, 4, donationUsername, "§6Советский Хлеб");
ExecUtils.giveToPlayer(player, Material.BREAD, MainConfig.getBreadAmount(), donationUsername, "§6Советский Хлеб");
}

public static void callNKVD (Player player, String donationUsername) {
Expand All @@ -206,16 +205,16 @@ public static void callNKVD (Player player, String donationUsername) {
announce(donationUsername, "хочет отправить тебя в ГУЛАГ!", "хочет отправить в ГУЛАГ", player, true);
direction.setY(0);
direction.normalize();
for (int i = 1; i <= 1; i++) {
for (int i = 1; i <= MainConfig.getAmountOfNKVD(); i++) {
Location newloc = player.getLocation().clone();
Vector newdir = direction.clone();
newdir = newdir.rotateAroundY(1.5708 * i).multiply(2);
newloc.add(newdir);
nkvdMob = (LivingEntity) player.getWorld().spawnEntity(newloc, EntityType.ZOMBIE);
nkvdMob.setCustomName("§cСотрудник НКВД");
nkvdMob.getEquipment().setItem(EquipmentSlot.HAND, new ItemStack(Material.WOODEN_SWORD));
Objects.requireNonNull(nkvdMob.getEquipment()).setItem(EquipmentSlot.HAND, new ItemStack(Material.WOODEN_SWORD));
if (((Zombie) nkvdMob).isAdult()) {
nkvdMob.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.28);
Objects.requireNonNull(nkvdMob.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(0.28);
}
}

Expand Down Expand Up @@ -248,15 +247,15 @@ public static void randomChange (Player player, String donationUsername) {

}

String replacedItems = new String("");
StringBuilder replacedItems = new StringBuilder();
int replacedCounter = 0;
for (int i = 0; i <= 4; i++) {
if (!(player.getInventory().getItem(randoms[i]) == null)) {
replacedCounter++;
if (replacedCounter > 1) {
replacedItems = replacedItems + "§f, ";
replacedItems.append("§f, ");
}
replacedItems = replacedItems + "§b" + Objects.requireNonNull(player.getInventory().getItem(randoms[i])).getAmount() + " §f" + Objects.requireNonNull(player.getInventory().getItem(randoms[i])).getI18NDisplayName();
replacedItems.append("§b").append(Objects.requireNonNull(player.getInventory().getItem(randoms[i])).getAmount()).append(" §f").append(Objects.requireNonNull(player.getInventory().getItem(randoms[i])).getI18NDisplayName());
}
player.getInventory().setItem(randoms[i], new ItemStack(Material.STONE, 1));
}
Expand Down Expand Up @@ -293,7 +292,7 @@ public static void tamedBecomesEnemies (Player player, String donationUsername)

public static void bigBoom (Player player, String donationUsername) {
announce(donationUsername, "сейчас тебя РАЗНЕСЕТ В КЛОЧЬЯ!!!", "сейчас РАЗНЕСЕТ В КЛОЧЬЯ", player, true);
player.getWorld().createExplosion(player.getLocation(), MainConfig.bigBoomRadius, true);
player.getWorld().createExplosion(player.getLocation(), MainConfig.getBigBoomRadius(), true);

}

Expand Down Expand Up @@ -353,7 +352,7 @@ public static void spawnTamedCat (Player player, String donationUsername) {

public static void healPlayer (Player player, String donationUsername) {
announce(donationUsername, "подарил тебе котейку!", "подарил котейку", player, true);
player.setHealth(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
player.setHealth(Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Boolean execute(String donationUsername, Player player) {
meta.setDisplayName("§cГОВНО ОТ §f" + donationUsername.toUpperCase());
meta.setLore(Arrays.asList("§7Это говно ужасно вонюче и занимает много места"));
itemStack.setItemMeta(meta);
for (int i = 0; i < MainConfig.dirtAmount; i++) {
for (int i = 0; i < MainConfig.getDirtAmount(); i++) {
player.getInventory().addItem(itemStack);
}
return true;
Expand Down
38 changes: 25 additions & 13 deletions src/main/java/igorlink/service/MainConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@
import org.bukkit.configuration.file.FileConfiguration;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MainConfig {
private static FileConfiguration config = DonationExecutor.getInstance().getConfig();
public static int dirtAmount = 0;
public static int diamondsAmount = 0;
public static int breadAmount = 0;
public static int bigBoomRadius = 0;
public static String token;
public static List<String> listOfBlackListedSubstrings = new ArrayList<>();
private static int dirtAmount;
private static int diamondsAmount;
private static int breadAmount;
private static int bigBoomRadius;
private static int timeForAnnouncement;
private static int amountOfNKVD;
private static String token;
private static List<String> listOfBlackListedSubstrings = new ArrayList<>();
public static List<String> listOfWhiteListedSubstrings = new ArrayList<>();
private static Boolean twitchFilter;
private static Boolean forceResourcePack;
Expand Down Expand Up @@ -45,10 +48,11 @@ public static void loadMainConfig(Boolean isReload) throws InterruptedException

config = DonationExecutor.getInstance().getConfig();

dirtAmount = config.getInt("DirtAmount");
diamondsAmount = config.getInt("DiamondsAmount");
breadAmount = config.getInt("BreadAmount");
bigBoomRadius = config.getInt("BigBoomRadius");
dirtAmount = config.getInt("dirt-amount");
diamondsAmount = config.getInt("diamonds-amount");
breadAmount = config.getInt("bread-amount");
bigBoomRadius = config.getInt("big-boom-radius");
timeForAnnouncement = config.getInt("announcement-duration-seconds");

token = config.getString("DonationAlertsToken");
listOfBlackListedSubstrings = config.getStringList("BlacklistedSubstrings");
Expand All @@ -57,6 +61,7 @@ public static void loadMainConfig(Boolean isReload) throws InterruptedException
optifineNotification = config.getBoolean("notify-about-optifine");
twitchFilter = config.getBoolean("twitch-filter");
forceResourcePack = config.getBoolean("force-download-resourcepack");

}


Expand All @@ -65,11 +70,18 @@ public static void turnFilterOn() {
}
public static void turnFilterOff() { twitchFilter = false; }

public static Boolean getFilterStatus() { return twitchFilter; }
public static Boolean isForceResourcePack() {
public static boolean getFilterStatus() { return twitchFilter; }
public static boolean isForceResourcePack() {
return forceResourcePack;
}
public static Boolean isOptifineNotificationOn() { return optifineNotification; }
public static boolean isOptifineNotificationOn() { return optifineNotification; }
public static int getDirtAmount() { return dirtAmount; }
public static int getBigBoomRadius() { return bigBoomRadius; }
public static int getDiamondsAmount() { return diamondsAmount; }
public static int getBreadAmount() { return breadAmount; }
public static int getTimeForAnnouncement() { return timeForAnnouncement; }
public static int getAmountOfNKVD() { return amountOfNKVD; }
public static List<String> getListOfBlackListedSubstrings() { return listOfBlackListedSubstrings; }


}
5 changes: 2 additions & 3 deletions src/main/java/igorlink/service/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public static void announce(String donaterName, String subText, String alterSubt
if (donaterName.equals("")) {
_donaterName = "Кто-то";
}
Title title = new Title("§c" + _donaterName, "§f" + subText);
player.sendTitle(title);
player.sendTitle("§c" + _donaterName,"§f" + subText, 7, MainConfig.getTimeForAnnouncement()*20, 7);
player.sendMessage("§c[DE] §fДонатер §c" + _donaterName, "§f" + subText);
}

Expand Down Expand Up @@ -180,7 +179,7 @@ public static Boolean isBlackListed(String text) {
}


for (String ss : MainConfig.listOfBlackListedSubstrings) {
for (String ss : MainConfig.getListOfBlackListedSubstrings()) {
for (int i = 0; i <= validationText.length() - ss.length(); i++) {
int tempi = i;
for (int j = 0; j <= ss.length(); j++) {
Expand Down
11 changes: 7 additions & 4 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ donation-amounts:
GiveStackOfDiamonds: 2012
#Далее вы можете добавите другие токены и других игроков по образцу выше.

# Сколько секунд будет висеть оповещение о донате
announcement-duration-seconds: 3

# Сколько блоков говна игроки будут получать в инвентарь от ShitToInventory
DirtAmount: 10
dirt-amount: 10
# Сколько алмазов игроки будут получать в инвентарь от GiveDiamonds
DiamondsAmount: 4
diamonds-amount: 4
# Сколько хлеба игроки будут получать в инвентарь от GiveBread
BreadAmount: 4
bread-amount: 4
# Радиус взрыва от BigBoom
BigBoomRadius: 20
big-boom-radius: 20

# ДЛЯ КОРРЕКТНОГО ОТОБРАЖЕНИЯ КАСТОМНЫХ СКИНОВ ПЛАГИНА У ИГРОКОВ ДОЛЖЕН БЫТЬ УСТАНОВЛЕН МОД OPTIFINE - https://optifine.net/downloads
# ЧТОБЫ ОТКЛЮЧИТЬ УВЕДОМЛЕНИЯ О НЕОБХОДИМОСТИ УСТАНОВИТЬ ОПТИФАЙН, ИЗМЕНИТЕ ЗНАЧЕНИЕ НИЖЕ С "true" НА "false"
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: DonationExecutor
version: 0.3.3
version: 0.3.4
website: "https://github.com/link1107/DonationExecutor"
main: igorlink.donationexecutor.DonationExecutor
api-version: 1.18
authors: [Igor Link]
Expand Down

0 comments on commit df8420d

Please sign in to comment.