3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Add option to truncate edited books with more than 50 pages

Dieser Commit ist enthalten in:
KennyTV 2019-03-04 10:14:52 +01:00
Ursprung 9a91250af7
Commit 9d0331e190
7 geänderte Dateien mit 52 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -249,4 +249,9 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
public int get1_13TabCompleteDelay() { public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0); return getInt("1_13-tab-complete-delay", 0);
} }
@Override
public boolean truncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
} }

Datei anzeigen

@ -302,4 +302,9 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
public int get1_13TabCompleteDelay() { public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0); return getInt("1_13-tab-complete-delay", 0);
} }
@Override
public boolean truncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
} }

Datei anzeigen

@ -305,7 +305,15 @@ public interface ViaVersionConfig {
/** /**
* When greater than 0, enables tab complete request delaying by x ticks * When greater than 0, enables tab complete request delaying by x ticks
*
* @return the delay in ticks * @return the delay in ticks
*/ */
int get1_13TabCompleteDelay(); int get1_13TabCompleteDelay();
/**
* When activated, edited books with more than 50 pages will be shortened to 50.
*
* @return True if enabled
*/
boolean truncate1_14Books();
} }

Datei anzeigen

@ -1,7 +1,12 @@
package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets; package us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.protocol.Protocol; import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler; import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper; import us.myles.ViaVersion.api.remapper.PacketRemapper;
@ -36,7 +41,23 @@ public class PlayerPackets {
handler(new PacketHandler() { handler(new PacketHandler() {
@Override @Override
public void handle(PacketWrapper wrapper) throws Exception { public void handle(PacketWrapper wrapper) throws Exception {
InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); final Item item = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
InventoryPackets.toServer(item);
// Client limit when editing a book was upped from 50 to 100 in 1.14, but some anti-exploit plugins ban with a size higher than the old client limit
if (Via.getConfig().truncate1_14Books()) {
if (item == null) return;
CompoundTag tag = item.getTag();
if (tag == null) return;
Tag pages = tag.get("pages");
if (!(pages instanceof ListTag)) return;
ListTag listTag = (ListTag) pages;
if (listTag.size() <= 50) return;
listTag.setValue(listTag.getValue().subList(0, 50));
}
} }
}); });
} }

Datei anzeigen

@ -118,6 +118,8 @@ disable-1_13-auto-complete: false
1_13-tab-complete-delay: 0 1_13-tab-complete-delay: 0
# For 1.13 clients the smallest (1 layer) snow doesn't have collision, this will send these as 2 snowlayers for 1.13+ clients to prevent them bugging through them # For 1.13 clients the smallest (1 layer) snow doesn't have collision, this will send these as 2 snowlayers for 1.13+ clients to prevent them bugging through them
fix-low-snow-collision: false fix-low-snow-collision: false
# In 1.14 the client page limit has been upped to 100 (from 50). Some anti-exploit plugins ban when clients go higher than 50. This option cuts edited books to 50 pages.
truncate-1_14-books: false
# #
# Enable serverside block-connections for 1.13+ clients # Enable serverside block-connections for 1.13+ clients
serverside-blockconnections: false serverside-blockconnections: false

Datei anzeigen

@ -255,4 +255,9 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
public int get1_13TabCompleteDelay() { public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0); return getInt("1_13-tab-complete-delay", 0);
} }
@Override
public boolean truncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
} }

Datei anzeigen

@ -307,4 +307,9 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
public int get1_13TabCompleteDelay() { public int get1_13TabCompleteDelay() {
return getInt("1_13-tab-complete-delay", 0); return getInt("1_13-tab-complete-delay", 0);
} }
@Override
public boolean truncate1_14Books() {
return getBoolean("truncate-1_14-books", false);
}
} }