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) {
|
public IPFilterPlugin (Bot bot) {
|
||||||
this.bot = bot;
|
this.bot = bot;
|
||||||
|
|
||||||
|
@ -42,11 +40,6 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
||||||
check(target);
|
check(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void playerLeft(PlayerEntry target) {
|
|
||||||
cached.remove(target.profile.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void check (PlayerEntry target) {
|
private void check (PlayerEntry target) {
|
||||||
final CompletableFuture<CompoundTag> future = bot.core.runTracked("essentials:seen " + target.profile.getIdAsString());
|
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 () {
|
private void checkAllPlayers () {
|
||||||
|
if (filteredIPs.isEmpty()) return;
|
||||||
|
|
||||||
int ms = 0;
|
int ms = 0;
|
||||||
for (PlayerEntry entry : bot.players.list) {
|
for (PlayerEntry entry : bot.players.list) {
|
||||||
bot.executor.schedule(() -> check(entry), ms, TimeUnit.MILLISECONDS);
|
bot.executor.schedule(() -> check(entry), ms, TimeUnit.MILLISECONDS);
|
||||||
|
@ -109,8 +104,6 @@ public class IPFilterPlugin extends PlayersPlugin.Listener {
|
||||||
for (JsonElement element : filteredIPs) {
|
for (JsonElement element : filteredIPs) {
|
||||||
if (!element.getAsString().equals(ip)) continue;
|
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;
|
if (entry.profile.getId().equals(bot.profile.getId())) continue;
|
||||||
|
|
||||||
bot.filter.doAll(entry);
|
bot.filter.doAll(entry);
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class MidiConverter implements Converter {
|
||||||
if (sm.getData2() == 0) continue;
|
if (sm.getData2() == 0) continue;
|
||||||
int pitch = sm.getData1();
|
int pitch = sm.getData1();
|
||||||
int velocity = sm.getData2();
|
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()];
|
int pan = channelPans[sm.getChannel()];
|
||||||
long deltaTick = event.getTick() - prevTick;
|
long deltaTick = event.getTick() - prevTick;
|
||||||
prevTick = event.getTick();
|
prevTick = event.getTick();
|
||||||
|
@ -171,7 +171,7 @@ public class MidiConverter implements Converter {
|
||||||
return song;
|
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 instrument = null;
|
||||||
Instrument[] instrumentList = instrumentMap.get(midiInstrument);
|
Instrument[] instrumentList = instrumentMap.get(midiInstrument);
|
||||||
if (instrumentList != null) {
|
if (instrumentList != null) {
|
||||||
|
@ -215,13 +215,13 @@ public class MidiConverter implements Converter {
|
||||||
|
|
||||||
int pitch = midiPitch-instrument.offset;
|
int pitch = midiPitch-instrument.offset;
|
||||||
|
|
||||||
float volume = (float) velocity / 127.0f;
|
float volume = velocity / 127.0f;
|
||||||
long time = microTime / 1000L;
|
long time = microTime / 1000L;
|
||||||
|
|
||||||
return new Note(instrument, pitch, midiPitch, volume, time, (int) ((panning - 64) / (float) 64) * 100, 100);
|
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)) {
|
if (percussionMap.containsKey(midiPitch)) {
|
||||||
int noteId = percussionMap.get(midiPitch);
|
int noteId = percussionMap.get(midiPitch);
|
||||||
int pitch = noteId % 25;
|
int pitch = noteId % 25;
|
||||||
|
|
Loading…
Reference in a new issue