Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
1人1000役!ついプラグインをたくさん入れちゃうあなたにおすすめのプラグイン - NotEnoughPlugins
public class NotEnoughPlugins extends JavaPlugin {
private static final String[] PLUGIN_NAMES = {
"わーい!", "みゃみゃみゃみゃみゃみゃみゃあ!", "たーのしー!",
"まんぞく", "若干ゃ草", "へーきへーき", "やったぁ!",
"えっへん!", "プラグインを入れるのが得意なフレンズなんだね!",
"もうお友達だから!", "その手があったでござるか", "すっごーい",
"狩りごっこだね!", "た、食べないでくださーい!", "ちがうよ!",
"ジャンプ力ぅですかねぇ", "でもまあ騒ぐほどでもないか",
"よぉこそぉ", "ぺっ", "どうぞどうぞぉ!", "ゆっぐりしでいっでぇ!",
"なにこれ!", "でしょでしょ?", "われわれは賢いので", "これはダメですね",
"ひどいよぉ", "やだやだー!", "アワワワワ"
};
public static final int NUMBER_OF_PLUGINS = 999;
@Override
public void onEnable() {
try {
Random random = new SecureRandom();
int size = PLUGIN_NAMES.length;
Field fieldPlugins = SimplePluginManager.class.getDeclaredField("plugins");
fieldPlugins.setAccessible(true);
List<Plugin> plugins = (List<Plugin>) fieldPlugins.get(getServer().getPluginManager());
for (int i = 0; i < NUMBER_OF_PLUGINS; i++) {
Plugin plugin = new FakePlugin(
PLUGIN_NAMES[random.nextInt(size)],
PLUGIN_NAMES[random.nextInt(size)]
);
getServer().getPluginManager().enablePlugin(plugin);
plugins.add(plugin);
}
} catch (ReflectiveOperationException ex) {
getLogger().log(Level.WARNING, "Failed to register plugin", ex);
}
}
}
public class FakePlugin extends PluginBase {
private static final FakePluginLoader loader = new FakePluginLoader();
private final PluginDescriptionFile description;
private boolean enabled = false;
public FakePlugin(String name, String version) {
this.description = new PluginDescriptionFile(name, version, null);
}
@Override
public File getDataFolder() {
return null;
}
@Override
public PluginDescriptionFile getDescription() {
return description;
}
@Override
public FileConfiguration getConfig() {
return null;
}
@Override
public InputStream getResource(String filename) {
return null;
}
@Override
public void saveConfig() {
}
@Override
public void saveDefaultConfig() {
}
@Override
public void saveResource(String resourcePath, boolean replace) {
}
@Override
public void reloadConfig() {
}
@Override
public PluginLoader getPluginLoader() {
return loader;
}
@Override
public Server getServer() {
return null;
}
@Override
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public void onDisable() {
}
@Override
public void onLoad() {
}
@Override
public void onEnable() {
}
@Override
public boolean isNaggable() {
return false;
}
@Override
public void setNaggable(boolean canNag) {
}
@Override
public EbeanServer getDatabase() {
return null;
}
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return null;
}
@Override
public Logger getLogger() {
return null;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return null;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
return false;
}
}
public class FakePluginLoader implements PluginLoader {
@Override
public Plugin loadPlugin(File file) throws InvalidPluginException, UnknownDependencyException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public PluginDescriptionFile getPluginDescription(File file) throws InvalidDescriptionException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Pattern[] getPluginFileFilters() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(Listener listener, Plugin plugin) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void enablePlugin(Plugin plugin) {
((FakePlugin) plugin).setEnabled(true);
}
@Override
public void disablePlugin(Plugin plugin) {
((FakePlugin) plugin).setEnabled(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.