FAudit Slots & Materials Configurable

Fixed IllegalPluginAccessException onDisable
This commit is contained in:
Driftay 2019-12-30 23:56:59 -05:00
parent fad866cf33
commit 016c82fa85
7 changed files with 51 additions and 49 deletions

View File

@ -57,7 +57,7 @@ public class FAuditMenu extends GUIMenu {
lore.add("");
if (logsLeft > 0) lore.add(CC.Yellow + "Left-Click " + CC.Gray + "to view more logs");
lore.add(CC.Yellow + "Right-Click " + CC.Gray + "to toggle timestamps");
setItem(index++, (new ClickableItemStack((new ItemBuilder(type.getDisplayMaterial())).name(CC.GreenB + type.getDisplayName()).lore(lore).build())).setClickCallback((click) -> {
setItem(index++, (new ClickableItemStack((new ItemBuilder(type.getMaterial())).name(CC.GreenB + type.getDisplayName()).lore(lore).build())).setClickCallback((click) -> {
click.setCancelled(true);
if (click.getClick() == ClickType.RIGHT) {
showTimestamps = !showTimestamps;

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd.audit;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.util.XMaterial;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import org.bukkit.Material;
/**
@ -10,22 +9,21 @@ import org.bukkit.Material;
*/
public enum FLogType {
INVITES("Roster Edits", XMaterial.WRITABLE_BOOK.parseMaterial(), "&e%s&7 &a%s&7 &e%s", 3),
BANS("Player Bans", XMaterial.ANVIL.parseMaterial(), "&e%s&7 &e%s&6 &e%s", 3),
CHUNK_CLAIMS("Claim Edits", XMaterial.WOODEN_AXE.parseMaterial(), "&e%s&7 %s&7 &e%s&7 near &e%s", 3),
PERM_EDIT_DEFAULTS("Default Perm Edits", XMaterial.WRITTEN_BOOK.parseMaterial(), "&e%s&7 %s&7 %s for &e%s", 4),
BANK_EDIT("/f money Edits", XMaterial.GOLD_INGOT.parseMaterial(), "&e%s&7 %s &e&l$&e%s", 3),
FCHEST_EDIT("/f chest Edits", XMaterial.CHEST.parseMaterial(), "&e%s&7 %s &f%s", 3),
RELATION_CHANGE("Relation Edits", XMaterial.GOLDEN_SWORD.parseMaterial(), "&e%s %s&e'd %s", 3),
FTAG_EDIT("/f tag Edits", XMaterial.NAME_TAG.parseMaterial(), "&e%s&7 set to &e'%s'", 2),
FDESC_EDIT("/f desc Edits", XMaterial.PAPER.parseMaterial(), "&e%s&7 set to &e'%s'", 2),
ROLE_PERM_EDIT("/f promote Edits", XMaterial.WRITTEN_BOOK.parseMaterial(), "&e%s&7&e %s &e%s &7to &e%s", 4),
SPAWNER_EDIT("Spawner Edits", XMaterial.SPAWNER.parseMaterial(), "&e%s&7 %s &e%s&7 %s", 4),
RANK_EDIT("Rank Edits", XMaterial.GOLDEN_HELMET.parseMaterial(), "&e%s&7 set &e%s&7 to %s", 3),
F_TNT("/f tnt Edits", XMaterial.TNT.parseMaterial(), "&e%s&7 %s &e%s", 3);
INVITES("Roster Edits", "&e%s&7 &a%s&7 &e%s", 3),
BANS("Player Bans", "&e%s&7 &e%s&6 &e%s", 3),
CHUNK_CLAIMS("Claim Edits", "&e%s&7 %s&7 &e%s&7 near &e%s", 3),
PERM_EDIT_DEFAULTS("Default Perm Edits", "&e%s&7 %s&7 %s for &e%s", 4),
BANK_EDIT("Money Edits", "&e%s&7 %s &e&l$&e%s", 3),
FCHEST_EDIT("Chest Edits", "&e%s&7 %s &f%s", 3),
RELATION_CHANGE("Relation Edits", "&e%s %s&e'd %s", 3),
FTAG_EDIT("Tag Edits", "&e%s&7 set to &e'%s'", 2),
FDESC_EDIT("Desc Edits", "&e%s&7 set to &e'%s'", 2),
ROLE_PERM_EDIT("Promotional Edits", "&e%s&7&e %s &e%s &7to &e%s", 4),
SPAWNER_EDIT("Spawner Edits", "&e%s&7 %s &e%s&7 %s", 4),
RANK_EDIT("Rank Edits", "&e%s&7 set &e%s&7 to %s", 3),
F_TNT("Tnt Edits", "&e%s&7 %s &e%s", 3);
private String displayName;
private Material displayMaterial;
private String msg;
private int requiredArgs;
@ -47,15 +45,17 @@ public enum FLogType {
}
return null;
}
public int getSlot() {
return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + this.displayName.toLowerCase());
@Override
public String toString() { return name(); }
public int getSlot() { return FactionsPlugin.getInstance().getConfig().getInt("faudit-gui.slots." + name().toLowerCase()); }
public Material getMaterial(){
return XMaterial.matchXMaterial(FactionsPlugin.getInstance().getConfig().getString("faudit-gui.materials." + name().toLowerCase())).parseMaterial();
}
public Material getDisplayMaterial() {
return this.displayMaterial;
}
public String getMsg() {
return this.msg;
}
@ -64,9 +64,8 @@ public enum FLogType {
return this.requiredArgs;
}
FLogType(String displayName, Material displayMaterial, String msg, int requiredArgs) {
FLogType(String displayName, String msg, int requiredArgs) {
this.displayName = displayName;
this.displayMaterial = displayMaterial;
this.msg = msg;
this.requiredArgs = requiredArgs;
}

View File

@ -15,6 +15,7 @@ import com.massivecraft.factions.zcore.util.TextUtil;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.IllegalPluginAccessException;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.*;
@ -177,17 +178,20 @@ public abstract class MPlugin extends JavaPlugin {
}
public void onDisable() {
if (saveTask != null) {
this.getServer().getScheduler().cancelTask(saveTask);
saveTask = null;
try {
if (saveTask != null) {
this.getServer().getScheduler().cancelTask(saveTask);
saveTask = null;
}
// only save data if plugin actually loaded successfully
if (loadSuccessful) {
Factions.getInstance().forceSave();
FPlayers.getInstance().forceSave();
Board.getInstance().forceSave();
}
log("Disabled");
} catch (IllegalPluginAccessException e){
}
// only save data if plugin actually loaded successfully
if (loadSuccessful) {
Factions.getInstance().forceSave();
FPlayers.getInstance().forceSave();
Board.getInstance().forceSave();
}
log("Disabled");
}
// -------------------------------------------- //

View File

@ -378,7 +378,6 @@ public class FUpgradesGUI implements Listener {
}
itemMeta.addEnchant(Enchantment.DURABILITY, 3, true);
cropItem.setItemMeta(itemMeta);
cropItem.setAmount(cropLevel);
}

View File

@ -54,7 +54,6 @@ public class JSONFPlayers extends MemoryFPlayers {
entitiesThatShouldBeSaved.put(entity.getId(), (JSONFPlayer) entity);
}
}
saveCore(file, entitiesThatShouldBeSaved, sync);
}

View File

@ -1291,19 +1291,19 @@ faudit-gui:
rank_edit: 11
f_tnt: 12
materials:
invites: 0
bans: 1
chunk_claims: 2
perm_edit_defaults: 3
bank_edit: 4
fchest_edit: 5
relation_change: 6
ftag_edit: 7
fdesc_edit: 8
role_perm_edit: 9
spawner_edit: 10
rank_edit: 11
f_tnt: 12
invites: WRITABLE_BOOK
bans: ANVIL
chunk_claims: WOODEN_AXE
perm_edit_defaults: WRITTEN_BOOK
bank_edit: GOLD_INGOT
fchest_edit: CHEST
relation_change: GOLDEN_SWORD
ftag_edit: NAME_TAG
fdesc_edit: PAPER
role_perm_edit: WRITTEN_BOOK
spawner_edit: SPAWNER
rank_edit: GOLDEN_HELMET
f_tnt: TNT
############################################################
# +------------------------------------------------------+ #

View File

@ -65,6 +65,7 @@ permissions:
factions.kit.halfplayer:
description: Can do all but create factions.
children:
factions.audit: true
factions.drain: true
factions.wild: true
factions.missions: true