1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-02-18 05:11:32 +01:00

Added potion support

- Added when the player drinking a potion and work a job get money.
- New ActionType
- Now if a BossBar boolean enabled then only send a console error.
- Now if a restricted area is empty (0) not send the message to console.
This commit is contained in:
montlikadani 2018-08-30 10:23:56 +02:00
parent c700d07c17
commit 5f72fabd26
7 changed files with 148 additions and 6 deletions

View File

@ -1213,7 +1213,47 @@ public class ItemManager {
PORKCHOP(319, 0, 30896, "Raw Porkchop", ""),
POTATO(392, 0, 21088, "Potato", "Potatoitem"),
POTATOES(142, 0, 10879, "Potatoes", "POTATO"),
// Potions
POTION(373, 0, 24020, "Potion", ""),
AWKWARD_POTION(373, 16, 24020, "Potion", ""),
THICK_POTION(373, 32, 24020, "Potion", ""),
MUNDANE_POTION(373, 64, 24020, "Potion", ""),
REGENERATION_POTION(373, 8193, 24020, "Potion", ""),
SWIFTNESS_POTION(373, 8194, 24020, "Potion", ""),
FIRE_RESISTANCE_POTION(373, 8195, 24020, "Potion", ""),
POISON_POTION(373, 8196, 24020, "Potion", ""),
HEALING_POTION(373, 8197, 24020, "Potion", ""),
NIGHT_VISION_POTION(373, 8198, 24020, "Potion", ""),
WEAKNESS_POTION(373, 8200, 24020, "Potion", ""),
STRENGTH_POTION(373, 8201, 24020, "Potion", ""),
SLOWNESS_POTION(373, 8202, 24020, "Potion", ""),
HARMING_POTION(373, 8204, 24020, "Potion", ""),
WATER_BREATHING_POTION(373, 8205, 24020, "Potion", ""),
INVISIBILITY_POTION(373, 8206, 24020, "Potion", ""),
REGENERATION_POTION2(373, 8225, 24020, "Potion", ""),
SWIFTNESS_POTION2(373, 8226, 24020, "Potion", ""),
POISON_POTION2(373, 8228, 24020, "Potion", ""),
HEALING_POTION2(373, 8229, 24020, "Potion", ""),
STRENGTH_POTION2(373, 8233, 24020, "Potion", ""),
LEAPING_POTION2(373, 8235, 24020, "Potion", ""),
HARMING_POTION2(373, 8236, 24020, "Potion", ""),
REGENERATION_POTION3(373, 8257, 24020, "Potion", ""),
SWIFTNESS_POTION3(373, 8258, 24020, "Potion", ""),
FIRE_RESISTANCE_POTION3(373, 8259, 24020, "Potion", ""),
POISON_POTION3(373, 8260, 24020, "Potion", ""),
NIGHT_VISION_POTION2(373, 8262, 24020, "Potion", ""),
WEAKNESS_POTION2(373, 8264, 24020, "Potion", ""),
STRENGTH_POTION3(373, 8265, 24020, "Potion", ""),
SLOWNESS_POTION2(373, 8266, 24020, "Potion", ""),
LEAPING_POTION3(373, 8267, 24020, "Potion", ""),
WATER_BREATHING_POTION2(373, 8269, 24020, "Potion", ""),
INVISIBILITY_POTION2(373, 8270, 24020, "Potion", ""),
REGENERATION_POTION4(373, 8289, 24020, "Potion", ""),
SWIFTNESS_POTION4(373, 8290, 24020, "Potion", ""),
POISON_POTION4(373, 8292, 24020, "Potion", ""),
STRENGTH_POTION4(373, 8297, 24020, "Potion", ""),
POTTED_ACACIA_SAPLING(-1, -1, 14096, "Potted Acacia Sapling", ""),
POTTED_ALLIUM(-1, -1, 13184, "Potted Allium", ""),
POTTED_AZURE_BLUET(-1, -1, 8754, "Potted Azure Bluet", ""),
@ -2036,6 +2076,61 @@ public class ItemManager {
return false;
}
// TODO
public static boolean isPotion(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
if (m == null)
return false;
return m.isPotion();
}
public boolean isPotion() {
switch (this) {
case POTION:
case AWKWARD_POTION:
case THICK_POTION:
case MUNDANE_POTION:
case REGENERATION_POTION:
case SWIFTNESS_POTION:
case FIRE_RESISTANCE_POTION:
case POISON_POTION:
case HEALING_POTION:
case NIGHT_VISION_POTION:
case WEAKNESS_POTION:
case STRENGTH_POTION:
case SLOWNESS_POTION:
case HARMING_POTION:
case WATER_BREATHING_POTION:
case INVISIBILITY_POTION:
case REGENERATION_POTION2:
case SWIFTNESS_POTION2:
case POISON_POTION2:
case HEALING_POTION2:
case STRENGTH_POTION2:
case LEAPING_POTION2:
case HARMING_POTION2:
case REGENERATION_POTION3:
case SWIFTNESS_POTION3:
case FIRE_RESISTANCE_POTION3:
case POISON_POTION3:
case NIGHT_VISION_POTION2:
case WEAKNESS_POTION2:
case STRENGTH_POTION3:
case SLOWNESS_POTION2:
case LEAPING_POTION3:
case WATER_BREATHING_POTION2:
case INVISIBILITY_POTION2:
case REGENERATION_POTION4:
case SWIFTNESS_POTION4:
case POISON_POTION4:
case STRENGTH_POTION4:
return true;
default:
break;
}
return false;
}
public static boolean isWool(Material mat) {
CMIMaterial m = CMIMaterial.get(mat);
if (m == null)

View File

@ -40,7 +40,6 @@ import com.gamingmesh.jobs.container.CurrencyLimit;
import com.gamingmesh.jobs.container.CurrencyType;
import com.gamingmesh.jobs.container.LocaleReader;
import com.gamingmesh.jobs.container.Schedule;
import com.gamingmesh.jobs.stuff.ChatColor;
import com.gamingmesh.jobs.stuff.VersionChecker.Version;
public class GeneralConfigManager {
@ -609,7 +608,7 @@ public class GeneralConfigManager {
DynamicPaymentEquation.setVariable("jobstotalplayers", 10);
DynamicPaymentEquation.getValue();
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "Dynamic payment equation has an invalid property. Disabling feature!");
Jobs.consoleMsg("&cDynamic payment equation has an invalid property. Disabling feature!");
useDynamicPayment = false;
}
@ -843,9 +842,9 @@ public class GeneralConfigManager {
c.getW().addComment("BossBar.Enabled", "Enables BossBar feature", "Works only from 1.9 mc version");
BossBarEnabled = c.get("BossBar.Enabled", true);
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1)) {
if (BossBarEnabled = true && Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1)) {
BossBarEnabled = false;
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Jobs] Your server version don't support BossBar. This feature will be disabled");
Jobs.consoleMsg("&c[Jobs] Your server version don't support BossBar. This feature will be disabled");
}
c.getW().addComment("BossBar.Messages.EnabledByDefault", "When this set to true player will see Bossbar messages by default");

