-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Automatically uses the best crash method based upon target client version Improved: Hover Component after executing the crash command Fixed: Wrongly detecting when someone was crashed / not crashed
- Loading branch information
Showing
12 changed files
with
215 additions
and
78 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
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
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
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
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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/deathmotion/playercrasher/events/PlayerQuit.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,22 @@ | ||
package com.deathmotion.playercrasher.events; | ||
|
||
import com.deathmotion.playercrasher.PlayerCrasher; | ||
import com.deathmotion.playercrasher.managers.CrashManager; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerQuitEvent; | ||
|
||
public class PlayerQuit implements Listener { | ||
|
||
private final CrashManager crashManager; | ||
|
||
public PlayerQuit(PlayerCrasher plugin) { | ||
this.crashManager = plugin.getCrashManager(); | ||
} | ||
|
||
@EventHandler(priority = EventPriority.MONITOR) | ||
public void onPlayerQuit(PlayerQuitEvent event) { | ||
crashManager.removeClientBrand(event.getPlayer().getUniqueId()); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/deathmotion/playercrasher/listeners/BrandHandler.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,51 @@ | ||
package com.deathmotion.playercrasher.listeners; | ||
|
||
import com.deathmotion.playercrasher.PlayerCrasher; | ||
import com.deathmotion.playercrasher.managers.CrashManager; | ||
import com.github.retrooper.packetevents.event.PacketListenerAbstract; | ||
import com.github.retrooper.packetevents.event.PacketReceiveEvent; | ||
import com.github.retrooper.packetevents.protocol.packettype.PacketType; | ||
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; | ||
|
||
public class BrandHandler extends PacketListenerAbstract { | ||
|
||
private final CrashManager crashManager; | ||
|
||
public BrandHandler(PlayerCrasher plugin) { | ||
crashManager = plugin.getCrashManager(); | ||
} | ||
|
||
@Override | ||
public void onPacketReceive(PacketReceiveEvent event) { | ||
if (event.getPacketType() != PacketType.Configuration.Client.PLUGIN_MESSAGE) return; | ||
WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); | ||
|
||
String channelName = wrapper.getChannelName(); | ||
byte[] data = wrapper.getData(); | ||
|
||
if (!channelName.equalsIgnoreCase("minecraft:brand") && !channelName.equals("MC|Brand")) return; | ||
if (data.length > 64 || data.length == 0) return; | ||
|
||
byte[] minusLength = new byte[data.length - 1]; | ||
System.arraycopy(data, 1, minusLength, 0, minusLength.length); | ||
String brand = new String(minusLength).replace(" (Velocity)", ""); // removes velocity's brand suffix | ||
|
||
crashManager.addClientBrand(event.getUser().getUUID(), prettyBrandName(brand)); | ||
} | ||
|
||
private String prettyBrandName(String brand) { | ||
if (brand.toLowerCase().contains("lunarclient")) { | ||
return "Lunar Client"; | ||
} | ||
|
||
return capitalizeFirstLetter(brand); | ||
} | ||
|
||
private String capitalizeFirstLetter(String str) { | ||
if (str == null || str.isEmpty()) { | ||
return str; | ||
} else { | ||
return Character.toUpperCase(str.charAt(0)) + str.substring(1); | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.