-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement WrapperPlayServerRecipeBookRemove
- Loading branch information
Showing
3 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
api/src/main/java/com/github/retrooper/packetevents/protocol/recipe/RecipeDisplayId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This file is part of packetevents - https://github.com/retrooper/packetevents | ||
* Copyright (C) 2024 retrooper and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.retrooper.packetevents.protocol.recipe; | ||
|
||
import com.github.retrooper.packetevents.wrapper.PacketWrapper; | ||
|
||
public final class RecipeDisplayId { | ||
|
||
private final int id; | ||
|
||
public RecipeDisplayId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public static RecipeDisplayId read(PacketWrapper<?> wrapper) { | ||
int id = wrapper.readVarInt(); | ||
return new RecipeDisplayId(id); | ||
} | ||
|
||
public static void write(PacketWrapper<?> wrapper, RecipeDisplayId id) { | ||
wrapper.writeVarInt(id.id); | ||
} | ||
|
||
public int getId() { | ||
return this.id; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
.../github/retrooper/packetevents/wrapper/play/server/WrapperPlayServerRecipeBookRemove.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* This file is part of packetevents - https://github.com/retrooper/packetevents | ||
* Copyright (C) 2024 retrooper and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.retrooper.packetevents.wrapper.play.server; | ||
|
||
import com.github.retrooper.packetevents.event.PacketSendEvent; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.protocol.recipe.RecipeDisplayId; | ||
import com.github.retrooper.packetevents.wrapper.PacketWrapper; | ||
|
||
import java.util.List; | ||
|
||
public class WrapperPlayServerRecipeBookRemove extends PacketWrapper<WrapperPlayServerRecipeBookRemove> { | ||
|
||
private List<RecipeDisplayId> recipeIds; | ||
|
||
public WrapperPlayServerRecipeBookRemove(PacketSendEvent event) { | ||
super(event); | ||
} | ||
|
||
public WrapperPlayServerRecipeBookRemove(List<RecipeDisplayId> recipeIds) { | ||
super(PacketType.Play.Server.RECIPE_BOOK_REMOVE); | ||
this.recipeIds = recipeIds; | ||
} | ||
|
||
@Override | ||
public void read() { | ||
this.recipeIds = this.readList(RecipeDisplayId::read); | ||
} | ||
|
||
@Override | ||
public void write() { | ||
this.writeList(this.recipeIds, RecipeDisplayId::write); | ||
} | ||
|
||
@Override | ||
public void copy(WrapperPlayServerRecipeBookRemove wrapper) { | ||
this.recipeIds = wrapper.recipeIds; | ||
} | ||
|
||
public List<RecipeDisplayId> getRecipeIds() { | ||
return this.recipeIds; | ||
} | ||
|
||
public void setRecipeIds(List<RecipeDisplayId> recipeIds) { | ||
this.recipeIds = recipeIds; | ||
} | ||
} |