use of com.loohp.interactionvisualizer.api.InteractionVisualizerAPI.Modules in project InteractionVisualizer by LOOHP.
the class Database method getPlayerInfo.
public static Map<Modules, BitSet> getPlayerInfo(UUID uuid) {
Map<Modules, BitSet> map = new HashMap<>();
synchronized (syncdb) {
open();
try {
PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM " + preferenceTable + " WHERE UUID=?");
statement.setString(1, uuid.toString());
ResultSet results = statement.executeQuery();
results.next();
String itemstand = results.getString("ITEMSTAND");
String itemdrop = results.getString("ITEMDROP");
String hologram = results.getString("HOLOGRAM");
try {
if (VALID_BITSET.matcher(itemstand).matches()) {
map.put(Modules.ITEMSTAND, BitSetUtils.fromNumberString(itemstand));
} else {
map.put(Modules.ITEMSTAND, BitSet.valueOf(ArrayUtils.fromBase64String(itemstand)));
}
if (VALID_BITSET.matcher(itemdrop).matches()) {
map.put(Modules.ITEMDROP, BitSetUtils.fromNumberString(itemdrop));
} else {
map.put(Modules.ITEMDROP, BitSet.valueOf(ArrayUtils.fromBase64String(itemdrop)));
}
if (VALID_BITSET.matcher(hologram).matches()) {
map.put(Modules.HOLOGRAM, BitSetUtils.fromNumberString(hologram));
} else {
map.put(Modules.HOLOGRAM, BitSet.valueOf(ArrayUtils.fromBase64String(hologram)));
}
} catch (Throwable e) {
new RuntimeException("Unable to load player preference (" + uuid + ")", e).printStackTrace();
map.put(Modules.ITEMSTAND, new BitSet());
map.put(Modules.ITEMDROP, new BitSet());
map.put(Modules.HOLOGRAM, new BitSet());
}
} catch (SQLException e) {
e.printStackTrace();
}
try {
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return map;
}
use of com.loohp.interactionvisualizer.api.InteractionVisualizerAPI.Modules in project InteractionVisualizer by LOOHP.
the class PreferenceManager method hasAnyPreferenceEnabled.
public boolean hasAnyPreferenceEnabled(UUID uuid, EntryKey entry) {
int i = entries.indexOf(entry);
if (i < 0) {
return false;
}
Map<Modules, BitSet> info = preferences.get(uuid);
if (info != null) {
for (BitSet bitset : info.values()) {
if (!bitset.get(i)) {
return true;
}
}
}
return false;
}
use of com.loohp.interactionvisualizer.api.InteractionVisualizerAPI.Modules in project InteractionVisualizer by LOOHP.
the class PreferenceManager method hasAnyPreferenceDisabled.
public boolean hasAnyPreferenceDisabled(UUID uuid, EntryKey entry) {
int i = entries.indexOf(entry);
if (i < 0) {
return false;
}
Map<Modules, BitSet> info = preferences.get(uuid);
if (info != null) {
for (BitSet bitset : info.values()) {
if (bitset.get(i)) {
return true;
}
}
}
return false;
}
use of com.loohp.interactionvisualizer.api.InteractionVisualizerAPI.Modules in project InteractionVisualizer by LOOHP.
the class PreferenceManager method getPlayerPreferences.
public Map<Modules, Map<EntryKey, Boolean>> getPlayerPreferences(UUID uuid) {
Map<Modules, Map<EntryKey, Boolean>> preferences = new HashMap<>();
for (Modules module : Modules.values()) {
Map<EntryKey, Boolean> entryPreference = new HashMap<>();
for (EntryKey entry : getRegisteredEntries()) {
entryPreference.put(entry, getPlayerPreference(uuid, module, entry));
}
preferences.put(module, entryPreference);
}
return preferences;
}
use of com.loohp.interactionvisualizer.api.InteractionVisualizerAPI.Modules in project InteractionVisualizer by LOOHP.
the class PreferenceManager method setPlayerPreference.
public void setPlayerPreference(UUID uuid, Modules module, EntryKey entry, boolean enabled, boolean update) {
int i = entries.indexOf(entry);
if (i < 0) {
return;
}
Map<Modules, BitSet> info = preferences.get(uuid);
if (info != null) {
BitSet bitset = info.get(module);
bitset.set(i, !enabled);
}
if (update) {
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
updatePlayer(player, true);
}
}
}
Aggregations