IP FILTER STOP SPAM AND SOME MIDI VELOCITY THING
This commit is contained in:
parent
75cc23a2bd
commit
1e8802076a
2 changed files with 6 additions and 13 deletions
|
@ -27,8 +27,6 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private final Map<UUID, String> cached = new HashMap<>();
|
||||
|
||||
public IPFilterPlugin (Bot bot) {
|
||||
this.bot = bot;
|
||||
|
||||
|
@ -42,11 +40,6 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
|||
check(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLeft(PlayerEntry target) {
|
||||
cached.remove(target.profile.getId());
|
||||
}
|
||||
|
||||
private void check (PlayerEntry target) {
|
||||
final CompletableFuture<CompoundTag> future = bot.core.runTracked("essentials:seen " + target.profile.getIdAsString());
|
||||
|
||||
|
@ -83,6 +76,8 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
|||
}
|
||||
|
||||
private void checkAllPlayers () {
|
||||
if (filteredIPs.isEmpty()) return;
|
||||
|
||||
int ms = 0;
|
||||
for (PlayerEntry entry : bot.players.list) {
|
||||
bot.executor.schedule(() -> check(entry), ms, TimeUnit.MILLISECONDS);
|
||||
|
@ -109,8 +104,6 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
|||
for (JsonElement element : filteredIPs) {
|
||||
if (!element.getAsString().equals(ip)) continue;
|
||||
|
||||
if (!cached.containsValue(ip)) cached.put(entry.profile.getId(), ip);
|
||||
|
||||
if (entry.profile.getId().equals(bot.profile.getId())) continue;
|
||||
|
||||
bot.filter.doAll(entry);
|
||||
|
|
|
@ -113,7 +113,7 @@ public class MidiConverter implements Converter {
|
|||
if (sm.getData2() == 0) continue;
|
||||
int pitch = sm.getData1();
|
||||
int velocity = sm.getData2();
|
||||
int effectiveVelocity = (int) ((float) velocity * channelVolumes[sm.getChannel()] / 127);
|
||||
float effectiveVelocity = (float) velocity * channelVolumes[sm.getChannel()] / 127;
|
||||
int pan = channelPans[sm.getChannel()];
|
||||
long deltaTick = event.getTick() - prevTick;
|
||||
prevTick = event.getTick();
|
||||
|
@ -171,7 +171,7 @@ public class MidiConverter implements Converter {
|
|||
return song;
|
||||
}
|
||||
|
||||
public static Note getMidiInstrumentNote(int midiInstrument, int midiPitch, int velocity, long microTime, int panning) {
|
||||
public static Note getMidiInstrumentNote(int midiInstrument, int midiPitch, float velocity, long microTime, int panning) {
|
||||
Instrument instrument = null;
|
||||
Instrument[] instrumentList = instrumentMap.get(midiInstrument);
|
||||
if (instrumentList != null) {
|
||||
|
@ -215,13 +215,13 @@ public class MidiConverter implements Converter {
|
|||
|
||||
int pitch = midiPitch-instrument.offset;
|
||||
|
||||
float volume = (float) velocity / 127.0f;
|
||||
float volume = velocity / 127.0f;
|
||||
long time = microTime / 1000L;
|
||||
|
||||
return new Note(instrument, pitch, midiPitch, volume, time, (int) ((panning - 64) / (float) 64) * 100, 100);
|
||||
}
|
||||
|
||||
private static Note getMidiPercussionNote (int midiPitch, int velocity, long microTime, int panning) {
|
||||
private static Note getMidiPercussionNote (int midiPitch, float velocity, long microTime, int panning) {
|
||||
if (percussionMap.containsKey(midiPitch)) {
|
||||
int noteId = percussionMap.get(midiPitch);
|
||||
int pitch = noteId % 25;
|
||||
|
|
Loading…
Reference in a new issue