View File

@ -211,7 +211,8 @@ public class RestrictedAreaManager {
}
}
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
if (restrictedAreas.size() != 0)
Jobs.consoleMsg("&e[Jobs] Loaded " + restrictedAreas.size() + " restricted areas!");
try {
conf.save(f);

View File

@ -20,6 +20,7 @@ package com.gamingmesh.jobs.container;
public enum ActionType {
BREAK("Break"),
DRINK("Drink"),
TNTBREAK("TNTBreak"),
PLACE("Place"),
KILL("Kill"),

View File

@ -659,7 +659,7 @@ public class JobsListener implements Listener {
List<JobProgression> prog = JPlayer.getJobProgression();
String name = null;
List<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
Map<Enchantment, Integer> enchants = new HashMap<>();
try {

View File

@ -71,6 +71,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.EnchantingInventory;
@ -1490,6 +1491,41 @@ public class JobsPaymentListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerItemConsume(PlayerItemConsumeEvent event) {
//disabling plugin in world
if (event.getPlayer() != null && !Jobs.getGCManager().canPerformActionInWorld(event.getPlayer().getWorld()))
return;
if (!this.plugin.isEnabled())
return;
if (event.isCancelled())
return;
Player p = event.getPlayer();
if (!p.isOnline())
return;
// check if in creative
if (p.getGameMode().equals(GameMode.CREATIVE) && !Jobs.getGCManager().payInCreative())
return;
if (!Jobs.getPermissionHandler().hasWorldPermission(p, p.getLocation().getWorld().getName()))
return;
// Item in hand
ItemStack item = p.getItemInHand();
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(p);
if (jPlayer == null)
return;
// Player drinking a potion
if (item.getType().equals(CMIMaterial.get(Material.POTION).isPotion()))
Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.DRINK));
}
@EventHandler
public void onExplore(JobsChunkChangeEvent event) {
//disabling plugin in world

View File

@ -417,6 +417,16 @@ Jobs:
REDSTONE:
income: 5.0
experience: 3.0
Drink:
POTION:
income: 0.5
experience: 2.0
REGENERATION_POTION2:
income: 1.3
experience: 2.0
HEALING_POTION:
income: 1.4
experience: 2.0
# Explore options. Each number represents players number in exploring that chunk
# 1 means that player is first in this chunk, 2 is second and so on, so you can give money not only for first player ho discovers that chunk
Explore: