mirror of
https://github.com/Coloryr/AllMusic.git
synced 2026-11-27 21:22:58 +00:00
up
This commit is contained in:
1 parent
65c91a9b87
commit
d377b71f2d
10 files changed
+21
-35
No files matched your search
@@ -170,7 +170,7 @@ public class CommandEX {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().addMusic.banMusic);
|
||||
} else if (PlayMusic.haveMusic(musicID)) {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().addMusic.existMusic);
|
||||
} else if (PlayMusic.havePlayer(name)) {
|
||||
} else if (PlayMusic.isPlayerMax(name)) {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().addMusic.playerToMany);
|
||||
} else if (AllMusic.getConfig().banPlayer.contains(name)) {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().addMusic.playerBan);
|
||||
@@ -182,7 +182,7 @@ public class CommandEX {
|
||||
AllMusic.getMessage().cost.addMusic)) {
|
||||
return;
|
||||
}
|
||||
AllMusic.getConfig().RemoveNoMusicPlayer(name);
|
||||
AllMusic.getConfig().removeNoMusicPlayer(name);
|
||||
if (AllMusic.side.needPlay()) {
|
||||
MusicObj obj = new MusicObj();
|
||||
obj.sender = sender;
|
||||
|
||||
@@ -7,7 +7,7 @@ public class CommandMute extends ACommand {
|
||||
public void ex(Object sender, String name, String[] args) {
|
||||
AllMusic.side.sendStop(name);
|
||||
AllMusic.side.clearHud(name);
|
||||
AllMusic.getConfig().AddNoMusicPlayer(name);
|
||||
AllMusic.getConfig().addNoMusicPlayer(name);
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().musicPlay.mute);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,6 @@ public class CommandNext extends ACommand {
|
||||
public void ex(Object sender, String name, String[] args) {
|
||||
PlayMusic.musicLessTime = 1;
|
||||
AllMusic.side.sendMessage(sender, "§d[AllMusic3]§2已强制切歌");
|
||||
AllMusic.getConfig().RemoveNoMusicPlayer(name);
|
||||
AllMusic.getConfig().removeNoMusicPlayer(name);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class CommandPush extends ACommand {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().push.arAgree);
|
||||
}
|
||||
}
|
||||
AllMusic.getConfig().RemoveNoMusicPlayer(name);
|
||||
AllMusic.getConfig().removeNoMusicPlayer(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,6 +52,6 @@ public class CommandVote extends ACommand {
|
||||
AllMusic.side.sendMessage(sender, AllMusic.getMessage().vote.arAgree);
|
||||
}
|
||||
}
|
||||
AllMusic.getConfig().RemoveNoMusicPlayer(name);
|
||||
AllMusic.getConfig().removeNoMusicPlayer(name);
|
||||
}
|
||||
}
|
||||
@@ -317,7 +317,12 @@ public class PlayMusic {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean havePlayer(String name) {
|
||||
/**
|
||||
* 判断玩家点歌数量是否超上限
|
||||
* @param name 玩家名
|
||||
* @return
|
||||
*/
|
||||
public static boolean isPlayerMax(String name) {
|
||||
int list = AllMusic.getConfig().maxPlayerList;
|
||||
if (list == 0) {
|
||||
return false;
|
||||
|
||||
@@ -143,12 +143,12 @@ public class ConfigObj {
|
||||
AllMusic.saveConfig();
|
||||
}
|
||||
|
||||
public void AddNoMusicPlayer(String ID) {
|
||||
public void addNoMusicPlayer(String ID) {
|
||||
mutePlayer.add(ID);
|
||||
AllMusic.saveConfig();
|
||||
}
|
||||
|
||||
public void RemoveNoMusicPlayer(String ID) {
|
||||
public void removeNoMusicPlayer(String ID) {
|
||||
mutePlayer.remove(ID);
|
||||
AllMusic.saveConfig();
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ mod_name=AllMusic Server
|
||||
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
|
||||
mod_license=GPL-3.0
|
||||
# The mod version. See https://semver.org/
|
||||
mod_version=3.1.2
|
||||
mod_version=3.1.3
|
||||
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
|
||||
# This should match the base package used for the mod sources.
|
||||
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.coloryr.allmusic.server.side.forge.LogForge;
|
||||
import com.coloryr.allmusic.server.side.forge.SideForge;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
@@ -19,22 +18,16 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.network.NetworkRegistry;
|
||||
import net.minecraftforge.network.simple.SimpleChannel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod(AllMusicForge.MODID)
|
||||
public class AllMusicForge {
|
||||
public static final SimpleChannel channel = NetworkRegistry.newSimpleChannel(new ResourceLocation("allmusic", "channel"),
|
||||
() -> "1.0", s -> true, s -> true);
|
||||
public static final ResourceLocation channel = new ResourceLocation("allmusic", "channel");
|
||||
// Define mod id in a common place for everything to reference
|
||||
public static final String MODID = "allmusic_server";
|
||||
// Directly reference a slf4j logger
|
||||
@@ -53,8 +46,6 @@ public class AllMusicForge {
|
||||
}
|
||||
|
||||
private void commonSetup(final FMLCommonSetupEvent event) {
|
||||
channel.registerMessage(0, String.class, this::enc, this::dec, this::proc);
|
||||
|
||||
String path = String.format(Locale.ROOT, "config/%s/", "AllMusic3");
|
||||
|
||||
AllMusic.log = new LogForge();
|
||||
@@ -63,19 +54,6 @@ public class AllMusicForge {
|
||||
new AllMusic().init(new File(path));
|
||||
}
|
||||
|
||||
private void enc(String str, FriendlyByteBuf buffer) {
|
||||
buffer.writeBytes(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private String dec(FriendlyByteBuf buffer) {
|
||||
return buffer.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private void proc(String str, Supplier<NetworkEvent.Context> supplier) {
|
||||
NetworkEvent.Context context = supplier.get();
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRegisterCommands(RegisterCommandsEvent event) {
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = event.getDispatcher();
|
||||
|
||||
@@ -17,7 +17,9 @@ import com.coloryr.allmusic.server.side.forge.event.MusicPlayEvent;
|
||||
import com.google.gson.Gson;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.commands.CommandSource;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.network.PacketDistributor;
|
||||
@@ -407,9 +409,10 @@ public class SideForge extends BaseSide {
|
||||
if (players == null)
|
||||
return;
|
||||
try {
|
||||
runTask(() -> AllMusicForge.channel.send(PacketDistributor.PLAYER.with(
|
||||
runTask(() -> PacketDistributor.PLAYER.with(
|
||||
() -> players
|
||||
), data));
|
||||
).send(new ClientboundCustomPayloadPacket(AllMusicForge.channel,
|
||||
new FriendlyByteBuf(data))));
|
||||
} catch (Exception e) {
|
||||
AllMusic.log.warning("§c数据发送发生错误");
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in new issue
Block a user