mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
Improve firework launching on level up
This commit is contained in:
parent
7ec1526a29
commit
2089f7afbd
@ -27,7 +27,6 @@ import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
@ -335,7 +334,7 @@ public class PlayerManager {
|
||||
if (!resetID && jPlayer.getUserId() == -1)
|
||||
continue;
|
||||
|
||||
for (JobProgression oneJ : jPlayer.getJobProgression())
|
||||
for (JobProgression oneJ : jPlayer.progression)
|
||||
dao.insertJob(jPlayer, oneJ);
|
||||
|
||||
dao.saveLog(jPlayer);
|
||||
@ -528,7 +527,7 @@ public class PlayerManager {
|
||||
* @param jPlayer {@link JobsPlayer}
|
||||
*/
|
||||
public void leaveAllJobs(JobsPlayer jPlayer) {
|
||||
for (JobProgression job : new ArrayList<>(jPlayer.getJobProgression()))
|
||||
for (JobProgression job : new ArrayList<>(jPlayer.progression))
|
||||
leaveJob(jPlayer, job.getJob());
|
||||
|
||||
jPlayer.leaveAllJobs();
|
||||
@ -687,11 +686,11 @@ public class PlayerManager {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
if (Jobs.getGCManager().FireworkLevelupUse) {
|
||||
if (Jobs.getGCManager().FireworkLevelupUse && player != null) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player == null || !player.isOnline())
|
||||
if (!player.isOnline())
|
||||
return;
|
||||
|
||||
Firework f = player.getWorld().spawn(player.getLocation(), Firework.class);
|
||||
@ -728,49 +727,7 @@ public class PlayerManager {
|
||||
|
||||
fm.setPower(r.nextInt(2) + 1);
|
||||
} else {
|
||||
Pattern comma = Pattern.compile(",", 16);
|
||||
List<String> colorStrings = Jobs.getGCManager().FwColors;
|
||||
Color[] colors = new Color[colorStrings.size()];
|
||||
|
||||
for (int s = 0; s < colorStrings.size(); s++) {
|
||||
String colorString = colorStrings.get(s);
|
||||
String[] sSplit = comma.split(colorString);
|
||||
if (sSplit.length < 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int[] colorRGB = new int[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
colorRGB[i] = Integer.parseInt(sSplit[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
int r = colorRGB[0], g = colorRGB[1], b = colorRGB[2];
|
||||
if (r > 255 || r < 0) {
|
||||
r = 1;
|
||||
}
|
||||
|
||||
if (g > 255 || g < 0) {
|
||||
g = 5;
|
||||
}
|
||||
|
||||
if (b > 255 || b < 0) {
|
||||
b = 3;
|
||||
}
|
||||
|
||||
colors[s] = Color.fromRGB(r, g, b);
|
||||
}
|
||||
|
||||
fm.addEffect(FireworkEffect.builder()
|
||||
.flicker(Jobs.getGCManager().UseFlicker)
|
||||
.trail(Jobs.getGCManager().UseTrail)
|
||||
.with(Type.valueOf(Jobs.getGCManager().FireworkType))
|
||||
.withColor(colors)
|
||||
.withFade(colors)
|
||||
.build());
|
||||
|
||||
fm.addEffect(Jobs.getGCManager().getFireworkEffect());
|
||||
fm.setPower(Jobs.getGCManager().FireworkPower);
|
||||
}
|
||||
|
||||
@ -841,29 +798,29 @@ public class PlayerManager {
|
||||
performCommandOnLevelUp(jPlayer, prog.getJob(), oldLevel);
|
||||
Jobs.getSignUtil().updateAllSign(job);
|
||||
|
||||
if (player != null && prog.getLevel() == jPlayer.getMaxJobLevelAllowed(prog.getJob())) {
|
||||
if (player != null && !job.getMaxLevelCommands().isEmpty() && prog.getLevel() == jPlayer.getMaxJobLevelAllowed(prog.getJob())) {
|
||||
for (String cmd : job.getMaxLevelCommands()) {
|
||||
if (cmd.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd.contains(":")) {
|
||||
String[] split = cmd.split(":", 2);
|
||||
|
||||
String command = "";
|
||||
if (split.length > 1) {
|
||||
command = split[1];
|
||||
command = command.replace("[playerName]", player.getName());
|
||||
command = command.replace("[job]", job.getName());
|
||||
}
|
||||
|
||||
if (split[0].equalsIgnoreCase("player:")) {
|
||||
player.performCommand(command);
|
||||
} else {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
} else {
|
||||
String[] split = cmd.split(":", 2);
|
||||
if (split.length == 0) {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
continue;
|
||||
}
|
||||
|
||||
String command = "";
|
||||
if (split.length > 1) {
|
||||
command = split[1];
|
||||
command = command.replace("[playerName]", player.getName());
|
||||
command = command.replace("[job]", job.getName());
|
||||
}
|
||||
|
||||
if (split[0].equalsIgnoreCase("player:")) {
|
||||
player.performCommand(command);
|
||||
} else {
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -949,7 +906,7 @@ public class PlayerManager {
|
||||
*/
|
||||
public void reload() {
|
||||
for (JobsPlayer jPlayer : players.values()) {
|
||||
for (JobProgression progression : jPlayer.getJobProgression()) {
|
||||
for (JobProgression progression : jPlayer.progression) {
|
||||
Job job = Jobs.getJob(progression.getJob().getName());
|
||||
if (job != null)
|
||||
progression.setJob(job);
|
||||
@ -1055,13 +1012,6 @@ public class PlayerManager {
|
||||
return ItemBoostManager.getItemByKey(itemName.toString());
|
||||
}
|
||||
|
||||
// public BoostMultiplier getJobsBoostByNbt(ItemStack item) {
|
||||
// JobItems b = getJobsItemByNbt(item);
|
||||
// if (b == null)
|
||||
// return null;
|
||||
// return b.getBoost();
|
||||
// }
|
||||
|
||||
public enum BoostOf {
|
||||
McMMO, PetPay, NearSpawner, Permission, Global, Dynamic, Item, Area
|
||||
}
|
||||
@ -1160,7 +1110,7 @@ public class PlayerManager {
|
||||
return;
|
||||
|
||||
int confMaxJobs = Jobs.getGCManager().getMaxJobs();
|
||||
short playerMaxJobs = (short) jPlayer.getJobProgression().size();
|
||||
short playerMaxJobs = (short) jPlayer.progression.size();
|
||||
|
||||
if (confMaxJobs > 0 && playerMaxJobs >= confMaxJobs && !getJobsLimit(jPlayer, playerMaxJobs))
|
||||
return;
|
||||
|
@ -24,8 +24,11 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -44,9 +47,10 @@ import com.gamingmesh.jobs.resources.jfep.Parser;
|
||||
public class GeneralConfigManager {
|
||||
|
||||
public List<Integer> BroadcastingLevelUpLevels = new ArrayList<>();
|
||||
public List<String> FwColors = new ArrayList<>(), DisabledWorldsList = new ArrayList<>();
|
||||
public List<String> DisabledWorldsList = new ArrayList<>();
|
||||
|
||||
public final Map<CMIMaterial, Map<Enchantment, Integer>> whiteListedItems = new HashMap<>();
|
||||
|
||||
private final Map<CurrencyType, CurrencyLimit> currencyLimitUse = new HashMap<>();
|
||||
private final Map<CurrencyType, Double> generalMulti = new HashMap<>();
|
||||
private final Map<String, List<String>> commandArgs = new HashMap<>();
|
||||
@ -57,7 +61,7 @@ public class GeneralConfigManager {
|
||||
protected boolean economyAsync, isBroadcastingSkillups, isBroadcastingLevelups, payInCreative, payExploringWhenFlying,
|
||||
addXpPlayer, hideJobsWithoutPermission, payNearSpawner, modifyChat, saveOnDisconnect, MultiServerCompatability;
|
||||
|
||||
public String modifyChatPrefix, modifyChatSuffix, modifyChatSeparator, FireworkType, SoundLevelupSound,
|
||||
public String modifyChatPrefix, modifyChatSuffix, modifyChatSeparator, SoundLevelupSound,
|
||||
SoundTitleChangeSound, ServerAccountName, ServertaxesAccountName, localeString = "";
|
||||
private String getSelectionTool, DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints;
|
||||
|
||||
@ -80,6 +84,8 @@ public class GeneralConfigManager {
|
||||
|
||||
private boolean FurnacesReassign, BrewingStandsReassign, useTnTFinder = false, ShowNewVersion;
|
||||
|
||||
private FireworkEffect fireworkEffect;
|
||||
|
||||
public boolean useBlockProtection, enableSchedule, PayForRenaming, PayForEnchantingOnAnvil, PayForEachCraft, SignsEnabled,
|
||||
SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useSilkTouchProtection, UseCustomNames,
|
||||
PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps,
|
||||
@ -90,7 +96,7 @@ public class GeneralConfigManager {
|
||||
LevelChangeActionBar, SoundLevelupUse, SoundTitleChangeUse, UseServerAccount, EmptyServerAccountChat,
|
||||
EmptyServerAccountActionBar, ActionBarsMessageByDefault, aBarSilentMode, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment,
|
||||
JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, ShowActionNames,
|
||||
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UseFlicker, UseTrail, UsePerPermissionForLeaving,
|
||||
DisableJoiningJobThroughGui, FireworkLevelupUse, UseRandom, UsePerPermissionForLeaving,
|
||||
EnableConfirmation, FilterHiddenPlayerFromTabComplete, jobsInfoOpensBrowse, MonsterDamageUse, useMaxPaymentCurve,
|
||||
hideJobsInfoWithoutPermission, UseTaxes, TransferToServerAccount, TakeFromPlayersPayment, AutoJobJoinUse, AllowDelevel,
|
||||
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
@ -891,12 +897,49 @@ public class GeneralConfigManager {
|
||||
c.addComment("Fireworks.LevelUp.Random", "Makes the firework to randomize, such as random colors, type, power and so on.",
|
||||
"These are under settings will not be work, when this enabled.");
|
||||
UseRandom = c.get("Fireworks.LevelUp.Random", true);
|
||||
UseFlicker = c.get("Fireworks.LevelUp.flicker", true);
|
||||
UseTrail = c.get("Fireworks.LevelUp.trail", true);
|
||||
|
||||
boolean useFlicker = c.get("Fireworks.LevelUp.flicker", true);
|
||||
boolean useTrail = c.get("Fireworks.LevelUp.trail", true);
|
||||
|
||||
c.addComment("Fireworks.LevelUp.type", "Firework type",
|
||||
"All types can be found in https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/FireworkEffect.Type.html");
|
||||
FireworkType = c.get("Fireworks.LevelUp.type", "STAR").toUpperCase();
|
||||
FwColors = c.get("Fireworks.LevelUp.colors", Arrays.asList("230,0,0", "0,90,0", "0,0,104"));
|
||||
|
||||
FireworkEffect.Type fwType = FireworkEffect.Type.STAR;
|
||||
try {
|
||||
fwType = FireworkEffect.Type.valueOf(c.get("Fireworks.LevelUp.type", "STAR").toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
|
||||
List<String> fwColors = c.get("Fireworks.LevelUp.colors", Arrays.asList("230,0,0", "0,90,0", "0,0,104"));
|
||||
|
||||
Color[] colors = new Color[fwColors.size()];
|
||||
Pattern comma = Pattern.compile(",", 16);
|
||||
|
||||
for (int s = 0; s < colors.length; s++) {
|
||||
String[] sSplit = comma.split(fwColors.get(s));
|
||||
if (sSplit.length < 3)
|
||||
continue;
|
||||
|
||||
int[] colorRGB = new int[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
int parsed = Integer.parseInt(sSplit[i]);
|
||||
colorRGB[i] = (parsed > 255 || parsed < 0) ? 1 : parsed;
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
|
||||
colors[s] = Color.fromRGB(colorRGB[0], colorRGB[1], colorRGB[2]);
|
||||
}
|
||||
|
||||
fireworkEffect = FireworkEffect.builder()
|
||||
.flicker(useFlicker)
|
||||
.trail(useTrail)
|
||||
.with(fwType)
|
||||
.withColor(colors)
|
||||
.withFade(colors)
|
||||
.build();
|
||||
|
||||
FireworkPower = c.get("Fireworks.LevelUp.power", 1);
|
||||
c.addComment("Fireworks.LevelUp.ShootTime", "Fire shooting time in ticks.", "20 tick = 1 second");
|
||||
ShootTime = c.get("Fireworks.LevelUp.ShootTime", 20);
|
||||
@ -990,18 +1033,10 @@ public class GeneralConfigManager {
|
||||
return ResetTimeHour;
|
||||
}
|
||||
|
||||
public void setResetTimeHour(int resetTimeHour) {
|
||||
ResetTimeHour = resetTimeHour;
|
||||
}
|
||||
|
||||
public int getResetTimeMinute() {
|
||||
return ResetTimeMinute;
|
||||
}
|
||||
|
||||
public void setResetTimeMinute(int resetTimeMinute) {
|
||||
ResetTimeMinute = resetTimeMinute;
|
||||
}
|
||||
|
||||
public boolean isFurnacesReassign() {
|
||||
return FurnacesReassign;
|
||||
}
|
||||
@ -1044,8 +1079,9 @@ public class GeneralConfigManager {
|
||||
if (JobsGUIBackButton < 1)
|
||||
JobsGUIBackButton = 1;
|
||||
|
||||
if (JobsGUIBackButton > JobsGUIRows * 9)
|
||||
JobsGUIBackButton = JobsGUIRows * 9;
|
||||
int mult = JobsGUIRows * 9;
|
||||
if (JobsGUIBackButton > mult)
|
||||
JobsGUIBackButton = mult;
|
||||
|
||||
return JobsGUIBackButton - 1;
|
||||
}
|
||||
@ -1054,8 +1090,9 @@ public class GeneralConfigManager {
|
||||
if (JobsGUINextButton < 1)
|
||||
JobsGUINextButton = 1;
|
||||
|
||||
if (JobsGUINextButton > JobsGUIRows * 9)
|
||||
JobsGUINextButton = JobsGUIRows * 9;
|
||||
int mult = JobsGUIRows * 9;
|
||||
if (JobsGUINextButton > mult)
|
||||
JobsGUINextButton = mult;
|
||||
|
||||
return JobsGUINextButton - 1;
|
||||
}
|
||||
@ -1087,4 +1124,7 @@ public class GeneralConfigManager {
|
||||
return DailyQuestsSkips;
|
||||
}
|
||||
|
||||
public FireworkEffect getFireworkEffect() {
|
||||
return fireworkEffect;
|
||||
}
|
||||
}
|
||||
|
@ -553,10 +553,12 @@ exampleJob:
|
||||
command: lp user [player] permission set essentials.fly
|
||||
|
||||
# When to execute this command first time
|
||||
# Set to 0 if you want to detect all the levels
|
||||
levelFrom: 100
|
||||
|
||||
# Until when to do this command
|
||||
# This can be set to same level as levelFrom, so this command will be executed only once
|
||||
# Set to 0 if you want to detect all the levels
|
||||
levelUntil: 100
|
||||
|
||||
kit:
|
||||
|
Loading…
Reference in New Issue
Block a user