From df8420d3fdc26b151cbdb41e06b426427fe5f39a Mon Sep 17 00:00:00 2001 From: link1107 <66795347+link1107@users.noreply.github.com> Date: Thu, 10 Feb 2022 15:48:41 +0100 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B5=D1=80=D1=81=D0=B8=D1=8F=200.3.4=20?= =?UTF-8?q?-=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D0=BC=D0=B5=D0=BD=D1=8F=D1=82=D1=8C=20=D0=B4=D0=BB?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=B2=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20?= =?UTF-8?q?=D0=BE=20=D0=B4=D0=BE=D0=BD=D0=B0=D1=82=D0=B0=D1=85=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D1=8D=D0=BA=D1=80=D0=B0=D0=BD=D0=B5=20-=20=D0=94?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D1=83?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D0=BD=D0=B0=D0=B2=D0=BB=D0=B8=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D1=8C=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=BE=20=D1=81=D0=BE=D1=82=D1=80=D1=83=D0=B4=D0=BD=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE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=B8=D0=BE=D0=BD=D0=BD=D0=BE=D0=BC=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=B5=20=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=81=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=89=D0=B5=D0=BF=D1=80=D0=B8=D0=BD=D1=8F=D1=82=D1=8B=D0=BC=20?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=BE=D0=BC=20-=20=D0=9C?= =?UTF-8?q?=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D1=84=D0=B8=D0=BA=D1=81=D1=8B?= =?UTF-8?q?=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2=20=D0=B8=20=D0=BE=D1=87=D0=B8?= =?UTF-8?q?=D1=81=D1=82=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../igorlink/donationexecutor/Executor.java | 23 ++++++----- .../executions/inventory/ShitToInventory.java | 2 +- .../java/igorlink/service/MainConfig.java | 38 ++++++++++++------- src/main/java/igorlink/service/Utils.java | 5 +-- src/main/resources/config.yml | 11 ++++-- src/main/resources/plugin.yml | 3 +- 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index 4076cbe..49bd225 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ IgorLink DonationExecutor - 0.3.3-SNAPSHOT + 0.3.4-SNAPSHOT jar DonationExecutor diff --git a/src/main/java/igorlink/donationexecutor/Executor.java b/src/main/java/igorlink/donationexecutor/Executor.java index df1cf3a..c056658 100644 --- a/src/main/java/igorlink/donationexecutor/Executor.java +++ b/src/main/java/igorlink/donationexecutor/Executor.java @@ -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 { @@ -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); } } @@ -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) { @@ -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) { @@ -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); } } @@ -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)); } @@ -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); } @@ -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()); } } diff --git a/src/main/java/igorlink/donationexecutor/executionsstaff/executionsmanagement/executions/inventory/ShitToInventory.java b/src/main/java/igorlink/donationexecutor/executionsstaff/executionsmanagement/executions/inventory/ShitToInventory.java index 6d93d5e..12f678e 100644 --- a/src/main/java/igorlink/donationexecutor/executionsstaff/executionsmanagement/executions/inventory/ShitToInventory.java +++ b/src/main/java/igorlink/donationexecutor/executionsstaff/executionsmanagement/executions/inventory/ShitToInventory.java @@ -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; diff --git a/src/main/java/igorlink/service/MainConfig.java b/src/main/java/igorlink/service/MainConfig.java index f1dd72e..de6431b 100644 --- a/src/main/java/igorlink/service/MainConfig.java +++ b/src/main/java/igorlink/service/MainConfig.java @@ -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 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 listOfBlackListedSubstrings = new ArrayList<>(); public static List listOfWhiteListedSubstrings = new ArrayList<>(); private static Boolean twitchFilter; private static Boolean forceResourcePack; @@ -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"); @@ -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"); + } @@ -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 getListOfBlackListedSubstrings() { return listOfBlackListedSubstrings; } } diff --git a/src/main/java/igorlink/service/Utils.java b/src/main/java/igorlink/service/Utils.java index 7c27f1a..04a9142 100644 --- a/src/main/java/igorlink/service/Utils.java +++ b/src/main/java/igorlink/service/Utils.java @@ -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); } @@ -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++) { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2cded3f..1dd9241 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -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" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f8b1e1d..49804ec 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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]