mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-08 19:51:05 +00:00
Fix exploit that allows staying in creative mode
This commit is contained in:
parent
060c8a7295
commit
00bdbaee53
@ -54,7 +54,6 @@ public class CreativeModeListener implements Listener {
|
|||||||
ClickType.removePlayerClickType(p);
|
ClickType.removePlayerClickType(p);
|
||||||
((SelectClickType) clickType).setItem(e.getCursor());
|
((SelectClickType) clickType).setItem(e.getCursor());
|
||||||
p.closeInventory();
|
p.closeInventory();
|
||||||
p.setGameMode(((SelectClickType) clickType).getGameMode());
|
|
||||||
|
|
||||||
p.sendMessage(LanguageUtils.getMessage(Message.ITEM_SELECTED,
|
p.sendMessage(LanguageUtils.getMessage(Message.ITEM_SELECTED,
|
||||||
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(e.getCursor()))));
|
new Replacement(Placeholder.ITEM_NAME, LanguageUtils.getItemName(e.getCursor()))));
|
||||||
@ -75,7 +74,6 @@ public class CreativeModeListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ClickType.removePlayerClickType(p);
|
ClickType.removePlayerClickType(p);
|
||||||
p.setGameMode(((SelectClickType) clickType).getGameMode());
|
|
||||||
p.sendMessage(LanguageUtils.getMessage(Message.CREATION_CANCELLED));
|
p.sendMessage(LanguageUtils.getMessage(Message.CREATION_CANCELLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,9 +82,6 @@ public class CreativeModeListener implements Listener {
|
|||||||
// Reset game mode on quit if SelectClickType is set
|
// Reset game mode on quit if SelectClickType is set
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
ClickType ct = ClickType.getPlayerClickType(p);
|
ClickType ct = ClickType.getPlayerClickType(p);
|
||||||
if (ct instanceof SelectClickType) {
|
|
||||||
p.setGameMode(((SelectClickType) ct).getGameMode());
|
|
||||||
}
|
|
||||||
ClickType.removePlayerClickType(p);
|
ClickType.removePlayerClickType(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +58,10 @@ public class ClickType {
|
|||||||
*/
|
*/
|
||||||
public static void removePlayerClickType(OfflinePlayer player) {
|
public static void removePlayerClickType(OfflinePlayer player) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (playerClickType.get(uuid) instanceof SelectClickType && player instanceof Player) {
|
||||||
|
// Reset gamemode player has select click type
|
||||||
|
((Player) player).setGameMode(((SelectClickType) playerClickType.get(uuid)).gameMode);
|
||||||
|
}
|
||||||
playerClickType.remove(uuid);
|
playerClickType.remove(uuid);
|
||||||
|
|
||||||
// If a timer is still running, cancel it
|
// If a timer is still running, cancel it
|
||||||
@ -73,6 +77,10 @@ public class ClickType {
|
|||||||
*/
|
*/
|
||||||
public static void setPlayerClickType(OfflinePlayer player, ClickType clickType) {
|
public static void setPlayerClickType(OfflinePlayer player, ClickType clickType) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
if (playerClickType.get(uuid) instanceof SelectClickType && player instanceof Player) {
|
||||||
|
// Reset gamemode player has select click type
|
||||||
|
((Player) player).setGameMode(((SelectClickType) playerClickType.get(uuid)).gameMode);
|
||||||
|
}
|
||||||
playerClickType.put(uuid, clickType);
|
playerClickType.put(uuid, clickType);
|
||||||
|
|
||||||
// If a timer is already running, cancel it
|
// If a timer is already running, cancel it
|
||||||
|
Loading…
Reference in New Issue
Block a user