forked from PaperMC/Debuggery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b6faec
commit d7e14b7
Showing
11 changed files
with
270 additions
and
55 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
87 changes: 87 additions & 0 deletions
87
debuggery-bukkit/src/main/java/io/zachbr/debuggery/commands/EventCommand.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,87 @@ | ||
/* | ||
* This file is part of Debuggery. | ||
* | ||
* Debuggery 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. | ||
* | ||
* Debuggery 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 Debuggery. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.zachbr.debuggery.commands; | ||
|
||
import io.zachbr.debuggery.DebuggeryBukkit; | ||
import io.zachbr.debuggery.commands.base.CommandReflection; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.Event; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class EventCommand extends CommandReflection { | ||
|
||
|
||
public EventCommand(DebuggeryBukkit debuggery) { | ||
super("devent", "debuggery.devent", true, Entity.class, debuggery); | ||
} | ||
|
||
@Override | ||
protected boolean commandLogic(CommandSender sender, Command command, String label, String[] args) { | ||
if (args.length == 0) { | ||
return true; | ||
} | ||
|
||
String clazz = args[0]; | ||
|
||
try { | ||
Class<?> event = Class.forName(clazz, true, this.getClass().getClassLoader()); | ||
updateReflectionClass(event); | ||
if (!Event.class.isAssignableFrom(event)) { | ||
sender.sendMessage(Component.text("Provided class is not an event.", NamedTextColor.RED)); | ||
return true; | ||
} | ||
|
||
String[] offsetArgs = Arrays.copyOfRange(args, 1, args.length); | ||
sender.sendMessage(Component.text("Added event debugger!", NamedTextColor.GREEN)); | ||
this.debuggery.getEventDebugger().addDebugger(event, (eventInstance) -> { | ||
this.doReflectionLookups(sender, offsetArgs, eventInstance); | ||
}); | ||
} catch (Exception e) { | ||
sender.sendMessage(Component.text("Unknown class name %s!".formatted(clazz), NamedTextColor.RED)); | ||
return true; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public List<String> tabCompleteLogic(CommandSender sender, Command command, String alias, String[] args) { | ||
if (args.length == 0) { | ||
return List.of(); | ||
} | ||
try { | ||
Class<?> event = Class.forName(args[0], true, this.getClass().getClassLoader()); | ||
updateReflectionClass(event); | ||
} catch (ClassNotFoundException e) { | ||
return List.of(); | ||
} | ||
|
||
String[] trimmed = Arrays.copyOfRange(args, 1, args.length); | ||
if (trimmed.length == 0) { | ||
return List.of(); | ||
} | ||
|
||
return super.tabCompleteLogic(sender, command, alias, trimmed); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
debuggery-bukkit/src/main/java/io/zachbr/debuggery/commands/EventRemoveCommand.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,75 @@ | ||
/* | ||
* This file is part of Debuggery. | ||
* | ||
* Debuggery 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. | ||
* | ||
* Debuggery 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 Debuggery. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.zachbr.debuggery.commands; | ||
|
||
import io.zachbr.debuggery.DebuggeryBukkit; | ||
import io.zachbr.debuggery.commands.base.CommandBase; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.format.NamedTextColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class EventRemoveCommand extends CommandBase { | ||
|
||
private final DebuggeryBukkit debuggery; | ||
|
||
public EventRemoveCommand(DebuggeryBukkit debuggery) { | ||
super("deventremove", "debuggery.devent.remove", true); | ||
this.debuggery = debuggery; | ||
} | ||
|
||
@Override | ||
protected boolean commandLogic(CommandSender sender, Command command, String label, String[] args) { | ||
if (args.length > 0 && args[0].equals("*")) { | ||
this.debuggery.getEventDebugger().clearAll(); | ||
sender.sendMessage(Component.text("Cleared all event debuggers!", NamedTextColor.GREEN)); | ||
return true; | ||
} | ||
|
||
try { | ||
Class<?> event = Class.forName(args[0], false, this.getClass().getClassLoader()); | ||
if (this.debuggery.getEventDebugger().clear(event)) { | ||
sender.sendMessage(Component.text("Cleared event debugger for " + event, NamedTextColor.GREEN)); | ||
} else { | ||
sender.sendMessage(Component.text("No debugger for that event found!", NamedTextColor.RED)); | ||
} | ||
} catch (Exception e) { | ||
sender.sendMessage(Component.text("Class not found!", NamedTextColor.RED)); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean helpLogic(CommandSender sender, String[] args) { | ||
sender.sendMessage(Component.text("Clears the event debugger for the provided event.")); | ||
return true; | ||
} | ||
|
||
@Override | ||
protected List<String> tabCompleteLogic(CommandSender sender, Command command, String alias, String[] args) { | ||
List<String> names = new ArrayList<>(); | ||
this.debuggery.getEventDebugger().getAll().forEach((clazz) -> names.add(clazz.getName())); | ||
names.add("*"); | ||
|
||
return names; | ||
} | ||
} |
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
43 changes: 0 additions & 43 deletions
43
.../io/zachbr/debuggery/reflection/types/handlers/bukkit/input/MaterialDataInputHandler.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.