Dieser Commit ist enthalten in:
Ursprung
58fb831950
Commit
334459b848
@ -28,7 +28,7 @@ import de.steamwar.bungeecore.sql.*;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -64,7 +64,7 @@ public class ModCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateAndCloseGui(Mod.ModType modType,String modName,Mod.Platform modPlatform,SWInventory toClose,ProxiedPlayer p) {
|
public void updateAndCloseGui(Mod.ModType modType,String modName,Mod.Platform modPlatform,SWInventory toClose,ProxiedPlayer p) {
|
||||||
Mod.get(modName,modPlatform).setModType(modType,modName,modPlatform);
|
Mod.getOrCreate(modName,modPlatform).setModType(modType);
|
||||||
toClose.close();
|
toClose.close();
|
||||||
openGui(p);
|
openGui(p);
|
||||||
}
|
}
|
||||||
@ -123,7 +123,7 @@ public class ModCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mod.get(modName,platform).setModType(newModType,modName,platform);
|
Mod.getOrCreate(modName,platform).setModType(newModType);
|
||||||
|
|
||||||
Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name());
|
Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name());
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class Fabric extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(JsonElement mod : array) {
|
for(JsonElement mod : array) {
|
||||||
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
|
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -26,9 +26,7 @@ import io.netty.channel.ChannelPipeline;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
|
||||||
import net.md_5.bungee.connection.InitialHandler;
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
|
||||||
import net.md_5.bungee.netty.ChannelWrapper;
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
import net.md_5.bungee.netty.HandlerBoss;
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
import net.md_5.bungee.netty.PacketHandler;
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
@ -135,7 +133,7 @@ public class Forge extends BasicListener {
|
|||||||
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
||||||
pos += nameLength.length;
|
pos += nameLength.length;
|
||||||
|
|
||||||
mods.add(Mod.get(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
mods.add(Mod.getOrCreate(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
||||||
pos += nameLength.value;
|
pos += nameLength.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ public class Forge12 extends BasicListener {
|
|||||||
//Version information is unused
|
//Version information is unused
|
||||||
bytePos += 1 + data[bytePos];
|
bytePos += 1 + data[bytePos];
|
||||||
|
|
||||||
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
mods.add(Mod.getOrCreate(new String(name), Mod.Platform.FORGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Utils.handleMods(p, mods)) {
|
if (Utils.handleMods(p, mods)) {
|
||||||
|
@ -67,7 +67,7 @@ public class LabyMod extends BasicListener {
|
|||||||
try{
|
try{
|
||||||
InfoPacket info = new InfoPacket(value.value);
|
InfoPacket info = new InfoPacket(value.value);
|
||||||
for(InfoPacket.Addon addon : info.addons) {
|
for(InfoPacket.Addon addon : info.addons) {
|
||||||
mods.add(Mod.get(addon.name, Mod.Platform.LABYMOD));
|
mods.add(Mod.getOrCreate(addon.name, Mod.Platform.LABYMOD));
|
||||||
}
|
}
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
BungeeCore.log("Could not read JSON", e);
|
BungeeCore.log("Could not read JSON", e);
|
||||||
|
@ -28,6 +28,6 @@ public class WorldDownloader extends BasicListener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.get("wdl", Mod.Platform.FORGE)));
|
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.getOrCreate("wdl", Mod.Platform.FORGE)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.sql;
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -49,7 +46,13 @@ public class Mod {
|
|||||||
this.modType = modType;
|
this.modType = modType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mod get(String modName, Platform platform){
|
private Mod(ResultSet resultSet) throws SQLException {
|
||||||
|
this.modName = resultSet.getString("ModName");
|
||||||
|
this.platform = Mod.Platform.valueOf(resultSet.getInt("Platform"));
|
||||||
|
this.modType = ModType.valueOf(resultSet.getInt("ModType"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Mod getOrCreate(String modName, Platform platform){
|
||||||
Mod mod = get.select(rs -> {
|
Mod mod = get.select(rs -> {
|
||||||
if(rs.next())
|
if(rs.next())
|
||||||
return new Mod(modName, platform, ModType.valueOf(rs.getInt("ModType")));
|
return new Mod(modName, platform, ModType.valueOf(rs.getInt("ModType")));
|
||||||
@ -62,15 +65,11 @@ public class Mod {
|
|||||||
return new Mod(modName, platform, ModType.UNKLASSIFIED);
|
return new Mod(modName, platform, ModType.UNKLASSIFIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mod get(String modName, int platform) {
|
|
||||||
return get(modName,Mod.Platform.valueOf(platform));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ModType getModType(String modName,Mod.Platform platform) {
|
public static ModType getModType(String modName,Mod.Platform platform) {
|
||||||
return get(modName,platform).modType;
|
return getOrCreate(modName,platform).modType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModType(Mod.ModType newModType,String modName,Mod.Platform platform) {
|
public void setModType(Mod.ModType newModType) {
|
||||||
set.update(newModType.value ,modName,platform.value);
|
set.update(newModType.value ,modName,platform.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +80,7 @@ public class Mod {
|
|||||||
return Mod.getAllFiltered.select(rs -> {
|
return Mod.getAllFiltered.select(rs -> {
|
||||||
List<Mod> f = new ArrayList<>();
|
List<Mod> f = new ArrayList<>();
|
||||||
while(rs.next()){
|
while(rs.next()){
|
||||||
Mod entry = new Mod(rs.getString("ModName"), Mod.Platform.valueOf(rs.getInt("Platform")),Mod.ModType.valueOf(rs.getInt("ModType")));
|
Mod entry = new Mod(rs);
|
||||||
f.add(entry);
|
f.add(entry);
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
@ -89,12 +88,11 @@ public class Mod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Mod findFirstMod() {
|
public static Mod findFirstMod() {
|
||||||
findFirst.select(rs -> {
|
return findFirst.select(rs -> {
|
||||||
String name = rs.getString("ModName");
|
String name = rs.getString("ModName");
|
||||||
int platform = rs.getInt("Platform");
|
int platform = rs.getInt("Platform");
|
||||||
return get(name,Platform.valueOf(platform));
|
return new Mod(name,Platform.valueOf(platform),ModType.UNKLASSIFIED);
|
||||||
});
|
});
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModName() {
|
public String getModName() {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren