mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Eat, tntbreak, title fix
This commit is contained in:
parent
f5f62f26b4
commit
72701a89a3
@ -525,8 +525,10 @@ public class PlayerManager {
|
||||
if (Perm(player, "jobs.max.*"))
|
||||
return true;
|
||||
|
||||
int totalJobs = Jobs.getJobs().size() + 5;
|
||||
|
||||
short count = (short) ConfigManager.getJobsConfiguration().getMaxJobs();
|
||||
for (short ctr = 0; ctr < 30; ctr++) {
|
||||
for (short ctr = 0; ctr < totalJobs; ctr++) {
|
||||
if (Perm(player, "jobs.max." + ctr))
|
||||
count = ctr;
|
||||
if (count > currentCount)
|
||||
|
@ -168,8 +168,8 @@ public class SignUtil {
|
||||
UpdateHead(sign.getLocation(), ((TopList) PlayerList.get(0)).getPlayerName(), timelapse);
|
||||
} else {
|
||||
String PlayerName = ((TopList) PlayerList.get(0)).getPlayerName();
|
||||
if (PlayerName.length() > 18) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{13})")[0];
|
||||
if (PlayerName.length() > 8) {
|
||||
String PlayerNameStrip = PlayerName.split("(?<=\\G.{7})")[0];
|
||||
PlayerName = PlayerNameStrip + "~";
|
||||
}
|
||||
String line1 = Language.getMessage("signs.SpecialList." + one.GetNumber() + ".1");
|
||||
|
@ -461,8 +461,11 @@ public class JobConfig {
|
||||
|
||||
if (entity != null && entity.isAlive()) {
|
||||
type = entity.toString();
|
||||
|
||||
id = entity.getTypeId();
|
||||
|
||||
// using breeder finder
|
||||
if (actionType == ActionType.BREED)
|
||||
ConfigManager.getJobsConfiguration().setBreederFinder(true);
|
||||
}
|
||||
|
||||
// Just to recognize wither skeleton
|
||||
@ -511,6 +514,9 @@ public class JobConfig {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (actionType == ActionType.TNTBREAK)
|
||||
ConfigManager.getJobsConfiguration().setTntFinder(true);
|
||||
|
||||
double income = section.getDouble("income", 0.0);
|
||||
double experience = section.getDouble("experience", 0.0);
|
||||
|
||||
|
@ -84,7 +84,9 @@ public class JobsConfiguration {
|
||||
public boolean useBlockProtection;
|
||||
public boolean useBlockTimer;
|
||||
public boolean useMinimumOveralPayment;
|
||||
public boolean useBreederFinder, CancelCowMilking;
|
||||
public boolean useBreederFinder = false;
|
||||
private boolean useTnTFinder = false;
|
||||
public boolean CancelCowMilking;
|
||||
public boolean fixAtMaxLevel, ToggleActionBar, TitleChangeChat, TitleChangeActionBar, LevelChangeChat,
|
||||
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAcountChat,
|
||||
EmptyServerAcountActionBar, JobsToggleEnabled, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||
@ -129,6 +131,22 @@ public class JobsConfiguration {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setBreederFinder(boolean state) {
|
||||
this.useBreederFinder = state;
|
||||
}
|
||||
|
||||
public boolean isUseBreederFinder() {
|
||||
return this.useBreederFinder;
|
||||
}
|
||||
|
||||
public void setTntFinder(boolean state) {
|
||||
this.useTnTFinder = state;
|
||||
}
|
||||
|
||||
public boolean isUseTntFinder() {
|
||||
return this.useTnTFinder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get how often in minutes to save job information
|
||||
* @return how often in minutes to save job information
|
||||
@ -172,7 +190,7 @@ public class JobsConfiguration {
|
||||
public synchronized boolean payInCreative() {
|
||||
return payInCreative;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function that tells if the player should be paid while exploring and flying
|
||||
* @return true - pay
|
||||
@ -389,7 +407,7 @@ public class JobsConfiguration {
|
||||
"Theroticali this should work without issues, but if you havving some, just disable",
|
||||
"But then you can feal some small (100-200ms) lag spikes while performings some jobs commands");
|
||||
LocalOfflinePlayersData = getBoolean("Optimizations.UseLocalOfflinePlayersData", true, config, writer);
|
||||
|
||||
|
||||
writer.addComment("Logging.Use", "With this set to true all players jobs actions will be logged to database for easy to see statistics",
|
||||
"This is still in development and in feature it will expand");
|
||||
LoggingUse = getBoolean("Logging.Use", false, config, writer);
|
||||
@ -424,7 +442,7 @@ public class JobsConfiguration {
|
||||
|
||||
writer.addComment("enable-pay-creative", "Option to allow payment to be made in creative mode");
|
||||
payInCreative = getBoolean("enable-pay-creative", false, config, writer);
|
||||
|
||||
|
||||
writer.addComment("enable-pay-for-exploring-when-flying", "Option to allow payment to be made for exploring when player flyies");
|
||||
payExploringWhenFlying = getBoolean("enable-pay-for-exploring-when-flying", false, config, writer);
|
||||
|
||||
|
@ -20,6 +20,7 @@ package com.gamingmesh.jobs.container;
|
||||
|
||||
public enum ActionType {
|
||||
BREAK("Break"),
|
||||
TNTBREAK("TNTBreak"),
|
||||
PLACE("Place"),
|
||||
KILL("Kill"),
|
||||
MMKILL("MMKill"),
|
||||
@ -35,6 +36,7 @@ public enum ActionType {
|
||||
SHEAR("Shear"),
|
||||
MILK("Milk"),
|
||||
EXPLORE("Explore"),
|
||||
EAT("Eat"),
|
||||
CUSTOMKILL("custom-kill");
|
||||
|
||||
private String name;
|
||||
|
@ -425,7 +425,7 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
|
||||
if (honorific.equalsIgnoreCase(" "))
|
||||
honorific = "";
|
||||
String format = event.getFormat();
|
||||
@ -444,7 +444,7 @@ public class JobsListener implements Listener {
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() + " " : "";
|
||||
String honorific = jPlayer != null ? jPlayer.getDisplayHonorific() : "";
|
||||
if (honorific.equalsIgnoreCase(" "))
|
||||
honorific = "";
|
||||
String format = event.getFormat();
|
||||
|
@ -25,6 +25,7 @@ import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -45,8 +46,10 @@ import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityTameEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.SlimeSplitEvent;
|
||||
import org.bukkit.event.inventory.BrewEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
@ -82,6 +85,7 @@ import com.gamingmesh.jobs.container.JobsPlayer;
|
||||
import com.gamingmesh.jobs.i18n.Language;
|
||||
import com.gamingmesh.jobs.stuff.ActionBar;
|
||||
import com.gamingmesh.jobs.stuff.ChatColor;
|
||||
import com.gamingmesh.jobs.stuff.Debug;
|
||||
import com.gamingmesh.jobs.stuff.Perm;
|
||||
import com.gmail.nossr50.api.AbilityAPI;
|
||||
import com.google.common.base.Objects;
|
||||
@ -290,7 +294,7 @@ public class JobsPaymentListener implements Listener {
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (event.getPlayer().getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
@ -1002,13 +1006,15 @@ public class JobsPaymentListener implements Listener {
|
||||
double closest = 30.0;
|
||||
Player player = null;
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
if (i.getWorld().getName().equals(animal.getWorld().getName())) {
|
||||
double dist = i.getLocation().distance(animal.getLocation());
|
||||
if (closest > dist) {
|
||||
closest = dist;
|
||||
player = i;
|
||||
}
|
||||
if (!i.getWorld().getName().equals(animal.getWorld().getName()))
|
||||
continue;
|
||||
|
||||
double dist = i.getLocation().distance(animal.getLocation());
|
||||
if (closest > dist) {
|
||||
closest = dist;
|
||||
player = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (player != null && closest < 30.0) {
|
||||
@ -1036,6 +1042,120 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerEat(FoodLevelChangeEvent event) {
|
||||
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (event.getEntity().hasMetadata("NPC"))
|
||||
return;
|
||||
|
||||
if (event.getFoodLevel() <= ((Player) event.getEntity()).getFoodLevel())
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// restricted area multiplier
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
Jobs.action(jPlayer, new ItemActionInfo(item, ActionType.EAT), multiplier, item, armor);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onTntExplode(EntityExplodeEvent event) {
|
||||
|
||||
// make sure plugin is enabled
|
||||
if (!plugin.isEnabled())
|
||||
return;
|
||||
|
||||
if (!ConfigManager.getJobsConfiguration().isUseTntFinder())
|
||||
return;
|
||||
|
||||
if (event.getEntityType() != EntityType.PRIMED_TNT && event.getEntityType() != EntityType.MINECART_TNT)
|
||||
return;
|
||||
|
||||
double closest = 30.0;
|
||||
Player player = null;
|
||||
Location loc = event.getEntity().getLocation();
|
||||
for (Player i : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
if (loc.getWorld() != i.getWorld())
|
||||
continue;
|
||||
|
||||
double dist = i.getLocation().distance(loc);
|
||||
if (closest > dist) {
|
||||
closest = dist;
|
||||
player = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (player == null || closest == 30.0)
|
||||
return;
|
||||
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
// check if in creative
|
||||
if (player.getGameMode().equals(GameMode.CREATIVE) && !ConfigManager.getJobsConfiguration().payInCreative())
|
||||
return;
|
||||
|
||||
if (!Jobs.getPermissionHandler().hasWorldPermission(player, player.getLocation().getWorld().getName()))
|
||||
return;
|
||||
|
||||
// restricted area multiplier
|
||||
double multiplier = ConfigManager.getJobsConfiguration().getRestrictedMultiplier(player);
|
||||
|
||||
// Item in hand
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
// Wearing armor
|
||||
ItemStack[] armor = player.getInventory().getArmorContents();
|
||||
|
||||
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||
if (jPlayer == null)
|
||||
return;
|
||||
|
||||
for (Block block : event.blockList()) {
|
||||
if (block == null)
|
||||
continue;
|
||||
|
||||
if (block.getType().equals(Material.FURNACE) && block.hasMetadata(furnaceOwnerMetadata))
|
||||
block.removeMetadata(furnaceOwnerMetadata, plugin);
|
||||
|
||||
if (ConfigManager.getJobsConfiguration().useBlockProtection)
|
||||
if (block.getState().hasMetadata(BlockMetadata))
|
||||
return;
|
||||
|
||||
BlockActionInfo bInfo = new BlockActionInfo(block, ActionType.TNTBREAK);
|
||||
Jobs.action(jPlayer, bInfo, multiplier, item, armor);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (!plugin.isEnabled())
|
||||
@ -1060,7 +1180,7 @@ public class JobsPaymentListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onExplore(JobsChunkChangeEvent event) {
|
||||
|
||||
|
||||
if (!Jobs.getExplore().isExploreEnabled())
|
||||
return;
|
||||
|
||||
|
@ -126,6 +126,11 @@ Jobs:
|
||||
income: 5.0
|
||||
# base experience
|
||||
experience: 5.0
|
||||
# payment for breaking a block with tnt
|
||||
TNTBreak:
|
||||
LOG:
|
||||
income: 5.0
|
||||
experience: 5.0
|
||||
# payment for placing a block
|
||||
Place:
|
||||
SAPLING:
|
||||
@ -165,6 +170,14 @@ Jobs:
|
||||
Wolf:
|
||||
income: 2.0
|
||||
experience: 5.0
|
||||
# Eating food
|
||||
Eat:
|
||||
cooked_rabbit:
|
||||
income: 5
|
||||
experience: 5
|
||||
baked_potato:
|
||||
income: 5
|
||||
experience: 5
|
||||
# Milking cows, only one option is available
|
||||
Milk:
|
||||
Cow:
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Jobs
|
||||
description: Jobs Plugin for the BukkitAPI
|
||||
main: com.gamingmesh.jobs.JobsPlugin
|
||||
version: 2.58.0
|
||||
version: 2.59.0
|
||||
author: phrstbrn
|
||||
softdepend: [Vault, CoreProtect, MythicMobs, McMMO]
|
||||
commands:
|
||||
|
Loading…
Reference in New Issue
Block a user