Skip to content

Commit

Permalink
Check sending direction for processing the forwarding command
Browse files Browse the repository at this point in the history
Related #205
  • Loading branch information
games647 committed Nov 10, 2020
1 parent 7e23e94 commit ba1957a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Expand Up @@ -77,7 +77,7 @@ public class SkinApplier extends SharedApplier {
Field localInteractionField = null;
Field localGamemode = null;

// TODO: In ProtocolLib4.6 We could use a specific modifier for the world key
// TODO: In ProtocolLib 4.6 We could use a specific modifier for the world key

// use standard reflection, because we cannot use the performance benefits of MethodHandles
// MethodHandles are only clearly faster with invokeExact
Expand Down
@@ -1,8 +1,8 @@
package com.github.games647.changeskin.bungee.listener;

import com.github.games647.changeskin.bungee.ChangeSkinBungee;
import com.github.games647.changeskin.core.message.NamespaceKey;
import com.github.games647.changeskin.core.message.ForwardMessage;
import com.github.games647.changeskin.core.message.NamespaceKey;
import com.github.games647.changeskin.core.message.PermResultMessage;
import com.github.games647.changeskin.core.model.UserPreference;
import com.github.games647.changeskin.core.model.skin.SkinModel;
Expand All @@ -14,6 +14,7 @@
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;

Expand Down Expand Up @@ -41,6 +42,11 @@ public void onPluginMessage(PluginMessageEvent messageEvent) {

ByteArrayDataInput dataInput = ByteStreams.newDataInput(messageEvent.getData());

if (!(messageEvent.getSender() instanceof Server)) {
//check if the message is sent from the server
return;
}

ProxiedPlayer invoker = (ProxiedPlayer) messageEvent.getReceiver();
if (channel.equals(permissionResultChannel)) {
PermResultMessage message = new PermResultMessage();
Expand Down
Expand Up @@ -198,9 +198,7 @@ private Configuration loadFile(String fileName) throws IOException {
private void saveDefaultFile(String fileName) {
Path dataFolder = plugin.getPluginFolder();
try {
if (Files.notExists(dataFolder)) {
Files.createDirectories(dataFolder);
}
Files.createDirectories(dataFolder);

Path configFile = dataFolder.resolve(fileName);
if (Files.notExists(configFile)) {
Expand Down

0 comments on commit ba1957a

Please sign in to comment.