use of com.loohp.interactionvisualizer.objectholders.EntryKey in project InteractionVisualizer by LOOHP.
the class Database method getBitIndex.
public static Map<Integer, EntryKey> getBitIndex() {
Map<Integer, EntryKey> index = new HashMap<>();
synchronized (syncdb) {
open();
try {
PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM " + indexMappingTable);
ResultSet results = statement.executeQuery();
while (results.next()) {
index.put(results.getInt("BITMASK_INDEX"), new EntryKey(results.getString("ENTRY")));
}
} catch (SQLException e) {
e.printStackTrace();
}
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return index;
}
}
use of com.loohp.interactionvisualizer.objectholders.EntryKey in project InteractionVisualizer by LOOHP.
the class Commands method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!label.equalsIgnoreCase("interactionvisualizer") && !label.equalsIgnoreCase("iv")) {
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.AQUA + "[InteractionVisualizer] InteractionVisualizer written by LOOHP!");
sender.sendMessage(ChatColor.GOLD + "[InteractionVisualizer] Running InteractionVisualizer version: " + plugin.getDescription().getVersion());
return true;
}
if (args[0].equalsIgnoreCase("reload")) {
if (sender.hasPermission("interactionvisualizer.reload")) {
plugin.loadConfig();
MusicManager.reloadConfig();
MaterialManager.reloadConfig();
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Reload")));
} else {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.NoPermission")));
}
return true;
}
if (args[0].equalsIgnoreCase("refresh")) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (player.hasPermission("interactionvisualizer.refresh")) {
Bukkit.getScheduler().runTask(InteractionVisualizer.plugin, () -> PacketManager.reset(player));
} else {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.NoPermission")));
}
} else {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Console")));
}
return true;
}
if (args[0].equalsIgnoreCase("update")) {
if (sender.hasPermission("interactionvisualizer.update")) {
sender.sendMessage(ChatColor.AQUA + "[InteractionVisualizer] InteractionVisualizer written by LOOHP!");
sender.sendMessage(ChatColor.GOLD + "[InteractionVisualizer] You are running InteractionVisualizer version: " + plugin.getDescription().getVersion());
InteractionVisualizer.asyncExecutorManager.runTaskAsynchronously(() -> {
UpdaterResponse version = Updater.checkUpdate();
if (version.getResult().equals("latest")) {
if (version.isDevBuildLatest()) {
sender.sendMessage(ChatColor.GREEN + "[InteractionVisualizer] You are running the latest version!");
} else {
Updater.sendUpdateMessage(sender, version.getResult(), version.getSpigotPluginId(), true);
}
} else {
Updater.sendUpdateMessage(sender, version.getResult(), version.getSpigotPluginId());
}
});
} else {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.NoPermission")));
}
return true;
}
if (args[0].equalsIgnoreCase("toggle")) {
if (sender.hasPermission("interactionvisualizer.toggle")) {
if ((args.length == 4 && (args[3].equalsIgnoreCase("true") || args[3].equalsIgnoreCase("false"))) || args.length == 3) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Console")));
return true;
}
Player player = (Player) sender;
InteractionVisualizer.asyncExecutorManager.runTaskAsynchronously(() -> {
EntryKey[] entries;
String verboseEntry = null;
if (args[2].equalsIgnoreCase("all")) {
entries = InteractionVisualizer.preferenceManager.getRegisteredEntries().toArray(new EntryKey[0]);
verboseEntry = ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.All"));
} else {
entries = new EntryKey[] { new EntryKey(args[2]) };
}
if (args.length == 4) {
boolean value = args[3].equalsIgnoreCase("true");
switch(args[1].toLowerCase()) {
case "itemstand":
Toggle.toggle(sender, player, Modules.ITEMSTAND, value, true, verboseEntry, entries);
break;
case "itemdrop":
Toggle.toggle(sender, player, Modules.ITEMDROP, value, true, verboseEntry, entries);
break;
case "hologram":
Toggle.toggle(sender, player, Modules.HOLOGRAM, value, true, verboseEntry, entries);
break;
case "all":
for (Modules modules : Modules.values()) {
Toggle.toggle(sender, player, modules, value, true, verboseEntry, entries);
}
break;
default:
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Modes")));
}
} else {
switch(args[1].toLowerCase()) {
case "itemstand":
Toggle.toggle(sender, player, Modules.ITEMSTAND, true, verboseEntry, entries);
break;
case "itemdrop":
Toggle.toggle(sender, player, Modules.ITEMDROP, true, verboseEntry, entries);
break;
case "hologram":
Toggle.toggle(sender, player, Modules.HOLOGRAM, true, verboseEntry, entries);
break;
case "all":
for (Modules modules : Modules.values()) {
Toggle.toggle(sender, player, modules, true, verboseEntry, entries);
}
break;
default:
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Modes")));
}
}
});
return true;
} else if (args.length == 5 || args.length == 4) {
Player player = Bukkit.getPlayer(args[args.length == 4 ? 3 : 4]);
if (sender instanceof Player) {
if (player != null) {
if (!player.equals(sender)) {
if (!sender.hasPermission("interactionvisualizer.toggle.others")) {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.NoPermission")));
return true;
}
}
}
}
if (player == null) {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.PlayerNotFound")));
return true;
}
InteractionVisualizer.asyncExecutorManager.runTaskAsynchronously(() -> {
EntryKey[] entries;
String verboseEntry = null;
if (args[2].equalsIgnoreCase("all")) {
entries = InteractionVisualizer.preferenceManager.getRegisteredEntries().toArray(new EntryKey[0]);
verboseEntry = ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.All"));
} else {
entries = new EntryKey[] { new EntryKey(args[2]) };
}
if (args.length == 5) {
boolean value = args[3].equalsIgnoreCase("true");
switch(args[1].toLowerCase()) {
case "itemstand":
Toggle.toggle(sender, player, Modules.ITEMSTAND, value, true, verboseEntry, entries);
break;
case "itemdrop":
Toggle.toggle(sender, player, Modules.ITEMDROP, value, true, verboseEntry, entries);
break;
case "hologram":
Toggle.toggle(sender, player, Modules.HOLOGRAM, value, true, verboseEntry, entries);
break;
case "all":
for (Modules modules : Modules.values()) {
Toggle.toggle(sender, player, modules, value, true, verboseEntry, entries);
}
break;
default:
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Modes")));
}
} else {
switch(args[1].toLowerCase()) {
case "itemstand":
Toggle.toggle(sender, player, Modules.ITEMSTAND, true, verboseEntry, entries);
break;
case "itemdrop":
Toggle.toggle(sender, player, Modules.ITEMDROP, true, verboseEntry, entries);
break;
case "hologram":
Toggle.toggle(sender, player, Modules.HOLOGRAM, true, verboseEntry, entries);
break;
case "all":
for (Modules modules : Modules.values()) {
Toggle.toggle(sender, player, modules, true, verboseEntry, entries);
}
break;
default:
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Modes")));
}
}
});
return true;
} else {
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.Toggle.Usage")));
}
return true;
}
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', plugin.getConfiguration().getString("Messages.NoPermission")));
return true;
}
if (args[0].equalsIgnoreCase("ethereal")) {
Component text = Component.text("She is Imaginary~~");
text = text.color(NamedTextColor.YELLOW);
Component bone = LegacyComponentSerializer.legacySection().deserialize("\u00a7eNana's Bone\n\u00a77Lost \u00a76In-\u00a7dMaginary~~");
text = text.hoverEvent(HoverEvent.showText(bone)).clickEvent(ClickEvent.openUrl("https://www.instagram.com/narliar/"));
InteractionVisualizer.sendMessage(sender, text);
return true;
}
sender.sendMessage(ChatColorUtils.translateAlternateColorCodes('&', Bukkit.spigot().getConfig().getString("messages.unknown-command")));
return true;
}
use of com.loohp.interactionvisualizer.objectholders.EntryKey in project InteractionVisualizer by LOOHP.
the class InteractionVisualizer method loadConfig.
public void loadConfig() {
Config config = Config.getConfig(CONFIG_ID);
config.reload();
itemStandEnabled = getConfiguration().getBoolean("Modules.ItemStand.Enabled");
itemDropEnabled = getConfiguration().getBoolean("Modules.ItemDrop.Enabled");
hologramsEnabled = getConfiguration().getBoolean("Modules.Hologram.Enabled");
itemStandDisabled = getConfiguration().getStringList("Modules.ItemStand.OverridingDisabled").stream().map(each -> new EntryKey(each)).collect(Collectors.toSet());
itemDropDisabled = getConfiguration().getStringList("Modules.ItemDrop.OverridingDisabled").stream().map(each -> new EntryKey(each)).collect(Collectors.toSet());
hologramsDisabled = getConfiguration().getStringList("Modules.Hologram.OverridingDisabled").stream().map(each -> new EntryKey(each)).collect(Collectors.toSet());
playerPickupYOffset = getConfiguration().getDouble("Settings.PickupAnimationPlayerYOffset");
tileEntityCheckingRange = getConfiguration().getInt("TileEntityUpdate.CheckingRange");
ignoreWalkSquared = getConfiguration().getDouble("TileEntityUpdate.IgnoreMovementSpeed.Normal");
ignoreWalkSquared *= ignoreWalkSquared;
ignoreFlySquared = getConfiguration().getDouble("TileEntityUpdate.IgnoreMovementSpeed.Flying");
ignoreFlySquared *= ignoreFlySquared;
ignoreGlideSquared = getConfiguration().getDouble("TileEntityUpdate.IgnoreMovementSpeed.Gliding");
ignoreGlideSquared *= ignoreGlideSquared;
handMovementEnabled = getConfiguration().getBoolean("Settings.UseHandSwingAnimation");
disabledWorlds = new HashSet<>(getConfiguration().getStringList("Settings.DisabledWorlds"));
hideIfObstructed = getConfiguration().getBoolean("Settings.HideIfViewObstructed");
lightUpdatePeriod = getConfiguration().getInt("LightUpdate.Period");
updaterEnabled = getConfiguration().getBoolean("Options.Updater");
language = getConfiguration().getString("Settings.Language");
playerTrackingRange.clear();
int defaultRange = getServer().spigot().getConfig().getInt("world-settings.default.entity-tracking-range.players", 64);
for (World world : getServer().getWorlds()) {
int range = getServer().spigot().getConfig().getInt("world-settings." + world.getName() + ".entity-tracking-range.players", defaultRange);
playerTrackingRange.put(world, range);
}
allPacketsSync = getConfiguration().getBoolean("Settings.SendAllPacketsInSync");
defaultDisabledAll = getConfiguration().getBoolean("Settings.DefaultDisableAll");
LanguageUtils.loadTranslations(language);
getServer().getPluginManager().callEvent(new InteractionVisualizerReloadEvent());
}
Aggregations